Title: [208828] trunk/Source/WebCore
Revision
208828
Author
[email protected]
Date
2016-11-16 16:39:55 -0800 (Wed, 16 Nov 2016)

Log Message

Use more references in TreeScope / TreeScopeAdopter
https://bugs.webkit.org/show_bug.cgi?id=164836

Reviewed by Ryosuke Niwa.

Use more references in TreeScope / TreeScopeAdopter and avoid some
unnecessary null checks.

No new tests, no Web-exposed behavior change.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::takeAllChildrenFrom):
(WebCore::ContainerNode::insertBefore):
(WebCore::ContainerNode::replaceChild):
(WebCore::ContainerNode::removeBetween):
(WebCore::ContainerNode::appendChildWithoutPreInsertionValidityCheck):
(WebCore::ContainerNode::parserAppendChild):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::addChildNodesToDeletionQueue):
* dom/Document.cpp:
(WebCore::Document::adoptNode):
(WebCore::Document::moveNodeIteratorsToNewDocument):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::didMoveToNewDocument):
(WebCore::Element::addShadowRoot):
(WebCore::Element::removeShadowRoot):
(WebCore::Element::setAttributeNode):
(WebCore::Element::setAttributeNodeNS):
(WebCore::Element::ensureAttr):
* dom/Element.h:
* dom/Node.cpp:
(WebCore::Node::didMoveToNewDocument):
* dom/Node.h:
* dom/NodeRareData.h:
(WebCore::NodeListsNodeData::adoptDocument):
* dom/TreeScope.cpp:
(WebCore::TreeScope::TreeScope):
(WebCore::TreeScope::setParentTreeScope):
(WebCore::TreeScope::adoptIfNeeded):
* dom/TreeScope.h:
(WebCore::TreeScope::documentScope):
(WebCore::TreeScope::setDocumentScope):
* dom/TreeScopeAdopter.cpp:
(WebCore::TreeScopeAdopter::moveTreeToNewScope):
(WebCore::TreeScopeAdopter::moveShadowTreeToNewDocument):
(WebCore::TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled):
(WebCore::TreeScopeAdopter::updateTreeScope):
(WebCore::TreeScopeAdopter::moveNodeToNewDocument):
* dom/TreeScopeAdopter.h:
(WebCore::TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled):
(WebCore::TreeScopeAdopter::TreeScopeAdopter):
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::didMoveToNewDocument):
* html/FormAssociatedElement.h:
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::didMoveToNewDocument):
* html/HTMLFieldSetElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::didMoveToNewDocument):
* html/HTMLFormControlElement.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::didMoveToNewDocument):
* html/HTMLFormElement.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::didMoveToNewDocument):
* html/HTMLImageElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didMoveToNewDocument):
* html/HTMLInputElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::didMoveToNewDocument):
* html/HTMLMediaElement.h:
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::didMoveToNewDocument):
* html/HTMLObjectElement.h:
* html/HTMLPictureElement.cpp:
(WebCore::HTMLPictureElement::didMoveToNewDocument):
* html/HTMLPictureElement.h:
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didMoveToNewDocument):
* html/HTMLPlugInImageElement.h:
* html/HTMLTemplateElement.cpp:
(WebCore::HTMLTemplateElement::didMoveToNewDocument):
* html/HTMLTemplateElement.h:
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::didMoveToNewDocument):
* html/HTMLVideoElement.h:
* html/ImageDocument.cpp:
(WebCore::ImageDocumentElement::didMoveToNewDocument):
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::didMoveToNewDocument):
* svg/SVGImageElement.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::didMoveToNewDocument):
* svg/SVGSVGElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208827 => 208828)


