Add an argument indicating the type of insertion to Node::insertedInto
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Oct 2017 21:34:25 +0000 (21:34 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Oct 2017 21:34:25 +0000 (21:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178431

Reviewed by Antti Koivisto.

Added InsertionType as the first argument to Node::insertedInto, which contains two booleans indicating
whether the node just become newly connected to a document, and whether node's tree scope had changed or not.

These boolean flags simplifie the logic in insertedInto implementations, and are required to have a better
guarantee about the correctness of node flags during calls to insertedInto. Right now, isConnected() and
isInShadowTree() are both outdated until Node::insertedInto is called.

Also renamed the second argument from insertionPoint to parentOfInsertedTree to make the semantics clear,
and renamed finishedInsertingSubtree to didFinishInsertingNode, and renamed InsertionNotificationRequest
to InsertedIntoResult using enum class.

Note that in some implementations of insertedInto, we check whether isConnected() was false to decide whether
the node is newly connected to a document. This extra check is no longer necessary since no node will be inserted
into a document without first being completely removed after r223458.

No new tests since there should be no behavioral changes.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::notifyChildInserted):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::notifyNodeInsertedIntoDocument): Replaced the check that the node had not been disconnected by scripts
by a release assert now that we believe we've eliminated all causes of these unwanted DOM mutations in r223458.
(WebCore::notifyNodeInsertedIntoTree): Removed NoEventDispatchAssertion since notifyChildNodeInserted has it
already since r223458.
(WebCore::notifyChildNodeInserted): Made this function return NodeVector (copy elision).
* dom/ContainerNodeAlgorithms.h:
* dom/Element.cpp:
(WebCore::Element::insertedInto): Use insertionType.connectedToDocument to detect when this element had become
connected to some document. Similarly, use insertionType.treeScopeChanged to detect when this element had been
inserted into a new tree scope. Removed the comment which became obsolete due to this cleanup.
(WebCore::Element::addShadowRoot): Simplified the code here since we never attach a ShadowRoot with children.
* dom/Element.h:
* dom/Node.cpp:
(WebCore::Node::insertedInto):
* dom/Node.h:
(WebCore::Node::InsertedIntoResult): Renamed from InsertionNotificationRequest, and turned into an enum class.
(WebCore::Node::InsertionType): Added. We pass this object by value to insertedInto as a performance optimization
as passing two booleans by value is faster than passing a pointer and then de-referencing it in a virtual callee.
(WebCore::Node::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::insertedInto):
(WebCore::ProcessingInstruction::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* dom/ProcessingInstruction.h:
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::shouldCallFinishedInsertingSubtree): Deleted.
(WebCore::ScriptElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* dom/ScriptElement.h:
(WebCore::ScriptElement::insertedInto const): Added. Extracted from shouldCallFinishedInsertingSubtree.
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::insertedInto): The extra isConnected() check is no longer needed. See the description above.
* dom/ShadowRoot.h:
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::insertedInto):
* html/FormAssociatedElement.h:
* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::insertedInto):
* html/HTMLBaseElement.h:
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::insertedInto):
(WebCore::HTMLBodyElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLBodyElement.h:
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::insertedInto):
(WebCore::HTMLFormControlElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLFormControlElement.h:
* html/HTMLFormControlElementWithState.cpp:
(WebCore::HTMLFormControlElementWithState::insertedInto):
* html/HTMLFormControlElementWithState.h:
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::insertedInto):
* html/HTMLFormElement.h:
* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::insertedInto):
(WebCore::HTMLFrameElementBase::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLFrameElementBase.h:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::insertedInto):
* html/HTMLFrameSetElement.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::insertedInto):
* html/HTMLImageElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::insertedInto):
(WebCore::HTMLInputElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLInputElement.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::insertedInto): The extra isConnected() check is no longer needed. See above.
(WebCore::HTMLLinkElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLLinkElement.h:
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::insertedInto):
* html/HTMLMapElement.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::insertedInto):
(WebCore::HTMLMediaElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLMediaElement.h:
* html/HTMLMetaElement.cpp:
(WebCore::HTMLMetaElement::insertedInto):
* html/HTMLMetaElement.h:
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::insertedInto):
(WebCore::HTMLObjectElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLObjectElement.h:
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::insertedInto):
* html/HTMLOptionElement.h:
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::insertedInto):
(WebCore::HTMLScriptElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* html/HTMLScriptElement.h:
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::insertedInto):
* html/HTMLSelectElement.h:
* html/HTMLSlotElement.cpp:
(WebCore::HTMLSlotElement::insertedInto): Replaced a cumbersome condition by a boolean check on insertionType's
treeScopeChanged and removed the accompanying comment which is no longer needed.
* html/HTMLSlotElement.h:
* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::insertedInto):
* html/HTMLSourceElement.h:
* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::insertedInto): The extra isConnected() check is no longer needed. See above.
* html/HTMLStyleElement.h:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::insertedInto):
* html/HTMLTextFormControlElement.h:
* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::insertedInto):
* html/HTMLTitleElement.h:
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::insertedInto): Added a FIXME since this code is clearly wrong.
* html/HTMLTrackElement.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::insertedInto):
* svg/SVGElement.h:
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::insertedInto):
(WebCore::SVGFEImageElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* svg/SVGFEImageElement.h:
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::insertedInto):
* svg/SVGFontFaceElement.h:
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::insertedInto):
* svg/SVGFontFaceUriElement.h:
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::insertedInto):
* svg/SVGImageElement.h:
* svg/SVGMPathElement.cpp:
(WebCore::SVGMPathElement::insertedInto):
(WebCore::SVGMPathElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* svg/SVGMPathElement.h:
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::insertedInto):
* svg/SVGPathElement.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::insertedInto):
* svg/SVGSVGElement.h:
* svg/SVGScriptElement.cpp:
(WebCore::SVGScriptElement::insertedInto):
(WebCore::SVGScriptElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* svg/SVGScriptElement.h:
* svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::insertedInto): The extra isConnected() check is no longer needed. See above description.
* svg/SVGStyleElement.h:
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::insertedInto):
(WebCore::SVGTRefElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* svg/SVGTRefElement.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::insertedInto):
(WebCore::SVGTextPathElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* svg/SVGTextPathElement.h:
* svg/SVGTitleElement.cpp:
(WebCore::SVGTitleElement::insertedInto):
* svg/SVGTitleElement.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::insertedInto):
* svg/SVGUseElement.h:
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::insertedInto):
(WebCore::SVGSMILElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
* svg/animation/SVGSMILElement.h:

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

92 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/dom/ProcessingInstruction.h
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/dom/ScriptElement.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/html/FormAssociatedElement.cpp
Source/WebCore/html/FormAssociatedElement.h
Source/WebCore/html/HTMLBaseElement.cpp
Source/WebCore/html/HTMLBaseElement.h
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/html/HTMLBodyElement.h
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLFormControlElementWithState.cpp
Source/WebCore/html/HTMLFormControlElementWithState.h
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLFormElement.h
Source/WebCore/html/HTMLFrameElementBase.cpp
Source/WebCore/html/HTMLFrameElementBase.h
Source/WebCore/html/HTMLFrameSetElement.cpp
Source/WebCore/html/HTMLFrameSetElement.h
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLLinkElement.h
Source/WebCore/html/HTMLMapElement.cpp
Source/WebCore/html/HTMLMapElement.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMetaElement.cpp
Source/WebCore/html/HTMLMetaElement.h
Source/WebCore/html/HTMLObjectElement.cpp
Source/WebCore/html/HTMLObjectElement.h
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLOptionElement.h
Source/WebCore/html/HTMLScriptElement.cpp
Source/WebCore/html/HTMLScriptElement.h
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/HTMLSelectElement.h
Source/WebCore/html/HTMLSlotElement.cpp
Source/WebCore/html/HTMLSlotElement.h
Source/WebCore/html/HTMLSourceElement.cpp
Source/WebCore/html/HTMLSourceElement.h
Source/WebCore/html/HTMLStyleElement.cpp
Source/WebCore/html/HTMLStyleElement.h
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/HTMLTitleElement.cpp
Source/WebCore/html/HTMLTitleElement.h
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFEImageElement.h
Source/WebCore/svg/SVGFontFaceElement.cpp
Source/WebCore/svg/SVGFontFaceElement.h
Source/WebCore/svg/SVGFontFaceUriElement.cpp
Source/WebCore/svg/SVGFontFaceUriElement.h
Source/WebCore/svg/SVGImageElement.cpp
Source/WebCore/svg/SVGImageElement.h
Source/WebCore/svg/SVGMPathElement.cpp
Source/WebCore/svg/SVGMPathElement.h
Source/WebCore/svg/SVGPathElement.cpp
Source/WebCore/svg/SVGPathElement.h
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGSVGElement.h
Source/WebCore/svg/SVGScriptElement.cpp
Source/WebCore/svg/SVGScriptElement.h
Source/WebCore/svg/SVGStyleElement.cpp
Source/WebCore/svg/SVGStyleElement.h
Source/WebCore/svg/SVGTRefElement.cpp
Source/WebCore/svg/SVGTRefElement.h
Source/WebCore/svg/SVGTextPathElement.cpp
Source/WebCore/svg/SVGTextPathElement.h
Source/WebCore/svg/SVGTitleElement.cpp
Source/WebCore/svg/SVGTitleElement.h
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.h

index 5d47d15..71abad7 100644 (file)
@@ -1,3 +1,194 @@
+2017-10-17  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Add an argument indicating the type of insertion to Node::insertedInto
+        https://bugs.webkit.org/show_bug.cgi?id=178431
+
+        Reviewed by Antti Koivisto.
+
+        Added InsertionType as the first argument to Node::insertedInto, which contains two booleans indicating
+        whether the node just become newly connected to a document, and whether node's tree scope had changed or not.
+
+        These boolean flags simplifie the logic in insertedInto implementations, and are required to have a better
+        guarantee about the correctness of node flags during calls to insertedInto. Right now, isConnected() and
+        isInShadowTree() are both outdated until Node::insertedInto is called.
+
+        Also renamed the second argument from insertionPoint to parentOfInsertedTree to make the semantics clear,
+        and renamed finishedInsertingSubtree to didFinishInsertingNode, and renamed InsertionNotificationRequest
+        to InsertedIntoResult using enum class.
+
+        Note that in some implementations of insertedInto, we check whether isConnected() was false to decide whether
+        the node is newly connected to a document. This extra check is no longer necessary since no node will be inserted
+        into a document without first being completely removed after r223458.
+
+        No new tests since there should be no behavioral changes.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::notifyChildInserted):
+        * dom/ContainerNodeAlgorithms.cpp:
+        (WebCore::notifyNodeInsertedIntoDocument): Replaced the check that the node had not been disconnected by scripts
+        by a release assert now that we believe we've eliminated all causes of these unwanted DOM mutations in r223458.
+        (WebCore::notifyNodeInsertedIntoTree): Removed NoEventDispatchAssertion since notifyChildNodeInserted has it
+        already since r223458.
+        (WebCore::notifyChildNodeInserted): Made this function return NodeVector (copy elision).
+        * dom/ContainerNodeAlgorithms.h:
+        * dom/Element.cpp:
+        (WebCore::Element::insertedInto): Use insertionType.connectedToDocument to detect when this element had become
+        connected to some document. Similarly, use insertionType.treeScopeChanged to detect when this element had been
+        inserted into a new tree scope. Removed the comment which became obsolete due to this cleanup.
+        (WebCore::Element::addShadowRoot): Simplified the code here since we never attach a ShadowRoot with children.
+        * dom/Element.h:
+        * dom/Node.cpp:
+        (WebCore::Node::insertedInto):
+        * dom/Node.h:
+        (WebCore::Node::InsertedIntoResult): Renamed from InsertionNotificationRequest, and turned into an enum class.
+        (WebCore::Node::InsertionType): Added. We pass this object by value to insertedInto as a performance optimization
+        as passing two booleans by value is faster than passing a pointer and then de-referencing it in a virtual callee.
+        (WebCore::Node::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::insertedInto):
+        (WebCore::ProcessingInstruction::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * dom/ProcessingInstruction.h:
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::shouldCallFinishedInsertingSubtree): Deleted.
+        (WebCore::ScriptElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * dom/ScriptElement.h:
+        (WebCore::ScriptElement::insertedInto const): Added. Extracted from shouldCallFinishedInsertingSubtree.
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::insertedInto): The extra isConnected() check is no longer needed. See the description above.
+        * dom/ShadowRoot.h:
+        * html/FormAssociatedElement.cpp:
+        (WebCore::FormAssociatedElement::insertedInto):
+        * html/FormAssociatedElement.h:
+        * html/HTMLBaseElement.cpp:
+        (WebCore::HTMLBaseElement::insertedInto):
+        * html/HTMLBaseElement.h:
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::insertedInto):
+        (WebCore::HTMLBodyElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLBodyElement.h:
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::insertedInto):
+        (WebCore::HTMLFormControlElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLFormControlElement.h:
+        * html/HTMLFormControlElementWithState.cpp:
+        (WebCore::HTMLFormControlElementWithState::insertedInto):
+        * html/HTMLFormControlElementWithState.h:
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::insertedInto):
+        * html/HTMLFormElement.h:
+        * html/HTMLFrameElementBase.cpp:
+        (WebCore::HTMLFrameElementBase::insertedInto):
+        (WebCore::HTMLFrameElementBase::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLFrameElementBase.h:
+        * html/HTMLFrameSetElement.cpp:
+        (WebCore::HTMLFrameSetElement::insertedInto):
+        * html/HTMLFrameSetElement.h:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::insertedInto):
+        * html/HTMLImageElement.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::insertedInto):
+        (WebCore::HTMLInputElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLInputElement.h:
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::insertedInto): The extra isConnected() check is no longer needed. See above.
+        (WebCore::HTMLLinkElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLLinkElement.h:
+        * html/HTMLMapElement.cpp:
+        (WebCore::HTMLMapElement::insertedInto):
+        * html/HTMLMapElement.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::insertedInto):
+        (WebCore::HTMLMediaElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLMediaElement.h:
+        * html/HTMLMetaElement.cpp:
+        (WebCore::HTMLMetaElement::insertedInto):
+        * html/HTMLMetaElement.h:
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::insertedInto):
+        (WebCore::HTMLObjectElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLObjectElement.h:
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::insertedInto):
+        * html/HTMLOptionElement.h:
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::insertedInto):
+        (WebCore::HTMLScriptElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * html/HTMLScriptElement.h:
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::insertedInto):
+        * html/HTMLSelectElement.h:
+        * html/HTMLSlotElement.cpp:
+        (WebCore::HTMLSlotElement::insertedInto): Replaced a cumbersome condition by a boolean check on insertionType's
+        treeScopeChanged and removed the accompanying comment which is no longer needed.
+        * html/HTMLSlotElement.h:
+        * html/HTMLSourceElement.cpp:
+        (WebCore::HTMLSourceElement::insertedInto):
+        * html/HTMLSourceElement.h:
+        * html/HTMLStyleElement.cpp:
+        (WebCore::HTMLStyleElement::insertedInto): The extra isConnected() check is no longer needed. See above.
+        * html/HTMLStyleElement.h:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::insertedInto):
+        * html/HTMLTextFormControlElement.h:
+        * html/HTMLTitleElement.cpp:
+        (WebCore::HTMLTitleElement::insertedInto):
+        * html/HTMLTitleElement.h:
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::insertedInto): Added a FIXME since this code is clearly wrong.
+        * html/HTMLTrackElement.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::insertedInto):
+        * svg/SVGElement.h:
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::insertedInto):
+        (WebCore::SVGFEImageElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * svg/SVGFEImageElement.h:
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::insertedInto):
+        * svg/SVGFontFaceElement.h:
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::SVGFontFaceUriElement::insertedInto):
+        * svg/SVGFontFaceUriElement.h:
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::insertedInto):
+        * svg/SVGImageElement.h:
+        * svg/SVGMPathElement.cpp:
+        (WebCore::SVGMPathElement::insertedInto):
+        (WebCore::SVGMPathElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * svg/SVGMPathElement.h:
+        * svg/SVGPathElement.cpp:
+        (WebCore::SVGPathElement::insertedInto):
+        * svg/SVGPathElement.h:
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::insertedInto):
+        * svg/SVGSVGElement.h:
+        * svg/SVGScriptElement.cpp:
+        (WebCore::SVGScriptElement::insertedInto):
+        (WebCore::SVGScriptElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * svg/SVGScriptElement.h:
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::insertedInto): The extra isConnected() check is no longer needed. See above description.
+        * svg/SVGStyleElement.h:
+        * svg/SVGTRefElement.cpp:
+        (WebCore::SVGTRefElement::insertedInto):
+        (WebCore::SVGTRefElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * svg/SVGTRefElement.h:
+        * svg/SVGTextPathElement.cpp:
+        (WebCore::SVGTextPathElement::insertedInto):
+        (WebCore::SVGTextPathElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * svg/SVGTextPathElement.h:
+        * svg/SVGTitleElement.cpp:
+        (WebCore::SVGTitleElement::insertedInto):
+        * svg/SVGTitleElement.h:
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::insertedInto):
+        * svg/SVGUseElement.h:
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::insertedInto):
+        (WebCore::SVGSMILElement::didFinishInsertingNode): Renamed from finishedInsertingSubtree.
+        * svg/animation/SVGSMILElement.h:
+
 2017-10-18  Eric Carlson  <eric.carlson@apple.com>
 
         Key events should not update Document.lastHandledUserGestureTimestamp unless key event is handled
