Changeset 139681 in webkit
- Timestamp:
- Jan 14, 2013, 3:57:39 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r139680 r139681 1 2013-01-11 Ryosuke Niwa <rniwa@webkit.org> 2 3 Move functions from NodeRareData to ElementRareData and other classes 4 https://bugs.webkit.org/show_bug.cgi?id=106679 5 6 Reviewed by Benjamin Poulain. 7 8 Moved tab index related functions from NodeRareData to ElementRareData since only 9 HTMLElement uses them, and moved related functions on Node to Element accordingly. 10 11 Also replaced transientMutationObserverRegistry and ensureTransientMutationObserverRegistry 12 by ensureMutationObserverData, and moved micro-data related member functions into 13 NodeMicroDataTokenLists, and moved NodeMutationObserverData and NodeMicroDataTokenLists 14 out of NodeRareData as they're used outside of NodeRareData now. 15 16 The intention is to move more code into NodeMutationObserverData and NodeMicroDataTokenLists 17 in the follow up patches so that they can detect the removability of NodeRareData. 18 19 No new tests are added since there should be no behavior changes. 20 21 * dom/Element.cpp: 22 (WebCore::Element::clearTabIndexExplicitlyIfNeeded): 23 (WebCore::Element::setTabIndexExplicitly): 24 (WebCore::Element::tabIndex): 25 (WebCore::Element::supportsFocus): 26 * dom/Element.h: 27 (Element): 28 * dom/ElementRareData.h: 29 (ElementRareData): 30 (WebCore::ElementRareData::tabIndex): 31 (WebCore::ElementRareData::setTabIndexExplicitly): 32 (WebCore::ElementRareData::tabIndexSetExplicitly): 33 (WebCore::ElementRareData::clearTabIndexExplicitly): 34 * dom/Node.cpp: 35 (WebCore::Node::tabIndex): 36 (WebCore::Node::supportsFocus): 37 (WebCore::Node::mutationObserverRegistry): 38 (WebCore::Node::transientMutationObserverRegistry): 39 (WebCore::Node::registerMutationObserver): 40 (WebCore::Node::registerTransientMutationObserver): 41 (WebCore::Node::itemProp): 42 (WebCore::Node::setItemProp): 43 (WebCore::Node::itemRef): 44 (WebCore::Node::setItemRef): 45 (WebCore::Node::itemType): 46 (WebCore::Node::setItemType): 47 * dom/Node.h: 48 (Node): 49 * dom/NodeRareData.h: 50 (NodeMutationObserverData): 51 (WebCore::NodeMutationObserverData::create): 52 (NodeMicroDataTokenLists): 53 (WebCore::NodeMicroDataTokenLists::create): 54 (WebCore::NodeMicroDataTokenLists::itemProp): 55 (WebCore::NodeMicroDataTokenLists::itemRef): 56 (WebCore::NodeMicroDataTokenLists::itemType): 57 (NodeRareData): 58 (WebCore::NodeRareData::mutationObserverData): 59 (WebCore::NodeRareData::ensureMutationObserverData): 60 (WebCore::NodeRareData::ensureMicroDataTokenLists): 61 * html/HTMLElement.cpp: 62 (WebCore::HTMLElement::parseAttribute): 63 1 64 2013-01-14 Ojan Vafai <ojan@chromium.org> 2 65 -
trunk/Source/WebCore/dom/Element.cpp
r139659 r139681 229 229 } 230 230 231 void Element::clearTabIndexExplicitlyIfNeeded() 232 { 233 if (hasRareData()) 234 elementRareData()->clearTabIndexExplicitly(); 235 } 236 237 void Element::setTabIndexExplicitly(short tabIndex) 238 { 239 ensureElementRareData()->setTabIndexExplicitly(tabIndex); 240 } 241 242 bool Element::supportsFocus() const 243 { 244 return hasRareData() && elementRareData()->tabIndexSetExplicitly(); 245 } 246 247 short Element::tabIndex() const 248 { 249 return hasRareData() ? elementRareData()->tabIndex() : 0; 250 } 251 231 252 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur); 232 253 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, error); -
trunk/Source/WebCore/dom/Element.h
r139639 r139681 516 516 virtual bool shouldRegisterAsExtraNamedItem() const { return false; } 517 517 518 void clearTabIndexExplicitlyIfNeeded(); 519 void setTabIndexExplicitly(short); 520 virtual bool supportsFocus() const OVERRIDE; 521 virtual short tabIndex() const OVERRIDE; 522 518 523 PassRefPtr<HTMLCollection> ensureCachedHTMLCollection(CollectionType); 519 524 HTMLCollection* cachedHTMLCollection(CollectionType); -
trunk/Source/WebCore/dom/ElementRareData.h
r139639 r139681 45 45 void resetComputedStyle(); 46 46 void resetDynamicRestyleObservations(); 47 48 short tabIndex() const { return m_tabIndex; } 49 void setTabIndexExplicitly(short index) { m_tabIndex = index; m_tabIndexWasSetExplicitly = true; } 50 bool tabIndexSetExplicitly() const { return m_tabIndexWasSetExplicitly; } 51 void clearTabIndexExplicitly() { m_tabIndex = 0; m_tabIndexWasSetExplicitly = false; } 47 52 48 53 bool needsFocusAppearanceUpdateSoonAfterAttach() const { return m_needsFocusAppearanceUpdateSoonAfterAttach; } … … 125 130 126 131 private: 127 // Many fields are in NodeRareData for better packing. 132 short m_tabIndex; 133 unsigned short m_childIndex; 134 unsigned m_tabIndexWasSetExplicitly : 1; 135 unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1; 136 unsigned m_styleAffectedByEmpty : 1; 137 unsigned m_isInCanvasSubtree : 1; 138 #if ENABLE(FULLSCREEN_API) 139 unsigned m_containsFullScreenElement : 1; 140 #endif 141 #if ENABLE(DIALOG_ELEMENT) 142 unsigned m_isInTopLayer : 1; 143 #endif 144 #if ENABLE(SVG) 145 unsigned m_hasPendingResources : 1; 146 #endif 147 unsigned m_childrenAffectedByHover : 1; 148 unsigned m_childrenAffectedByActive : 1; 149 unsigned m_childrenAffectedByDrag : 1; 150 // Bits for dynamic child matching. 151 // We optimize for :first-child and :last-child. The other positional child selectors like nth-child or 152 // *-child-of-type, we will just give up and re-evaluate whenever children change at all. 153 unsigned m_childrenAffectedByFirstChildRules : 1; 154 unsigned m_childrenAffectedByLastChildRules : 1; 155 unsigned m_childrenAffectedByDirectAdjacentRules : 1; 156 unsigned m_childrenAffectedByForwardPositionalRules : 1; 157 unsigned m_childrenAffectedByBackwardPositionalRules : 1; 158 #if ENABLE(VIDEO_TRACK) 159 unsigned m_webVTTNodeType : 2; // WebVTTNodeType 160 #endif 161 128 162 LayoutSize m_minimumSizeForResizing; 129 163 RefPtr<RenderStyle> m_computedStyle; … … 149 183 150 184 inline ElementRareData::ElementRareData() 151 : m_minimumSizeForResizing(defaultMinimumSizeForResizing()) 185 : m_tabIndex(0) 186 , m_childIndex(0) 187 , m_tabIndexWasSetExplicitly(false) 188 , m_needsFocusAppearanceUpdateSoonAfterAttach(false) 189 , m_styleAffectedByEmpty(false) 190 , m_isInCanvasSubtree(false) 191 #if ENABLE(FULLSCREEN_API) 192 , m_containsFullScreenElement(false) 193 #endif 194 #if ENABLE(DIALOG_ELEMENT) 195 , m_isInTopLayer(false) 196 #endif 197 #if ENABLE(SVG) 198 , m_hasPendingResources(false) 199 #endif 200 , m_childrenAffectedByHover(false) 201 , m_childrenAffectedByActive(false) 202 , m_childrenAffectedByDrag(false) 203 , m_childrenAffectedByFirstChildRules(false) 204 , m_childrenAffectedByLastChildRules(false) 205 , m_childrenAffectedByDirectAdjacentRules(false) 206 , m_childrenAffectedByForwardPositionalRules(false) 207 , m_childrenAffectedByBackwardPositionalRules(false) 208 #if ENABLE(VIDEO_TRACK) 209 , m_webVTTNodeType(WebVTTNodeTypeNone) 210 #endif 211 , m_minimumSizeForResizing(defaultMinimumSizeForResizing()) 152 212 { 153 213 } -
trunk/Source/WebCore/dom/Node.cpp
r139541 r139681 493 493 short Node::tabIndex() const 494 494 { 495 return hasRareData() ? rareData()->tabIndex() : 0; 496 } 497 498 void Node::setTabIndexExplicitly(short i) 499 { 500 ensureRareData()->setTabIndexExplicitly(i); 501 } 502 503 void Node::clearTabIndexExplicitly() 504 { 505 ensureRareData()->clearTabIndexExplicitly(); 495 return 0; 506 496 } 507 497 … … 864 854 bool Node::supportsFocus() const 865 855 { 866 return hasRareData() && rareData()->tabIndexSetExplicitly();856 return false; 867 857 } 868 858 … … 2193 2183 Vector<OwnPtr<MutationObserverRegistration> >* Node::mutationObserverRegistry() 2194 2184 { 2195 return hasRareData() ? rareData()->mutationObserverRegistry() : 0; 2185 if (!hasRareData()) 2186 return 0; 2187 NodeMutationObserverData* data = rareData()->mutationObserverData(); 2188 if (!data) 2189 return 0; 2190 return &data->registry; 2196 2191 } 2197 2192 2198 2193 HashSet<MutationObserverRegistration*>* Node::transientMutationObserverRegistry() 2199 2194 { 2200 return hasRareData() ? rareData()->transientMutationObserverRegistry() : 0; 2195 if (!hasRareData()) 2196 return 0; 2197 NodeMutationObserverData* data = rareData()->mutationObserverData(); 2198 if (!data) 2199 return 0; 2200 return &data->transientRegistry; 2201 2201 } 2202 2202 … … 2231 2231 { 2232 2232 MutationObserverRegistration* registration = 0; 2233 Vector<OwnPtr<MutationObserverRegistration> > * registry = ensureRareData()->ensureMutationObserverRegistry();2234 for (size_t i = 0; i < registry ->size(); ++i) {2235 if (registry ->at(i)->observer() == observer) {2236 registration = registry ->at(i).get();2233 Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData()->ensureMutationObserverData()->registry; 2234 for (size_t i = 0; i < registry.size(); ++i) { 2235 if (registry[i]->observer() == observer) { 2236 registration = registry[i].get(); 2237 2237 registration->resetObservation(options, attributeFilter); 2238 2238 } … … 2240 2240 2241 2241 if (!registration) { 2242 registry ->append(MutationObserverRegistration::create(observer, this, options, attributeFilter));2243 registration = registry ->last().get();2242 registry.append(MutationObserverRegistration::create(observer, this, options, attributeFilter)); 2243 registration = registry.last().get(); 2244 2244 } 2245 2245 … … 2264 2264 void Node::registerTransientMutationObserver(MutationObserverRegistration* registration) 2265 2265 { 2266 ensureRareData()->ensure TransientMutationObserverRegistry()->add(registration);2266 ensureRareData()->ensureMutationObserverData()->transientRegistry.add(registration); 2267 2267 } 2268 2268 … … 2519 2519 DOMSettableTokenList* Node::itemProp() 2520 2520 { 2521 return ensureRareData()-> itemProp();2521 return ensureRareData()->ensureMicroDataTokenLists()->itemProp(); 2522 2522 } 2523 2523 2524 2524 void Node::setItemProp(const String& value) 2525 2525 { 2526 ensureRareData()-> setItemProp(value);2526 ensureRareData()->ensureMicroDataTokenLists()->itemProp()->setValue(value); 2527 2527 } 2528 2528 2529 2529 DOMSettableTokenList* Node::itemRef() 2530 2530 { 2531 return ensureRareData()-> itemRef();2531 return ensureRareData()->ensureMicroDataTokenLists()->itemRef(); 2532 2532 } 2533 2533 2534 2534 void Node::setItemRef(const String& value) 2535 2535 { 2536 ensureRareData()-> setItemRef(value);2536 ensureRareData()->ensureMicroDataTokenLists()->itemRef()->setValue(value); 2537 2537 } 2538 2538 2539 2539 DOMSettableTokenList* Node::itemType() 2540 2540 { 2541 return ensureRareData()-> itemType();2541 return ensureRareData()->ensureMicroDataTokenLists()->itemType(); 2542 2542 } 2543 2543 2544 2544 void Node::setItemType(const String& value) 2545 2545 { 2546 ensureRareData()-> setItemType(value);2546 ensureRareData()->ensureMicroDataTokenLists()->itemType()->setValue(value); 2547 2547 } 2548 2548 -
trunk/Source/WebCore/dom/Node.h
r138811 r139681 749 749 750 750 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const { } 751 void setTabIndexExplicitly(short); 752 void clearTabIndexExplicitly(); 753 751 754 752 bool hasRareData() const { return getFlag(HasRareDataFlag); } 755 753 -
trunk/Source/WebCore/dom/NodeRareData.cpp
r138879 r139681 41 41 struct SameSizeAsNodeRareData { 42 42 void* m_pointer[4]; 43 unsigned m_indicesAndBitfields[2];44 45 43 #if ENABLE(MICRODATA) 46 44 void* m_microData; -
trunk/Source/WebCore/dom/NodeRareData.h
r139639 r139681 227 227 }; 228 228 229 class NodeMutationObserverData { 230 WTF_MAKE_NONCOPYABLE(NodeMutationObserverData); WTF_MAKE_FAST_ALLOCATED; 231 public: 232 Vector<OwnPtr<MutationObserverRegistration> > registry; 233 HashSet<MutationObserverRegistration*> transientRegistry; 234 235 static PassOwnPtr<NodeMutationObserverData> create() { return adoptPtr(new NodeMutationObserverData); } 236 237 private: 238 NodeMutationObserverData() { } 239 }; 240 241 #if ENABLE(MICRODATA) 242 class NodeMicroDataTokenLists { 243 WTF_MAKE_NONCOPYABLE(NodeMicroDataTokenLists); WTF_MAKE_FAST_ALLOCATED; 244 public: 245 static PassOwnPtr<NodeMicroDataTokenLists> create() { return adoptPtr(new NodeMicroDataTokenLists); } 246 247 DOMSettableTokenList* itemProp() const 248 { 249 if (!m_itemProp) 250 m_itemProp = DOMSettableTokenList::create(); 251 return m_itemProp.get(); 252 } 253 254 DOMSettableTokenList* itemRef() const 255 { 256 if (!m_itemRef) 257 m_itemRef = DOMSettableTokenList::create(); 258 return m_itemRef.get(); 259 } 260 261 DOMSettableTokenList* itemType() const 262 { 263 if (!m_itemType) 264 m_itemType = DOMSettableTokenList::create(); 265 return m_itemType.get(); 266 } 267 268 private: 269 DOMSettableTokenList() { } 270 271 mutable RefPtr<DOMSettableTokenList> m_itemProp; 272 mutable RefPtr<DOMSettableTokenList> m_itemRef; 273 mutable RefPtr<DOMSettableTokenList> m_itemType; 274 }; 275 #endif 276 229 277 class NodeRareData : public NodeRareDataBase { 230 278 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; 231 232 struct NodeMutationObserverData {233 Vector<OwnPtr<MutationObserverRegistration> > m_registry;234 HashSet<MutationObserverRegistration*> m_transientRegistry;235 236 static PassOwnPtr<NodeMutationObserverData> create() { return adoptPtr(new NodeMutationObserverData); }237 };238 239 #if ENABLE(MICRODATA)240 struct NodeMicroDataTokenLists {241 RefPtr<DOMSettableTokenList> m_itemProp;242 RefPtr<DOMSettableTokenList> m_itemRef;243 RefPtr<DOMSettableTokenList> m_itemType;244 245 static PassOwnPtr<NodeMicroDataTokenLists> create() { return adoptPtr(new NodeMicroDataTokenLists); }246 };247 #endif248 249 279 public: 250 280 NodeRareData() 251 : m_tabIndex(0) 252 , m_childIndex(0) 253 , m_tabIndexWasSetExplicitly(false) 254 , m_needsFocusAppearanceUpdateSoonAfterAttach(false) 255 , m_styleAffectedByEmpty(false) 256 , m_isInCanvasSubtree(false) 257 #if ENABLE(FULLSCREEN_API) 258 , m_containsFullScreenElement(false) 259 #endif 260 #if ENABLE(DIALOG_ELEMENT) 261 , m_isInTopLayer(false) 262 #endif 263 #if ENABLE(SVG) 264 , m_hasPendingResources(false) 265 #endif 266 , m_childrenAffectedByHover(false) 267 , m_childrenAffectedByActive(false) 268 , m_childrenAffectedByDrag(false) 269 , m_childrenAffectedByFirstChildRules(false) 270 , m_childrenAffectedByLastChildRules(false) 271 , m_childrenAffectedByDirectAdjacentRules(false) 272 , m_childrenAffectedByForwardPositionalRules(false) 273 , m_childrenAffectedByBackwardPositionalRules(false) 274 #if ENABLE(VIDEO_TRACK) 275 , m_webVTTNodeType(WebVTTNodeTypeNone) 276 #endif 277 { 278 } 281 { } 279 282 280 283 virtual ~NodeRareData() 281 { 282 } 284 { } 283 285 284 286 void clearNodeLists() { m_nodeLists.clear(); } … … 291 293 } 292 294 293 short tabIndex() const { return m_tabIndex; } 294 void setTabIndexExplicitly(short index) { m_tabIndex = index; m_tabIndexWasSetExplicitly = true; } 295 bool tabIndexSetExplicitly() const { return m_tabIndexWasSetExplicitly; } 296 void clearTabIndexExplicitly() { m_tabIndex = 0; m_tabIndexWasSetExplicitly = false; } 297 298 Vector<OwnPtr<MutationObserverRegistration> >* mutationObserverRegistry() { return m_mutationObserverData ? &m_mutationObserverData->m_registry : 0; } 299 Vector<OwnPtr<MutationObserverRegistration> >* ensureMutationObserverRegistry() 295 NodeMutationObserverData* mutationObserverData() { return m_mutationObserverData.get(); } 296 NodeMutationObserverData* ensureMutationObserverData() 300 297 { 301 298 if (!m_mutationObserverData) 302 299 m_mutationObserverData = NodeMutationObserverData::create(); 303 return &m_mutationObserverData->m_registry; 304 } 305 306 HashSet<MutationObserverRegistration*>* transientMutationObserverRegistry() { return m_mutationObserverData ? &m_mutationObserverData->m_transientRegistry : 0; } 307 HashSet<MutationObserverRegistration*>* ensureTransientMutationObserverRegistry() 308 { 309 if (!m_mutationObserverData) 310 m_mutationObserverData = NodeMutationObserverData::create(); 311 return &m_mutationObserverData->m_transientRegistry; 300 return m_mutationObserverData.get(); 312 301 } 313 302 … … 319 308 return m_microDataTokenLists.get(); 320 309 } 321 322 DOMSettableTokenList* itemProp() const323 {324 if (!ensureMicroDataTokenLists()->m_itemProp)325 m_microDataTokenLists->m_itemProp = DOMSettableTokenList::create();326 327 return m_microDataTokenLists->m_itemProp.get();328 }329 330 void setItemProp(const String& value)331 {332 if (!ensureMicroDataTokenLists()->m_itemProp)333 m_microDataTokenLists->m_itemProp = DOMSettableTokenList::create();334 335 m_microDataTokenLists->m_itemProp->setValue(value);336 }337 338 DOMSettableTokenList* itemRef() const339 {340 if (!ensureMicroDataTokenLists()->m_itemRef)341 m_microDataTokenLists->m_itemRef = DOMSettableTokenList::create();342 343 return m_microDataTokenLists->m_itemRef.get();344 }345 346 void setItemRef(const String& value)347 {348 if (!ensureMicroDataTokenLists()->m_itemRef)349 m_microDataTokenLists->m_itemRef = DOMSettableTokenList::create();350 351 m_microDataTokenLists->m_itemRef->setValue(value);352 }353 354 DOMSettableTokenList* itemType() const355 {356 if (!ensureMicroDataTokenLists()->m_itemType)357 m_microDataTokenLists->m_itemType = DOMSettableTokenList::create();358 359 return m_microDataTokenLists->m_itemType.get();360 }361 362 void setItemType(const String& value)363 {364 if (!ensureMicroDataTokenLists()->m_itemType)365 m_microDataTokenLists->m_itemType = DOMSettableTokenList::create();366 367 m_microDataTokenLists->m_itemType->setValue(value);368 }369 310 #endif 370 311 371 312 virtual void reportMemoryUsage(MemoryObjectInfo*) const; 372 373 protected:374 short m_tabIndex;375 unsigned short m_childIndex;376 unsigned m_tabIndexWasSetExplicitly : 1;377 unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1;378 unsigned m_styleAffectedByEmpty : 1;379 unsigned m_isInCanvasSubtree : 1;380 #if ENABLE(FULLSCREEN_API)381 unsigned m_containsFullScreenElement : 1;382 #endif383 #if ENABLE(DIALOG_ELEMENT)384 unsigned m_isInTopLayer : 1;385 #endif386 #if ENABLE(SVG)387 unsigned m_hasPendingResources : 1;388 #endif389 unsigned m_childrenAffectedByHover : 1;390 unsigned m_childrenAffectedByActive : 1;391 unsigned m_childrenAffectedByDrag : 1;392 // Bits for dynamic child matching.393 // We optimize for :first-child and :last-child. The other positional child selectors like nth-child or394 // *-child-of-type, we will just give up and re-evaluate whenever children change at all.395 unsigned m_childrenAffectedByFirstChildRules : 1;396 unsigned m_childrenAffectedByLastChildRules : 1;397 unsigned m_childrenAffectedByDirectAdjacentRules : 1;398 unsigned m_childrenAffectedByForwardPositionalRules : 1;399 unsigned m_childrenAffectedByBackwardPositionalRules : 1;400 #if ENABLE(VIDEO_TRACK)401 unsigned m_webVTTNodeType : 2; // WebVTTNodeType402 #endif403 313 404 314 private: -
trunk/Source/WebCore/html/HTMLElement.cpp
r137221 r139681 224 224 int tabindex = 0; 225 225 if (value.isEmpty()) 226 clearTabIndexExplicitly ();226 clearTabIndexExplicitlyIfNeeded(); 227 227 else if (parseHTMLInteger(value, tabindex)) { 228 228 // Clamp tabindex to the range of 'short' to match Firefox's behavior.
Note:
See TracChangeset
for help on using the changeset viewer.