CTTE: Node::treeScope() should return a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Oct 2013 02:30:52 +0000 (02:30 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Oct 2013 02:30:52 +0000 (02:30 +0000)
<https://webkit.org/b/122399>

Reviewed by Superlative Sam.

Every Node belongs to a TreeScope. To enforce this, I've made
treeScope() return a TreeScope&, and setTreeScope() now takes a
TreeScope& so there is no way to clear it.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156981 268f45cc-cd09-0410-ab3c-d52691b4dbfc

45 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNode.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/EventContext.h
Source/WebCore/dom/EventRetargeter.cpp
Source/WebCore/dom/EventRetargeter.h
Source/WebCore/dom/LiveNodeList.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/SelectorQuery.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/dom/TreeScope.h
Source/WebCore/dom/TreeScopeAdopter.cpp
Source/WebCore/dom/TreeScopeAdopter.h
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/editing/VisibleSelection.cpp
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/html/FormAssociatedElement.cpp
Source/WebCore/html/HTMLCollection.cpp
Source/WebCore/html/HTMLDataListElement.cpp
Source/WebCore/html/HTMLDocument.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLLabelElement.cpp
Source/WebCore/html/HTMLMapElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/ValidationMessage.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/FrameTree.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/svg/SVGAElement.cpp
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGViewSpec.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/xml/XPathFunctions.cpp

index db713a5..1eaeaf6 100644 (file)
@@ -1,3 +1,14 @@
+2013-10-05  Andreas Kling  <akling@apple.com>
+
+        CTTE: Node::treeScope() should return a reference.
+        <https://webkit.org/b/122399>
+
+        Reviewed by Superlative Sam.
+
+        Every Node belongs to a TreeScope. To enforce this, I've made
+        treeScope() return a TreeScope&, and setTreeScope() now takes a
+        TreeScope& so there is no way to clear it.
+
 2013-10-05  Sam Weinig  <sam@webkit.org>
 
         CTTE: Use references more for the Document parser
index 7d96faa..11d6ee1 100644 (file)
@@ -1111,7 +1111,7 @@ HTMLLabelElement* AccessibilityNodeObject::labelForElement(Element* element) con
 
     const AtomicString& id = element->getIdAttribute();
     if (!id.isEmpty()) {
-        if (HTMLLabelElement* label = element->treeScope()->labelElementForId(id))
+        if (HTMLLabelElement* label = element->treeScope().labelElementForId(id))
             return label;
     }
 
@@ -1819,9 +1819,7 @@ void AccessibilityNodeObject::elementsFromAttribute(Vector<Element*>& elements,
     if (!node || !node->isElementNode())
         return;
 
-    TreeScope* scope = node->treeScope();
-    if (!scope)
-        return;
+    TreeScope& treeScope = node->treeScope();
 
     String idList = getAttribute(attribute).string();
     if (idList.isEmpty())
@@ -1834,7 +1832,7 @@ void AccessibilityNodeObject::elementsFromAttribute(Vector<Element*>& elements,
     unsigned size = idVector.size();
     for (unsigned i = 0; i < size; ++i) {
         AtomicString idName(idVector[i]);
-        Element* idElement = scope->getElementById(idName);
+        Element* idElement = treeScope.getElementById(idName);
         if (idElement)
             elements.append(idElement);
     }
index 9ea79a1..e03dd8b 100644 (file)
@@ -2263,7 +2263,7 @@ AccessibilityObject* AccessibilityRenderObject::activeDescendant() const
     if (activeDescendantAttrStr.isNull() || activeDescendantAttrStr.isEmpty())
         return 0;
     
-    Element* target = element->treeScope()->getElementById(activeDescendantAttrStr);
+    Element* target = element->treeScope().getElementById(activeDescendantAttrStr);
     if (!target)
         return 0;
     
index 4d9a1ad..5656e1b 100644 (file)
@@ -163,9 +163,8 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
     // a) it's a UA rule
     // b) the tree scope allows author rules
     // c) the rules comes from a scoped style sheet within the same tree scope
-    TreeScope* treeScope = element->treeScope();
     if (!MatchingUARulesScope::isMatchingUARules()
-        && !treeScope->applyAuthorStyles())
+        && !element->treeScope().applyAuthorStyles())
         return;
 
     // We need to collect the rules for id, class, tag, and everything else into a buffer and
index cc4b2f5..49215a3 100644 (file)
@@ -156,7 +156,7 @@ void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
         // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
         // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
         // Can we do better?
-        treeScope()->adoptIfNeeded(adoptedChild.get());
+        treeScope().adoptIfNeeded(adoptedChild.get());
         if (attached() && !adoptedChild->attached())
             attachChild(*adoptedChild.get());
     }
@@ -320,7 +320,7 @@ bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
         if (child.parentNode())
             break;
 
-        treeScope()->adoptIfNeeded(&child);
+        treeScope().adoptIfNeeded(&child);
 
         insertBeforeCommon(next.get(), child);
 
@@ -474,7 +474,7 @@ bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
         if (child.parentNode())
             break;
 
-        treeScope()->adoptIfNeeded(&child);
+        treeScope().adoptIfNeeded(&child);
 
         // Add child before "next".
         {
@@ -721,7 +721,7 @@ bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, At
         if (child.parentNode())
             break;
 
-        treeScope()->adoptIfNeeded(&child);
+        treeScope().adoptIfNeeded(&child);
 
         // Append child to the end of the list
         {
@@ -752,7 +752,7 @@ void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild)
         NoEventDispatchAssertion assertNoEventDispatch;
         // FIXME: This method should take a PassRefPtr.
         appendChildToContainer(newChild.get(), *this);
-        treeScope()->adoptIfNeeded(newChild.get());
+        treeScope().adoptIfNeeded(newChild.get());
     }
 
     newChild->updateAncestorConnectedSubframeCountForInsertion();
index 38e7b94..3a5cf08 100644 (file)
@@ -248,7 +248,7 @@ inline bool Node::needsNodeRenderingTraversalSlowPath() const
 
 inline bool Node::isTreeScope() const
 {
-    return treeScope()->rootNode() == this;
+    return treeScope().rootNode() == this;
 }
 
 // This constant controls how much buffer is initially allocated
index 4ed8478..eec512b 100644 (file)
@@ -3262,7 +3262,7 @@ void Document::removeFocusedNodeOfSubtree(Node* node, bool amongChildrenOnly)
     if (!m_focusedElement || this->inPageCache()) // If the document is in the page cache, then we don't need to clear out the focused node.
         return;
 
-    Element* focusedElement = node->treeScope()->focusedElement();
+    Element* focusedElement = node->treeScope().focusedElement();
     if (!focusedElement)
         return;
 
index e9a7fbb..4f15968 100644 (file)
@@ -1632,7 +1632,7 @@ inline bool Node::isDocumentNode() const
 inline Node::Node(Document* document, ConstructionType type)
     : m_nodeFlags(type)
     , m_parentNode(0)
-    , m_treeScope(document ? document : TreeScope::noDocumentInstance())
+    , m_treeScope(document ? document : &TreeScope::noDocumentInstance())
     , m_previous(0)
     , m_next(0)
 {
index b2e528b..869dd2b 100644 (file)
@@ -1333,15 +1333,15 @@ Node::InsertionNotificationRequest Element::insertedInto(ContainerNode& insertio
     if (hasRareData())
         elementRareData()->clearClassListValueForQuirksMode();
 
-    TreeScope* newScope = insertionPoint.treeScope();
+    TreeScope* newScope = &insertionPoint.treeScope();
     HTMLDocument* newDocument = !wasInDocument && inDocument() && newScope->documentScope()->isHTMLDocument() ? toHTMLDocument(newScope->documentScope()) : 0;
-    if (newScope != treeScope())
+    if (newScope != &treeScope())
         newScope = 0;
 
     const AtomicString& idValue = getIdAttribute();
     if (!idValue.isNull()) {
         if (newScope)
-            updateIdForTreeScope(newScope, nullAtom, idValue);
+            updateIdForTreeScope(*newScope, nullAtom, idValue);
         if (newDocument)
             updateIdForDocument(*newDocument, nullAtom, idValue, AlwaysUpdateHTMLDocumentNamedItemMaps);
     }
@@ -1349,14 +1349,14 @@ Node::InsertionNotificationRequest Element::insertedInto(ContainerNode& insertio
     const AtomicString& nameValue = getNameAttribute();
     if (!nameValue.isNull()) {
         if (newScope)
-            updateNameForTreeScope(newScope, nullAtom, nameValue);
+            updateNameForTreeScope(*newScope, nullAtom, nameValue);
         if (newDocument)
             updateNameForDocument(*newDocument, nullAtom, nameValue);
     }
 
     if (newScope && hasTagName(labelTag)) {
         if (newScope->shouldCacheLabelsByForAttribute())
-            updateLabel(newScope, nullAtom, fastGetAttribute(forAttr));
+            updateLabel(*newScope, nullAtom, fastGetAttribute(forAttr));
     }
 
     return InsertionDone;
@@ -1376,15 +1376,15 @@ void Element::removedFrom(ContainerNode& insertionPoint)
     setSavedLayerScrollOffset(IntSize());
 
     if (insertionPoint.isInTreeScope()) {
-        TreeScope* oldScope = insertionPoint.treeScope();
+        TreeScope* oldScope = &insertionPoint.treeScope();
         HTMLDocument* oldDocument = inDocument() && oldScope->documentScope()->isHTMLDocument() ? toHTMLDocument(oldScope->documentScope()) : 0;
-        if (oldScope != treeScope())
+        if (oldScope != &treeScope())
             oldScope = 0;
 
         const AtomicString& idValue = getIdAttribute();
         if (!idValue.isNull()) {
             if (oldScope)
-                updateIdForTreeScope(oldScope, idValue, nullAtom);
+                updateIdForTreeScope(*oldScope, idValue, nullAtom);
             if (oldDocument)
                 updateIdForDocument(*oldDocument, idValue, nullAtom, AlwaysUpdateHTMLDocumentNamedItemMaps);
         }
@@ -1392,14 +1392,14 @@ void Element::removedFrom(ContainerNode& insertionPoint)
         const AtomicString& nameValue = getNameAttribute();
         if (!nameValue.isNull()) {
             if (oldScope)
-                updateNameForTreeScope(oldScope, nameValue, nullAtom);
+                updateNameForTreeScope(*oldScope, nameValue, nullAtom);
             if (oldDocument)
                 updateNameForDocument(*oldDocument, nameValue, nullAtom);
         }
 
         if (oldScope && hasTagName(labelTag)) {
             if (oldScope->shouldCacheLabelsByForAttribute())
-                updateLabel(oldScope, fastGetAttribute(forAttr), nullAtom);
+                updateLabel(*oldScope, fastGetAttribute(forAttr), nullAtom);
         }
     }
 
@@ -1480,7 +1480,7 @@ void Element::addShadowRoot(PassRefPtr<ShadowRoot> newShadowRoot)
     ensureElementRareData().setShadowRoot(newShadowRoot);
 
     shadowRoot->setHostElement(this);
-    shadowRoot->setParentTreeScope(treeScope());
+    shadowRoot->setParentTreeScope(&treeScope());
     shadowRoot->distributor().didShadowBoundaryChange(this);
 
     ChildNodeInsertionNotifier(*this).notify(*shadowRoot);
@@ -1768,7 +1768,7 @@ PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionCode& ec)
     setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute);
 
     attrNode->attachToElement(this);
-    treeScope()->adoptIfNeeded(attrNode);
+    treeScope().adoptIfNeeded(attrNode);
     ensureAttrNodeListForElement(this).append(attrNode);
 
     return oldAttrNode.release();
@@ -2009,7 +2009,7 @@ void Element::updateFocusAppearance(bool /*restorePreviousSelection*/)
 void Element::blur()
 {
     cancelFocusAppearanceUpdate();
-    if (treeScope()->focusedElement() == this) {
+    if (treeScope().focusedElement() == this) {
         if (Frame* frame = document().frame())
             frame->page()->focusController().setFocusedElement(0, frame);
         else
@@ -2777,15 +2777,15 @@ inline void Element::updateName(const AtomicString& oldName, const AtomicString&
     updateNameForDocument(toHTMLDocument(document()), oldName, newName);
 }
 
-void Element::updateNameForTreeScope(TreeScope* scope, const AtomicString& oldName, const AtomicString& newName)
+void Element::updateNameForTreeScope(TreeScope& scope, const AtomicString& oldName, const AtomicString& newName)
 {
     ASSERT(isInTreeScope());
     ASSERT(oldName != newName);
 
     if (!oldName.isEmpty())
-        scope->removeElementByName(*oldName.impl(), *this);
+        scope.removeElementByName(*oldName.impl(), *this);
     if (!newName.isEmpty())
-        scope->addElementByName(*newName.impl(), *this);
+        scope.addElementByName(*newName.impl(), *this);
 }
 
 void Element::updateNameForDocument(HTMLDocument& document, const AtomicString& oldName, const AtomicString& newName)
@@ -2827,15 +2827,15 @@ inline void Element::updateId(const AtomicString& oldId, const AtomicString& new
     updateIdForDocument(toHTMLDocument(document()), oldId, newId, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute);
 }
 
-void Element::updateIdForTreeScope(TreeScope* scope, const AtomicString& oldId, const AtomicString& newId)
+void Element::updateIdForTreeScope(TreeScope& scope, const AtomicString& oldId, const AtomicString& newId)
 {
     ASSERT(isInTreeScope());
     ASSERT(oldId != newId);
 
     if (!oldId.isEmpty())
-        scope->removeElementById(*oldId.impl(), *this);
+        scope.removeElementById(*oldId.impl(), *this);
     if (!newId.isEmpty())
-        scope->addElementById(*newId.impl(), *this);
+        scope.addElementById(*newId.impl(), *this);
 }
 
 void Element::updateIdForDocument(HTMLDocument& document, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition condition)
@@ -2860,7 +2860,7 @@ void Element::updateIdForDocument(HTMLDocument& document, const AtomicString& ol
     }
 }
 
-void Element::updateLabel(TreeScope* scope, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue)
+void Element::updateLabel(TreeScope& scope, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue)
 {
     ASSERT(hasTagName(labelTag));
 
@@ -2871,9 +2871,9 @@ void Element::updateLabel(TreeScope* scope, const AtomicString& oldForAttributeV
         return;
 
     if (!oldForAttributeValue.isEmpty())
-        scope->removeLabel(*oldForAttributeValue.impl(), *toHTMLLabelElement(this));
+        scope.removeLabel(*oldForAttributeValue.impl(), *toHTMLLabelElement(this));
     if (!newForAttributeValue.isEmpty())
-        scope->addLabel(*newForAttributeValue.impl(), *toHTMLLabelElement(this));
+        scope.addLabel(*newForAttributeValue.impl(), *toHTMLLabelElement(this));
 }
 
 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
@@ -2883,9 +2883,8 @@ void Element::willModifyAttribute(const QualifiedName& name, const AtomicString&
     else if (name == HTMLNames::nameAttr)
         updateName(oldValue, newValue);
     else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
-        TreeScope* scope = treeScope();
-        if (scope->shouldCacheLabelsByForAttribute())
-            updateLabel(scope, oldValue, newValue);
+        if (treeScope().shouldCacheLabelsByForAttribute())
+            updateLabel(treeScope(), oldValue, newValue);
     }
 
     if (oldValue != newValue) {
@@ -2971,7 +2970,7 @@ PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name)
     RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name);
     if (!attrNode) {
         attrNode = Attr::create(this, name);
-        treeScope()->adoptIfNeeded(attrNode.get());
+        treeScope().adoptIfNeeded(attrNode.get());
         attrNodeList.append(attrNode);
     }
     return attrNode.release();
index 9a7a201..fd8911e 100644 (file)
@@ -616,13 +616,13 @@ private:
     void synchronizeAttribute(const AtomicString& localName) const;
 
     void updateName(const AtomicString& oldName, const AtomicString& newName);
-    void updateNameForTreeScope(TreeScope*, const AtomicString& oldName, const AtomicString& newName);
+    void updateNameForTreeScope(TreeScope&, const AtomicString& oldName, const AtomicString& newName);
     void updateNameForDocument(HTMLDocument&, const AtomicString& oldName, const AtomicString& newName);
     void updateId(const AtomicString& oldId, const AtomicString& newId);
-    void updateIdForTreeScope(TreeScope*, const AtomicString& oldId, const AtomicString& newId);
+    void updateIdForTreeScope(TreeScope&, const AtomicString& oldId, const AtomicString& newId);
     enum HTMLDocumentNamedItemMapsUpdatingCondition { AlwaysUpdateHTMLDocumentNamedItemMaps, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute };
     void updateIdForDocument(HTMLDocument&, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition);
-    void updateLabel(TreeScope*, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue);
+    void updateLabel(TreeScope&, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue);
 
     void scrollByUnits(int units, ScrollGranularity);
 
index 6e3a09a..6e1f269 100644 (file)
@@ -117,9 +117,9 @@ inline bool EventContext::isUnreachableNode(EventTarget* target)
 inline bool EventContext::isReachable(Node* target) const
 {
     ASSERT(target);
-    TreeScope* targetScope = target->treeScope();
-    for (TreeScope* scope = m_node->treeScope(); scope; scope = scope->parentTreeScope()) {
-        if (scope == targetScope)
+    TreeScope& targetScope = target->treeScope();
+    for (TreeScope* scope = &m_node->treeScope(); scope; scope = scope->parentTreeScope()) {
+        if (scope == &targetScope)
             return true;
     }
     return false;
index 283057c..984b094 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target)
 {
-    return target->toNode() && target->toNode()->treeScope()->rootNode() == shadowRoot;
+    return target->toNode() && target->toNode()->treeScope().rootNode() == shadowRoot;
 }
 
 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, ShadowRoot* shadowRoot, EventTarget* target)
@@ -192,7 +192,7 @@ void EventRetargeter::calculateAdjustedNodes(const Node* node, const Node* relat
     TreeScope* lastTreeScope = 0;
     Node* adjustedNode = 0;
     for (EventPath::const_iterator iter = eventPath.begin(); iter < eventPath.end(); ++iter) {
-        TreeScope* scope = (*iter)->node()->treeScope();
+        TreeScope* scope = &(*iter)->node()->treeScope();
         if (scope == lastTreeScope) {
             // Re-use the previous adjustedRelatedTarget if treeScope does not change. Just for the performance optimization.
             adjustedNodes.append(adjustedNode);
@@ -204,7 +204,7 @@ void EventRetargeter::calculateAdjustedNodes(const Node* node, const Node* relat
         if (eventWithRelatedTargetDispatchBehavior == DoesNotStopAtBoundary)
             continue;
         if (targetIsIdenticalToToRelatedTarget) {
-            if (node->treeScope()->rootNode() == (*iter)->node()) {
+            if (node->treeScope().rootNode() == (*iter)->node()) {
                 eventPath.shrink(iter + 1 - eventPath.begin());
                 break;
             }
@@ -224,7 +224,7 @@ void EventRetargeter::buildRelatedNodeMap(const Node* relatedNode, RelatedNodeMa
     for (Node* node = nodeOrHostIfPseudoElement(const_cast<Node*>(relatedNode)); node; node = node->parentOrShadowHostNode()) {
         if (relatedNodeStack.isEmpty())
             relatedNodeStack.append(node);
-        TreeScope* scope = node->treeScope();
+        TreeScope* scope = &node->treeScope();
         // Skips adding a node to the map if treeScope does not change. Just for the performance optimization.
         if (scope != lastTreeScope)
             relatedNodeMap.add(scope, relatedNodeStack.last());
index ff2b625..9dd9aab 100644 (file)
@@ -90,7 +90,7 @@ inline EventTarget* EventRetargeter::eventTargetRespectingTargetRules(Node* refe
 
     // Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included
     // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects
-    Node* rootNode = referenceNode->treeScope()->rootNode();
+    Node* rootNode = referenceNode->treeScope().rootNode();
     Element* shadowHostElement = rootNode->isShadowRoot() ? toShadowRoot(rootNode)->hostElement() : 0;
     // At this time, SVG nodes are not supported in non-<use> shadow trees.
     if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag))
index e0bb650..1edfa19 100644 (file)
@@ -74,7 +74,7 @@ Node* LiveNodeList::namedItem(const AtomicString& elementId) const
     Node* rootNode = this->rootNode();
 
     if (rootNode->inDocument()) {
-        Element* element = rootNode->treeScope()->getElementById(elementId);
+        Element* element = rootNode->treeScope().getElementById(elementId);
         if (element && nodeMatches(element) && element->isDescendantOf(rootNode))
             return element;
         if (!element)
index 210de6a..f92d4da 100644 (file)
@@ -975,7 +975,7 @@ Node* Node::deprecatedShadowAncestorNode() const
 
 ShadowRoot* Node::containingShadowRoot() const
 {
-    ContainerNode* root = treeScope()->rootNode();
+    ContainerNode* root = treeScope().rootNode();
     return root && root->isShadowRoot() ? toShadowRoot(root) : 0;
 }
 
@@ -1035,7 +1035,7 @@ void Node::removedFrom(ContainerNode& insertionPoint)
     ASSERT(insertionPoint.inDocument() || isContainerNode());
     if (insertionPoint.inDocument())
         clearFlag(InDocumentFlag);
-    if (isInShadowTree() && !treeScope()->rootNode()->isShadowRoot())
+    if (isInShadowTree() && !treeScope().rootNode()->isShadowRoot())
         clearFlag(IsInShadowTreeFlag);
 }
 
@@ -1530,7 +1530,7 @@ unsigned short Node::compareDocumentPosition(Node* otherNode)
     // If the nodes have different owning documents, they must be disconnected.  Note that we avoid
     // comparing Attr nodes here, since they return false from inDocument() all the time (which seems like a bug).
     if (start1->inDocument() != start2->inDocument() ||
-        start1->treeScope() != start2->treeScope())
+        &start1->treeScope() != &start2->treeScope())
         return compareDetachedElementsPosition(this, otherNode);
 
     // We need to find a common ancestor container, and then compare the indices of the two immediate children.
@@ -2265,7 +2265,7 @@ void Node::removedLastRef()
     // faster for non-Document nodes, and because the call to removedLastRef that is inlined
     // at all deref call sites is smaller if it's a non-virtual function.
     if (isTreeScope()) {
-        treeScope()->removedLastRefToScope();
+        treeScope().removedLastRefToScope();
         return;
     }
 
index 44575d5..b537ac1 100644 (file)
@@ -397,7 +397,11 @@ public:
         return *documentInternal();
     }
 
-    TreeScope* treeScope() const { return m_treeScope; }
+    TreeScope& treeScope() const
+    {
+        ASSERT(m_treeScope);
+        return *m_treeScope;
+    }
 
     // Returns true if this node is associated with a document and is in its associated document's
     // node tree, false otherwise.
@@ -650,8 +654,8 @@ protected:
 
     void setNeedsNodeRenderingTraversalSlowPath(bool flag) { setFlag(flag, NeedsNodeRenderingTraversalSlowPathFlag); }
 
-    Document* documentInternal() const { return treeScope()->documentScope(); }
-    void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
+    Document* documentInternal() const { return treeScope().documentScope(); }
+    void setTreeScope(TreeScope& scope) { m_treeScope = &scope; }
 
     void setStyleChange(StyleChangeType changeType) { m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; }
 
index dcc6cbe..8dfbae8 100644 (file)
@@ -141,8 +141,8 @@ ALWAYS_INLINE void SelectorDataList::executeFastPathForIdSelector(const Node* ro
     ASSERT(idSelector);
 
     const AtomicString& idToMatch = idSelector->value();
-    if (UNLIKELY(rootNode->treeScope()->containsMultipleElementsWithId(idToMatch))) {
-        const Vector<Element*>* elements = rootNode->treeScope()->getAllElementsById(idToMatch);
+    if (UNLIKELY(rootNode->treeScope().containsMultipleElementsWithId(idToMatch))) {
+        const Vector<Element*>* elements = rootNode->treeScope().getAllElementsById(idToMatch);
         ASSERT(elements);
         size_t count = elements->size();
         bool rootNodeIsTreeScopeRoot = isTreeScopeRoot(rootNode);
@@ -157,7 +157,7 @@ ALWAYS_INLINE void SelectorDataList::executeFastPathForIdSelector(const Node* ro
         return;
     }
 
-    Element* element = rootNode->treeScope()->getElementById(idToMatch);
+    Element* element = rootNode->treeScope().getElementById(idToMatch);
     if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(rootNode)))
         return;
     if (selectorMatches(selectorData, element, rootNode))
index 93d912f..8515221 100644 (file)
@@ -102,7 +102,7 @@ private:
 
 inline Element* ShadowRoot::activeElement() const
 {
-    return treeScope()->focusedElement();
+    return treeScope().focusedElement();
 }
 
 inline const ShadowRoot* toShadowRoot(const Node* node)
index 32d8a33..86eb702 100644 (file)
@@ -75,7 +75,7 @@ TreeScope::TreeScope(ContainerNode* rootNode, Document* document)
     ASSERT(document);
     ASSERT(rootNode != document);
     m_parentTreeScope->selfOnlyRef();
-    m_rootNode->setTreeScope(this);
+    m_rootNode->setTreeScope(*this);
 }
 
 TreeScope::TreeScope(Document* document)
@@ -86,7 +86,7 @@ TreeScope::TreeScope(Document* document)
     , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
 {
     ASSERT(document);
-    m_rootNode->setTreeScope(this);
+    m_rootNode->setTreeScope(*this);
 }
 
 TreeScope::TreeScope()
@@ -198,7 +198,7 @@ void TreeScope::removeElementByName(const AtomicStringImpl& name, Element& eleme
 Node* TreeScope::ancestorInThisScope(Node* node) const
 {
     while (node) {
-        if (node->treeScope() == this)
+        if (&node->treeScope() == this)
             return node;
         if (!node->isInShadowTree())
             return 0;
@@ -371,7 +371,7 @@ void TreeScope::adoptIfNeeded(Node* node)
     ASSERT(node);
     ASSERT(!node->isDocumentNode());
     ASSERT(!node->m_deletionHasBegun);
-    TreeScopeAdopter adopter(node, this);
+    TreeScopeAdopter adopter(node, *this);
     if (adopter.needsScopeChange())
         adopter.execute();
 }
@@ -394,10 +394,10 @@ Element* TreeScope::focusedElement()
         element = focusedFrameOwnerElement(document.page()->focusController().focusedFrame(), document.frame());
     if (!element)
         return 0;
-    TreeScope* treeScope = element->treeScope();
+    TreeScope* treeScope = &element->treeScope();
     while (treeScope != this && treeScope != &document) {
         element = toShadowRoot(treeScope->rootNode())->hostElement();
-        treeScope = element->treeScope();
+        treeScope = &element->treeScope();
     }
     if (this != treeScope)
         return 0;
@@ -407,7 +407,7 @@ Element* TreeScope::focusedElement()
 static void listTreeScopes(Node* node, Vector<TreeScope*, 5>& treeScopes)
 {
     while (true) {
-        treeScopes.append(node->treeScope());
+        treeScopes.append(&node->treeScope());
         Element* ancestor = node->shadowHost();
         if (!ancestor)
             break;
@@ -420,8 +420,8 @@ TreeScope* commonTreeScope(Node* nodeA, Node* nodeB)
     if (!nodeA || !nodeB)
         return 0;
 
-    if (nodeA->treeScope() == nodeB->treeScope())
-        return nodeA->treeScope();
+    if (&nodeA->treeScope() == &nodeB->treeScope())
+        return &nodeA->treeScope();
 
     Vector<TreeScope*, 5> treeScopesA;
     listTreeScopes(nodeA, treeScopesA);
@@ -445,7 +445,7 @@ bool TreeScope::deletionHasBegun()
 
 void TreeScope::beginDeletion()
 {
-    ASSERT(this != noDocumentInstance());
+    ASSERT(this != &noDocumentInstance());
     rootNode()->m_deletionHasBegun = true;
 }
 #endif
index e4afcb0..c1c1dec 100644 (file)
@@ -102,10 +102,10 @@ public:
 
     IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTargetObserverRegistry.get(); }
 
-    static TreeScope* noDocumentInstance()
+    static TreeScope& noDocumentInstance()
     {
         DEFINE_STATIC_LOCAL(TreeScope, instance, ());
-        return &instance;
+        return instance;
     }
 
     // Nodes belonging to this scope hold self-only references -
@@ -123,7 +123,7 @@ public:
     {
         ASSERT(!deletionHasBegun());
         --m_selfOnlyRefCount;
-        if (!m_selfOnlyRefCount && !refCount() && this != noDocumentInstance()) {
+        if (!m_selfOnlyRefCount && !refCount() && this != &noDocumentInstance()) {
             beginDeletion();
             delete this;
         }
@@ -141,7 +141,7 @@ protected:
     void setDocumentScope(Document* document)
     {
         ASSERT(document);
-        ASSERT(this != noDocumentInstance());
+        ASSERT(this != &noDocumentInstance());
         m_documentScope = document;
     }
 
index 497e3c5..fc8d576 100644 (file)
@@ -40,14 +40,14 @@ void TreeScopeAdopter::moveTreeToNewScope(Node* root) const
 {
     ASSERT(needsScopeChange());
 
-    m_oldScope->selfOnlyRef();
+    m_oldScope.selfOnlyRef();
 
     // If an element is moved from a document and then eventually back again the collection cache for
     // that element may contain stale data as changes made to it will have updated the DOMTreeVersion
     // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
     // we ensure that the collection cache will be invalidated as needed when the element is moved back.
-    Document* oldDocument = m_oldScope->documentScope();
-    Document* newDocument = m_newScope->documentScope();
+    Document* oldDocument = m_oldScope.documentScope();
+    Document* newDocument = m_newScope.documentScope();
     bool willMoveToNewDocument = oldDocument != newDocument;
     if (oldDocument && willMoveToNewDocument)
         oldDocument->incDOMTreeVersion();
@@ -73,13 +73,13 @@ void TreeScopeAdopter::moveTreeToNewScope(Node* root) const
         }
 
         if (ShadowRoot* shadow = node->shadowRoot()) {
-            shadow->setParentTreeScope(m_newScope);
+            shadow->setParentTreeScope(&m_newScope);
             if (willMoveToNewDocument)
                 moveTreeToNewDocument(shadow, oldDocument, newDocument);
         }
     }
 
-    m_oldScope->selfOnlyDeref();
+    m_oldScope.selfOnlyDeref();
 }
 
 void TreeScopeAdopter::moveTreeToNewDocument(Node* root, Document* oldDocument, Document* newDocument) const
@@ -106,9 +106,9 @@ void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document* oldDocument
 inline void TreeScopeAdopter::updateTreeScope(Node* node) const
 {
     ASSERT(!node->isTreeScope());
-    ASSERT(node->treeScope() == m_oldScope);
-    m_newScope->selfOnlyRef();
-    m_oldScope->selfOnlyDeref();
+    ASSERT(&node->treeScope() == &m_oldScope);
+    m_newScope.selfOnlyRef();
+    m_oldScope.selfOnlyDeref();
     node->setTreeScope(m_newScope);
 }
 
index cea4dca..da821d4 100644 (file)
@@ -33,10 +33,10 @@ class TreeScope;
 
 class TreeScopeAdopter {
 public:
-    explicit TreeScopeAdopter(Node* toAdopt, TreeScope* newScope);
+    explicit TreeScopeAdopter(Node* toAdopt, TreeScope& newScope);
 
     void execute() const { moveTreeToNewScope(m_toAdopt); }
-    bool needsScopeChange() const { return m_oldScope != m_newScope; }
+    bool needsScopeChange() const { return &m_oldScope != &m_newScope; }
 
 #ifdef NDEBUG
     static void ensureDidMoveToNewDocumentWasCalled(Document*) { }
@@ -51,16 +51,15 @@ private:
     void moveNodeToNewDocument(Node*, Document* oldDocument, Document* newDocument) const;
 
     Node* m_toAdopt;
-    TreeScope* m_newScope;
-    TreeScope* m_oldScope;
+    TreeScope& m_newScope;
+    TreeScope& m_oldScope;
 };
 
-inline TreeScopeAdopter::TreeScopeAdopter(Node* toAdopt, TreeScope* newScope)
+inline TreeScopeAdopter::TreeScopeAdopter(Node* toAdopt, TreeScope& newScope)
     : m_toAdopt(toAdopt)
     , m_newScope(newScope)
     , m_oldScope(toAdopt->treeScope())
 {
-    ASSERT(newScope);
 }
 
 }
index bf2164b..f567d83 100644 (file)
@@ -127,7 +127,7 @@ Node* FrameSelection::rootEditableElementOrTreeScopeRootNode() const
         return selectionRoot;
 
     Node* node = m_selection.base().containerNode();
-    return node ? node->treeScope()->rootNode() : 0;
+    return node ? node->treeScope().rootNode() : 0;
 }
 
 Element* FrameSelection::rootEditableElementRespectingShadowTree() const
index 2881213..059dd74 100644 (file)
@@ -463,17 +463,17 @@ void VisibleSelection::setWithoutValidation(const Position& base, const Position
 
 static Position adjustPositionForEnd(const Position& currentPosition, Node* startContainerNode)
 {
-    TreeScope* treeScope = startContainerNode->treeScope();
+    TreeScope& treeScope = startContainerNode->treeScope();
 
-    ASSERT(currentPosition.containerNode()->treeScope() != treeScope);
+    ASSERT(&currentPosition.containerNode()->treeScope() != &treeScope);
 
-    if (Node* ancestor = treeScope->ancestorInThisScope(currentPosition.containerNode())) {
+    if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.containerNode())) {
         if (ancestor->contains(startContainerNode))
             return positionAfterNode(ancestor);
         return positionBeforeNode(ancestor);
     }
 
-    if (Node* lastChild = treeScope->rootNode()->lastChild())
+    if (Node* lastChild = treeScope.rootNode()->lastChild())
         return positionAfterNode(lastChild);
 
     return Position();
@@ -481,17 +481,17 @@ static Position adjustPositionForEnd(const Position& currentPosition, Node* star
 
 static Position adjustPositionForStart(const Position& currentPosition, Node* endContainerNode)
 {
-    TreeScope* treeScope = endContainerNode->treeScope();
+    TreeScope& treeScope = endContainerNode->treeScope();
 
-    ASSERT(currentPosition.containerNode()->treeScope() != treeScope);
+    ASSERT(&currentPosition.containerNode()->treeScope() != &treeScope);
     
-    if (Node* ancestor = treeScope->ancestorInThisScope(currentPosition.containerNode())) {
+    if (Node* ancestor = treeScope.ancestorInThisScope(currentPosition.containerNode())) {
         if (ancestor->contains(endContainerNode))
             return positionBeforeNode(ancestor);
         return positionAfterNode(ancestor);
     }
 
-    if (Node* firstChild = treeScope->rootNode()->firstChild())
+    if (Node* firstChild = treeScope.rootNode()->firstChild())
         return positionBeforeNode(firstChild);
 
     return Position();
@@ -502,7 +502,7 @@ void VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries()
     if (m_base.isNull() || m_start.isNull() || m_end.isNull())
         return;
 
-    if (m_start.anchorNode()->treeScope() == m_end.anchorNode()->treeScope())
+    if (&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope())
         return;
 
     if (m_baseIsFirst) {
@@ -513,7 +513,7 @@ void VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries()
         m_start = m_extent;
     }
 
-    ASSERT(m_start.anchorNode()->treeScope() == m_end.anchorNode()->treeScope());
+    ASSERT(&m_start.anchorNode()->treeScope() == &m_end.anchorNode()->treeScope());
 }
 
 void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
index b901050..2ff8d91 100644 (file)
@@ -260,8 +260,8 @@ VisiblePosition firstEditablePositionAfterPositionInRoot(const Position& positio
 
     Position p = position;
 
-    if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) {
-        Node* shadowAncestor = highestRoot->treeScope()->ancestorInThisScope(p.deprecatedNode());
+    if (&position.deprecatedNode()->treeScope() != &highestRoot->treeScope()) {
+        Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.deprecatedNode());
         if (!shadowAncestor)
             return VisiblePosition();
 
@@ -285,8 +285,8 @@ VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& positio
 
     Position p = position;
 
-    if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) {
-        Node* shadowAncestor = highestRoot->treeScope()->ancestorInThisScope(p.deprecatedNode());
+    if (&position.deprecatedNode()->treeScope() != &highestRoot->treeScope()) {
+        Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(p.deprecatedNode());
         if (!shadowAncestor)
             return VisiblePosition();
 
index 7d9f65f..0ebe1a9 100644 (file)
@@ -105,9 +105,9 @@ HTMLFormElement* FormAssociatedElement::findAssociatedForm(const HTMLElement* el
         // The HTML5 spec says that the element should be associated with
         // the first element in the document to have an ID that equal to
         // the value of form attribute, so we put the result of
-        // treeScope()->getElementById() over the given element.
+        // treeScope().getElementById() over the given element.
         HTMLFormElement* newForm = 0;
-        Element* newFormCandidate = element->treeScope()->getElementById(formId);
+        Element* newFormCandidate = element->treeScope().getElementById(formId);
         if (newFormCandidate && isHTMLFormElement(newFormCandidate))
             newForm = toHTMLFormElement(newFormCandidate);
         return newForm;
@@ -279,7 +279,7 @@ OwnPtr<FormAttributeTargetObserver> FormAttributeTargetObserver::create(const At
 }
 
 FormAttributeTargetObserver::FormAttributeTargetObserver(const AtomicString& id, FormAssociatedElement* element)
-    : IdTargetObserver(toHTMLElement(element)->treeScope()->idTargetObserverRegistry(), id)
+    : IdTargetObserver(toHTMLElement(element)->treeScope().idTargetObserverRegistry(), id)
     , m_element(element)
 {
 }
index 508284e..555683e 100644 (file)
@@ -580,14 +580,14 @@ Node* HTMLCollection::namedItem(const AtomicString& name) const
         return 0;
 
     if (!overridesItemAfter() && root->isInTreeScope()) {
-        TreeScope* treeScope = root->treeScope();
+        TreeScope& treeScope = root->treeScope();
         Element* candidate = 0;
-        if (treeScope->hasElementWithId(*name.impl())) {
-            if (!treeScope->containsMultipleElementsWithId(name))
-                candidate = treeScope->getElementById(name);
-        } else if (treeScope->hasElementWithName(*name.impl())) {
-            if (!treeScope->containsMultipleElementsWithName(name)) {
-                candidate = treeScope->getElementByName(name);
+        if (treeScope.hasElementWithId(*name.impl())) {
+            if (!treeScope.containsMultipleElementsWithId(name))
+                candidate = treeScope.getElementById(name);
+        } else if (treeScope.hasElementWithName(*name.impl())) {
+            if (!treeScope.containsMultipleElementsWithName(name)) {
+                candidate = treeScope.getElementByName(name);
                 if (candidate && type() == DocAll && (!candidate->isHTMLElement() || !nameShouldBeVisibleInDocumentAll(toHTMLElement(candidate))))
                     candidate = 0;
             }
index 4fe49bc..8c204eb 100644 (file)
@@ -57,7 +57,7 @@ PassRefPtr<HTMLCollection> HTMLDataListElement::options()
 
 void HTMLDataListElement::optionElementChildrenChanged()
 {
-    treeScope()->idTargetObserverRegistry().notifyObservers(getIdAttribute());
+    treeScope().idTargetObserverRegistry().notifyObservers(getIdAttribute());
 }
 
 } // namespace WebCore
index a04cad9..c1e4ef0 100644 (file)
@@ -140,7 +140,7 @@ void HTMLDocument::setDesignMode(const String& value)
 
 Element* HTMLDocument::activeElement()
 {
-    if (Element* element = treeScope()->focusedElement())
+    if (Element* element = treeScope().focusedElement())
         return element;
     return body();
 }
index 4701aa0..820cecc 100644 (file)
@@ -1599,7 +1599,7 @@ HTMLDataListElement* HTMLInputElement::dataList() const
     if (!m_inputType->shouldRespectListAttribute())
         return 0;
 
-    Element* element = treeScope()->getElementById(fastGetAttribute(listAttr));
+    Element* element = treeScope().getElementById(fastGetAttribute(listAttr));
     if (!element)
         return 0;
     if (!element->hasTagName(datalistTag))
@@ -1895,7 +1895,7 @@ OwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(const At
 }
 
 ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element)
-    : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id)
+    : IdTargetObserver(element->treeScope().idTargetObserverRegistry(), id)
     , m_element(element)
 {
 }
index 1062a62..0441008 100644 (file)
@@ -79,7 +79,7 @@ LabelableElement* HTMLLabelElement::control()
     
     // Find the first element whose id is controlId. If it is found and it is a labelable form control,
     // return it, otherwise return 0.
-    return nodeAsSupportedLabelableElement(treeScope()->getElementById(controlId));
+    return nodeAsSupportedLabelableElement(treeScope().getElementById(controlId));
 }
 
 HTMLFormElement* HTMLLabelElement::form() const
index d677c4b..396c7ab 100644 (file)
@@ -99,13 +99,13 @@ void HTMLMapElement::parseAttribute(const QualifiedName& name, const AtomicStrin
                 return;
         }
         if (inDocument())
-            treeScope()->removeImageMap(*this);
+            treeScope().removeImageMap(*this);
         String mapName = value;
         if (mapName[0] == '#')
             mapName = mapName.substring(1);
         m_name = document().isHTMLDocument() ? mapName.lower() : mapName;
         if (inDocument())
-            treeScope()->addImageMap(*this);
+            treeScope().addImageMap(*this);
 
         return;
     }
@@ -121,14 +121,14 @@ PassRefPtr<HTMLCollection> HTMLMapElement::areas()
 Node::InsertionNotificationRequest HTMLMapElement::insertedInto(ContainerNode& insertionPoint)
 {
     if (insertionPoint.inDocument())
-        treeScope()->addImageMap(*this);
+        treeScope().addImageMap(*this);
     return HTMLElement::insertedInto(insertionPoint);
 }
 
 void HTMLMapElement::removedFrom(ContainerNode& insertionPoint)
 {
     if (insertionPoint.inDocument())
-        treeScope()->removeImageMap(*this);
+        treeScope().removeImageMap(*this);
     HTMLElement::removedFrom(insertionPoint);
 }
 
index 92ec5dc..226eb4b 100644 (file)
@@ -591,7 +591,7 @@ bool HTMLMediaElement::childShouldCreateRenderer(const Node* child) const
     // be rendered. So this should return false for most of the children.
     // One exception is a shadow tree built for rendering controls which should be visible.
     // So we let them go here by comparing its subtree root with one of the controls.
-    return mediaControls()->treeScope() == child->treeScope()
+    return &mediaControls()->treeScope() == &child->treeScope()
         && hasShadowRootParent(child)
         && HTMLElement::childShouldCreateRenderer(child);
 #endif
index b38c74c..7e9c3ea 100644 (file)
@@ -230,7 +230,7 @@ bool ValidationMessage::shadowTreeContains(const Node* node) const
 {
     if (validationMessageClient() || !m_bubble)
         return false;
-    return m_bubble->treeScope() == node->treeScope();
+    return &m_bubble->treeScope() == &node->treeScope();
 }
 
 void ValidationMessage::deleteBubbleTree(Timer<ValidationMessage>*)
index fd54bdb..3966582 100644 (file)
@@ -275,8 +275,8 @@ static HTMLInputElement* asFileInput(Node* node)
     HTMLInputElement* inputElement = node->toInputElement();
 
     // If this is a button inside of the a file input, move up to the file input.
-    if (inputElement && inputElement->isTextButton() && inputElement->treeScope()->rootNode()->isShadowRoot())
-        inputElement = toShadowRoot(inputElement->treeScope()->rootNode())->hostElement()->toInputElement();
+    if (inputElement && inputElement->isTextButton() && inputElement->treeScope().rootNode()->isShadowRoot())
+        inputElement = toShadowRoot(inputElement->treeScope().rootNode())->hostElement()->toInputElement();
 
     return inputElement && inputElement->isFileUpload() ? inputElement : 0;
 }
index d6af703..8aec072 100644 (file)
@@ -96,7 +96,7 @@ FocusNavigationScope FocusNavigationScope::focusNavigationScopeOf(Node* node)
         root = n;
     // The result is not always a ShadowRoot nor a DocumentNode since
     // a starting node is in an orphaned tree in composed shadow tree.
-    return FocusNavigationScope(root->treeScope());
+    return FocusNavigationScope(&root->treeScope());
 }
 
 FocusNavigationScope FocusNavigationScope::focusNavigationScopeOwnedByShadowHost(Node* node)
index dbe88a3..025d32e 100644 (file)
@@ -179,7 +179,7 @@ static bool inScope(Frame& frame, TreeScope& scope)
     HTMLFrameOwnerElement* owner = document->ownerElement();
     if (!owner)
         return false;
-    return owner->treeScope() == &scope;
+    return &owner->treeScope() == &scope;
 }
 
 inline Frame* FrameTree::scopedChild(unsigned index, TreeScope* scope) const
index 20bcf97..318a390 100644 (file)
@@ -563,7 +563,7 @@ LayoutUnit RenderImage::minimumReplacedHeight() const
 HTMLMapElement* RenderImage::imageMap() const
 {
     HTMLImageElement* i = element() && isHTMLImageElement(element()) ? toHTMLImageElement(element()) : 0;
-    return i ? i->treeScope()->getImageMap(i->fastGetAttribute(usemapAttr)) : 0;
+    return i ? i->treeScope().getImageMap(i->fastGetAttribute(usemapAttr)) : 0;
 }
 
 bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
index d04509f..7614dcb 100644 (file)
@@ -160,7 +160,7 @@ void SVGAElement::defaultEventHandler(Event* event)
             String url = stripLeadingAndTrailingHTMLSpaces(href());
 
             if (url[0] == '#') {
-                Element* targetElement = treeScope()->getElementById(url.substring(1));
+                Element* targetElement = treeScope().getElementById(url.substring(1));
                 if (SVGSMILElement::isSMILElement(targetElement)) {
                     toSVGSMILElement(targetElement)->beginByLinkActivation();
                     event->setDefaultHandled();
index 0c56e52..f379212 100644 (file)
@@ -909,7 +909,7 @@ String SVGElement::title() const
 
     // Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title.
     if (isInShadowTree()) {
-        Element* shadowHostElement = toShadowRoot(treeScope()->rootNode())->hostElement();
+        Element* shadowHostElement = toShadowRoot(treeScope().rootNode())->hostElement();
         // At this time, SVG nodes are not allowed in non-<use> shadow trees, so any shadow root we do
         // have should be a use. The assert and following test is here to catch future shadow DOM changes
         // that do enable SVG in a shadow tree.
index d3e3425..1974d07 100644 (file)
@@ -771,7 +771,7 @@ void SVGSVGElement::documentDidResumeFromPageCache()
 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement
 Element* SVGSVGElement::getElementById(const AtomicString& id)
 {
-    Element* element = treeScope()->getElementById(id);
+    Element* element = treeScope().getElementById(id);
     if (element && element->isDescendantOf(this))
         return element;
 
index 67aac2c..c3d829c 100644 (file)
@@ -142,7 +142,7 @@ SVGElement* SVGViewSpec::viewTarget() const
 {
     if (!m_contextElement)
         return 0;
-    Element* element = m_contextElement->treeScope()->getElementById(m_viewTargetString);
+    Element* element = m_contextElement->treeScope().getElementById(m_viewTargetString);
     if (!element || !element->isSVGElement())
         return 0;
     return toSVGElement(element);
index 2102dae..d903171 100644 (file)
@@ -517,7 +517,7 @@ void SVGSMILElement::svgAttributeChanged(const QualifiedName& attrName)
 
 inline Element* SVGSMILElement::eventBaseFor(const Condition& condition)
 {
-    return condition.m_baseID.isEmpty() ? targetElement() : treeScope()->getElementById(condition.m_baseID);
+    return condition.m_baseID.isEmpty() ? targetElement() : treeScope().getElementById(condition.m_baseID);
 }
 
 void SVGSMILElement::connectConditions()
@@ -537,7 +537,7 @@ void SVGSMILElement::connectConditions()
             eventBase->addEventListener(condition.m_name, condition.m_eventListener, false);
         } else if (condition.m_type == Condition::Syncbase) {
             ASSERT(!condition.m_baseID.isEmpty());
-            condition.m_syncbase = treeScope()->getElementById(condition.m_baseID);
+            condition.m_syncbase = treeScope().getElementById(condition.m_baseID);
             if (!isSMILElement(condition.m_syncbase.get())) {
                 condition.m_syncbase = 0;
                 continue;
index 70933b0..b32f31d 100644 (file)
@@ -348,7 +348,7 @@ Node* Internals::treeScopeRootNode(Node* node, ExceptionCode& ec)
         return 0;
     }
 
-    return node->treeScope()->rootNode();
+    return node->treeScope().rootNode();
 }
 
 Node* Internals::parentTreeScope(Node* node, ExceptionCode& ec)
@@ -357,7 +357,7 @@ Node* Internals::parentTreeScope(Node* node, ExceptionCode& ec)
         ec = INVALID_ACCESS_ERR;
         return 0;
     }
-    const TreeScope* parentTreeScope = node->treeScope()->parentTreeScope();
+    const TreeScope* parentTreeScope = node->treeScope().parentTreeScope();
     return parentTreeScope ? parentTreeScope->rootNode() : 0;
 }
 
index d3cc991..2d24e1a 100644 (file)
@@ -330,7 +330,7 @@ Value FunId::evaluate() const
         idList.append(str);
     }
     
-    TreeScope* contextScope = evaluationContext().node->treeScope();
+    TreeScope& contextScope = evaluationContext().node->treeScope();
     NodeSet result;
     HashSet<Node*> resultSet;
 
@@ -349,7 +349,7 @@ Value FunId::evaluate() const
 
         // If there are several nodes with the same id, id() should return the first one.
         // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
-        Node* node = contextScope->getElementById(String(idList.characters() + startPos, endPos - startPos));
+        Node* node = contextScope.getElementById(String(idList.characters() + startPos, endPos - startPos));
         if (node && resultSet.add(node).isNewEntry)
             result.append(node);