Title: [273622] trunk/Source/WebCore
Revision
273622
Author
[email protected]
Date
2021-02-27 01:33:00 -0800 (Sat, 27 Feb 2021)

Log Message

Unreviewed, reverting r273474 and r273479.
https://bugs.webkit.org/show_bug.cgi?id=222510

Not a speedup after all

Reverted changesets:

"Optimize the code to check if an element delegates focus to
its shadow root or not"
https://bugs.webkit.org/show_bug.cgi?id=222404
https://trac.webkit.org/changeset/273474

"Avoid tree traversals to look for form and canvas elements"
https://bugs.webkit.org/show_bug.cgi?id=222159
https://trac.webkit.org/changeset/273479

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273621 => 273622)


--- trunk/Source/WebCore/ChangeLog	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/ChangeLog	2021-02-27 09:33:00 UTC (rev 273622)
@@ -1,3 +1,21 @@
+2021-02-27  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r273474 and r273479.
+        https://bugs.webkit.org/show_bug.cgi?id=222510
+
+        Not a speedup after all
+
+        Reverted changesets:
+
+        "Optimize the code to check if an element delegates focus to
+        its shadow root or not"
+        https://bugs.webkit.org/show_bug.cgi?id=222404
+        https://trac.webkit.org/changeset/273474
+
+        "Avoid tree traversals to look for form and canvas elements"
+        https://bugs.webkit.org/show_bug.cgi?id=222159
+        https://trac.webkit.org/changeset/273479
+
 2021-02-27  Antti Koivisto  <[email protected]>
 
         Render tree updates for Text node content mutations should happen during rendering update

Modified: trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp (273621 => 273622)


--- trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/dom/ContainerNodeAlgorithms.cpp	2021-02-27 09:33:00 UTC (rev 273622)
@@ -41,20 +41,19 @@
 
 enum class TreeScopeChange { Changed, DidNotChange };
 
-static void notifyNodeInsertedIntoDocument(ContainerNode& parentOfInsertedTree, Node& node, TreeScopeChange treeScopeChange, OptionSet<Node::AncestorState> ancestorStates, NodeVector& postInsertionNotificationTargets)
+static void notifyNodeInsertedIntoDocument(ContainerNode& parentOfInsertedTree, Node& node, TreeScopeChange treeScopeChange, NodeVector& postInsertionNotificationTargets)
 {
     ASSERT(parentOfInsertedTree.isConnected());
     ASSERT(!node.isConnected());
-    if (node.insertedIntoAncestor(Node::InsertionType { /* connectedToDocument */ true, treeScopeChange == TreeScopeChange::Changed, ancestorStates }, parentOfInsertedTree) == Node::InsertedIntoAncestorResult::NeedsPostInsertionCallback)
+    if (node.insertedIntoAncestor(Node::InsertionType { /* connectedToDocument */ true, treeScopeChange == TreeScopeChange::Changed }, parentOfInsertedTree) == Node::InsertedIntoAncestorResult::NeedsPostInsertionCallback)
         postInsertionNotificationTargets.append(node);
 
     if (!is<ContainerNode>(node))
         return;
 
-    auto ancestorStatesOfChildNodes = node.inclusiveAncestorStates();
     for (RefPtr<Node> child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling()) {
         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(node.isConnected() && child->parentNode() == &node);
-        notifyNodeInsertedIntoDocument(parentOfInsertedTree, *child, treeScopeChange, ancestorStatesOfChildNodes, postInsertionNotificationTargets);
+        notifyNodeInsertedIntoDocument(parentOfInsertedTree, *child, treeScopeChange, postInsertionNotificationTargets);
     }
 
     if (!is<Element>(node))
@@ -62,30 +61,29 @@
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(node.isConnected() && root->host() == &node);
-        notifyNodeInsertedIntoDocument(parentOfInsertedTree, *root, TreeScopeChange::DidNotChange, { }, postInsertionNotificationTargets);
+        notifyNodeInsertedIntoDocument(parentOfInsertedTree, *root, TreeScopeChange::DidNotChange, postInsertionNotificationTargets);
     }
 }
 