--- trunk/Source/WebCore/ChangeLog	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/ChangeLog	2016-11-17 00:39:55 UTC (rev 208828)
@@ -1,3 +1,102 @@
+2016-11-16  Chris Dumez  <[email protected]>
+
+        Use more references in TreeScope / TreeScopeAdopter
+        https://bugs.webkit.org/show_bug.cgi?id=164836
+
+        Reviewed by Ryosuke Niwa.
+
+        Use more references in TreeScope / TreeScopeAdopter and avoid some
+        unnecessary null checks.
+
+        No new tests, no Web-exposed behavior change.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::takeAllChildrenFrom):
+        (WebCore::ContainerNode::insertBefore):
+        (WebCore::ContainerNode::replaceChild):
+        (WebCore::ContainerNode::removeBetween):
+        (WebCore::ContainerNode::appendChildWithoutPreInsertionValidityCheck):
+        (WebCore::ContainerNode::parserAppendChild):
+        * dom/ContainerNodeAlgorithms.cpp:
+        (WebCore::addChildNodesToDeletionQueue):
+        * dom/Document.cpp:
+        (WebCore::Document::adoptNode):
+        (WebCore::Document::moveNodeIteratorsToNewDocument):
+        * dom/Document.h:
+        * dom/Element.cpp:
+        (WebCore::Element::didMoveToNewDocument):
+        (WebCore::Element::addShadowRoot):
+        (WebCore::Element::removeShadowRoot):
+        (WebCore::Element::setAttributeNode):
+        (WebCore::Element::setAttributeNodeNS):
+        (WebCore::Element::ensureAttr):
+        * dom/Element.h:
+        * dom/Node.cpp:
+        (WebCore::Node::didMoveToNewDocument):
+        * dom/Node.h:
+        * dom/NodeRareData.h:
+        (WebCore::NodeListsNodeData::adoptDocument):
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::TreeScope):
+        (WebCore::TreeScope::setParentTreeScope):
+        (WebCore::TreeScope::adoptIfNeeded):
+        * dom/TreeScope.h:
+        (WebCore::TreeScope::documentScope):
+        (WebCore::TreeScope::setDocumentScope):
+        * dom/TreeScopeAdopter.cpp:
+        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
+        (WebCore::TreeScopeAdopter::moveShadowTreeToNewDocument):
+        (WebCore::TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled):
+        (WebCore::TreeScopeAdopter::updateTreeScope):
+        (WebCore::TreeScopeAdopter::moveNodeToNewDocument):
+        * dom/TreeScopeAdopter.h:
+        (WebCore::TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled):
+        (WebCore::TreeScopeAdopter::TreeScopeAdopter):
+        * html/FormAssociatedElement.cpp:
+        (WebCore::FormAssociatedElement::didMoveToNewDocument):
+        * html/FormAssociatedElement.h:
+        * html/HTMLFieldSetElement.cpp:
+        (WebCore::HTMLFieldSetElement::didMoveToNewDocument):
+        * html/HTMLFieldSetElement.h:
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::didMoveToNewDocument):
+        * html/HTMLFormControlElement.h:
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::didMoveToNewDocument):
+        * html/HTMLFormElement.h:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::didMoveToNewDocument):
+        * html/HTMLImageElement.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::didMoveToNewDocument):
+        * html/HTMLInputElement.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::didMoveToNewDocument):
+        * html/HTMLMediaElement.h:
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::didMoveToNewDocument):
+        * html/HTMLObjectElement.h:
+        * html/HTMLPictureElement.cpp:
+        (WebCore::HTMLPictureElement::didMoveToNewDocument):
+        * html/HTMLPictureElement.h:
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::didMoveToNewDocument):
+        * html/HTMLPlugInImageElement.h:
+        * html/HTMLTemplateElement.cpp:
+        (WebCore::HTMLTemplateElement::didMoveToNewDocument):
+        * html/HTMLTemplateElement.h:
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::didMoveToNewDocument):
+        * html/HTMLVideoElement.h:
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocumentElement::didMoveToNewDocument):
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::didMoveToNewDocument):
+        * svg/SVGImageElement.h:
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::didMoveToNewDocument):
+        * svg/SVGSVGElement.h:
+
 2016-11-16  Jon Davis  <[email protected]>
 
         Added Web App Manifest to the Feature Status page.

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -139,12 +139,12 @@
         destroyRenderTreeIfNeeded(child);
 
         // FIXME: We need a no mutation event version of adoptNode.
-        RefPtr<Node> adoptedChild = document().adoptNode(child).releaseReturnValue();
-        parserAppendChild(*adoptedChild);
+        auto adoptedChild = document().adoptNode(child).releaseReturnValue();
+        parserAppendChild(adoptedChild);
         // 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);
     }
 }
 
@@ -280,7 +280,7 @@
         if (child->parentNode())
             break;
 
-        treeScope().adoptIfNeeded(child.ptr());
+        treeScope().adoptIfNeeded(child);
 
         insertBeforeCommon(next, child);
 
@@ -444,7 +444,7 @@
         if (child->parentNode())
             break;
 
-        treeScope().adoptIfNeeded(child.ptr());
+        treeScope().adoptIfNeeded(child);
 
         {
             NoEventDispatchAssertion assertNoEventDispatch;
@@ -579,7 +579,7 @@
     ASSERT(!oldChild.nextSibling());
     oldChild.setParentNode(nullptr);
 
-    document().adoptIfNeeded(&oldChild);
+    document().adoptIfNeeded(oldChild);
 }
 
 void ContainerNode::parserRemoveChild(Node& oldChild)
@@ -679,7 +679,7 @@
         if (child->parentNode())
             break;
 
-        treeScope().adoptIfNeeded(child.ptr());
+        treeScope().adoptIfNeeded(child);
 
         // Append child to the end of the list
         {
@@ -706,7 +706,7 @@
     {
         NoEventDispatchAssertion assertNoEventDispatch;
         appendChildCommon(newChild);
-        treeScope().adoptIfNeeded(&newChild);
+        treeScope().adoptIfNeeded(newChild);
     }
 
     newChild.updateAncestorConnectedSubframeCountForInsertion();

Modified: trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -190,7 +190,7 @@
         } else {
             Ref<Node> protect(*node); // removedFromDocument may remove remove all references to this node.
             if (Document* containerDocument = container.ownerDocument())
-                containerDocument->adoptIfNeeded(node);
+                containerDocument->adoptIfNeeded(*node);
             if (node->isInTreeScope())
                 notifyChildNodeRemoved(container, *node);
         }

Modified: trunk/Source/WebCore/dom/Document.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/Document.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -1024,7 +1024,7 @@
             return result.releaseException();
     }
 
-    adoptIfNeeded(&source);
+    adoptIfNeeded(source);
 
     return Ref<Node> { source };
 }
@@ -3865,14 +3865,14 @@
     m_nodeIterators.remove(ni);
 }
 
-void Document::moveNodeIteratorsToNewDocument(Node* node, Document* newDocument)
+void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)
 {
     Vector<NodeIterator*> nodeIterators;
     copyToVector(m_nodeIterators, nodeIterators);
     for (auto* it : nodeIterators) {
-        if (&it->root() == node) {
+        if (&it->root() == &node) {
             detachNodeIterator(it);
-            newDocument->attachNodeIterator(it);
+            newDocument.attachNodeIterator(it);
         }
     }
 }

Modified: trunk/Source/WebCore/dom/Document.h (208827 => 208828)


--- trunk/Source/WebCore/dom/Document.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/Document.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -735,7 +735,7 @@
 
     void attachNodeIterator(NodeIterator*);
     void detachNodeIterator(NodeIterator*);
-    void moveNodeIteratorsToNewDocument(Node*, Document*);
+    void moveNodeIteratorsToNewDocument(Node&, Document&);
 
     void attachRange(Range*);
     void detachRange(Range*);

Modified: trunk/Source/WebCore/dom/Element.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/Element.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -1531,11 +1531,11 @@
 {
 }
 
-void Element::didMoveToNewDocument(Document* oldDocument)
+void Element::didMoveToNewDocument(Document& oldDocument)
 {
     Node::didMoveToNewDocument(oldDocument);
 
-    if (oldDocument->inQuirksMode() != document().inQuirksMode()) {
+    if (oldDocument.inQuirksMode() != document().inQuirksMode()) {
         // ElementData::m_classNames or ElementData::m_idForStyleResolution need to be updated with the right case.
         if (hasID())
             attributeChanged(idAttr, nullAtom, getIdAttribute());
@@ -1544,7 +1544,7 @@
     }
 
     if (UNLIKELY(isDefinedCustomElement()))
-        CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded(*this, *oldDocument, document());
+        CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded(*this, oldDocument, document());
 }
 
 bool Element::hasAttributes() const
@@ -1746,7 +1746,7 @@
     ensureElementRareData().setShadowRoot(WTFMove(newShadowRoot));
 
     shadowRoot.setHost(this);
-    shadowRoot.setParentTreeScope(&treeScope());
+    shadowRoot.setParentTreeScope(treeScope());
 
     NodeVector postInsertionNotificationTargets;
     notifyChildNodeInserted(*this, shadowRoot, postInsertionNotificationTargets);
@@ -1775,7 +1775,7 @@
     elementRareData()->clearShadowRoot();
 
     oldRoot->setHost(nullptr);
-    oldRoot->setParentTreeScope(&document());
+    oldRoot->setParentTreeScope(document());
 }
 
 static bool canAttachAuthorShadowRoot(const Element& element)
@@ -2147,7 +2147,7 @@
     }
     if (attrNode.ownerElement() != this) {
         attrNode.attachToElement(*this);
-        treeScope().adoptIfNeeded(&attrNode);
+        treeScope().adoptIfNeeded(attrNode);
         ensureAttrNodeListForElement(*this).append(&attrNode);
     }
     return WTFMove(oldAttrNode);
@@ -2178,7 +2178,7 @@
     setAttributeInternal(index, attrNode.qualifiedName(), attrNode.value(), NotInSynchronizationOfLazyAttribute);
 
     attrNode.attachToElement(*this);
-    treeScope().adoptIfNeeded(&attrNode);
+    treeScope().adoptIfNeeded(attrNode);
     ensureAttrNodeListForElement(*this).append(&attrNode);
 
     return WTFMove(oldAttrNode);
@@ -3389,7 +3389,7 @@
     RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name);
     if (!attrNode) {
         attrNode = Attr::create(*this, name);
-        treeScope().adoptIfNeeded(attrNode.get());
+        treeScope().adoptIfNeeded(*attrNode);
         attrNodeList.append(attrNode);
     }
     return attrNode.releaseNonNull();

Modified: trunk/Source/WebCore/dom/Element.h (208827 => 208828)


--- trunk/Source/WebCore/dom/Element.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/Element.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -586,7 +586,7 @@
     void childrenChanged(const ChildChange&) override;
     void removeAllEventListeners() final;
     virtual void parserDidSetAttributes();
-    void didMoveToNewDocument(Document*) override;
+    void didMoveToNewDocument(Document&) override;
 
     void clearTabIndexExplicitlyIfNeeded();
     void setTabIndexExplicitly(int);

Modified: trunk/Source/WebCore/dom/Node.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/Node.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/Node.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -1864,7 +1864,7 @@
     return NodeEventTargetInterfaceType;
 }
 
-void Node::didMoveToNewDocument(Document* oldDocument)
+void Node::didMoveToNewDocument(Document& oldDocument)
 {
     TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument);
 
@@ -1875,14 +1875,14 @@
         }
     }
 
-    if (AXObjectCache::accessibilityEnabled() && oldDocument) {
-        if (auto* cache = oldDocument->existingAXObjectCache())
+    if (AXObjectCache::accessibilityEnabled()) {
+        if (auto* cache = oldDocument.existingAXObjectCache())
             cache->remove(this);
     }
 
     unsigned numWheelEventHandlers = eventListeners(eventNames().mousewheelEvent).size() + eventListeners(eventNames().wheelEvent).size();
     for (unsigned i = 0; i < numWheelEventHandlers; ++i) {
-        oldDocument->didRemoveWheelEventHandler(*this);
+        oldDocument.didRemoveWheelEventHandler(*this);
         document().didAddWheelEventHandler(*this);
     }
 
@@ -1891,7 +1891,7 @@
         numTouchEventHandlers += eventListeners(name).size();
 
     for (unsigned i = 0; i < numTouchEventHandlers; ++i) {
-        oldDocument->didRemoveTouchEventHandler(*this);
+        oldDocument.didRemoveTouchEventHandler(*this);
         document().didAddTouchEventHandler(*this);
     }
 

Modified: trunk/Source/WebCore/dom/Node.h (208827 => 208828)


--- trunk/Source/WebCore/dom/Node.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/Node.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -628,7 +628,7 @@
     };
     Node(Document&, ConstructionType);
 