index d1f77e5..3d18646 100644 (file)
@@ -356,13 +356,12 @@ void ContainerNode::notifyChildInserted(Node& child, const ChildChange& change)
 {
     ChildListMutationScope(*this).childAdded(child);
 
-    NodeVector postInsertionNotificationTargets;
-    notifyChildNodeInserted(*this, child, postInsertionNotificationTargets);
+    auto postInsertionNotificationTargets = notifyChildNodeInserted(*this, child);
 
     childrenChanged(change);
 
     for (auto& target : postInsertionNotificationTargets)
-        target->finishedInsertingSubtree();
+        target->didFinishInsertingNode();
 }
 
 void ContainerNode::notifyChildRemoved(Node& child, Node* previousSibling, Node* nextSibling, ChildChangeSource source)
index 4e3ea3b..a400276 100644 (file)
 
 namespace WebCore {
 
-static void notifyNodeInsertedIntoDocument(ContainerNode& insertionPoint, Node& node, NodeVector& postInsertionNotificationTargets)
+enum class TreeScopeChange { Changed, DidNotChange };
+
+static void notifyNodeInsertedIntoDocument(ContainerNode& parentOfInsertedTree, Node& node, TreeScopeChange treeScopeChange, NodeVector& postInsertionNotificationTargets)
 {
-    ASSERT(insertionPoint.isConnected());
-    if (node.insertedInto(insertionPoint) == Node::InsertionShouldCallFinishedInsertingSubtree)
+    ASSERT(parentOfInsertedTree.isConnected());
+    ASSERT(!node.isConnected());
+    if (node.insertedInto(Node::InsertionType { /* connectedToDocument */ true, treeScopeChange == TreeScopeChange::Changed }, parentOfInsertedTree) == Node::InsertedIntoResult::NeedsPostInsertionCallback)
         postInsertionNotificationTargets.append(node);
 
     if (!is<ContainerNode>(node))
         return;
 
-    ChildNodesLazySnapshot snapshot(downcast<ContainerNode>(node));
-    while (RefPtr<Node> child = snapshot.nextNode()) {
-        // If we have been removed from the document during this loop, then
-        // we don't want to tell the rest of our children that they've been
-        // inserted into the document because they haven't.
-        if (node.isConnected() && child->parentNode() == &node)
-            notifyNodeInsertedIntoDocument(insertionPoint, *child, postInsertionNotificationTargets);
+    for (RefPtr<Node> child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling()) {
+        RELEASE_ASSERT(node.isConnected() && child->parentNode() == &node);
+        notifyNodeInsertedIntoDocument(parentOfInsertedTree, *child, treeScopeChange, postInsertionNotificationTargets);
     }
 
     if (!is<Element>(node))
         return;
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
-        if (node.isConnected() && root->host() == &node)
-            notifyNodeInsertedIntoDocument(insertionPoint, *root, postInsertionNotificationTargets);
+        RELEASE_ASSERT(node.isConnected() && root->host() == &node);
+        notifyNodeInsertedIntoDocument(parentOfInsertedTree, *root, TreeScopeChange::DidNotChange, postInsertionNotificationTargets);
     }
 }
 
-static void notifyNodeInsertedIntoTree(ContainerNode& insertionPoint, Node& node, NodeVector& postInsertionNotificationTargets)
+static void notifyNodeInsertedIntoTree(ContainerNode& parentOfInsertedTree, Node& node, TreeScopeChange treeScopeChange, NodeVector& postInsertionNotificationTargets)
 {
-    NoEventDispatchAssertion assertNoEventDispatch;
-    ASSERT(!insertionPoint.isConnected());
+    ASSERT(!parentOfInsertedTree.isConnected());
+    ASSERT(!node.isConnected());
 
-    if (node.insertedInto(insertionPoint) == Node::InsertionShouldCallFinishedInsertingSubtree)
+    if (node.insertedInto(Node::InsertionType { /* connectedToDocument */ false, treeScopeChange == TreeScopeChange::Changed }, parentOfInsertedTree) == Node::InsertedIntoResult::NeedsPostInsertionCallback)
         postInsertionNotificationTargets.append(node);
 
     if (!is<ContainerNode>(node))
         return;
 
-    for (auto* child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling())
-        notifyNodeInsertedIntoTree(insertionPoint, *child, postInsertionNotificationTargets);
+    for (RefPtr<Node> child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling())
+        notifyNodeInsertedIntoTree(parentOfInsertedTree, *child, treeScopeChange, postInsertionNotificationTargets);
 
     if (!is<Element>(node))
         return;
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot())
-        notifyNodeInsertedIntoTree(insertionPoint, *root, postInsertionNotificationTargets);
+        notifyNodeInsertedIntoTree(parentOfInsertedTree, *root, TreeScopeChange::DidNotChange, postInsertionNotificationTargets);
 }
 