-static void notifyNodeInsertedIntoTree(ContainerNode& parentOfInsertedTree, Node& node, TreeScopeChange treeScopeChange, OptionSet<Node::AncestorState> ancestorStates, NodeVector& postInsertionNotificationTargets)
+static void notifyNodeInsertedIntoTree(ContainerNode& parentOfInsertedTree, Node& node, TreeScopeChange treeScopeChange, NodeVector& postInsertionNotificationTargets)
 {
     ASSERT(!parentOfInsertedTree.isConnected());
     ASSERT(!node.isConnected());
 
-    if (node.insertedIntoAncestor(Node::InsertionType { /* connectedToDocument */ false, treeScopeChange == TreeScopeChange::Changed, ancestorStates }, parentOfInsertedTree) == Node::InsertedIntoAncestorResult::NeedsPostInsertionCallback)
+    if (node.insertedIntoAncestor(Node::InsertionType { /* connectedToDocument */ false, treeScopeChange == TreeScopeChange::Changed }, parentOfInsertedTree) == Node::InsertedIntoAncestorResult::NeedsPostInsertionCallback)
         postInsertionNotificationTargets.append(node);
 
     if (!is<ContainerNode>(node))
         return;
 
-    auto ancestorStatesOfChildNodes = node.inclusiveAncestorStates();
     for (RefPtr<Node> child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling())
-        notifyNodeInsertedIntoTree(parentOfInsertedTree, *child, treeScopeChange, ancestorStatesOfChildNodes, postInsertionNotificationTargets);
+        notifyNodeInsertedIntoTree(parentOfInsertedTree, *child, treeScopeChange, postInsertionNotificationTargets);
 
     if (!is<Element>(node))
         return;
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot())
-        notifyNodeInsertedIntoTree(parentOfInsertedTree, *root, TreeScopeChange::DidNotChange, { }, postInsertionNotificationTargets);
+        notifyNodeInsertedIntoTree(parentOfInsertedTree, *root, TreeScopeChange::DidNotChange, postInsertionNotificationTargets);
 }
 
 NodeVector notifyChildNodeInserted(ContainerNode& parentOfInsertedTree, Node& node)
@@ -102,9 +100,9 @@
     // 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, parentOfInsertedTree.inclusiveAncestorStates(), postInsertionNotificationTargets);
+        notifyNodeInsertedIntoDocument(parentOfInsertedTree, node, treeScopeChange, postInsertionNotificationTargets);
     else
-        notifyNodeInsertedIntoTree(parentOfInsertedTree, node, treeScopeChange, parentOfInsertedTree.inclusiveAncestorStates(), postInsertionNotificationTargets);
+        notifyNodeInsertedIntoTree(parentOfInsertedTree, node, treeScopeChange, postInsertionNotificationTargets);
 
     return postInsertionNotificationTargets;
 }
@@ -121,20 +119,19 @@
         currentObservability = newStatus;
 }
 