-    virtual void didMoveToNewDocument(Document* oldDocument);
+    virtual void didMoveToNewDocument(Document& oldDocument);
     
     virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const { }
 

Modified: trunk/Source/WebCore/dom/NodeRareData.h (208827 => 208828)


--- trunk/Source/WebCore/dom/NodeRareData.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/NodeRareData.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -202,24 +202,23 @@
         invalidateCaches();
     }
 
-    void adoptDocument(Document* oldDocument, Document* newDocument)
+    void adoptDocument(Document& oldDocument, Document& newDocument)
     {
-        ASSERT(oldDocument);
-        if (oldDocument == newDocument) {
+        if (&oldDocument == &newDocument) {
             invalidateCaches();
             return;
         }
 
         for (auto& cache : m_atomicNameCaches.values())
-            cache->invalidateCache(*oldDocument);
+            cache->invalidateCache(oldDocument);
 
         for (auto& list : m_tagCollectionNSCache.values()) {
             ASSERT(!list->isRootedAtDocument());
-            list->invalidateCache(*oldDocument);
+            list->invalidateCache(oldDocument);
         }
 
         for (auto& collection : m_cachedCollections.values())
-            collection->invalidateCache(*oldDocument);
+            collection->invalidateCache(oldDocument);
     }
 
 private:

Modified: trunk/Source/WebCore/dom/TreeScope.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/TreeScope.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/TreeScope.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -57,7 +57,7 @@
 
 TreeScope::TreeScope(ShadowRoot& shadowRoot, Document& document)
     : m_rootNode(shadowRoot)
-    , m_documentScope(&document)
+    , m_documentScope(document)
     , m_parentTreeScope(&document)
     , m_idTargetObserverRegistry(std::make_unique<IdTargetObserverRegistry>())
 {
@@ -66,7 +66,7 @@
 
 TreeScope::TreeScope(Document& document)
     : m_rootNode(document)
-    , m_documentScope(&document)
+    , m_documentScope(document)
     , m_parentTreeScope(nullptr)
     , m_idTargetObserverRegistry(std::make_unique<IdTargetObserverRegistry>())
 {
@@ -84,15 +84,13 @@
     m_labelsByForAttribute = nullptr;
 }
 
-void TreeScope::setParentTreeScope(TreeScope* newParentScope)
+void TreeScope::setParentTreeScope(TreeScope& newParentScope)
 {
     // A document node cannot be re-parented.
     ASSERT(!m_rootNode.isDocumentNode());
-    // Every scope other than document needs a parent scope.
-    ASSERT(newParentScope);
 
-    m_parentTreeScope = newParentScope;
-    setDocumentScope(&newParentScope->documentScope());
+    m_parentTreeScope = &newParentScope;
+    setDocumentScope(newParentScope.documentScope());
 }
 
 Element* TreeScope::getElementById(const AtomicString& elementId) const
@@ -348,11 +346,10 @@
     return nullptr;
 }
 
-void TreeScope::adoptIfNeeded(Node* node)
+void TreeScope::adoptIfNeeded(Node& node)
 {
-    ASSERT(node);
-    ASSERT(!node->isDocumentNode());
-    ASSERT(!node->m_deletionHasBegun);
+    ASSERT(!node.isDocumentNode());
+    ASSERT(!node.m_deletionHasBegun);
     TreeScopeAdopter adopter(node, *this);
     if (adopter.needsScopeChange())
         adopter.execute();

Modified: trunk/Source/WebCore/dom/TreeScope.h (208827 => 208828)


--- trunk/Source/WebCore/dom/TreeScope.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/TreeScope.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -49,7 +49,7 @@
 
 public:
     TreeScope* parentTreeScope() const { return m_parentTreeScope; }
-    void setParentTreeScope(TreeScope*);
+    void setParentTreeScope(TreeScope&);
 
     Element* focusedElement();
     WEBCORE_EXPORT Element* getElementById(const AtomicString&) const;
@@ -66,7 +66,7 @@
     void addElementByName(const AtomicStringImpl&, Element&);
     void removeElementByName(const AtomicStringImpl&, Element&);
 
-    Document& documentScope() const { return *m_documentScope; }
+    Document& documentScope() const { return m_documentScope.get(); }
     static ptrdiff_t documentScopeMemoryOffset() { return OBJECT_OFFSETOF(TreeScope, m_documentScope); }
 
     // https://dom.spec.whatwg.org/#retarget
@@ -94,7 +94,7 @@
     Element* findAnchor(const String& name);
 
     // Used by the basic DOM mutation methods (e.g., appendChild()).
-    void adoptIfNeeded(Node*);
+    void adoptIfNeeded(Node&);
 
     ContainerNode& rootNode() const { return m_rootNode; }
 
@@ -106,9 +106,8 @@
     ~TreeScope();
 
     void destroyTreeScopeData();
-    void setDocumentScope(Document* document)
+    void setDocumentScope(Document& document)
     {
-        ASSERT(document);
         m_documentScope = document;
     }
 
@@ -116,7 +115,7 @@
 
 private:
     ContainerNode& m_rootNode;
-    Document* m_documentScope;
+    std::reference_wrapper<Document> m_documentScope;
     TreeScope* m_parentTreeScope;
 
     std::unique_ptr<DocumentOrderedMap> m_elementsById;

Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.cpp (208827 => 208828)


--- trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -33,7 +33,7 @@
 namespace WebCore {
 
 // FIXME: Do we ever change tree scopes except between documents?
-void TreeScopeAdopter::moveTreeToNewScope(Node* root) const
+void TreeScopeAdopter::moveTreeToNewScope(Node& root) const
 {
     ASSERT(needsScopeChange());
 
@@ -49,11 +49,11 @@
         oldDocument.incDOMTreeVersion();
     }
 
-    for (Node* node = root; node; node = NodeTraversal::next(*node, root)) {
-        updateTreeScope(node);
+    for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
+        updateTreeScope(*node);
 
         if (willMoveToNewDocument)
-            moveNodeToNewDocument(node, &oldDocument, &newDocument);
+            moveNodeToNewDocument(*node, oldDocument, newDocument);
         else if (node->hasRareData()) {
             NodeRareData* rareData = node->rareData();
             if (rareData->nodeLists())
@@ -65,13 +65,13 @@
 
         if (node->hasSyntheticAttrChildNodes()) {
             for (auto& attr : downcast<Element>(*node).attrNodeList())
-                moveTreeToNewScope(attr.get());
+                moveTreeToNewScope(*attr);
         }
 
-        if (ShadowRoot* shadow = node->shadowRoot()) {
-            shadow->setParentTreeScope(&m_newScope);
+        if (auto* shadow = node->shadowRoot()) {
+            shadow->setParentTreeScope(m_newScope);
             if (willMoveToNewDocument)
-                moveShadowTreeToNewDocument(shadow, &oldDocument, &newDocument);
+                moveShadowTreeToNewDocument(*shadow, oldDocument, newDocument);
         }
     }
 
@@ -79,12 +79,12 @@
         oldDocument.decrementReferencingNodeCount();
 }
 
-void TreeScopeAdopter::moveShadowTreeToNewDocument(ShadowRoot* shadowRoot, Document* oldDocument, Document* newDocument) const
+void TreeScopeAdopter::moveShadowTreeToNewDocument(ShadowRoot& shadowRoot, Document& oldDocument, Document& newDocument) const
 {
-    for (Node* node = shadowRoot; node; node = NodeTraversal::next(*node, shadowRoot)) {
-        moveNodeToNewDocument(node, oldDocument, newDocument);
-        if (ShadowRoot* shadow = node->shadowRoot())
-            moveShadowTreeToNewDocument(shadow, oldDocument, newDocument);
+    for (Node* node = &shadowRoot; node; node = NodeTraversal::next(*node, &shadowRoot)) {
+        moveNodeToNewDocument(*node, oldDocument, newDocument);
+        if (auto* shadow = node->shadowRoot())
+            moveShadowTreeToNewDocument(*shadow, oldDocument, newDocument);
     }
 }
 
@@ -92,46 +92,45 @@
 static bool didMoveToNewDocumentWasCalled = false;
 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = nullptr;
 
-void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document* oldDocument)
+void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document& oldDocument)
 {
     ASSERT(!didMoveToNewDocumentWasCalled);
-    ASSERT_UNUSED(oldDocument, oldDocument == oldDocumentDidMoveToNewDocumentWasCalledWith);
+    ASSERT_UNUSED(oldDocument, &oldDocument == oldDocumentDidMoveToNewDocumentWasCalledWith);
     didMoveToNewDocumentWasCalled = true;
 }
 #endif
 
-inline void TreeScopeAdopter::updateTreeScope(Node* node) const
+inline void TreeScopeAdopter::updateTreeScope(Node& node) const
 {
-    ASSERT(!node->isTreeScope());
-    ASSERT(&node->treeScope() == &m_oldScope);
-    node->setTreeScope(m_newScope);
+    ASSERT(!node.isTreeScope());
+    ASSERT(&node.treeScope() == &m_oldScope);
+    node.setTreeScope(m_newScope);
 }
 
-inline void TreeScopeAdopter::moveNodeToNewDocument(Node* node, Document* oldDocument, Document* newDocument) const
+inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDocument, Document& newDocument) const
 {
-    ASSERT(!node->inDocument() || oldDocument != newDocument);
+    ASSERT(!node.inDocument() || &oldDocument != &newDocument);
 
-    newDocument->incrementReferencingNodeCount();
-    oldDocument->decrementReferencingNodeCount();
+    newDocument.incrementReferencingNodeCount();
+    oldDocument.decrementReferencingNodeCount();
 
-    if (node->hasRareData()) {
-        NodeRareData* rareData = node->rareData();
-        if (rareData->nodeLists())
-            rareData->nodeLists()->adoptDocument(oldDocument, newDocument);
+    if (node.hasRareData()) {
+        NodeRareData* rareData = node.rareData();
+        if (auto* nodeLists = rareData->nodeLists())
+            nodeLists->adoptDocument(oldDocument, newDocument);
     }
 
-    if (oldDocument)
-        oldDocument->moveNodeIteratorsToNewDocument(node, newDocument);
+    oldDocument.moveNodeIteratorsToNewDocument(node, newDocument);
 
-    if (is<ShadowRoot>(*node))
-        downcast<ShadowRoot>(*node).setDocumentScope(newDocument);
+    if (is<ShadowRoot>(node))
+        downcast<ShadowRoot>(node).setDocumentScope(newDocument);
 
 #ifndef NDEBUG
     didMoveToNewDocumentWasCalled = false;
-    oldDocumentDidMoveToNewDocumentWasCalledWith = oldDocument;
+    oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument;
 #endif
 
-    node->didMoveToNewDocument(oldDocument);
+    node.didMoveToNewDocument(oldDocument);
     ASSERT(didMoveToNewDocumentWasCalled);
 }
 

Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.h (208827 => 208828)


--- trunk/Source/WebCore/dom/TreeScopeAdopter.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -33,32 +33,32 @@
 
 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; }
 
 #ifdef NDEBUG
-    static void ensureDidMoveToNewDocumentWasCalled(Document*) { }
+    static void ensureDidMoveToNewDocumentWasCalled(Document&) { }
 #else
-    static void ensureDidMoveToNewDocumentWasCalled(Document*);
+    static void ensureDidMoveToNewDocumentWasCalled(Document&);
 #endif
 
 private:
-    void updateTreeScope(Node*) const;
-    void moveTreeToNewScope(Node*) const;
-    void moveShadowTreeToNewDocument(ShadowRoot*, Document* oldDocument, Document* newDocument) const;
-    void moveNodeToNewDocument(Node*, Document* oldDocument, Document* newDocument) const;
+    void updateTreeScope(Node&) const;
+    void moveTreeToNewScope(Node&) const;
+    void moveShadowTreeToNewDocument(ShadowRoot&, Document& oldDocument, Document& newDocument) const;
+    void moveNodeToNewDocument(Node&, Document& oldDocument, Document& newDocument) const;
 
-    Node* m_toAdopt;
+    Node& m_toAdopt;
     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())
+    , m_oldScope(toAdopt.treeScope())
 {
 }
 

Modified: trunk/Source/WebCore/html/FormAssociatedElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/FormAssociatedElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/FormAssociatedElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -60,10 +60,10 @@
     setForm(nullptr);
 }
 