-void notifyChildNodeInserted(ContainerNode& insertionPoint, Node& node, NodeVector& postInsertionNotificationTargets)
+NodeVector notifyChildNodeInserted(ContainerNode& parentOfInsertedTree, Node& node)
 {
     NoEventDispatchAssertion assertNoEventDispatch;
 
@@ -92,10 +91,16 @@ void notifyChildNodeInserted(ContainerNode& insertionPoint, Node& node, NodeVect
     Ref<Document> protectDocument(node.document());
     Ref<Node> protectNode(node);
 
-    if (insertionPoint.isConnected())
-        notifyNodeInsertedIntoDocument(insertionPoint, node, postInsertionNotificationTargets);
+    NodeVector postInsertionNotificationTargets;
+
+    // Tree scope has changed if the container node into which "node" is inserted is in a document or a shadow root.
+    auto treeScopeChange = parentOfInsertedTree.isInTreeScope() ? TreeScopeChange::Changed : TreeScopeChange::DidNotChange;
+    if (parentOfInsertedTree.isConnected())
+        notifyNodeInsertedIntoDocument(parentOfInsertedTree, node, treeScopeChange, postInsertionNotificationTargets);
     else
-        notifyNodeInsertedIntoTree(insertionPoint, node, postInsertionNotificationTargets);
+        notifyNodeInsertedIntoTree(parentOfInsertedTree, node, treeScopeChange, postInsertionNotificationTargets);
+
+    return postInsertionNotificationTargets;
 }
 
 static void notifyNodeRemovedFromDocument(ContainerNode& insertionPoint, Node& node)
index 42d66be..3280930 100644 (file)
@@ -26,7 +26,7 @@
 
 namespace WebCore {
 
-void notifyChildNodeInserted(ContainerNode& insertionPoint, Node&, NodeVector& postInsertionNotificationTargets);
+NodeVector notifyChildNodeInserted(ContainerNode& parentOfInsertedTree, Node&);
 void notifyChildNodeRemoved(ContainerNode& insertionPoint, Node&);
 void removeDetachedChildrenInContainer(ContainerNode&);
 
index fb8c674..9a42e0f 100644 (file)
@@ -1629,34 +1629,27 @@ RenderPtr<RenderElement> Element::createElementRenderer(RenderStyle&& style, con
     return RenderElement::createFor(*this, WTFMove(style));
 }
 
-Node::InsertionNotificationRequest Element::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult Element::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    bool wasInDocument = isConnected();
-    // need to do superclass processing first so isConnected() is true
-    // by the time we reach updateId
-    ContainerNode::insertedInto(insertionPoint);
-    ASSERT(!wasInDocument || isConnected());
+    ContainerNode::insertedInto(insertionType, parentOfInsertedTree);
 
 #if ENABLE(FULLSCREEN_API)
     if (containsFullScreenElement() && parentElement() && !parentElement()->containsFullScreenElement())
         setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
 #endif
 
-    if (parentNode() == &insertionPoint) {
+    if (parentNode() == &parentOfInsertedTree) {
         if (auto* shadowRoot = parentNode()->shadowRoot())
             shadowRoot->hostChildElementDidChange(*this);
     }
 
-    if (!insertionPoint.isInTreeScope())
-        return InsertionDone;
+    if (!parentOfInsertedTree.isInTreeScope())
+        return InsertedIntoResult::Done;
 
-    // This function could be called when this element's shadow root's host or its ancestor is inserted.
-    // This element is new to the shadow tree (and its tree scope) only if the parent into which this element
-    // or its ancestor is inserted belongs to the same tree scope as this element's.
-    TreeScope* newScope = &insertionPoint.treeScope();
-    bool becomeConnected = !wasInDocument && isConnected();
+    bool becomeConnected = insertionType.connectedToDocument;
+    TreeScope* newScope = &parentOfInsertedTree.treeScope();
     HTMLDocument* newDocument = becomeConnected && is<HTMLDocument>(newScope->documentScope()) ? &downcast<HTMLDocument>(newScope->documentScope()) : nullptr;
-    if (newScope != &treeScope())
+    if (!insertionType.treeScopeChanged)
         newScope = nullptr;
 
     const AtomicString& idValue = getIdAttribute();
@@ -1687,7 +1680,7 @@ Node::InsertionNotificationRequest Element::insertedInto(ContainerNode& insertio
             CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded(*this);
     }
 
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void Element::removedFrom(ContainerNode& insertionPoint)
@@ -1765,6 +1758,7 @@ ShadowRoot* Element::shadowRoot() const
 
 void Element::addShadowRoot(Ref<ShadowRoot>&& newShadowRoot)
 {
+    ASSERT(!newShadowRoot->hasChildNodes());
     ASSERT(!shadowRoot());
     
     if (renderer())
@@ -1776,10 +1770,11 @@ void Element::addShadowRoot(Ref<ShadowRoot>&& newShadowRoot)
     shadowRoot.setHost(this);
     shadowRoot.setParentTreeScope(treeScope());
 
-    NodeVector postInsertionNotificationTargets;
-    notifyChildNodeInserted(*this, shadowRoot, postInsertionNotificationTargets);
-    for (auto& target : postInsertionNotificationTargets)
-        target->finishedInsertingSubtree();
+#if !ASSERT_DISABLED
+    ASSERT(notifyChildNodeInserted(*this, shadowRoot).isEmpty());
+#else
+    notifyChildNodeInserted(*this, shadowRoot);
+#endif
 
     invalidateStyleAndRenderersForSubtree();
 
index 5938f2e..f269695 100644 (file)
@@ -551,7 +551,7 @@ public:
 protected:
     Element(const QualifiedName&, Document&, ConstructionType);
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
     void childrenChanged(const ChildChange&) override;
     void removeAllEventListeners() final;
index 0fc9c44..1cae7e8 100644 (file)
@@ -1241,16 +1241,16 @@ Node& Node::getRootNode(const GetRootNodeOptions& options) const
     return options.composed ? shadowIncludingRoot() : rootNode();
 }
 
-Node::InsertionNotificationRequest Node::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult Node::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    if (insertionPoint.isConnected())
+    if (insertionType.connectedToDocument)
         setFlag(IsConnectedFlag);
-    if (insertionPoint.isInShadowTree())
+    if (parentOfInsertedTree.isInShadowTree())
         setFlag(IsInShadowTreeFlag);
 
     invalidateStyle(Style::Validity::SubtreeAndRenderersInvalid);
 
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void Node::removedFrom(ContainerNode& insertionPoint)
index 39289c6..3cf7546 100644 (file)
@@ -443,19 +443,28 @@ public:
     //
     // WebKit notifies this callback regardless if the subtree of the node is a document tree or a floating subtree.
     // Implementation can determine the type of subtree by seeing insertionPoint->isConnected().
-    // For a performance reason, notifications are delivered only to ContainerNode subclasses if the insertionPoint is out of document.
     //
-    // There is another callback named finishedInsertingSubtree(), which is called after all descendants are notified.
-    // Only a few subclasses actually need this. To utilize this, the node should return InsertionShouldCallFinishedInsertingSubtree
+    // There is another callback named didFinishInsertingNode(), which is called after all descendants are notified.
+    // Only a few subclasses actually need this. To utilize this, the node should return InsertedIntoResult::NeedsPostInsertionCallback
     // from insrtedInto().
     //
-    enum InsertionNotificationRequest {
-        InsertionDone,
-        InsertionShouldCallFinishedInsertingSubtree
+    enum class InsertedIntoResult {
+        Done,
+        NeedsPostInsertionCallback,
     };
 
-    virtual InsertionNotificationRequest insertedInto(ContainerNode& insertionPoint);
-    virtual void finishedInsertingSubtree() { }
+    struct InsertionType {
+#if !COMPILER_SUPPORTS(NSDMI_FOR_AGGREGATES)
+        InsertionType(bool connectedToDocument, bool treeScopeChanged)
+            : connectedToDocument(connectedToDocument)
+            , treeScopeChanged(treeScopeChanged)
+        { }
+#endif
+        bool connectedToDocument { false };
+        bool treeScopeChanged { false };
+    };
+    virtual InsertedIntoResult insertedInto(InsertionType, ContainerNode& parentOfInsertedTree);
+    virtual void didFinishInsertingNode() { }
 
     // Notifies the node that it is no longer part of the tree.
     //
index 9ff35a4..f084476 100644 (file)
@@ -274,16 +274,16 @@ void ProcessingInstruction::addSubresourceAttributeURLs(ListHashSet<URL>& urls)
     addSubresourceURL(urls, sheet()->baseURL());
 }
 
-Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult ProcessingInstruction::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    CharacterData::insertedInto(insertionPoint);
-    if (!insertionPoint.isConnected())
-        return InsertionDone;
+    CharacterData::insertedInto(insertionType, parentOfInsertedTree);
+    if (!insertionType.connectedToDocument)
+        return InsertedIntoResult::Done;
     document().styleScope().addStyleSheetCandidateNode(*this, m_createdByParser);
-    return InsertionShouldCallFinishedInsertingSubtree;
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void ProcessingInstruction::finishedInsertingSubtree()
+void ProcessingInstruction::didFinishInsertingNode()
 {
     checkStyleSheet();
 }
index a50a2e5..57df57f 100644 (file)
@@ -58,8 +58,8 @@ private:
     NodeType nodeType() const override;
     Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
-    void finishedInsertingSubtree() override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
+    void didFinishInsertingNode() override;
     void removedFrom(ContainerNode&) override;
 
     void checkStyleSheet();
index 4286b17..584f4cd 100644 (file)
@@ -78,12 +78,7 @@ ScriptElement::ScriptElement(Element& element, bool parserInserted, bool already
         m_startLineNumber = m_element.document().scriptableDocumentParser()->textPosition().m_line;
 }
 
-bool ScriptElement::shouldCallFinishedInsertingSubtree(ContainerNode& insertionPoint)
-{
-    return insertionPoint.isConnected() && !m_parserInserted;
-}
-
-void ScriptElement::finishedInsertingSubtree()
+void ScriptElement::didFinishInsertingNode()
 {
     ASSERT(!m_parserInserted);
     prepareScript(); // FIXME: Provide a real starting line number here.
index 5616675..6c81b3d 100644 (file)
@@ -81,8 +81,14 @@ protected:
     bool forceAsync() const { return m_forceAsync; }
 
     // Helper functions used by our parent classes.
-    bool shouldCallFinishedInsertingSubtree(ContainerNode&);
-    void finishedInsertingSubtree();
+    Node::InsertedIntoResult insertedInto(Node::InsertionType insertionType, ContainerNode&) const
+    {
+        if (insertionType.connectedToDocument && !m_parserInserted)
+            return Node::InsertedIntoResult::NeedsPostInsertionCallback;
+        return Node::InsertedIntoResult::Done;
+    }
+
+    void didFinishInsertingNode();
     void childrenChanged(const ContainerNode::ChildChange&);
     void handleSourceAttribute(const String& sourceURL);
     void handleAsyncAttribute();
index ba38c94..98137ed 100644 (file)
@@ -85,13 +85,12 @@ ShadowRoot::~ShadowRoot()
     removeDetachedChildren();
 }
 
-Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult ShadowRoot::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    bool wasInDocument = isConnected();
-    DocumentFragment::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected() && !wasInDocument)
+    DocumentFragment::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         document().didInsertInDocumentShadowRoot(*this);
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void ShadowRoot::removedFrom(ContainerNode& insertionPoint)
index 808f0cc..fa3cdb2 100644 (file)
@@ -94,7 +94,7 @@ private:
 
     Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
 
-    Node::InsertionNotificationRequest insertedInto(ContainerNode& insertionPoint) override;
+    Node::InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode& insertionPoint) override;
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) override;
 