-static RemovedSubtreeObservability notifyNodeRemovedFromDocument(ContainerNode& oldParentOfRemovedTree, TreeScopeChange treeScopeChange, OptionSet<Node::AncestorState> ancestorStates, Node& node)
+static RemovedSubtreeObservability notifyNodeRemovedFromDocument(ContainerNode& oldParentOfRemovedTree, TreeScopeChange treeScopeChange, Node& node)
 {
     ASSERT(oldParentOfRemovedTree.isConnected());
     ASSERT(node.isConnected());
-    node.removedFromAncestor(Node::RemovalType { /* disconnectedFromDocument */ true, treeScopeChange == TreeScopeChange::Changed, ancestorStates }, oldParentOfRemovedTree);
+    node.removedFromAncestor(Node::RemovalType { /* disconnectedFromDocument */ true, treeScopeChange == TreeScopeChange::Changed }, oldParentOfRemovedTree);
 
     auto observability = observabilityOfRemovedNode(node);
     if (!is<ContainerNode>(node))
         return observability;
 
-    auto ancestorStatesOfChildNodes = node.inclusiveAncestorStates();
     for (RefPtr<Node> child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling()) {
         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!node.isConnected() && child->parentNode() == &node);
-        updateObservability(observability, notifyNodeRemovedFromDocument(oldParentOfRemovedTree, treeScopeChange, ancestorStatesOfChildNodes, *child.get()));
+        updateObservability(observability, notifyNodeRemovedFromDocument(oldParentOfRemovedTree, treeScopeChange, *child.get()));
     }
 
     if (!is<Element>(node))
@@ -142,30 +139,29 @@
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!node.isConnected() && root->host() == &node);
-        updateObservability(observability, notifyNodeRemovedFromDocument(oldParentOfRemovedTree, TreeScopeChange::DidNotChange, { }, *root.get()));
+        updateObservability(observability, notifyNodeRemovedFromDocument(oldParentOfRemovedTree, TreeScopeChange::DidNotChange, *root.get()));
     }
     return observability;
 }
 
-static RemovedSubtreeObservability notifyNodeRemovedFromTree(ContainerNode& oldParentOfRemovedTree, TreeScopeChange treeScopeChange, OptionSet<Node::AncestorState> ancestorStates, Node& node)
+static RemovedSubtreeObservability notifyNodeRemovedFromTree(ContainerNode& oldParentOfRemovedTree, TreeScopeChange treeScopeChange, Node& node)
 {
     ASSERT(!oldParentOfRemovedTree.isConnected());
 
-    node.removedFromAncestor(Node::RemovalType { /* disconnectedFromDocument */ false, treeScopeChange == TreeScopeChange::Changed, ancestorStates }, oldParentOfRemovedTree);
+    node.removedFromAncestor(Node::RemovalType { /* disconnectedFromDocument */ false, treeScopeChange == TreeScopeChange::Changed }, oldParentOfRemovedTree);
 
     auto observability = observabilityOfRemovedNode(node);
     if (!is<ContainerNode>(node))
         return observability;
 
-    auto ancestorStatesOfChildNodes = node.inclusiveAncestorStates();
     for (RefPtr<Node> child = downcast<ContainerNode>(node).firstChild(); child; child = child->nextSibling())
-        updateObservability(observability, notifyNodeRemovedFromTree(oldParentOfRemovedTree, treeScopeChange, ancestorStatesOfChildNodes, *child));
+        updateObservability(observability, notifyNodeRemovedFromTree(oldParentOfRemovedTree, treeScopeChange, *child));
 
     if (!is<Element>(node))
         return observability;
 
     if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot())
-        updateObservability(observability, notifyNodeRemovedFromTree(oldParentOfRemovedTree, TreeScopeChange::DidNotChange, { }, *root));
+        updateObservability(observability, notifyNodeRemovedFromTree(oldParentOfRemovedTree, TreeScopeChange::DidNotChange, *root));
 
     return observability;
 }
@@ -179,8 +175,8 @@
     // Tree scope has changed if the container node from which "node" is removed is in a document or a shadow root.
     auto treeScopeChange = oldParentOfRemovedTree.isInTreeScope() ? TreeScopeChange::Changed : TreeScopeChange::DidNotChange;
     if (child.isConnected())
-        return notifyNodeRemovedFromDocument(oldParentOfRemovedTree, treeScopeChange, { }, child);
-    return notifyNodeRemovedFromTree(oldParentOfRemovedTree, treeScopeChange, { }, child);
+        return notifyNodeRemovedFromDocument(oldParentOfRemovedTree, treeScopeChange, child);
+    return notifyNodeRemovedFromTree(oldParentOfRemovedTree, treeScopeChange, child);
 }
 
 void addChildNodesToDeletionQueue(Node*& head, Node*& tail, ContainerNode& container)