-void FormAssociatedElement::didMoveToNewDocument(Document* oldDocument)
+void FormAssociatedElement::didMoveToNewDocument(Document&)
 {
     HTMLElement& element = asHTMLElement();
-    if (oldDocument && element.hasAttributeWithoutSynchronization(formAttr))
+    if (element.hasAttributeWithoutSynchronization(formAttr))
         resetFormAttributeTargetObserver();
 }
 

Modified: trunk/Source/WebCore/html/FormAssociatedElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/FormAssociatedElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/FormAssociatedElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -92,7 +92,7 @@
 
     void insertedInto(ContainerNode&);
     void removedFrom(ContainerNode&);
-    void didMoveToNewDocument(Document* oldDocument);
+    void didMoveToNewDocument(Document& oldDocument);
 
     void setForm(HTMLFormElement*);
     void formAttributeChanged();

Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLFieldSetElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -122,12 +122,11 @@
         updateFromControlElementsAncestorDisabledStateUnder(*legend, true);
 }
 
-void HTMLFieldSetElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLFieldSetElement::didMoveToNewDocument(Document& oldDocument)
 {
     HTMLFormControlElement::didMoveToNewDocument(oldDocument);
     if (m_hasDisabledAttribute) {
-        if (oldDocument)
-            oldDocument->removeDisabledFieldsetElement();
+        oldDocument.removeDisabledFieldsetElement();
         document().addDisabledFieldsetElement();
     }
 }

Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLFieldSetElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -61,7 +61,7 @@
     void disabledAttributeChanged() final;
     void disabledStateChanged() final;
     void childrenChanged(const ChildChange&) final;
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     bool matchesValidPseudoClass() const final;
     bool matchesInvalidPseudoClass() const final;

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -250,7 +250,7 @@
     }
 }
 
-void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument)
 {
     FormAssociatedElement::didMoveToNewDocument(oldDocument);
     HTMLElement::didMoveToNewDocument(oldDocument);

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLFormControlElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -138,7 +138,7 @@
     InsertionNotificationRequest insertedInto(ContainerNode&) override;
     void finishedInsertingSubtree() override;
     void removedFrom(ContainerNode&) override;
-    void didMoveToNewDocument(Document* oldDocument) override;
+    void didMoveToNewDocument(Document& oldDocument) override;
 
     bool supportsFocus() const override;
     bool isKeyboardFocusable(KeyboardEvent&) const override;

Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLFormElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -843,11 +843,10 @@
     }
 }
 
-void HTMLFormElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLFormElement::didMoveToNewDocument(Document& oldDocument)
 {
     if (!shouldAutocomplete()) {
-        if (oldDocument)
-            oldDocument->unregisterForDocumentSuspensionCallbacks(this);
+        oldDocument.unregisterForDocumentSuspensionCallbacks(this);
         document().registerForDocumentSuspensionCallbacks(this);
     }
 

Modified: trunk/Source/WebCore/html/HTMLFormElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLFormElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLFormElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -145,7 +145,7 @@
 
     void resumeFromDocumentSuspension() final;
 
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     void copyNonAttributePropertiesFromElement(const Element&) final;
 

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -555,7 +555,7 @@
     addSubresourceURL(urls, document().completeURL(attributeWithoutSynchronization(usemapAttr)));
 }
 
