Title: [294605] trunk/Source/WebCore
- Revision
- 294605
- Author
- cdu...@apple.com
- Date
- 2022-05-20 19:24:37 -0700 (Fri, 20 May 2022)
Log Message
Reduce branching a little under JSNodeOwner::isReachableFromOpaqueRoots()
https://bugs.webkit.org/show_bug.cgi?id=240742
Reviewed by Geoffrey Garen.
Given that JSNodeOwner::isReachableFromOpaqueRoots() already checks if the Node is
connected or not, make sure to avoid the same check under Node::opaqueRoot().
* Source/WebCore/bindings/js/JSNodeCustom.cpp:
(WebCore::JSNodeOwner::isReachableFromOpaqueRoots):
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::traverseToOpaqueRoot const):
(WebCore::Node::opaqueRootSlow const): Deleted.
* Source/WebCore/dom/Node.h:
(WebCore::Node::opaqueRoot const):
Canonical link: https://commits.webkit.org/250831@main
Modified Paths
Diff
Modified: trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp (294604 => 294605)
--- trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp 2022-05-21 01:23:37 UTC (rev 294604)
+++ trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp 2022-05-21 02:24:37 UTC (rev 294605)
@@ -74,12 +74,13 @@
*reason = "Node is scheduled to be used in an async script invocation)";
return true;
}
+ return visitor.containsOpaqueRoot(node.traverseToOpaqueRoot());
}
if (UNLIKELY(reason))
*reason = "Connected node";
- return visitor.containsOpaqueRoot(root(node));
+ return visitor.containsOpaqueRoot(&node.document());
}
JSScope* JSNode::pushEventHandlerScope(JSGlobalObject* lexicalGlobalObject, JSScope* node) const
Modified: trunk/Source/WebCore/dom/Node.cpp (294604 => 294605)
--- trunk/Source/WebCore/dom/Node.cpp 2022-05-21 01:23:37 UTC (rev 294604)
+++ trunk/Source/WebCore/dom/Node.cpp 2022-05-21 02:24:37 UTC (rev 294605)
@@ -2639,8 +2639,9 @@
return isConnected() && document().hasLivingRenderTree();
}
-void* Node::opaqueRootSlow() const
+void* Node::traverseToOpaqueRoot() const
{
+ ASSERT_WITH_MESSAGE(!isConnected(), "Call opaqueRoot() or document() when the node is connected");
const Node* node = this;
for (;;) {
const Node* nextNode = node->parentOrShadowHostNode();
Modified: trunk/Source/WebCore/dom/Node.h (294604 => 294605)
--- trunk/Source/WebCore/dom/Node.h 2022-05-21 01:23:37 UTC (rev 294604)
+++ trunk/Source/WebCore/dom/Node.h 2022-05-21 02:24:37 UTC (rev 294605)
@@ -267,6 +267,7 @@
Node& getRootNode(const GetRootNodeOptions&) const;
void* opaqueRoot() const;
+ void* traverseToOpaqueRoot() const;
void queueTaskKeepingThisNodeAlive(TaskSource, Function<void ()>&&);
void queueTaskToDispatchEvent(TaskSource, Ref<Event>&&);
@@ -716,8 +717,6 @@
void adjustStyleValidity(Style::Validity, Style::InvalidationMode);
- void* opaqueRootSlow() const;
-
static void moveShadowTreeToNewDocument(ShadowRoot&, Document& oldDocument, Document& newDocument);
static void moveTreeToNewScope(Node&, TreeScope& oldScope, TreeScope& newScope);
void moveNodeToNewDocument(Document& oldDocument, Document& newDocument);
@@ -852,7 +851,7 @@
// https://bugs.webkit.org/show_bug.cgi?id=165713
if (isConnected())
return &document();
- return opaqueRootSlow();
+ return traverseToOpaqueRoot();
}
inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes