OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> | 3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #ifndef ElementRareData_h | 22 #ifndef ElementRareData_h |
23 #define ElementRareData_h | 23 #define ElementRareData_h |
24 | 24 |
25 #include "core/animation/ElementAnimations.h" | 25 #include "core/animation/ElementAnimations.h" |
26 #include "core/dom/Attr.h" | 26 #include "core/dom/Attr.h" |
27 #include "core/dom/DatasetDOMStringMap.h" | 27 #include "core/dom/DatasetDOMStringMap.h" |
28 #include "core/dom/NamedNodeMap.h" | 28 #include "core/dom/NamedNodeMap.h" |
29 #include "core/dom/NodeRareData.h" | 29 #include "core/dom/NodeRareData.h" |
| 30 #include "core/dom/ProxiedPropertyCounts.h" |
30 #include "core/dom/PseudoElement.h" | 31 #include "core/dom/PseudoElement.h" |
31 #include "core/dom/custom/CustomElementDefinition.h" | 32 #include "core/dom/custom/CustomElementDefinition.h" |
32 #include "core/dom/shadow/ElementShadow.h" | 33 #include "core/dom/shadow/ElementShadow.h" |
33 #include "core/html/ClassList.h" | 34 #include "core/html/ClassList.h" |
34 #include "core/style/StyleInheritedData.h" | 35 #include "core/style/StyleInheritedData.h" |
35 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
36 #include "wtf/OwnPtr.h" | 37 #include "wtf/OwnPtr.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 class HTMLElement; | 41 class HTMLElement; |
| 42 class ProxiedPropertyCounts; |
41 | 43 |
42 class ElementRareData : public NodeRareData { | 44 class ElementRareData : public NodeRareData { |
43 public: | 45 public: |
44 static ElementRareData* create(LayoutObject* layoutObject) | 46 static ElementRareData* create(LayoutObject* layoutObject) |
45 { | 47 { |
46 return new ElementRareData(layoutObject); | 48 return new ElementRareData(layoutObject); |
47 } | 49 } |
48 | 50 |
49 ~ElementRareData(); | 51 ~ElementRareData(); |
50 | 52 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 105 |
104 ElementAnimations* elementAnimations() { return m_elementAnimations.get(); } | 106 ElementAnimations* elementAnimations() { return m_elementAnimations.get(); } |
105 void setElementAnimations(ElementAnimations* elementAnimations) | 107 void setElementAnimations(ElementAnimations* elementAnimations) |
106 { | 108 { |
107 m_elementAnimations = elementAnimations; | 109 m_elementAnimations = elementAnimations; |
108 } | 110 } |
109 | 111 |
110 bool hasPseudoElements() const; | 112 bool hasPseudoElements() const; |
111 void clearPseudoElements(); | 113 void clearPseudoElements(); |
112 | 114 |
113 uint32_t incrementProxyCount() { return ++m_proxyCount; } | 115 void incrementProxiedPropertyCounts(uint32_t properties); |
114 uint32_t decrementProxyCount() | 116 void decrementProxiedPropertyCounts(uint32_t properties); |
115 { | 117 ProxiedPropertyCounts* proxiedPropertyCounts() const { return m_proxiedPrope
rties.get(); } |
116 ASSERT(m_proxyCount); | |
117 return --m_proxyCount; | |
118 } | |
119 uint32_t proxyCount() const { return m_proxyCount; } | |
120 | 118 |
121 void setCustomElementDefinition(PassRefPtrWillBeRawPtr<CustomElementDefiniti
on> definition) { m_customElementDefinition = definition; } | 119 void setCustomElementDefinition(PassRefPtrWillBeRawPtr<CustomElementDefiniti
on> definition) { m_customElementDefinition = definition; } |
122 CustomElementDefinition* customElementDefinition() const { return m_customEl
ementDefinition.get(); } | 120 CustomElementDefinition* customElementDefinition() const { return m_customEl
ementDefinition.get(); } |
123 | 121 |
124 AttrNodeList& ensureAttrNodeList(); | 122 AttrNodeList& ensureAttrNodeList(); |
125 AttrNodeList* attrNodeList() { return m_attrNodeList.get(); } | 123 AttrNodeList* attrNodeList() { return m_attrNodeList.get(); } |
126 void removeAttrNodeList() { m_attrNodeList.clear(); } | 124 void removeAttrNodeList() { m_attrNodeList.clear(); } |
127 | 125 |
128 DECLARE_TRACE_AFTER_DISPATCH(); | 126 DECLARE_TRACE_AFTER_DISPATCH(); |
129 | 127 |
130 private: | 128 private: |
| 129 ProxiedPropertyCounts& ensureProxiedPropertyCounts(); |
| 130 void clearProxiedPropertyCounts() { m_proxiedProperties = nullptr; } |
| 131 |
131 short m_tabindex; | 132 short m_tabindex; |
132 // As m_proxyCount usually doesn't exceed 10bits (1024), if you want to add
some booleans you | |
133 // can steal some bits from m_proxyCount by using bitfields to prevent Eleme
ntRareData bloat. | |
134 unsigned short m_proxyCount; | |
135 | 133 |
136 LayoutSize m_minimumSizeForResizing; | 134 LayoutSize m_minimumSizeForResizing; |
137 IntSize m_savedLayerScrollOffset; | 135 IntSize m_savedLayerScrollOffset; |
138 | 136 |
139 OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset; | 137 OwnPtrWillBeMember<DatasetDOMStringMap> m_dataset; |
140 OwnPtrWillBeMember<ClassList> m_classList; | 138 OwnPtrWillBeMember<ClassList> m_classList; |
141 OwnPtrWillBeMember<ElementShadow> m_shadow; | 139 OwnPtrWillBeMember<ElementShadow> m_shadow; |
142 OwnPtrWillBeMember<NamedNodeMap> m_attributeMap; | 140 OwnPtrWillBeMember<NamedNodeMap> m_attributeMap; |
143 OwnPtrWillBeMember<AttrNodeList> m_attrNodeList; | 141 OwnPtrWillBeMember<AttrNodeList> m_attrNodeList; |
144 PersistentWillBeMember<ElementAnimations> m_elementAnimations; | 142 PersistentWillBeMember<ElementAnimations> m_elementAnimations; |
145 OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper; | 143 OwnPtrWillBeMember<InlineCSSStyleDeclaration> m_cssomWrapper; |
| 144 OwnPtrWillBeMember<ProxiedPropertyCounts> m_proxiedProperties; |
146 | 145 |
147 RefPtr<ComputedStyle> m_computedStyle; | 146 RefPtr<ComputedStyle> m_computedStyle; |
148 RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition; | 147 RefPtrWillBeMember<CustomElementDefinition> m_customElementDefinition; |
149 | 148 |
150 RefPtrWillBeMember<PseudoElement> m_generatedBefore; | 149 RefPtrWillBeMember<PseudoElement> m_generatedBefore; |
151 RefPtrWillBeMember<PseudoElement> m_generatedAfter; | 150 RefPtrWillBeMember<PseudoElement> m_generatedAfter; |
152 RefPtrWillBeMember<PseudoElement> m_generatedFirstLetter; | 151 RefPtrWillBeMember<PseudoElement> m_generatedFirstLetter; |
153 RefPtrWillBeMember<PseudoElement> m_backdrop; | 152 RefPtrWillBeMember<PseudoElement> m_backdrop; |
154 | 153 |
155 explicit ElementRareData(LayoutObject*); | 154 explicit ElementRareData(LayoutObject*); |
156 }; | 155 }; |
157 | 156 |
158 inline LayoutSize defaultMinimumSizeForResizing() | 157 inline LayoutSize defaultMinimumSizeForResizing() |
159 { | 158 { |
160 return LayoutSize(LayoutUnit::max(), LayoutUnit::max()); | 159 return LayoutSize(LayoutUnit::max(), LayoutUnit::max()); |
161 } | 160 } |
162 | 161 |
163 inline ElementRareData::ElementRareData(LayoutObject* layoutObject) | 162 inline ElementRareData::ElementRareData(LayoutObject* layoutObject) |
164 : NodeRareData(layoutObject) | 163 : NodeRareData(layoutObject) |
165 , m_tabindex(0) | 164 , m_tabindex(0) |
166 , m_proxyCount(0) | |
167 , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) | 165 , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) |
168 { | 166 { |
169 m_isElementRareData = true; | 167 m_isElementRareData = true; |
170 } | 168 } |
171 | 169 |
172 inline ElementRareData::~ElementRareData() | 170 inline ElementRareData::~ElementRareData() |
173 { | 171 { |
174 #if !ENABLE(OILPAN) | 172 #if !ENABLE(OILPAN) |
175 if (m_elementAnimations) | 173 if (m_elementAnimations) |
176 m_elementAnimations->dispose(); | 174 m_elementAnimations->dispose(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 return m_generatedAfter.get(); | 230 return m_generatedAfter.get(); |
233 case BACKDROP: | 231 case BACKDROP: |
234 return m_backdrop.get(); | 232 return m_backdrop.get(); |
235 case FIRST_LETTER: | 233 case FIRST_LETTER: |
236 return m_generatedFirstLetter.get(); | 234 return m_generatedFirstLetter.get(); |
237 default: | 235 default: |
238 return 0; | 236 return 0; |
239 } | 237 } |
240 } | 238 } |
241 | 239 |
| 240 inline void ElementRareData::incrementProxiedPropertyCounts(uint32_t properties) |
| 241 { |
| 242 ensureProxiedPropertyCounts().increment(properties); |
| 243 } |
| 244 |
| 245 inline void ElementRareData::decrementProxiedPropertyCounts(uint32_t properties) |
| 246 { |
| 247 m_proxiedProperties->decrement(properties); |
| 248 if (m_proxiedProperties->empty()) |
| 249 clearProxiedPropertyCounts(); |
| 250 } |
| 251 |
| 252 inline ProxiedPropertyCounts& ElementRareData::ensureProxiedPropertyCounts() |
| 253 { |
| 254 if (!m_proxiedProperties) |
| 255 m_proxiedProperties = ProxiedPropertyCounts::create(); |
| 256 return *m_proxiedProperties; |
| 257 } |
| 258 |
242 } // namespace | 259 } // namespace |
243 | 260 |
244 #endif // ElementRareData_h | 261 #endif // ElementRareData_h |
OLD | NEW |