From 8fdfadb0c919f3efb3d1209966619b14509e4290 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 5 Jan 2025 00:29:13 +0300 Subject: [PATCH] LibWeb: Optimize inherited style update caused by animation It is possible to skip inherited style recalculation for children if parent's recalculation does not cause any changes. Improves performance on Github where we could avoid dozens of inherited style calculations that do not produce any visible changes. --- Libraries/LibWeb/Animations/KeyframeEffect.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index ac843dda7f8..d04114a59b2 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -939,7 +939,10 @@ void KeyframeEffect::update_computed_properties() // Traversal of the subtree is necessary to update the animated properties inherited from the target element. target->for_each_in_subtree_of_type([&](auto& element) { - invalidation |= element.recompute_inherited_style(); + auto element_invalidation = element.recompute_inherited_style(); + if (element_invalidation.is_none()) + return TraversalDecision::SkipChildrenAndContinue; + invalidation |= element_invalidation; return TraversalDecision::Continue; });