From a122685896600fced3d6461c5298f31d7ccabd88 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Apr 2025 16:30:19 +0200 Subject: [PATCH] LibWeb: Don't look for animations to activate in disconnected subtrees Knocks down a 3.3% profile item to 1.6% on Speedometer 3. --- Libraries/LibWeb/DOM/Node.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index 68a28d34d60..aa82cf2f476 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -2937,6 +2937,10 @@ bool Node::has_inclusive_ancestor_with_display_none() void Node::play_or_cancel_animations_after_display_property_change() { + // OPTIMIZATION: We don't care about animations in disconnected subtrees. + if (!is_connected()) + return; + // https://www.w3.org/TR/css-animations-1/#animations // Setting the display property to none will terminate any running animation applied to the element and its descendants. // If an element has a display of none, updating display to a value other than none will start all animations applied to