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/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);