-void HTMLImageElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLImageElement::didMoveToNewDocument(Document& oldDocument)
 {
     m_imageLoader.elementDidMoveToNewDocument();
     HTMLElement::didMoveToNewDocument(oldDocument);

Modified: trunk/Source/WebCore/html/HTMLImageElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLImageElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLImageElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -97,7 +97,7 @@
 protected:
     HTMLImageElement(const QualifiedName&, Document&, HTMLFormElement* = 0);
 
-    void didMoveToNewDocument(Document* oldDocument) override;
+    void didMoveToNewDocument(Document& oldDocument) override;
 
 private:
     void parseAttribute(const QualifiedName&, const AtomicString&) override;

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -1531,23 +1531,21 @@
 #endif
 }
 
-void HTMLInputElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLInputElement::didMoveToNewDocument(Document& oldDocument)
 {
     if (imageLoader())
         imageLoader()->elementDidMoveToNewDocument();
 
     bool needsSuspensionCallback = this->needsSuspensionCallback();
-    if (oldDocument) {
-        // Always unregister for cache callbacks when leaving a document, even if we would otherwise like to be registered
-        if (needsSuspensionCallback)
-            oldDocument->unregisterForDocumentSuspensionCallbacks(this);
-        if (isRadioButton())
-            oldDocument->formController().radioButtonGroups().removeButton(this);
+    // Always unregister for cache callbacks when leaving a document, even if we would otherwise like to be registered
+    if (needsSuspensionCallback)
+        oldDocument.unregisterForDocumentSuspensionCallbacks(this);
+    if (isRadioButton())
+        oldDocument.formController().radioButtonGroups().removeButton(this);
 #if ENABLE(TOUCH_EVENTS)
-        if (m_hasTouchEventHandler)
-            oldDocument->didRemoveEventTargetNode(*this);
+    if (m_hasTouchEventHandler)
+        oldDocument.didRemoveEventTargetNode(*this);
 #endif
-    }
 
     if (needsSuspensionCallback)
         document().registerForDocumentSuspensionCallbacks(this);

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -337,7 +337,7 @@
     InsertionNotificationRequest insertedInto(ContainerNode&) final;
     void finishedInsertingSubtree() final;
     void removedFrom(ContainerNode&) final;
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     bool hasCustomFocusLogic() const final;
     bool isKeyboardFocusable(KeyboardEvent&) const final;

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -664,16 +664,14 @@
     removeElementFromDocumentMap(*this, document);
 }
 
-void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
 {
     if (m_shouldDelayLoadEvent) {
-        if (oldDocument)
-            oldDocument->decrementLoadEventDelayCount();
+        oldDocument.decrementLoadEventDelayCount();
         document().incrementLoadEventDelayCount();
     }
 
-    if (oldDocument)
-        unregisterWithDocument(*oldDocument);
+    unregisterWithDocument(oldDocument);
 
     registerWithDocument(document());
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -495,7 +495,7 @@
     void willDetachRenderers() override;
     void didDetachRenderers() override;
 
-    void didMoveToNewDocument(Document* oldDocument) override;
+    void didMoveToNewDocument(Document& oldDocument) override;
 
     enum DisplayMode { Unknown, None, Poster, PosterWaitingForVideo, Video };
     DisplayMode displayMode() const { return m_displayMode; }

Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLObjectElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -498,7 +498,7 @@
         addSubresourceURL(urls, document().completeURL(useMap));
 }
 
-void HTMLObjectElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLObjectElement::didMoveToNewDocument(Document& oldDocument)
 {
     FormAssociatedElement::didMoveToNewDocument(oldDocument);
     HTMLPlugInImageElement::didMoveToNewDocument(oldDocument);

Modified: trunk/Source/WebCore/html/HTMLObjectElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLObjectElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLObjectElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -67,7 +67,7 @@
     void finishedInsertingSubtree() final;
     void removedFrom(ContainerNode&) final;
 
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     void childrenChanged(const ChildChange&) final;
 

Modified: trunk/Source/WebCore/html/HTMLPictureElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLPictureElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLPictureElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -42,10 +42,9 @@
     document().removeViewportDependentPicture(*this);
 }
 
-void HTMLPictureElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLPictureElement::didMoveToNewDocument(Document& oldDocument)
 {
-    if (oldDocument)
-        oldDocument->removeViewportDependentPicture(*this);
+    oldDocument.removeViewportDependentPicture(*this);
     HTMLElement::didMoveToNewDocument(oldDocument);
     sourcesChanged();
 }

Modified: trunk/Source/WebCore/html/HTMLPictureElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLPictureElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLPictureElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -48,7 +48,7 @@
 private:
     HTMLPictureElement(const QualifiedName&, Document&);
 
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     WeakPtrFactory<HTMLPictureElement> m_weakFactory { this };
     Vector<MediaQueryResult> m_viewportDependentMediaQueryResults;

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -309,10 +309,10 @@
         invalidateStyleForSubtree();
 }
 
-void HTMLPlugInImageElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLPlugInImageElement::didMoveToNewDocument(Document& oldDocument)
 {
     if (m_needsDocumentActivationCallbacks) {
-        oldDocument->unregisterForDocumentSuspensionCallbacks(this);
+        oldDocument.unregisterForDocumentSuspensionCallbacks(this);
         document().registerForDocumentSuspensionCallbacks(this);
     }
 

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -92,7 +92,7 @@
 protected:
     HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool createdByParser);
 
