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, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 static PassOwnPtr<ElementRareData> create(RenderObject* renderer) { return a
doptPtr(new ElementRareData(renderer)); } | 42 static PassOwnPtr<ElementRareData> create(RenderObject* renderer) { return a
doptPtr(new ElementRareData(renderer)); } |
43 | 43 |
44 ~ElementRareData(); | 44 ~ElementRareData(); |
45 | 45 |
46 void setPseudoElement(PseudoId, PassRefPtr<PseudoElement>); | 46 void setPseudoElement(PseudoId, PassRefPtr<PseudoElement>); |
47 PseudoElement* pseudoElement(PseudoId) const; | 47 PseudoElement* pseudoElement(PseudoId) const; |
48 | 48 |
49 void resetStyleState(); | 49 void resetStyleState(); |
50 void resetDynamicRestyleObservations(); | 50 void resetDynamicRestyleObservations(); |
51 | 51 |
52 short tabIndex() const { return m_tabIndex; } | 52 short tabIndex() const { return m_tabindex; } |
53 void setTabIndexExplicitly(short index) { m_tabIndex = index; m_tabIndexWasS
etExplicitly = true; } | |
54 bool tabIndexSetExplicitly() const { return m_tabIndexWasSetExplicitly; } | |
55 void clearTabIndexExplicitly() { m_tabIndex = 0; m_tabIndexWasSetExplicitly
= false; } | |
56 | 53 |
57 bool needsFocusAppearanceUpdateSoonAfterAttach() const { return m_needsFocus
AppearanceUpdateSoonAfterAttach; } | 54 void setTabIndexExplicitly(short index) |
58 void setNeedsFocusAppearanceUpdateSoonAfterAttach(bool needs) { m_needsFocus
AppearanceUpdateSoonAfterAttach = needs; } | 55 { |
| 56 m_tabindex = index; |
| 57 setFlag(TabIndexWasSetExplicitly, true); |
| 58 } |
59 | 59 |
60 bool styleAffectedByEmpty() const { return m_styleAffectedByEmpty; } | 60 void clearTabIndexExplicitly() |
61 void setStyleAffectedByEmpty(bool value) { m_styleAffectedByEmpty = value; } | 61 { |
| 62 m_tabindex = 0; |
| 63 clearFlag(TabIndexWasSetExplicitly); |
| 64 } |
62 | 65 |
63 bool isInCanvasSubtree() const { return m_isInCanvasSubtree; } | 66 bool hasFlag(ElementFlags mask) const { return m_flags & mask; } |
64 void setIsInCanvasSubtree(bool value) { m_isInCanvasSubtree = value; } | 67 void setFlag(ElementFlags mask, bool value) { m_flags = (m_flags & ~mask) |
(-(int32_t)value & mask); } |
| 68 void clearFlag(ElementFlags mask) { m_flags &= ~mask; } |
65 | 69 |
66 bool containsFullScreenElement() { return m_containsFullScreenElement; } | |
67 void setContainsFullScreenElement(bool value) { m_containsFullScreenElement
= value; } | |
68 | |
69 bool isInTopLayer() const { return m_isInTopLayer; } | |
70 void setIsInTopLayer(bool value) { m_isInTopLayer = value; } | |
71 | |
72 bool childrenAffectedByFocus() const { return m_childrenAffectedByFocus; } | |
73 void setChildrenAffectedByFocus(bool value) { m_childrenAffectedByFocus = va
lue; } | |
74 bool childrenAffectedByHover() const { return m_childrenAffectedByHover; } | |
75 void setChildrenAffectedByHover(bool value) { m_childrenAffectedByHover = va
lue; } | |
76 bool childrenAffectedByActive() const { return m_childrenAffectedByActive; } | |
77 void setChildrenAffectedByActive(bool value) { m_childrenAffectedByActive =
value; } | |
78 bool childrenAffectedByDrag() const { return m_childrenAffectedByDrag; } | |
79 void setChildrenAffectedByDrag(bool value) { m_childrenAffectedByDrag = valu
e; } | |
80 | |
81 bool childrenAffectedByFirstChildRules() const { return m_childrenAffectedBy
FirstChildRules; } | |
82 void setChildrenAffectedByFirstChildRules(bool value) { m_childrenAffectedBy
FirstChildRules = value; } | |
83 bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByL
astChildRules; } | |
84 void setChildrenAffectedByLastChildRules(bool value) { m_childrenAffectedByL
astChildRules = value; } | |
85 bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffect
edByDirectAdjacentRules; } | |
86 void setChildrenAffectedByDirectAdjacentRules(bool value) { m_childrenAffect
edByDirectAdjacentRules = value; } | |
87 bool childrenAffectedByForwardPositionalRules() const { return m_childrenAff
ectedByForwardPositionalRules; } | |
88 void setChildrenAffectedByForwardPositionalRules(bool value) { m_childrenAff
ectedByForwardPositionalRules = value; } | |
89 bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAf
fectedByBackwardPositionalRules; } | |
90 void setChildrenAffectedByBackwardPositionalRules(bool value) { m_childrenAf
fectedByBackwardPositionalRules = value; } | |
91 unsigned childIndex() const { return m_childIndex; } | 70 unsigned childIndex() const { return m_childIndex; } |
92 void setChildIndex(unsigned index) { m_childIndex = index; } | 71 void setChildIndex(unsigned index) { m_childIndex = index; } |
93 | 72 |
94 CSSStyleDeclaration& ensureInlineCSSStyleDeclaration(Element* ownerElement); | 73 CSSStyleDeclaration& ensureInlineCSSStyleDeclaration(Element* ownerElement); |
95 | 74 |
96 void clearShadow() { m_shadow = nullptr; } | 75 void clearShadow() { m_shadow = nullptr; } |
97 ElementShadow* shadow() const { return m_shadow.get(); } | 76 ElementShadow* shadow() const { return m_shadow.get(); } |
98 ElementShadow& ensureShadow() | 77 ElementShadow& ensureShadow() |
99 { | 78 { |
100 if (!m_shadow) | 79 if (!m_shadow) |
(...skipping 25 matching lines...) Expand all Loading... |
126 | 105 |
127 IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } | 106 IntSize savedLayerScrollOffset() const { return m_savedLayerScrollOffset; } |
128 void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = si
ze; } | 107 void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = si
ze; } |
129 | 108 |
130 ActiveAnimations* activeAnimations() { return m_activeAnimations.get(); } | 109 ActiveAnimations* activeAnimations() { return m_activeAnimations.get(); } |
131 void setActiveAnimations(PassOwnPtr<ActiveAnimations> activeAnimations) | 110 void setActiveAnimations(PassOwnPtr<ActiveAnimations> activeAnimations) |
132 { | 111 { |
133 m_activeAnimations = activeAnimations; | 112 m_activeAnimations = activeAnimations; |
134 } | 113 } |
135 | 114 |
136 bool hasPendingResources() const { return m_hasPendingResources; } | |
137 void setHasPendingResources(bool has) { m_hasPendingResources = has; } | |
138 | |
139 bool hasInputMethodContext() const { return m_inputMethodContext; } | 115 bool hasInputMethodContext() const { return m_inputMethodContext; } |
140 InputMethodContext& ensureInputMethodContext(HTMLElement* element) | 116 InputMethodContext& ensureInputMethodContext(HTMLElement* element) |
141 { | 117 { |
142 if (!m_inputMethodContext) | 118 if (!m_inputMethodContext) |
143 m_inputMethodContext = InputMethodContext::create(element); | 119 m_inputMethodContext = InputMethodContext::create(element); |
144 return *m_inputMethodContext; | 120 return *m_inputMethodContext; |
145 } | 121 } |
146 | 122 |
147 bool hasPseudoElements() const; | 123 bool hasPseudoElements() const; |
148 void clearPseudoElements(); | 124 void clearPseudoElements(); |
149 | 125 |
150 private: | 126 private: |
151 short m_tabIndex; | 127 short m_tabindex; |
152 unsigned short m_childIndex; | 128 unsigned short m_childIndex; |
153 unsigned m_tabIndexWasSetExplicitly : 1; | 129 unsigned m_flags; |
154 unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1; | |
155 unsigned m_styleAffectedByEmpty : 1; | |
156 unsigned m_isInCanvasSubtree : 1; | |
157 unsigned m_containsFullScreenElement : 1; | |
158 unsigned m_isInTopLayer : 1; | |
159 unsigned m_hasPendingResources : 1; | |
160 unsigned m_childrenAffectedByFocus : 1; | |
161 unsigned m_childrenAffectedByHover : 1; | |
162 unsigned m_childrenAffectedByActive : 1; | |
163 unsigned m_childrenAffectedByDrag : 1; | |
164 // Bits for dynamic child matching. | |
165 // We optimize for :first-child and :last-child. The other positional child
selectors like nth-child or | |
166 // *-child-of-type, we will just give up and re-evaluate whenever children c
hange at all. | |
167 unsigned m_childrenAffectedByFirstChildRules : 1; | |
168 unsigned m_childrenAffectedByLastChildRules : 1; | |
169 unsigned m_childrenAffectedByDirectAdjacentRules : 1; | |
170 unsigned m_childrenAffectedByForwardPositionalRules : 1; | |
171 unsigned m_childrenAffectedByBackwardPositionalRules : 1; | |
172 | 130 |
173 LayoutSize m_minimumSizeForResizing; | 131 LayoutSize m_minimumSizeForResizing; |
174 IntSize m_savedLayerScrollOffset; | 132 IntSize m_savedLayerScrollOffset; |
175 RefPtr<RenderStyle> m_computedStyle; | 133 RefPtr<RenderStyle> m_computedStyle; |
176 | 134 |
177 OwnPtr<DatasetDOMStringMap> m_dataset; | 135 OwnPtr<DatasetDOMStringMap> m_dataset; |
178 OwnPtr<ClassList> m_classList; | 136 OwnPtr<ClassList> m_classList; |
179 OwnPtr<ElementShadow> m_shadow; | 137 OwnPtr<ElementShadow> m_shadow; |
180 OwnPtr<NamedNodeMap> m_attributeMap; | 138 OwnPtr<NamedNodeMap> m_attributeMap; |
181 OwnPtr<InputMethodContext> m_inputMethodContext; | 139 OwnPtr<InputMethodContext> m_inputMethodContext; |
182 OwnPtr<ActiveAnimations> m_activeAnimations; | 140 OwnPtr<ActiveAnimations> m_activeAnimations; |
183 OwnPtr<InlineCSSStyleDeclaration> m_cssomWrapper; | 141 OwnPtr<InlineCSSStyleDeclaration> m_cssomWrapper; |
184 | 142 |
185 RefPtr<PseudoElement> m_generatedBefore; | 143 RefPtr<PseudoElement> m_generatedBefore; |
186 RefPtr<PseudoElement> m_generatedAfter; | 144 RefPtr<PseudoElement> m_generatedAfter; |
187 RefPtr<PseudoElement> m_backdrop; | 145 RefPtr<PseudoElement> m_backdrop; |
188 | 146 |
189 ElementRareData(RenderObject*); | 147 explicit ElementRareData(RenderObject*); |
190 }; | 148 }; |
191 | 149 |
192 inline IntSize defaultMinimumSizeForResizing() | 150 inline IntSize defaultMinimumSizeForResizing() |
193 { | 151 { |
194 return IntSize(LayoutUnit::max(), LayoutUnit::max()); | 152 return IntSize(LayoutUnit::max(), LayoutUnit::max()); |
195 } | 153 } |
196 | 154 |
197 inline ElementRareData::ElementRareData(RenderObject* renderer) | 155 inline ElementRareData::ElementRareData(RenderObject* renderer) |
198 : NodeRareData(renderer) | 156 : NodeRareData(renderer) |
199 , m_tabIndex(0) | 157 , m_tabindex(0) |
200 , m_childIndex(0) | 158 , m_childIndex(0) |
201 , m_tabIndexWasSetExplicitly(false) | 159 , m_flags(0) |
202 , m_needsFocusAppearanceUpdateSoonAfterAttach(false) | |
203 , m_styleAffectedByEmpty(false) | |
204 , m_isInCanvasSubtree(false) | |
205 , m_containsFullScreenElement(false) | |
206 , m_isInTopLayer(false) | |
207 , m_hasPendingResources(false) | |
208 , m_childrenAffectedByFocus(false) | |
209 , m_childrenAffectedByHover(false) | |
210 , m_childrenAffectedByActive(false) | |
211 , m_childrenAffectedByDrag(false) | |
212 , m_childrenAffectedByFirstChildRules(false) | |
213 , m_childrenAffectedByLastChildRules(false) | |
214 , m_childrenAffectedByDirectAdjacentRules(false) | |
215 , m_childrenAffectedByForwardPositionalRules(false) | |
216 , m_childrenAffectedByBackwardPositionalRules(false) | |
217 , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) | 160 , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) |
218 { | 161 { |
219 } | 162 } |
220 | 163 |
221 inline ElementRareData::~ElementRareData() | 164 inline ElementRareData::~ElementRareData() |
222 { | 165 { |
223 ASSERT(!m_shadow); | 166 ASSERT(!m_shadow); |
224 ASSERT(!m_generatedBefore); | 167 ASSERT(!m_generatedBefore); |
225 ASSERT(!m_generatedAfter); | 168 ASSERT(!m_generatedAfter); |
226 ASSERT(!m_backdrop); | 169 ASSERT(!m_backdrop); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 return m_generatedAfter.get(); | 213 return m_generatedAfter.get(); |
271 case BACKDROP: | 214 case BACKDROP: |
272 return m_backdrop.get(); | 215 return m_backdrop.get(); |
273 default: | 216 default: |
274 return 0; | 217 return 0; |
275 } | 218 } |
276 } | 219 } |
277 | 220 |
278 inline void ElementRareData::resetStyleState() | 221 inline void ElementRareData::resetStyleState() |
279 { | 222 { |
280 setStyleAffectedByEmpty(false); | 223 clearFlag(StyleAffectedByEmpty); |
281 setChildIndex(0); | 224 setChildIndex(0); |
282 } | 225 } |
283 | 226 |
284 inline void ElementRareData::resetDynamicRestyleObservations() | 227 inline void ElementRareData::resetDynamicRestyleObservations() |
285 { | 228 { |
286 setChildrenAffectedByFocus(false); | 229 clearFlag(ChildrenAffectedByFocus); |
287 setChildrenAffectedByHover(false); | 230 clearFlag(ChildrenAffectedByHover); |
288 setChildrenAffectedByActive(false); | 231 clearFlag(ChildrenAffectedByActive); |
289 setChildrenAffectedByDrag(false); | 232 clearFlag(ChildrenAffectedByDrag); |
290 setChildrenAffectedByFirstChildRules(false); | 233 clearFlag(ChildrenAffectedByFirstChildRules); |
291 setChildrenAffectedByLastChildRules(false); | 234 clearFlag(ChildrenAffectedByLastChildRules); |
292 setChildrenAffectedByDirectAdjacentRules(false); | 235 clearFlag(ChildrenAffectedByDirectAdjacentRules); |
293 setChildrenAffectedByForwardPositionalRules(false); | 236 clearFlag(ChildrenAffectedByForwardPositionalRules); |
294 setChildrenAffectedByBackwardPositionalRules(false); | 237 clearFlag(ChildrenAffectedByBackwardPositionalRules); |
295 } | 238 } |
296 | 239 |
297 } // namespace | 240 } // namespace |
298 | 241 |
299 #endif // ElementRareData_h | 242 #endif // ElementRareData_h |
OLD | NEW |