From 268143681e40d1adae6cdfc70802df05186fe9b7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 8 Mar 2025 18:06:15 +0100 Subject: [PATCH] LibWeb: Don't drop layout tree in CSS animation invalidation It's possible to do a partial tree rebuild instead. --- Libraries/LibWeb/Animations/KeyframeEffect.cpp | 11 +++++++++-- Libraries/LibWeb/DOM/Document.h | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 543a827cd22..0360d7b9b91 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -963,8 +963,15 @@ void KeyframeEffect::update_computed_properties() if (invalidation.relayout) target->set_needs_layout_update(DOM::SetNeedsLayoutReason::KeyframeEffect); - if (invalidation.rebuild_layout_tree) - document.invalidate_layout_tree(DOM::InvalidateLayoutTreeReason::KeyframeEffect); + if (invalidation.rebuild_layout_tree) { + // We mark layout tree for rebuild starting from parent element to correctly invalidate + // "display" property change to/from "contents" value. + if (auto* parent_element = target->parent_element()) { + parent_element->set_needs_layout_tree_update(true); + } else { + target->set_needs_layout_tree_update(true); + } + } if (invalidation.repaint) { document.set_needs_display(); document.set_needs_to_resolve_paint_only_properties(); diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 464ca275f99..52e0e5dbc22 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -55,7 +55,6 @@ enum class QuirksMode { X(DocumentRequestAnElementToBeRemovedFromTheTopLayer) \ X(HTMLInputElementSrcAttributeChange) \ X(HTMLObjectElement) \ - X(KeyframeEffect) \ X(SVGGraphicsElementTransformAttributeChange) \ X(ShadowRootSetInnerHTML)