index 0b4177c..76ab44f 100644 (file)
@@ -68,7 +68,7 @@ void FormAssociatedElement::didMoveToNewDocument(Document&)
         resetFormAttributeTargetObserver();
 }
 
-void FormAssociatedElement::insertedInto(ContainerNode& insertionPoint)
+void FormAssociatedElement::insertedInto(Node::InsertionType insertionType, ContainerNode&)
 {
     HTMLElement& element = asHTMLElement();
     if (m_formSetByParser) {
@@ -81,7 +81,7 @@ void FormAssociatedElement::insertedInto(ContainerNode& insertionPoint)
     if (m_form && element.rootElement() != m_form->rootElement())
         setForm(nullptr);
 
-    if (!insertionPoint.isConnected())
+    if (!insertionType.connectedToDocument)
         return;
 
     if (element.hasAttributeWithoutSynchronization(formAttr))
index 266e6cf..e2c5713 100644 (file)
@@ -24,6 +24,7 @@
 #pragma once
 
 #include "FormNamedItem.h"
+#include "Node.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -34,7 +35,6 @@ class Document;
 class FormAttributeTargetObserver;
 class HTMLElement;
 class HTMLFormElement;
-class Node;
 class ValidityState;
 
 class FormAssociatedElement : public FormNamedItem {
@@ -90,7 +90,7 @@ public:
 protected:
     FormAssociatedElement(HTMLFormElement*);
 
-    void insertedInto(ContainerNode&);
+    void insertedInto(Node::InsertionType, ContainerNode&);
     void removedFrom(ContainerNode&);
     void didMoveToNewDocument(Document& oldDocument);
 
index fcfd67b..3dd9058 100644 (file)
@@ -51,12 +51,12 @@ void HTMLBaseElement::parseAttribute(const QualifiedName& name, const AtomicStri
         HTMLElement::parseAttribute(name, value);
 }
 
-Node::InsertionNotificationRequest HTMLBaseElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLBaseElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected())
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         document().processBaseElement();
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLBaseElement::removedFrom(ContainerNode& insertionPoint)
index b5541b4..08e0c00 100644 (file)
@@ -39,7 +39,7 @@ private:
     String target() const final;
     bool isURLAttribute(const Attribute&) const final;
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 };
 
index 0133c88..0a36471 100644 (file)
@@ -187,23 +187,23 @@ void HTMLBodyElement::parseAttribute(const QualifiedName& name, const AtomicStri
     HTMLElement::parseAttribute(name, value);
 }
 
-Node::InsertionNotificationRequest HTMLBodyElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLBodyElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
-    if (!insertionPoint.isConnected())
-        return InsertionDone;
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (!insertionType.connectedToDocument)
+        return InsertedIntoResult::Done;
 
     // FIXME: It's surprising this is web compatible since it means a marginwidth and marginheight attribute can
     // magically appear on the <body> of all documents embedded through <iframe> or <frame>.
     // FIXME: Perhaps this code should be in attach() instead of here.
     auto* ownerElement = document().ownerElement();
     if (!is<HTMLFrameElementBase>(ownerElement))
-        return InsertionDone;
+        return InsertedIntoResult::Done;
 
-    return InsertionShouldCallFinishedInsertingSubtree;
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void HTMLBodyElement::finishedInsertingSubtree()
+void HTMLBodyElement::didFinishInsertingNode()
 {
     auto* ownerElement = document().ownerElement();
     RELEASE_ASSERT(is<HTMLFrameElementBase>(ownerElement));
index 698b47d..1d64495 100644 (file)
@@ -44,8 +44,8 @@ private:
     bool isPresentationAttribute(const QualifiedName&) const final;
     void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
 
     bool isURLAttribute(const Attribute&) const final;
     
index cf64a47..7096d10 100644 (file)
@@ -274,20 +274,20 @@ static void removeInvalidElementToAncestorFromInsertionPoint(const HTMLFormContr
         ancestor.removeInvalidDescendant(element);
 }
 
-Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLFormControlElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     m_dataListAncestorState = Unknown;
     setNeedsWillValidateCheck();
     if (willValidate() && !isValidFormControlElement())
-        addInvalidElementToAncestorFromInsertionPoint(*this, &insertionPoint);
+        addInvalidElementToAncestorFromInsertionPoint(*this, &parentOfInsertedTree);
     if (document().hasDisabledFieldsetElement())
         setAncestorDisabled(computeIsDisabledByFieldsetAncestor());
-    HTMLElement::insertedInto(insertionPoint);
-    FormAssociatedElement::insertedInto(insertionPoint);
-    return InsertionShouldCallFinishedInsertingSubtree;
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    FormAssociatedElement::insertedInto(insertionType, parentOfInsertedTree);
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void HTMLFormControlElement::finishedInsertingSubtree()
+void HTMLFormControlElement::didFinishInsertingNode()
 {
     resetFormOwner();
 }
index 8d1462c..2be9a91 100644 (file)
@@ -136,8 +136,8 @@ protected:
     virtual void readOnlyAttributeChanged();
     virtual void requiredAttributeChanged();
     void didAttachRenderers() override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
-    void finishedInsertingSubtree() override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
+    void didFinishInsertingNode() override;
     void removedFrom(ContainerNode&) override;
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) override;
 
index 676b27c..9247c85 100644 (file)
@@ -40,11 +40,11 @@ HTMLFormControlElementWithState::~HTMLFormControlElementWithState()
 {
 }
 
-Node::InsertionNotificationRequest HTMLFormControlElementWithState::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLFormControlElementWithState::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    if (insertionPoint.isConnected() && !containingShadowRoot())
+    if (insertionType.connectedToDocument && !containingShadowRoot())
         document().formController().registerFormElementWithState(this);
-    return HTMLFormControlElement::insertedInto(insertionPoint);
+    return HTMLFormControlElement::insertedInto(insertionType, parentOfInsertedTree);
 }
 
 void HTMLFormControlElementWithState::removedFrom(ContainerNode& insertionPoint)
