darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | f5247d1 | 2010-06-13 17:29:10 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008 David Smith <catfish.man@gmail.com> |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Library General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Library General Public License |
| 16 | * along with this library; see the file COPYING.LIB. If not, write to |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef ElementRareData_h |
| 23 | #define ElementRareData_h |
| 24 | |
commit-queue@webkit.org | 691d04f | 2010-10-29 09:32:14 +0000 | [diff] [blame] | 25 | #include "ClassList.h" |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 26 | #include "DatasetDOMStringMap.h" |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 27 | #include "Element.h" |
morrita@google.com | 948bd53 | 2012-05-07 06:05:42 +0000 | [diff] [blame] | 28 | #include "ElementShadow.h" |
rniwa@webkit.org | f57f8e0 | 2012-07-13 19:48:40 +0000 | [diff] [blame] | 29 | #include "HTMLCollection.h" |
caio.oliveira@openbossa.org | 26b85d3 | 2012-03-08 17:42:28 +0000 | [diff] [blame] | 30 | #include "NamedNodeMap.h" |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 31 | #include "NodeRareData.h" |
commit-queue@webkit.org | d0c076d | 2012-08-22 22:25:59 +0000 | [diff] [blame] | 32 | #include "StyleInheritedData.h" |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 33 | #include <wtf/OwnPtr.h> |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 34 | |
| 35 | namespace WebCore { |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 36 | |
rniwa@webkit.org | 28acc31 | 2012-06-29 23:56:42 +0000 | [diff] [blame] | 37 | class HTMLCollection; |
| 38 | |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 39 | class ElementRareData : public NodeRareData { |
| 40 | public: |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 41 | ElementRareData(); |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 42 | virtual ~ElementRareData(); |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 43 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 44 | void resetComputedStyle(); |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 45 | |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 46 | using NodeRareData::needsFocusAppearanceUpdateSoonAfterAttach; |
| 47 | using NodeRareData::setNeedsFocusAppearanceUpdateSoonAfterAttach; |
kling@webkit.org | c7b06df | 2012-10-03 12:55:24 +0000 | [diff] [blame] | 48 | using NodeRareData::styleAffectedByEmpty; |
| 49 | using NodeRareData::setStyleAffectedByEmpty; |
| 50 | using NodeRareData::isInCanvasSubtree; |
| 51 | using NodeRareData::setIsInCanvasSubtree; |
| 52 | #if ENABLE(FULLSCREEN_API) |
| 53 | using NodeRareData::containsFullScreenElement; |
| 54 | using NodeRareData::setContainsFullScreenElement; |
| 55 | #endif |
darin@apple.com | 929b907 | 2008-12-13 22:53:55 +0000 | [diff] [blame] | 56 | |
kling@webkit.org | a3a65e3 | 2012-01-01 21:05:42 +0000 | [diff] [blame] | 57 | bool hasCachedHTMLCollections() const |
| 58 | { |
| 59 | return m_cachedCollections; |
| 60 | } |
| 61 | |
rniwa@webkit.org | 4823cc1 | 2012-07-09 17:40:09 +0000 | [diff] [blame] | 62 | PassRefPtr<HTMLCollection> ensureCachedHTMLCollection(Element*, CollectionType); |
rniwa@webkit.org | 28acc31 | 2012-06-29 23:56:42 +0000 | [diff] [blame] | 63 | HTMLCollection* cachedHTMLCollection(CollectionType type) |
kling@webkit.org | a3a65e3 | 2012-01-01 21:05:42 +0000 | [diff] [blame] | 64 | { |
| 65 | if (!m_cachedCollections) |
rniwa@webkit.org | 28acc31 | 2012-06-29 23:56:42 +0000 | [diff] [blame] | 66 | return 0; |
kling@webkit.org | a3a65e3 | 2012-01-01 21:05:42 +0000 | [diff] [blame] | 67 | |
rniwa@webkit.org | 4823cc1 | 2012-07-09 17:40:09 +0000 | [diff] [blame] | 68 | return (*m_cachedCollections)[type - FirstNodeCollectionType]; |
| 69 | } |
rniwa@webkit.org | f57f8e0 | 2012-07-13 19:48:40 +0000 | [diff] [blame] | 70 | |
rniwa@webkit.org | 4823cc1 | 2012-07-09 17:40:09 +0000 | [diff] [blame] | 71 | void removeCachedHTMLCollection(HTMLCollection* collection, CollectionType type) |
| 72 | { |
| 73 | ASSERT(m_cachedCollections); |
| 74 | ASSERT_UNUSED(collection, (*m_cachedCollections)[type - FirstNodeCollectionType] == collection); |
| 75 | (*m_cachedCollections)[type - FirstNodeCollectionType] = 0; |
kling@webkit.org | a3a65e3 | 2012-01-01 21:05:42 +0000 | [diff] [blame] | 76 | } |
| 77 | |
rniwa@webkit.org | 198f43c | 2012-07-13 22:44:46 +0000 | [diff] [blame] | 78 | void clearHTMLCollectionCaches(const QualifiedName* attrName) |
rniwa@webkit.org | f57f8e0 | 2012-07-13 19:48:40 +0000 | [diff] [blame] | 79 | { |
| 80 | if (!m_cachedCollections) |
| 81 | return; |
| 82 | |
rniwa@webkit.org | 198f43c | 2012-07-13 22:44:46 +0000 | [diff] [blame] | 83 | bool shouldIgnoreType = !attrName || *attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr; |
| 84 | |
rniwa@webkit.org | f57f8e0 | 2012-07-13 19:48:40 +0000 | [diff] [blame] | 85 | for (unsigned i = 0; i < (*m_cachedCollections).size(); i++) { |
rniwa@webkit.org | 198f43c | 2012-07-13 22:44:46 +0000 | [diff] [blame] | 86 | if (HTMLCollection* collection = (*m_cachedCollections)[i]) { |
| 87 | if (shouldIgnoreType || DynamicNodeListCacheBase::shouldInvalidateTypeOnAttributeChange(collection->invalidationType(), *attrName)) |
| 88 | collection->invalidateCache(); |
| 89 | } |
rniwa@webkit.org | f57f8e0 | 2012-07-13 19:48:40 +0000 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
| 93 | void adoptTreeScope(Document* oldDocument, Document* newDocument) |
| 94 | { |
| 95 | if (!m_cachedCollections) |
| 96 | return; |
| 97 | |
| 98 | for (unsigned i = 0; i < (*m_cachedCollections).size(); i++) { |
| 99 | HTMLCollection* collection = (*m_cachedCollections)[i]; |
| 100 | if (!collection) |
| 101 | continue; |
| 102 | collection->invalidateCache(); |
| 103 | if (oldDocument != newDocument) { |
| 104 | oldDocument->unregisterNodeListCache(collection); |
| 105 | newDocument->registerNodeListCache(collection); |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
loislo@chromium.org | edc2201 | 2012-11-02 09:11:19 +0000 | [diff] [blame] | 110 | virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; |
| 111 | |
rniwa@webkit.org | 4823cc1 | 2012-07-09 17:40:09 +0000 | [diff] [blame] | 112 | typedef FixedArray<HTMLCollection*, NumNodeCollectionTypes> CachedHTMLCollectionArray; |
kling@webkit.org | a3a65e3 | 2012-01-01 21:05:42 +0000 | [diff] [blame] | 113 | OwnPtr<CachedHTMLCollectionArray> m_cachedCollections; |
| 114 | |
eae@chromium.org | 5b93f41 | 2011-08-15 23:51:21 +0000 | [diff] [blame] | 115 | LayoutSize m_minimumSizeForResizing; |
hyatt@apple.com | dec0cbf2 | 2008-10-17 00:25:33 +0000 | [diff] [blame] | 116 | RefPtr<RenderStyle> m_computedStyle; |
weinig@apple.com | 96a2cf9 | 2010-06-30 23:15:15 +0000 | [diff] [blame] | 117 | |
| 118 | OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap; |
commit-queue@webkit.org | 691d04f | 2010-10-29 09:32:14 +0000 | [diff] [blame] | 119 | OwnPtr<ClassList> m_classList; |
morrita@google.com | 948bd53 | 2012-05-07 06:05:42 +0000 | [diff] [blame] | 120 | OwnPtr<ElementShadow> m_shadow; |
caio.oliveira@openbossa.org | 26b85d3 | 2012-03-08 17:42:28 +0000 | [diff] [blame] | 121 | OwnPtr<NamedNodeMap> m_attributeMap; |
jer.noble@apple.com | 366ebb0 | 2011-05-30 02:05:30 +0000 | [diff] [blame] | 122 | |
commit-queue@webkit.org | ba181c4 | 2012-04-02 19:37:59 +0000 | [diff] [blame] | 123 | IntSize m_savedLayerScrollOffset; |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | inline IntSize defaultMinimumSizeForResizing() |
| 127 | { |
eae@chromium.org | 9717cd8 | 2012-11-07 18:33:44 +0000 | [diff] [blame^] | 128 | return IntSize(LayoutUnit::max(), LayoutUnit::max()); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 129 | } |
| 130 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 131 | inline ElementRareData::ElementRareData() |
kling@webkit.org | c7b06df | 2012-10-03 12:55:24 +0000 | [diff] [blame] | 132 | : m_minimumSizeForResizing(defaultMinimumSizeForResizing()) |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 133 | { |
| 134 | } |
| 135 | |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 136 | inline ElementRareData::~ElementRareData() |
| 137 | { |
morrita@google.com | 948bd53 | 2012-05-07 06:05:42 +0000 | [diff] [blame] | 138 | ASSERT(!m_shadow); |
morrita@google.com | d75075c | 2011-01-20 01:24:40 +0000 | [diff] [blame] | 139 | } |
| 140 | |
darin@apple.com | faced26 | 2009-01-12 07:44:27 +0000 | [diff] [blame] | 141 | inline void ElementRareData::resetComputedStyle() |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 142 | { |
hyatt@apple.com | dec0cbf2 | 2008-10-17 00:25:33 +0000 | [diff] [blame] | 143 | m_computedStyle.clear(); |
dsmith@webkit.org | bee65b5 | 2008-09-26 02:36:38 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | } |
alp@webkit.org | 2122a04 | 2008-10-03 12:38:12 +0000 | [diff] [blame] | 147 | #endif // ElementRareData_h |