-    void didMoveToNewDocument(Document* oldDocument) override;
+    void didMoveToNewDocument(Document& oldDocument) override;
     bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) final;
 
     bool isImageType();

Modified: trunk/Source/WebCore/html/HTMLTemplateElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLTemplateElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLTemplateElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -82,12 +82,12 @@
     return clone.releaseNonNull();
 }
 
-void HTMLTemplateElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLTemplateElement::didMoveToNewDocument(Document& oldDocument)
 {
     HTMLElement::didMoveToNewDocument(oldDocument);
     if (!m_content)
         return;
-    document().ensureTemplateDocument().adoptIfNeeded(m_content.get());
+    document().ensureTemplateDocument().adoptIfNeeded(*m_content);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLTemplateElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLTemplateElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLTemplateElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -48,7 +48,7 @@
     HTMLTemplateElement(const QualifiedName&, Document&);
 
     Ref<Node> cloneNodeInternal(Document&, CloningOperation) final;
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     mutable RefPtr<TemplateContentDocumentFragment> m_content;
 };

Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLVideoElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -353,7 +353,7 @@
 }
 #endif
 
-void HTMLVideoElement::didMoveToNewDocument(Document* oldDocument)
+void HTMLVideoElement::didMoveToNewDocument(Document& oldDocument)
 {
     if (m_imageLoader)
         m_imageLoader->elementDidMoveToNewDocument();

Modified: trunk/Source/WebCore/html/HTMLVideoElement.h (208827 => 208828)


--- trunk/Source/WebCore/html/HTMLVideoElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/HTMLVideoElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -107,7 +107,7 @@
 
     bool hasAvailableVideoFrame() const;
     void updateDisplayState() final;
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
     void setDisplayMode(DisplayMode) final;
 
     PlatformMediaSession::MediaType presentationType() const final { return PlatformMediaSession::Video; }

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (208827 => 208828)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -101,7 +101,7 @@
     }
 
     virtual ~ImageDocumentElement();
-    void didMoveToNewDocument(Document* oldDocument) override;
+    void didMoveToNewDocument(Document& oldDocument) override;
 
     ImageDocument* m_imageDocument;
 };
@@ -421,7 +421,7 @@
         m_imageDocument->disconnectImageElement();
 }
 
-void ImageDocumentElement::didMoveToNewDocument(Document* oldDocument)
+void ImageDocumentElement::didMoveToNewDocument(Document& oldDocument)
 {
     if (m_imageDocument) {
         m_imageDocument->disconnectImageElement();

Modified: trunk/Source/WebCore/svg/SVGImageElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/svg/SVGImageElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/svg/SVGImageElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -212,7 +212,7 @@
     addSubresourceURL(urls, document().completeURL(href()));
 }
 
-void SVGImageElement::didMoveToNewDocument(Document* oldDocument)
+void SVGImageElement::didMoveToNewDocument(Document& oldDocument)
 {
     m_imageLoader.elementDidMoveToNewDocument();
     SVGGraphicsElement::didMoveToNewDocument(oldDocument);

Modified: trunk/Source/WebCore/svg/SVGImageElement.h (208827 => 208828)


--- trunk/Source/WebCore/svg/SVGImageElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/svg/SVGImageElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -58,7 +58,7 @@
     bool haveLoadedRequiredResources() final;
 
     bool selfHasRelativeLengths() const final { return true; }
-    void didMoveToNewDocument(Document* oldDocument) final;
+    void didMoveToNewDocument(Document& oldDocument) final;
 
     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGImageElement)
         DECLARE_ANIMATED_LENGTH(X, x)

Modified: trunk/Source/WebCore/svg/SVGSVGElement.cpp (208827 => 208828)


--- trunk/Source/WebCore/svg/SVGSVGElement.cpp	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/svg/SVGSVGElement.cpp	2016-11-17 00:39:55 UTC (rev 208828)
@@ -98,10 +98,9 @@
     document().accessSVGExtensions().removeTimeContainer(this);
 }
 
-void SVGSVGElement::didMoveToNewDocument(Document* oldDocument)
+void SVGSVGElement::didMoveToNewDocument(Document& oldDocument)
 {
-    if (oldDocument)
-        oldDocument->unregisterForDocumentSuspensionCallbacks(this);
+    oldDocument.unregisterForDocumentSuspensionCallbacks(this);
     document().registerForDocumentSuspensionCallbacks(this);
     SVGGraphicsElement::didMoveToNewDocument(oldDocument);
 }

Modified: trunk/Source/WebCore/svg/SVGSVGElement.h (208827 => 208828)


--- trunk/Source/WebCore/svg/SVGSVGElement.h	2016-11-17 00:37:15 UTC (rev 208827)
+++ trunk/Source/WebCore/svg/SVGSVGElement.h	2016-11-17 00:39:55 UTC (rev 208828)
@@ -138,7 +138,7 @@
     virtual ~SVGSVGElement();
 
     bool isValid() const override;
-    void didMoveToNewDocument(Document* oldDocument) override;
+    void didMoveToNewDocument(Document& oldDocument) override;
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     bool rendererIsNeeded(const RenderStyle&) override;
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to