index 72a1453..ccaa97b 100644 (file)
@@ -45,7 +45,7 @@ protected:
 
     virtual bool shouldAutocomplete() const;
     void finishParsingChildren() override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
     bool isFormControlElementWithState() const override;
 };
index ce154ca..4fc09b7 100644 (file)
@@ -121,12 +121,12 @@ bool HTMLFormElement::rendererIsNeeded(const RenderStyle& style)
     return formIsTablePart;
 }
 
-Node::InsertionNotificationRequest HTMLFormElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLFormElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected())
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         document().didAssociateFormControl(this);
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLFormElement::removedFrom(ContainerNode& insertionPoint)
index 746c7bf..5838080 100644 (file)
@@ -124,7 +124,7 @@ private:
     HTMLFormElement(const QualifiedName&, Document&);
 
     bool rendererIsNeeded(const RenderStyle&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     void finishParsingChildren() final;
 
index d81287b..4f7cd92 100644 (file)
@@ -138,15 +138,15 @@ void HTMLFrameElementBase::setNameAndOpenURL()
     openURL();
 }
 
-Node::InsertionNotificationRequest HTMLFrameElementBase::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLFrameElementBase::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLFrameOwnerElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected())
-        return InsertionShouldCallFinishedInsertingSubtree;
-    return InsertionDone;
+    HTMLFrameOwnerElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
+        return InsertedIntoResult::NeedsPostInsertionCallback;
+    return InsertedIntoResult::Done;
 }
 
-void HTMLFrameElementBase::finishedInsertingSubtree()
+void HTMLFrameElementBase::didFinishInsertingNode()
 {
     if (!isConnected())
         return;
index 8126b9e..6751ebd 100644 (file)
@@ -56,8 +56,8 @@ protected:
     bool isURLAllowed() const;
 
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
     void didAttachRenderers() override;
 
 private:
index 3145390..dd0b0ef 100644 (file)
@@ -208,15 +208,15 @@ void HTMLFrameSetElement::willRecalcStyle(Style::Change)
         renderer()->setNeedsLayout();
 }
 
-Node::InsertionNotificationRequest HTMLFrameSetElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLFrameSetElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected()) {
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument) {
         if (Frame* frame = document().frame())
             frame->loader().client().dispatchDidBecomeFrameset(document().isFrameSet());
     }
 
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLFrameSetElement::removedFrom(ContainerNode& insertionPoint)
index fcc33a5..f832c53 100644 (file)
@@ -64,7 +64,7 @@ private:
 
     void willRecalcStyle(Style::Change) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 
     std::unique_ptr<Length[]> m_rowLengths;
index 8c1f56f..cef7baf 100644 (file)
@@ -293,7 +293,7 @@ void HTMLImageElement::didAttachRenderers()
         renderImage.setImageSizeForAltText();
 }
 
-Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLImageElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     if (m_formSetByParser) {
         m_form = m_formSetByParser;
@@ -313,9 +313,9 @@ Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode&
     }
     // Insert needs to complete first, before we start updating the loader. Loader dispatches events which could result
     // in callbacks back to this node.
-    Node::InsertionNotificationRequest insertNotificationRequest = HTMLElement::insertedInto(insertionPoint);
+    Node::InsertedIntoResult insertNotificationRequest = HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
 
-    if (insertionPoint.isConnected() && !m_parsedUsemap.isNull())
+    if (insertionType.connectedToDocument && !m_parsedUsemap.isNull())
         document().addImageElementByUsemap(*m_parsedUsemap.impl(), *this);
 
     if (is<HTMLPictureElement>(parentNode())) {
@@ -325,7 +325,7 @@ Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode&
 
     // If we have been inserted from a renderer-less document,
     // our loader may have not fetched the image, so do it now.
-    if (insertionPoint.isConnected() && !m_imageLoader.image())
+    if (insertionType.connectedToDocument && !m_imageLoader.image())
         m_imageLoader.updateFromElement();
 
     return insertNotificationRequest;
index ce965e1..bd5d76d 100644 (file)
@@ -120,7 +120,7 @@ private:
 
     void addSubresourceAttributeURLs(ListHashSet<URL>&) const override;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
 
     bool isFormAssociatedElement() const final { return false; }
index f5d36af..3fd528d 100644 (file)
@@ -1502,18 +1502,18 @@ void HTMLInputElement::didChangeForm()
     addToRadioButtonGroup();
 }
 
-Node::InsertionNotificationRequest HTMLInputElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLInputElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLTextFormControlElement::insertedInto(insertionPoint);
+    HTMLTextFormControlElement::insertedInto(insertionType, parentOfInsertedTree);
 #if ENABLE(DATALIST_ELEMENT)
     resetListAttributeTargetObserver();
 #endif
-    return InsertionShouldCallFinishedInsertingSubtree;
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void HTMLInputElement::finishedInsertingSubtree()
+void HTMLInputElement::didFinishInsertingNode()
 {
-    HTMLTextFormControlElement::finishedInsertingSubtree();
+    HTMLTextFormControlElement::didFinishInsertingNode();
     if (isConnected() && !form())
         addToRadioButtonGroup();
 }
index 928991e..0596d99 100644 (file)
@@ -350,8 +350,8 @@ private:
 
     void willChangeForm() final;
     void didChangeForm() final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
     void removedFrom(ContainerNode&) final;
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
 
index e7d0f7c..1597d7a 100644 (file)
@@ -340,20 +340,19 @@ void HTMLLinkElement::clearSheet()
     m_sheet = nullptr;
 }
 
-Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLLinkElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    bool wasInDocument = isConnected();
-    HTMLElement::insertedInto(insertionPoint);
-    if (!insertionPoint.isConnected() || wasInDocument)
-        return InsertionDone;
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (!insertionType.connectedToDocument)
+        return InsertedIntoResult::Done;
 
     m_styleScope = &Style::Scope::forNode(*this);
     m_styleScope->addStyleSheetCandidateNode(*this, m_createdByParser);
 
-    return InsertionShouldCallFinishedInsertingSubtree;
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void HTMLLinkElement::finishedInsertingSubtree()
+void HTMLLinkElement::didFinishInsertingNode()
 {
     process();
 }
index 4f5ed78..9e6bdc8 100644 (file)
@@ -81,8 +81,8 @@ private:
     static void processCallback(Node*);
     void clearSheet();
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
     void removedFrom(ContainerNode&) final;
 
     void initializeStyleSheet(Ref<StyleSheetContents>&&, const CachedCSSStyleSheet&);
index 01e6eda..e657018 100644 (file)
@@ -114,10 +114,10 @@ Ref<HTMLCollection> HTMLMapElement::areas()
     return ensureRareData().ensureNodeLists().addCachedCollection<GenericCachedHTMLCollection<CollectionTypeTraits<MapAreas>::traversalType>>(*this, MapAreas);
 }
 
-Node::InsertionNotificationRequest HTMLMapElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLMapElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    Node::InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected())
+    Node::InsertedIntoResult request = HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         treeScope().addImageMap(*this);
     return request;
 }
index 18265d0..c4cbf6f 100644 (file)
@@ -47,7 +47,7 @@ private:
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 
     AtomicString m_name;
index 2499910..d21d6c0 100644 (file)
@@ -871,12 +871,12 @@ bool HTMLMediaElement::childShouldCreateRenderer(const Node& child) const
 #endif
 }
 
-Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLMediaElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     INFO_LOG(LOGIDENTIFIER);
 
-    HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected()) {
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument) {
         m_inActiveDocument = true;
 
 #if PLATFORM(IOS)
@@ -893,10 +893,10 @@ Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode&
         m_mediaSession->canProduceAudioChanged();
     }
 
-    return InsertionShouldCallFinishedInsertingSubtree;
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void HTMLMediaElement::finishedInsertingSubtree()
+void HTMLMediaElement::didFinishInsertingNode()
 {
     configureMediaControls();
 }
index c8418f1..9458c80 100644 (file)
@@ -588,8 +588,8 @@ private:
     bool isMouseFocusable() const override;
     bool rendererIsNeeded(const RenderStyle&) override;
     bool childShouldCreateRenderer(const Node&) const override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
-    void finishedInsertingSubtree() override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
+    void didFinishInsertingNode() override;
     void removedFrom(ContainerNode&) override;
     void didRecalcStyle(Style::Change) override;
 
index 15f0021..b22e8cd 100644 (file)
@@ -60,12 +60,12 @@ void HTMLMetaElement::parseAttribute(const QualifiedName& name, const AtomicStri
         HTMLElement::parseAttribute(name, value);
 }
 
-Node::InsertionNotificationRequest HTMLMetaElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLMetaElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected())
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         process();
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLMetaElement::process()
index 1650311..e0ef4cf 100644 (file)
@@ -39,7 +39,7 @@ private:
     HTMLMetaElement(const QualifiedName&, Document&);
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
 
     void process();
 };
index 8000c25..ea7694b 100644 (file)
@@ -313,14 +313,14 @@ void HTMLObjectElement::updateWidget(CreatePlugins createPlugins)
         renderFallbackContent();
 }
 
-Node::InsertionNotificationRequest HTMLObjectElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLObjectElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLPlugInImageElement::insertedInto(insertionPoint);
-    FormAssociatedElement::insertedInto(insertionPoint);
-    return InsertionShouldCallFinishedInsertingSubtree;
+    HTMLPlugInImageElement::insertedInto(insertionType, parentOfInsertedTree);
+    FormAssociatedElement::insertedInto(insertionType, parentOfInsertedTree);
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void HTMLObjectElement::finishedInsertingSubtree()
+void HTMLObjectElement::didFinishInsertingNode()
 {
     resetFormOwner();
 }
index c4571c0..ecde934 100644 (file)
@@ -62,8 +62,8 @@ private:
     bool isPresentationAttribute(const QualifiedName&) const final;
     void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
     void removedFrom(ContainerNode&) final;
 
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
index 0512ff2..a09e3ab 100644 (file)
@@ -317,7 +317,7 @@ bool HTMLOptionElement::isDisabledFormControl() const
     return downcast<HTMLOptGroupElement>(*parentNode()).isDisabledFormControl();
 }
 
-Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLOptionElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     if (HTMLSelectElement* select = ownerSelectElement()) {
         select->setRecalcListItems();
@@ -331,7 +331,7 @@ Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode
         select->scrollToSelection();
     }
 
-    return HTMLElement::insertedInto(insertionPoint);
+    return HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
 }
 
 String HTMLOptionElement::collectOptionInnerText() const
index 25bdc8e..cb5e1f4 100644 (file)
@@ -74,7 +74,7 @@ private:
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void accessKeyAction(bool) final;
 
     void childrenChanged(const ChildChange&) final;
index a8e14b4..77b6052 100644 (file)
@@ -68,15 +68,15 @@ void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt
         HTMLElement::parseAttribute(name, value);
 }
 
-Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLScriptElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
-    return shouldCallFinishedInsertingSubtree(insertionPoint) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone;
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    return ScriptElement::insertedInto(insertionType, parentOfInsertedTree);
 }
 
-void HTMLScriptElement::finishedInsertingSubtree()
+void HTMLScriptElement::didFinishInsertingNode()
 {
-    ScriptElement::finishedInsertingSubtree();
+    ScriptElement::didFinishInsertingNode();
 }
 
 // https://html.spec.whatwg.org/multipage/scripting.html#dom-script-text
index 7abbd35..ddec401 100644 (file)
@@ -50,8 +50,8 @@ private:
     HTMLScriptElement(const QualifiedName&, Document&, bool wasInsertedByParser, bool alreadyStarted);
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
     void childrenChanged(const ChildChange&) final;
 
     bool isURLAttribute(const Attribute&) const final;
index 3920f9b..08543bf 100644 (file)
@@ -1560,13 +1560,13 @@ void HTMLSelectElement::typeAheadFind(KeyboardEvent& event)
         listBoxOnChange();
 }
 
-Node::InsertionNotificationRequest HTMLSelectElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLSelectElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     // When the element is created during document parsing, it won't have any
     // items yet - but for innerHTML and related methods, this method is called
     // after the whole subtree is constructed.
     recalcListItems();
-    return HTMLFormControlElementWithState::insertedInto(insertionPoint);
+    return HTMLFormControlElementWithState::insertedInto(insertionType, parentOfInsertedTree);
 }
 
 void HTMLSelectElement::accessKeySetSelectedIndex(int index)
index 2d582ab..15fac69 100644 (file)
@@ -147,7 +147,7 @@ private:
     void typeAheadFind(KeyboardEvent&);
     void saveLastSelection();
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
 
     bool isOptionalFormControl() const final { return !isRequiredFormControl(); }
     bool isRequiredFormControl() const final;
index 58ef059..21e225b 100644 (file)
@@ -48,20 +48,17 @@ HTMLSlotElement::HTMLSlotElement(const QualifiedName& tagName, Document& documen
     ASSERT(hasTagName(slotTag));
 }
 
-HTMLSlotElement::InsertionNotificationRequest HTMLSlotElement::insertedInto(ContainerNode& insertionPoint)
+HTMLSlotElement::InsertedIntoResult HTMLSlotElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    auto insertionResult = HTMLElement::insertedInto(insertionPoint);
-    ASSERT_UNUSED(insertionResult, insertionResult == InsertionDone);
+    auto insertionResult = HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    ASSERT_UNUSED(insertionResult, insertionResult == InsertedIntoResult::Done);
 
-    // This function could be called when this element's shadow root's host or its ancestor is inserted.
-    // This element is new to the shadow tree (and its tree scope) only if the parent into which this element
-    // or its ancestor is inserted belongs to the same tree scope as this element's.
-    if (insertionPoint.isInShadowTree() && isInShadowTree() && &insertionPoint.treeScope() == &treeScope()) {
+    if (insertionType.treeScopeChanged && isInShadowTree()) {
         if (auto shadowRoot = containingShadowRoot())
             shadowRoot->addSlotElementByName(attributeWithoutSynchronization(nameAttr), *this);
     }
 
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLSlotElement::removedFrom(ContainerNode& insertionPoint)
index 2d25c63..fa2d966 100644 (file)
@@ -48,7 +48,7 @@ public:
 private:
     HTMLSlotElement(const QualifiedName&, Document&);
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) final;
 
index a49ff20..712c66d 100644 (file)
@@ -63,9 +63,9 @@ Ref<HTMLSourceElement> HTMLSourceElement::create(Document& document)
     return create(sourceTag, document);
 }
 
-Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLSourceElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
     if (auto* parent = parentElement()) {
 #if ENABLE(VIDEO)
         if (is<HTMLMediaElement>(*parent))
@@ -75,7 +75,7 @@ Node::InsertionNotificationRequest HTMLSourceElement::insertedInto(ContainerNode
         if (is<HTMLPictureElement>(*parent))
             downcast<HTMLPictureElement>(*parent).sourcesChanged();
     }
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLSourceElement::removedFrom(ContainerNode& removalRoot)
index 6b891ff..b9c5e38 100644 (file)
@@ -45,7 +45,7 @@ public:
 private:
     HTMLSourceElement(const QualifiedName&, Document&);
     
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     bool isURLAttribute(const Attribute&) const final;
 
index fdf0cdb..ab09c19 100644 (file)
@@ -96,11 +96,10 @@ void HTMLStyleElement::finishParsingChildren()
     HTMLElement::finishParsingChildren();
 }
 
-Node::InsertionNotificationRequest HTMLStyleElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLStyleElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    bool wasInDocument = isConnected();
-    auto result = HTMLElement::insertedInto(insertionPoint);
-    if (insertionPoint.isConnected() && !wasInDocument)
+    auto result = HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         m_styleSheetOwner.insertedIntoDocument(*this);
     return result;
 }
index a00d133..e6946f1 100644 (file)
@@ -54,7 +54,7 @@ private:
     HTMLStyleElement(const QualifiedName&, Document&, bool createdByParser);
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     void childrenChanged(const ChildChange&) final;
 
index f4560f4..5652a70 100644 (file)
@@ -80,14 +80,14 @@ bool HTMLTextFormControlElement::childShouldCreateRenderer(const Node& child) co
     return hasShadowRootParent(child) && HTMLFormControlElementWithState::childShouldCreateRenderer(child);
 }
 
-Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(ContainerNode& insertionPoint)
-{
-    InsertionNotificationRequest insertionNotificationRequest = HTMLFormControlElementWithState::insertedInto(insertionPoint);
-    if (!insertionPoint.isConnected())
-        return insertionNotificationRequest;
-    String initialValue = value();
-    setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue);
-    return insertionNotificationRequest;
+Node::InsertedIntoResult HTMLTextFormControlElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
+{
+    InsertedIntoResult InsertedIntoResult = HTMLFormControlElementWithState::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument) {
+        String initialValue = value();
+        setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue);
+    }
+    return InsertedIntoResult;
 }
 
 void HTMLTextFormControlElement::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection direction)
index 128b031..65418ff 100644 (file)
@@ -52,7 +52,7 @@ public:
     int minLength() const { return m_minLength; }
     ExceptionOr<void> setMinLength(int);
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
 
     // The derived class should return true if placeholder processing is needed.
     bool isPlaceholderVisible() const { return m_isPlaceholderVisible; }
index 28de0b9..c559287 100644 (file)
@@ -50,11 +50,11 @@ Ref<HTMLTitleElement> HTMLTitleElement::create(const QualifiedName& tagName, Doc
     return adoptRef(*new HTMLTitleElement(tagName, document));
 }
 
-Node::InsertionNotificationRequest HTMLTitleElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLTitleElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
     document().titleElementAdded(*this);
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLTitleElement::removedFrom(ContainerNode& insertionPoint)
index d0b4a7b..cbfb4b4 100644 (file)
@@ -39,7 +39,7 @@ public:
 private:
     HTMLTitleElement(const QualifiedName&, Document&);
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     void childrenChanged(const ChildChange&) final;
 
index 87788ad..92c084a 100644 (file)
@@ -76,17 +76,19 @@ Ref<HTMLTrackElement> HTMLTrackElement::create(const QualifiedName& tagName, Doc
     return adoptRef(*new HTMLTrackElement(tagName, document));
 }
 
-Node::InsertionNotificationRequest HTMLTrackElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult HTMLTrackElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    HTMLElement::insertedInto(insertionPoint);
+    HTMLElement::insertedInto(insertionType, parentOfInsertedTree);
 
-    if (is<HTMLMediaElement>(insertionPoint))
-        downcast<HTMLMediaElement>(insertionPoint).didAddTextTrack(*this);
+    // FIXME: This code is wrong. If HTMLTrackElement can be any descendent of HTMLMediaElement, then check ancestors of parentOfInsertedTree.
+    // If HTMLMediaElement only supports HTMLTrackElement which is an immediate child, then check parentNode() instead.
+    if (is<HTMLMediaElement>(parentOfInsertedTree))
+        downcast<HTMLMediaElement>(parentOfInsertedTree).didAddTextTrack(*this);
 
     // Since we've moved to a new parent, we may now be able to load.
     scheduleLoad();
 
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void HTMLTrackElement::removedFrom(ContainerNode& insertionPoint)
index 2251027..4ba643d 100644 (file)
@@ -65,7 +65,7 @@ private:
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 
     bool isURLAttribute(const Attribute&) const final;
index 65cd3ab..f72f8b6 100644 (file)
@@ -982,12 +982,12 @@ void SVGElement::svgAttributeChanged(const QualifiedName& attrName)
     }
 }
 
-Node::InsertionNotificationRequest SVGElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    StyledElement::insertedInto(rootParent);
+    StyledElement::insertedInto(insertionType, parentOfInsertedTree);
     updateRelativeLengthsInformation();
     buildPendingResourcesIfNeeded();
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void SVGElement::buildPendingResourcesIfNeeded()
index 4101b74..ee2dccf 100644 (file)
@@ -159,7 +159,7 @@ protected:
 
     bool isPresentationAttribute(const QualifiedName&) const override;
     void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
     void childrenChanged(const ChildChange&) override;
     virtual bool selfHasRelativeLengths() const { return false; }
index ec74a8d..6b32da4 100644 (file)
@@ -150,13 +150,13 @@ void SVGFEImageElement::svgAttributeChanged(const QualifiedName& attrName)
     SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
 }
 
-Node::InsertionNotificationRequest SVGFEImageElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGFEImageElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGFilterPrimitiveStandardAttributes::insertedInto(rootParent);
-    return InsertionShouldCallFinishedInsertingSubtree;
+    SVGFilterPrimitiveStandardAttributes::insertedInto(insertionType, parentOfInsertedTree);
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void SVGFEImageElement::finishedInsertingSubtree()
+void SVGFEImageElement::didFinishInsertingNode()
 {
     buildPendingResource();
 }
index 0771360..ffffcfb 100644 (file)
@@ -45,7 +45,7 @@ public:
 private:
     SVGFEImageElement(const QualifiedName&, Document&);
 
-    void finishedInsertingSubtree() override;
+    void didFinishInsertingNode() override;
 
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     void svgAttributeChanged(const QualifiedName&) override;
@@ -58,7 +58,7 @@ private:
     void requestImageResource();
 
     void buildPendingResource() override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
 
     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEImageElement)
index b8ba9b0..c80fafa 100644 (file)
@@ -271,17 +271,17 @@ void SVGFontFaceElement::rebuildFontFace()
     document().styleScope().didChangeStyleSheetEnvironment();
 }
 
-Node::InsertionNotificationRequest SVGFontFaceElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGFontFaceElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGElement::insertedInto(rootParent);
-    if (!rootParent.isConnected()) {
+    SVGElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (!insertionType.connectedToDocument) {
         ASSERT(!m_fontElement);
-        return InsertionDone;
+        return InsertedIntoResult::Done;
     }
     document().accessSVGExtensions().registerSVGFontFaceElement(this);
 
     rebuildFontFace();
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void SVGFontFaceElement::removedFrom(ContainerNode& rootParent)
index 5afef2c..74e118c 100644 (file)
@@ -58,7 +58,7 @@ private:
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
     void childrenChanged(const ChildChange&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 
     bool rendererIsNeeded(const RenderStyle&) final { return false; }
index b419576..bfd891e 100644 (file)
@@ -81,10 +81,10 @@ void SVGFontFaceUriElement::childrenChanged(const ChildChange& change)
         downcast<SVGFontFaceElement>(*grandparent).rebuildFontFace();
 }
 
-Node::InsertionNotificationRequest SVGFontFaceUriElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGFontFaceUriElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     loadFont();
-    return SVGElement::insertedInto(rootParent);
+    return SVGElement::insertedInto(insertionType, parentOfInsertedTree);
 }
 
 static bool isSVGFontTarget(const SVGFontFaceUriElement& element)
index 58fc1ca..5ed3d9b 100644 (file)
@@ -42,7 +42,7 @@ private:
     
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
     void childrenChanged(const ChildChange&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     bool rendererIsNeeded(const RenderStyle&) final { return false; }
 
     void loadFont();
index 54889c0..b460a6f 100644 (file)
@@ -186,15 +186,15 @@ void SVGImageElement::didAttachRenderers()
     }
 }
 
-Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGImageElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGGraphicsElement::insertedInto(rootParent);
-    if (!rootParent.isConnected())
-        return InsertionDone;
+    SVGGraphicsElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (!insertionType.connectedToDocument)
+        return InsertedIntoResult::Done;
     // Update image loader, as soon as we're living in the tree.
     // We can only resolve base URIs properly, after that!
     m_imageLoader.updateFromElement();
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 const AtomicString& SVGImageElement::imageSourceURL() const
index 2147563..8b5b675 100644 (file)
@@ -49,7 +49,7 @@ private:
     void svgAttributeChanged(const QualifiedName&) final;
 
     void didAttachRenderers() final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
 
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
index ff7d487..c4cdab8 100644 (file)
@@ -86,15 +86,15 @@ void SVGMPathElement::clearResourceReferences()
     document().accessSVGExtensions().removeAllTargetReferencesForElement(this);
 }
 
-Node::InsertionNotificationRequest SVGMPathElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGMPathElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGElement::insertedInto(rootParent);
-    if (rootParent.isConnected())
-        return InsertionShouldCallFinishedInsertingSubtree;
-    return InsertionDone;
+    SVGElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
+        return InsertedIntoResult::NeedsPostInsertionCallback;
+    return InsertedIntoResult::Done;
 }
 
-void SVGMPathElement::finishedInsertingSubtree()
+void SVGMPathElement::didFinishInsertingNode()
 {
     buildPendingResource();
 }
index 246973c..5672cbb 100644 (file)
@@ -45,14 +45,14 @@ private:
 
     void buildPendingResource() final;
     void clearResourceReferences();
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
     void svgAttributeChanged(const QualifiedName&) final;
 
     bool rendererIsNeeded(const RenderStyle&) final { return false; }
-    void finishedInsertingSubtree() final;
+    void didFinishInsertingNode() final;
 
     void notifyParentOfPathChange(ContainerNode*);
 
index 4042317..60751fe 100644 (file)
@@ -279,11 +279,11 @@ void SVGPathElement::invalidateMPathDependencies()
     }
 }
 
-Node::InsertionNotificationRequest SVGPathElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGPathElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGGraphicsElement::insertedInto(rootParent);
+    SVGGraphicsElement::insertedInto(insertionType, parentOfInsertedTree);
     invalidateMPathDependencies();
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void SVGPathElement::removedFrom(ContainerNode& rootParent)
index 4824782..35ab1bb 100644 (file)
@@ -124,7 +124,7 @@ private:
 
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
-    Node::InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    Node::InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
 
     void invalidateMPathDependencies();
index 89879a9..b5ab19e 100644 (file)
@@ -467,9 +467,9 @@ RenderPtr<RenderElement> SVGSVGElement::createElementRenderer(RenderStyle&& styl
     return createRenderer<RenderSVGViewportContainer>(*this, WTFMove(style));
 }
 