Modified: trunk/Source/WebCore/dom/Element.cpp (273621 => 273622)


--- trunk/Source/WebCore/dom/Element.cpp	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/dom/Element.cpp	2021-02-27 09:33:00 UTC (rev 273622)
@@ -315,8 +315,11 @@
 {
     if (!(isFocusable() && !shouldBeIgnoredInSequentialFocusNavigation() && tabIndexSetExplicitly().valueOr(0) >= 0))
         return false;
-    ASSERT(delegatesFocusToShadowRoot() == (shadowRoot() && shadowRoot()->delegatesFocus()));
-    return !delegatesFocusToShadowRoot();
+    if (auto* root = shadowRoot()) {
+        if (root->delegatesFocus())
+            return false;
+    }
+    return true;
 }
 
 bool Element::isMouseFocusable() const
@@ -636,10 +639,7 @@
     if (!isConnected() || !supportsFocus())
         return false;
 
-    bool hasCanvasAsInclusiveAncestor = inclusiveAncestorStates().contains(AncestorState::Canvas);
-    ASSERT(hasCanvasAsInclusiveAncestor == !!ancestorsOfType<HTMLCanvasElement>(*this).first()
-        || (hasCanvasAsInclusiveAncestor && is<HTMLCanvasElement>(*this)));
-    if (!renderer() && hasCanvasAsInclusiveAncestor) {
+    if (!renderer()) {
         // Elements in canvas fallback content are not rendered, but they are allowed to be
         // focusable as long as their canvas is displayed and visible.
         if (auto* canvas = ancestorsOfType<HTMLCanvasElement>(*this).first())
@@ -2154,8 +2154,6 @@
 {
     ContainerNode::insertedIntoAncestor(insertionType, parentOfInsertedTree);
 
-    setInclusiveAncestorStates(insertionType.ancestorStates);
-
 #if ENABLE(FULLSCREEN_API)
     if (containsFullScreenElement() && parentElement() && !parentElement()->containsFullScreenElement())
         setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
@@ -2213,8 +2211,6 @@
 
 void Element::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
 {
-    setInclusiveAncestorStates(removalType.ancestorStates);
-
 #if ENABLE(FULLSCREEN_API)
     if (containsFullScreenElement())
         setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
@@ -2397,8 +2393,6 @@
     if (init.mode == ShadowRootMode::UserAgent)
         return Exception { TypeError };
     auto shadow = ShadowRoot::create(document(), init.mode, init.delegatesFocus ? ShadowRoot::DelegatesFocus::Yes : ShadowRoot::DelegatesFocus::No);
-    if (init.delegatesFocus)
-        setDelegatesFocusToShadowRoot();
     auto& result = shadow.get();
     addShadowRoot(WTFMove(shadow));
     return result;
@@ -2982,8 +2976,7 @@
 {
     ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
-    ASSERT(element.delegatesFocusToShadowRoot() == !!shadowRootWithDelegatesFocus(element));
-    if (element.delegatesFocusToShadowRoot())
+    if (shadowRootWithDelegatesFocus(element))
         return false;
 
     // If the stylesheets have already been loaded we can reliably check isFocusable.
@@ -3030,9 +3023,7 @@
     if (&newTarget->document() != document.ptr())
         return;
 
-    ASSERT(delegatesFocusToShadowRoot() == !!shadowRootWithDelegatesFocus(*this));
-    if (delegatesFocusToShadowRoot()) {
-        auto root = shadowRootWithDelegatesFocus(*this);
+    if (auto root = shadowRootWithDelegatesFocus(*this)) {
         auto currentlyFocusedElement = makeRefPtr(document->focusedElement());
         if (root->containsIncludingShadowDOM(currentlyFocusedElement.get())) {
             if (document->page())

Modified: trunk/Source/WebCore/dom/Node.h (273621 => 273622)


--- trunk/Source/WebCore/dom/Node.h	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/dom/Node.h	2021-02-27 09:33:00 UTC (rev 273622)
@@ -222,7 +222,6 @@
     ShadowRoot* containingShadowRoot() const;
     ShadowRoot* shadowRoot() const;
     bool isClosedShadowHidden(const Node&) const;
-    bool delegatesFocusToShadowRoot() const { return hasNodeFlag(NodeFlag::DelegatesFocusToShadowRoot); }
 
     HTMLSlotElement* assignedSlot() const;
     HTMLSlotElement* assignedSlotForBindings() const;
@@ -406,14 +405,9 @@
         Done,
         NeedsPostInsertionCallback,
     };
-    enum class AncestorState : uint8_t {
-        Form = 1 << 0,
-        Canvas = 1 << 1,
-    };
     struct InsertionType {
         bool connectedToDocument { false };
         bool treeScopeChanged { false };
-        OptionSet<AncestorState> ancestorStates;
     };
     // Called *after* this node or its ancestor is inserted into a new parent (may or may not be a part of document) by scripts or parser.
     // insertedInto **MUST NOT** invoke scripts. Return NeedsPostInsertionCallback and implement didFinishInsertingNode instead to run scripts.
@@ -423,7 +417,6 @@
     struct RemovalType {
         bool disconnectedFromDocument { false };
         bool treeScopeChanged { false };
-        OptionSet<AncestorState> ancestorStates;
     };
     virtual void removedFromAncestor(RemovalType, ContainerNode& oldParentOfRemovedTree);
 
@@ -501,8 +494,6 @@
     void updateAncestorConnectedSubframeCountForRemoval() const;
     void updateAncestorConnectedSubframeCountForInsertion() const;
 
-    OptionSet<AncestorState> inclusiveAncestorStates() const;
-
 #if ENABLE(JIT)
     static ptrdiff_t nodeFlagsMemoryOffset() { return OBJECT_OFFSETOF(Node, m_nodeFlags); }
     static ptrdiff_t rareDataMemoryOffset() { return OBJECT_OFFSETOF(Node, m_rareDataWithBitfields); }
@@ -557,11 +548,8 @@
         ContainsFullScreenElement = 1 << 25,
 #endif
         IsComputedStyleInvalidFlag = 1 << 26,
-        DelegatesFocusToShadowRoot = 1 << 27,
 
-        InclusiveAncestorStateForForm = 1 << 28,
-        InclusiveAncestorStateForCanvas = 1 << 29,
-        // Bits 30-31 are free.
+        // Bits 27-31 are free.
     };
 
     enum class TabIndexState : uint8_t {
@@ -601,11 +589,6 @@
     void setIsParsingChildrenFinished() { setNodeFlag(NodeFlag::IsParsingChildrenFinished); }
     void clearIsParsingChildrenFinished() { clearNodeFlag(NodeFlag::IsParsingChildrenFinished); }
 
-    void setDelegatesFocusToShadowRoot() { setNodeFlag(NodeFlag::DelegatesFocusToShadowRoot); }
-
-    void setInclusiveAncestorStates(OptionSet<AncestorState>);
-    void addInclusiveAncestorState(AncestorState);
-
     constexpr static auto DefaultNodeFlags = OptionSet<NodeFlag>(NodeFlag::IsParsingChildrenFinished);
     constexpr static auto CreateOther = DefaultNodeFlags;
     constexpr static auto CreateCharacterData = DefaultNodeFlags | NodeFlag::IsCharacterData;
@@ -903,44 +886,6 @@
         moveTreeToNewScope(*this, *m_treeScope, newTreeScope);
 }
 
-ALWAYS_INLINE OptionSet<Node::AncestorState> Node::inclusiveAncestorStates() const
-{
-    ASSERT(isElementNode() || isTreeScope() || isDocumentFragment()); // Only Element supports ancestor states for expediency.
-    OptionSet<Node::AncestorState> states;
-    if (hasNodeFlag(NodeFlag::InclusiveAncestorStateForForm))
-        states.add(AncestorState::Form);
-    if (hasNodeFlag(NodeFlag::InclusiveAncestorStateForCanvas))
-        states.add(AncestorState::Canvas);
-    return states;
-}
-
-ALWAYS_INLINE void Node::setInclusiveAncestorStates(OptionSet<AncestorState> states)
-{
-    ASSERT(isElementNode());
-    if (states.contains(AncestorState::Form))
-        setNodeFlag(NodeFlag::InclusiveAncestorStateForForm);
-    else
-        clearNodeFlag(NodeFlag::InclusiveAncestorStateForForm);
-
-    if (states.contains(AncestorState::Canvas))
-        setNodeFlag(NodeFlag::InclusiveAncestorStateForCanvas);
-    else
-        clearNodeFlag(NodeFlag::InclusiveAncestorStateForCanvas);
-}
-
-inline void Node::addInclusiveAncestorState(AncestorState state)
-{
-    ASSERT(isHTMLElement());
-    switch (state) {
-    case AncestorState::Form:
-        setNodeFlag(NodeFlag::InclusiveAncestorStateForForm);
-        break;
-    case AncestorState::Canvas:
-        setNodeFlag(NodeFlag::InclusiveAncestorStateForCanvas);
-        break;
-    }
-}
-
 inline constexpr PartialOrdering PartialOrdering::less(Type::Less);
 inline constexpr PartialOrdering PartialOrdering::equivalent(Type::Equivalent);
 inline constexpr PartialOrdering PartialOrdering::greater(Type::Greater);

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (273621 => 273622)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2021-02-27 09:33:00 UTC (rev 273622)
@@ -148,8 +148,7 @@
     if (!document().frame()->eventHandler().tabsToLinks(event))
         return false;
 
-    ASSERT(inclusiveAncestorStates().contains(AncestorState::Canvas) == !!ancestorsOfType<HTMLCanvasElement>(*this).first());
-    if (!renderer() && inclusiveAncestorStates().contains(AncestorState::Canvas))
+    if (!renderer() && ancestorsOfType<HTMLCanvasElement>(*this).first())
         return true;
 
     return hasNonEmptyBox(renderBoxModelObject());

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (273621 => 273622)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2021-02-27 09:33:00 UTC (rev 273622)
@@ -128,7 +128,6 @@
     , CanvasBase(IntSize(defaultWidth, defaultHeight))
     , ActiveDOMObject(document)
 {
-    addInclusiveAncestorState(AncestorState::Canvas);
     ASSERT(hasTagName(canvasTag));
 }
 
@@ -1050,10 +1049,7 @@
             document.canvasChanged(*this, FloatRect { });
     }
 
-    HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
-    addInclusiveAncestorState(AncestorState::Canvas);
-
-    return InsertedIntoAncestorResult::Done;
+    return HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
 }
 
 void HTMLCanvasElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
@@ -1064,7 +1060,6 @@
     }
 
     HTMLElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
-    addInclusiveAncestorState(AncestorState::Canvas);
 }
 
 bool HTMLCanvasElement::needsPreparationForDisplay()

Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (273621 => 273622)


--- trunk/Source/WebCore/html/HTMLFormElement.cpp	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp	2021-02-27 09:33:00 UTC (rev 273622)
@@ -66,7 +66,6 @@
 HTMLFormElement::HTMLFormElement(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document)
 {
-    addInclusiveAncestorState(AncestorState::Form);
     ASSERT(hasTagName(formTag));
 }
 
@@ -136,7 +135,6 @@
 Node::InsertedIntoAncestorResult HTMLFormElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
 {
     HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
-    addInclusiveAncestorState(AncestorState::Form);
     if (insertionType.connectedToDocument)
         document().didAssociateFormControl(*this);
     return InsertedIntoAncestorResult::Done;
@@ -149,7 +147,6 @@
     for (auto& associatedElement : associatedElements)
         associatedElement->formOwnerRemovedFromTree(root);
     HTMLElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
-    addInclusiveAncestorState(AncestorState::Form);
 }
 
 unsigned HTMLFormElement::length() const
@@ -895,15 +892,8 @@
     HTMLElement::copyNonAttributePropertiesFromElement(source);
 }
 
-HTMLFormElement* HTMLFormElement::findClosestFormAncestorSlowCase(const Element& startElement)
+HTMLFormElement* HTMLFormElement::findClosestFormAncestor(const Element& startElement)
 {
-    if (UNLIKELY(is<HTMLFormElement>(startElement))) {
-        auto* parentElement = startElement.parentElement();
-        if (!parentElement || !parentElement->inclusiveAncestorStates().contains(AncestorState::Form)) {
-            ASSERT(!ancestorsOfType<HTMLFormElement>(startElement).first());
-            return nullptr;
-        }
-    }
     return const_cast<HTMLFormElement*>(ancestorsOfType<HTMLFormElement>(startElement).first());
 }
 

Modified: trunk/Source/WebCore/html/HTMLFormElement.h (273621 => 273622)


--- trunk/Source/WebCore/html/HTMLFormElement.h	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/html/HTMLFormElement.h	2021-02-27 09:33:00 UTC (rev 273622)
@@ -26,7 +26,6 @@
 #include "FormState.h"
 #include "FormSubmission.h"
 #include "HTMLElement.h"
-#include "HTMLNames.h"
 #include "RadioButtonGroups.h"
 #include <memory>
 #include <wtf/IsoMalloc.h>
@@ -122,16 +121,7 @@
 
     StringPairVector textFieldValues() const;
 
-    static HTMLFormElement* findClosestFormAncestor(const Element& element)
-    {
-        if (!element.inclusiveAncestorStates().contains(AncestorState::Form)) {
-            ASSERT(!findClosestFormAncestorSlowCase(element));
-            return nullptr;
-        }
-        auto* result = findClosestFormAncestorSlowCase(element);
-        ASSERT(result || element.tagQName() == HTMLNames::formTag);
-        return result;
-    }
+    static HTMLFormElement* findClosestFormAncestor(const Element&);
 
 private:
     HTMLFormElement(const QualifiedName&, Document&);
@@ -174,8 +164,6 @@
 
     void resetAssociatedFormControlElements();
 
-    static HTMLFormElement* findClosestFormAncestorSlowCase(const Element&);
-
     FormSubmission::Attributes m_attributes;
     HashMap<AtomString, WeakPtr<HTMLElement>> m_pastNamesMap;
 

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (273621 => 273622)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2021-02-27 08:24:02 UTC (rev 273621)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2021-02-27 09:33:00 UTC (rev 273622)
@@ -368,10 +368,6 @@
         m_form = nullptr;
     }
 
-    // Insert needs to complete first, before we start updating the loader. Loader dispatches events which could result
-    // in callbacks back to this node.
-    Node::InsertedIntoAncestorResult insertNotificationRequest = HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
-
     if (!m_form) {
         if (auto* newForm = HTMLFormElement::findClosestFormAncestor(*this)) {
             m_form = makeWeakPtr(newForm);
@@ -379,6 +375,10 @@
         }
     }
 
+    // Insert needs to complete first, before we start updating the loader. Loader dispatches events which could result
+    // in callbacks back to this node.
+    Node::InsertedIntoAncestorResult insertNotificationRequest = HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
+
     if (insertionType.treeScopeChanged && !m_parsedUsemap.isNull())
         treeScope().addImageElementByUsemap(*m_parsedUsemap.impl(), *this);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to