Changeset 164251 in webkit
- Timestamp:
- Feb 17, 2014 3:29:31 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r164249 r164251 1 2014-02-17 Antti Koivisto <antti@apple.com> 2 3 Make TreeScope::rootNode return a reference 4 https://bugs.webkit.org/show_bug.cgi?id=128934 5 6 Reviewed by Andreas Kling. 7 8 It is never null. 9 10 * css/ElementRuleCollector.cpp: 11 (WebCore::ElementRuleCollector::collectMatchingRules): 12 * dom/ContainerNode.h: 13 (WebCore::Node::isTreeScope): 14 * dom/Document.cpp: 15 (WebCore::Document::buildAccessKeyMap): 16 * dom/DocumentOrderedMap.cpp: 17 (WebCore::DocumentOrderedMap::add): 18 (WebCore::DocumentOrderedMap::get): 19 (WebCore::DocumentOrderedMap::getAllElementsById): 20 * dom/EventDispatcher.cpp: 21 (WebCore::EventRelatedNodeResolver::moveToParentOrShadowHost): 22 (WebCore::eventTargetRespectingTargetRules): 23 (WebCore::shouldEventCrossShadowBoundary): 24 * dom/Node.cpp: 25 (WebCore::Node::containingShadowRoot): 26 (WebCore::Node::removedFrom): 27 * dom/ShadowRoot.h: 28 (WebCore::isShadowRoot): 29 * dom/TreeScope.h: 30 (WebCore::TreeScope::rootNode): 31 * page/DOMSelection.cpp: 32 (WebCore::DOMSelection::DOMSelection): 33 * page/DragController.cpp: 34 (WebCore::asFileInput): 35 * page/FocusController.cpp: 36 (WebCore::FocusNavigationScope::rootNode): 37 1 38 2014-02-17 Chris Fleizach <cfleizach@apple.com> 2 39 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r164202 r164251 156 156 #endif 157 157 // Only match UA rules in shadow tree. 158 if (!MatchingUARulesScope::isMatchingUARules() && m_element.treeScope().rootNode() ->isShadowRoot())158 if (!MatchingUARulesScope::isMatchingUARules() && m_element.treeScope().rootNode().isShadowRoot()) 159 159 return; 160 160 -
trunk/Source/WebCore/dom/ContainerNode.h
r164248 r164251 237 237 inline bool Node::isTreeScope() const 238 238 { 239 return treeScope().rootNode() == this;239 return &treeScope().rootNode() == this; 240 240 } 241 241 -
trunk/Source/WebCore/dom/Document.cpp
r164248 r164251 713 713 { 714 714 ASSERT(scope); 715 ContainerNode* rootNode = scope->rootNode(); 716 for (auto& element : descendantsOfType<Element>(*rootNode)) { 715 for (auto& element : descendantsOfType<Element>(scope->rootNode())) { 717 716 const AtomicString& accessKey = element.fastGetAttribute(accesskeyAttr); 718 717 if (!accessKey.isEmpty()) -
trunk/Source/WebCore/dom/DocumentOrderedMap.cpp
r164195 r164251 92 92 UNUSED_PARAM(treeScope); 93 93 ASSERT_WITH_SECURITY_IMPLICATION(element.isInTreeScope()); 94 ASSERT_WITH_SECURITY_IMPLICATION(treeScope.rootNode() ->containsIncludingShadowDOM(&element));94 ASSERT_WITH_SECURITY_IMPLICATION(treeScope.rootNode().containsIncludingShadowDOM(&element)); 95 95 if (!element.isInTreeScope()) 96 96 return; … … 145 145 146 146 // We know there's at least one node that matches; iterate to find the first one. 147 for (auto& element : descendantsOfType<Element>( *scope.rootNode())) {147 for (auto& element : descendantsOfType<Element>(scope.rootNode())) { 148 148 if (!keyMatches(key, element)) 149 149 continue; … … 212 212 if (entry.orderedList.isEmpty()) { 213 213 entry.orderedList.reserveCapacity(entry.count); 214 auto elementDescandents = descendantsOfType<Element>( *scope.rootNode());214 auto elementDescandents = descendantsOfType<Element>(scope.rootNode()); 215 215 auto it = entry.element ? elementDescandents.beginAt(*entry.element) : elementDescandents.begin(); 216 216 auto end = elementDescandents.end(); -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r163440 r164251 144 144 145 145 if (m_currentTreeScope) { 146 ASSERT(m_currentTreeScope->rootNode() ->isShadowRoot());147 ASSERT(&newTarget == toShadowRoot(m_currentTreeScope->rootNode()) ->hostElement());146 ASSERT(m_currentTreeScope->rootNode().isShadowRoot()); 147 ASSERT(&newTarget == toShadowRoot(m_currentTreeScope->rootNode()).hostElement()); 148 148 ASSERT(m_currentTreeScope->parentTreeScope() == &newTreeScope); 149 149 } … … 185 185 // Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included 186 186 // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects 187 Node*rootNode = referenceNode.treeScope().rootNode();188 Element* shadowHostElement = rootNode ->isShadowRoot() ? toShadowRoot(rootNode)->hostElement() : 0;187 auto& rootNode = referenceNode.treeScope().rootNode(); 188 Element* shadowHostElement = rootNode.isShadowRoot() ? toShadowRoot(rootNode).hostElement() : nullptr; 189 189 // At this time, SVG nodes are not supported in non-<use> shadow trees. 190 190 if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag)) … … 367 367 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. 368 368 const AtomicString& eventType = event.type(); 369 bool targetIsInShadowRoot = targetNode && targetNode->treeScope().rootNode() == &shadowRoot;369 bool targetIsInShadowRoot = targetNode && &targetNode->treeScope().rootNode() == &shadowRoot; 370 370 return !targetIsInShadowRoot 371 371 || !(eventType == eventNames().abortEvent -
trunk/Source/WebCore/dom/Node.cpp
r164248 r164251 952 952 ShadowRoot* Node::containingShadowRoot() const 953 953 { 954 ContainerNode *root = treeScope().rootNode();955 return root && root->isShadowRoot() ? toShadowRoot(root) : 0;954 ContainerNode& root = treeScope().rootNode(); 955 return root.isShadowRoot() ? toShadowRoot(&root) : nullptr; 956 956 } 957 957 … … 1012 1012 if (insertionPoint.inDocument()) 1013 1013 clearFlag(InDocumentFlag); 1014 if (isInShadowTree() && !treeScope().rootNode() ->isShadowRoot())1014 if (isInShadowTree() && !treeScope().rootNode().isShadowRoot()) 1015 1015 clearFlag(IsInShadowTreeFlag); 1016 1016 } -
trunk/Source/WebCore/dom/ShadowRoot.h
r164195 r164251 96 96 } 97 97 98 inline const ShadowRoot* toShadowRoot(const Node* node) 99 { 100 ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isShadowRoot()); 101 return static_cast<const ShadowRoot*>(node); 102 } 98 inline bool isShadowRoot(const Node& node) { return node.isShadowRoot(); } 103 99 104 inline ShadowRoot* toShadowRoot(Node* node) 105 { 106 return const_cast<ShadowRoot*>(toShadowRoot(static_cast<const Node*>(node))); 107 } 100 NODE_TYPE_CASTS(ShadowRoot) 108 101 109 102 inline ShadowRoot* Node::shadowRoot() const -
trunk/Source/WebCore/dom/TreeScope.cpp
r164195 r164251 93 93 { 94 94 // A document node cannot be re-parented. 95 ASSERT(! rootNode()->isDocumentNode());95 ASSERT(!m_rootNode.isDocumentNode()); 96 96 // Every scope other than document needs a parent scope. 97 97 ASSERT(newParentScope); … … 199 199 if (name.isEmpty()) 200 200 return nullptr; 201 if ( rootNode()->document().isHTMLDocument()) {201 if (m_rootNode.document().isHTMLDocument()) { 202 202 AtomicString lowercasedName = name.lower(); 203 203 return m_imageMapsByName->getElementByLowercasedMapName(*lowercasedName.impl(), *this); … … 240 240 Element* TreeScope::elementFromPoint(int x, int y) const 241 241 { 242 Node* node = nodeFromPoint(& rootNode()->document(), x, y);242 Node* node = nodeFromPoint(&m_rootNode.document(), x, y); 243 243 while (node && !node->isElementNode()) 244 244 node = node->parentNode(); … … 269 269 m_labelsByForAttribute = std::make_unique<DocumentOrderedMap>(); 270 270 271 for (auto& label : descendantsOfType<HTMLLabelElement>( *rootNode())) {271 for (auto& label : descendantsOfType<HTMLLabelElement>(m_rootNode)) { 272 272 const AtomicString& forValue = label.fastGetAttribute(forAttr); 273 273 if (!forValue.isEmpty()) … … 281 281 DOMSelection* TreeScope::getSelection() const 282 282 { 283 if (! rootNode()->document().frame())283 if (!m_rootNode.document().frame()) 284 284 return nullptr; 285 285 … … 287 287 return m_selection.get(); 288 288 289 if (this != & rootNode()->document())290 return rootNode()->document().getSelection();291 292 m_selection = DOMSelection::create(& rootNode()->document());289 if (this != &m_rootNode.document()) 290 return m_rootNode.document().getSelection(); 291 292 m_selection = DOMSelection::create(&m_rootNode.document()); 293 293 return m_selection.get(); 294 294 } … … 300 300 if (Element* element = getElementById(name)) 301 301 return element; 302 for (auto& anchor : descendantsOfType<HTMLAnchorElement>( *rootNode())) {303 if ( rootNode()->document().inQuirksMode()) {302 for (auto& anchor : descendantsOfType<HTMLAnchorElement>(m_rootNode)) { 303 if (m_rootNode.document().inQuirksMode()) { 304 304 // Quirks mode, case insensitive comparison of names. 305 305 if (equalIgnoringCase(anchor.name(), name)) … … 336 336 Element* TreeScope::focusedElement() 337 337 { 338 Document& document = rootNode()->document();338 Document& document = m_rootNode.document(); 339 339 Element* element = document.focusedElement(); 340 340 … … 345 345 TreeScope* treeScope = &element->treeScope(); 346 346 while (treeScope != this && treeScope != &document) { 347 element = toShadowRoot(treeScope->rootNode()) ->hostElement();347 element = toShadowRoot(treeScope->rootNode()).hostElement(); 348 348 treeScope = &element->treeScope(); 349 349 } -
trunk/Source/WebCore/dom/TreeScope.h
r164195 r164251 96 96 void adoptIfNeeded(Node*); 97 97 98 ContainerNode * rootNode() const { return &m_rootNode; }98 ContainerNode& rootNode() const { return m_rootNode; } 99 99 100 100 IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTargetObserverRegistry.get(); } -
trunk/Source/WebCore/editing/VisibleSelection.cpp
r163712 r164251 486 486 } 487 487 488 if (Node* lastChild = treeScope.rootNode() ->lastChild())488 if (Node* lastChild = treeScope.rootNode().lastChild()) 489 489 return positionAfterNode(lastChild); 490 490 … … 504 504 } 505 505 506 if (Node* firstChild = treeScope.rootNode() ->firstChild())506 if (Node* firstChild = treeScope.rootNode().firstChild()) 507 507 return positionBeforeNode(firstChild); 508 508 -
trunk/Source/WebCore/page/DOMSelection.cpp
r164188 r164251 58 58 59 59 DOMSelection::DOMSelection(const TreeScope* treeScope) 60 : DOMWindowProperty(treeScope->rootNode() ->document().frame())60 : DOMWindowProperty(treeScope->rootNode().document().frame()) 61 61 , m_treeScope(treeScope) 62 62 { -
trunk/Source/WebCore/page/DragController.cpp
r163739 r164251 273 273 274 274 // If this is a button inside of the a file input, move up to the file input. 275 if (inputElement && inputElement->isTextButton() && inputElement->treeScope().rootNode() ->isShadowRoot())276 inputElement = toShadowRoot(inputElement->treeScope().rootNode()) ->hostElement()->toInputElement();275 if (inputElement && inputElement->isTextButton() && inputElement->treeScope().rootNode().isShadowRoot()) 276 inputElement = toShadowRoot(inputElement->treeScope().rootNode()).hostElement()->toInputElement(); 277 277 278 278 return inputElement && inputElement->isFileUpload() ? inputElement : 0; -
trunk/Source/WebCore/page/FocusController.cpp
r163524 r164251 75 75 ContainerNode* FocusNavigationScope::rootNode() const 76 76 { 77 return m_rootTreeScope->rootNode();77 return &m_rootTreeScope->rootNode(); 78 78 } 79 79 -
trunk/Source/WebCore/svg/SVGElement.cpp
r164123 r164251 948 948 // Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title. 949 949 if (isInShadowTree()) { 950 Element* shadowHostElement = toShadowRoot(treeScope().rootNode()) ->hostElement();950 Element* shadowHostElement = toShadowRoot(treeScope().rootNode()).hostElement(); 951 951 // At this time, SVG nodes are not allowed in non-<use> shadow trees, so any shadow root we do 952 952 // have should be a use. The assert and following test is here to catch future shadow DOM changes -
trunk/Source/WebCore/testing/Internals.cpp
r164245 r164251 366 366 if (!node) { 367 367 ec = INVALID_ACCESS_ERR; 368 return 0;369 } 370 371 return node->treeScope().rootNode();368 return nullptr; 369 } 370 371 return &node->treeScope().rootNode(); 372 372 } 373 373 … … 376 376 if (!node) { 377 377 ec = INVALID_ACCESS_ERR; 378 return 0;378 return nullptr; 379 379 } 380 380 const TreeScope* parentTreeScope = node->treeScope().parentTreeScope(); 381 return parentTreeScope ? parentTreeScope->rootNode() : 0;381 return parentTreeScope ? &parentTreeScope->rootNode() : nullptr; 382 382 } 383 383
Note: See TracChangeset
for help on using the changeset viewer.