-Node::InsertionNotificationRequest SVGSVGElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGSVGElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    if (rootParent.isConnected()) {
+    if (insertionType.connectedToDocument) {
         document().accessSVGExtensions().addTimeContainer(this);
         if (!document().accessSVGExtensions().areAnimationsPaused())
             unpauseAnimations();
@@ -480,7 +480,7 @@ Node::InsertionNotificationRequest SVGSVGElement::insertedInto(ContainerNode& ro
         if (!document().parsing() && !document().processingLoadEvent() && document().loadEventFinished() && !m_timeContainer->isStarted())
             m_timeContainer->begin();
     }
-    return SVGGraphicsElement::insertedInto(rootParent);
+    return SVGGraphicsElement::insertedInto(insertionType, parentOfInsertedTree);
 }
 
 void SVGSVGElement::removedFrom(ContainerNode& rootParent)
index 97d19b4..5808370 100644 (file)
@@ -143,7 +143,7 @@ private:
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     bool rendererIsNeeded(const RenderStyle&) override;
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
     void svgAttributeChanged(const QualifiedName&) override;
     bool selfHasRelativeLengths() const override;
index d6649fa..a342d1b 100644 (file)
@@ -71,17 +71,17 @@ void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName)
     SVGElement::svgAttributeChanged(attrName);
 }
 
-Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGScriptElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGElement::insertedInto(rootParent);
-    if (rootParent.isConnected())
+    SVGElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         SVGExternalResourcesRequired::insertedIntoDocument(this);
-    return shouldCallFinishedInsertingSubtree(rootParent) ? InsertionShouldCallFinishedInsertingSubtree : InsertionDone;
+    return ScriptElement::insertedInto(insertionType, parentOfInsertedTree);
 }
 
-void SVGScriptElement::finishedInsertingSubtree()
+void SVGScriptElement::didFinishInsertingNode()
 {
-    ScriptElement::finishedInsertingSubtree();
+    ScriptElement::didFinishInsertingNode();
 }
 
 void SVGScriptElement::childrenChanged(const ChildChange& change)
index 23277f7..88f9692 100644 (file)
@@ -41,8 +41,8 @@ private:
     SVGScriptElement(const QualifiedName&, Document&, bool wasInsertedByParser, bool alreadyStarted);
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
-    void finishedInsertingSubtree() final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
+    void didFinishInsertingNode() final;
     void childrenChanged(const ChildChange&) final;
 
     void svgAttributeChanged(const QualifiedName&) final;
index 8f8f9ef..32f5a41 100644 (file)
@@ -113,11 +113,10 @@ void SVGStyleElement::finishParsingChildren()
     SVGElement::finishParsingChildren();
 }
 
-Node::InsertionNotificationRequest SVGStyleElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGStyleElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    bool wasInDocument = isConnected();
-    auto result = SVGElement::insertedInto(rootParent);
-    if (rootParent.isConnected() && !wasInDocument)
+    auto result = SVGElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
         m_styleSheetOwner.insertedIntoDocument(*this);
     return result;
 }
index 701dad7..993b6b1 100644 (file)
@@ -46,7 +46,7 @@ private:
     SVGStyleElement(const QualifiedName&, Document&, bool createdByParser);
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     void childrenChanged(const ChildChange&) final;
 
index b083736..f6c04b4 100644 (file)
@@ -254,15 +254,15 @@ void SVGTRefElement::buildPendingResource()
     updateReferencedText(target.get());
 }
 
-Node::InsertionNotificationRequest SVGTRefElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGTRefElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGElement::insertedInto(rootParent);
-    if (rootParent.isConnected())
-        return InsertionShouldCallFinishedInsertingSubtree;
-    return InsertionDone;
+    SVGElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument)
+        return InsertedIntoResult::NeedsPostInsertionCallback;
+    return InsertedIntoResult::Done;
 }
 
-void SVGTRefElement::finishedInsertingSubtree()
+void SVGTRefElement::didFinishInsertingNode()
 {
     buildPendingResource();
 }
index f720cf2..3648c52 100644 (file)
@@ -44,9 +44,9 @@ private:
     bool childShouldCreateRenderer(const Node&) const override;
     bool rendererIsNeeded(const RenderStyle&) override;
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
-    void finishedInsertingSubtree() override;
+    void didFinishInsertingNode() override;
 
     void clearTarget() override;
 
index 7517e8b..c795333 100644 (file)
@@ -173,13 +173,13 @@ void SVGTextPathElement::buildPendingResource()
     }
 }
 
-Node::InsertionNotificationRequest SVGTextPathElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGTextPathElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGTextContentElement::insertedInto(rootParent);
-    return InsertionShouldCallFinishedInsertingSubtree;
+    SVGTextContentElement::insertedInto(insertionType, parentOfInsertedTree);
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void SVGTextPathElement::finishedInsertingSubtree()
+void SVGTextPathElement::didFinishInsertingNode()
 {
     buildPendingResource();
 }
index d16204e..fdd4c67 100644 (file)
@@ -111,7 +111,7 @@ public:
     static Ref<SVGTextPathElement> create(const QualifiedName&, Document&);
 
 protected:
-    void finishedInsertingSubtree() override;
+    void didFinishInsertingNode() override;
 
 private:
     SVGTextPathElement(const QualifiedName&, Document&);
@@ -121,7 +121,7 @@ private:
     void clearResourceReferences();
 
     void buildPendingResource() override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
 
     static bool isSupportedAttribute(const QualifiedName&);
index 01a7571..59fda40 100644 (file)
@@ -38,11 +38,11 @@ Ref<SVGTitleElement> SVGTitleElement::create(const QualifiedName& tagName, Docum
     return adoptRef(*new SVGTitleElement(tagName, document));
 }
 
-Node::InsertionNotificationRequest SVGTitleElement::insertedInto(ContainerNode& insertionPoint)
+Node::InsertedIntoResult SVGTitleElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGElement::insertedInto(insertionPoint);
+    SVGElement::insertedInto(insertionType, parentOfInsertedTree);
     document().titleElementAdded(*this);
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void SVGTitleElement::removedFrom(ContainerNode& insertionPoint)
index 9afa2cc..85ed4e5 100644 (file)
@@ -32,7 +32,7 @@ public:
 private:
     SVGTitleElement(const QualifiedName&, Document&);
 
-    InsertionNotificationRequest insertedInto(ContainerNode&) final;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) final;
     void removedFrom(ContainerNode&) final;
     void childrenChanged(const ChildChange&) final;
 
index 5e73238..8622e43 100644 (file)
@@ -103,15 +103,15 @@ void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString
     SVGURIReference::parseAttribute(name, value);
 }
 
-Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGUseElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGGraphicsElement::insertedInto(rootParent);
-    if (isConnected()) {
+    SVGGraphicsElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (insertionType.connectedToDocument) {
         SVGExternalResourcesRequired::insertedIntoDocument(this);
         invalidateShadowTree();
         updateExternalDocument();
     }
-    return InsertionDone;
+    return InsertedIntoResult::Done;
 }
 
 void SVGUseElement::removedFrom(ContainerNode& rootParent)
index 070fdfd..2f975fb 100644 (file)
@@ -57,7 +57,7 @@ private:
     SVGUseElement(const QualifiedName&, Document&);
 
     bool isValid() const override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
     void buildPendingResource() override;
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
index 862d68a..fdf143b 100644 (file)
@@ -252,11 +252,11 @@ void SVGSMILElement::reset()
     resolveFirstInterval();
 }
 
-Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode& rootParent)
+Node::InsertedIntoResult SVGSMILElement::insertedInto(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
-    SVGElement::insertedInto(rootParent);
-    if (!rootParent.isConnected())
-        return InsertionDone;
+    SVGElement::insertedInto(insertionType, parentOfInsertedTree);
+    if (!insertionType.connectedToDocument)
+        return InsertedIntoResult::Done;
 
     // Verify we are not in <use> instance tree.
     ASSERT(!isInShadowTree());
@@ -265,7 +265,7 @@ Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode& r
 
     SVGSVGElement* owner = ownerSVGElement();
     if (!owner)
-        return InsertionDone;
+        return InsertedIntoResult::Done;
 
     m_timeContainer = &owner->timeContainer();
     m_timeContainer->setDocumentOrderIndexesDirty();
@@ -280,10 +280,10 @@ Node::InsertionNotificationRequest SVGSMILElement::insertedInto(ContainerNode& r
     if (m_timeContainer)
         m_timeContainer->notifyIntervalsChanged();
 
-    return InsertionShouldCallFinishedInsertingSubtree;
+    return InsertedIntoResult::NeedsPostInsertionCallback;
 }
 
-void SVGSMILElement::finishedInsertingSubtree()
+void SVGSMILElement::didFinishInsertingNode()
 {
     buildPendingResource();
 }
index fc34ce7..7ceb8a0 100644 (file)
@@ -47,7 +47,7 @@ public:
 
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     void svgAttributeChanged(const QualifiedName&) override;
-    InsertionNotificationRequest insertedInto(ContainerNode&) override;
+    InsertedIntoResult insertedInto(InsertionType, ContainerNode&) override;
     void removedFrom(ContainerNode&) override;
     
     virtual bool hasValidAttributeType() = 0;
@@ -118,7 +118,7 @@ protected:
     virtual void setTargetElement(SVGElement*);
     virtual void setAttributeName(const QualifiedName&);
 
-    void finishedInsertingSubtree() override;
+    void didFinishInsertingNode() override;
 
 private:
     void buildPendingResource() override;