From 868981a46b541b25f290d04b6b0836d2f6a06f06 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 8 Mar 2025 18:09:52 +0100 Subject: [PATCH] LibWeb: Skip animation invalidation for elements nested in display none Paper over the fact we sometimes fail to cancel animations for elements nested in display none, and do lots of wasted work. --- Libraries/LibWeb/Animations/KeyframeEffect.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 0360d7b9b91..c6a4efd4df9 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -923,6 +923,13 @@ void KeyframeEffect::update_computed_properties() if (!target || !target->is_connected()) return; + if (target->has_inclusive_ancestor_with_display_none()) { + // FIXME: Reaching this point means we failed to cancel animation for an element that started + // being nested in "display: none". + // For now this hack is needed to avoid lots of unnecessary work. + return; + } + GC::Ptr style = {}; if (!pseudo_element_type().has_value()) style = target->computed_properties();