From 1ce1a8f8f1c15215146ec70422c3bc9037581587 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 3 Mar 2025 20:25:06 +0100 Subject: [PATCH] LibWeb: Reset and update animated style in a single pass ...and skip resetting animated style of finished animations. --- Libraries/LibWeb/DOM/Document.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 67137bb6492..bf1f992fa9b 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -1523,16 +1523,14 @@ void Document::update_animated_style_if_needed() invalidate_display_list(); for (auto& timeline : m_associated_animation_timelines) { - for (auto& animation : timeline->associated_animations()) { - if (auto effect = animation->effect(); effect && effect->target()) - effect->target()->reset_animated_css_properties(); - } - for (auto& animation : timeline->associated_animations()) { if (animation->is_finished()) continue; - if (auto effect = animation->effect()) + if (auto effect = animation->effect()) { + if (auto* target = effect->target()) + target->reset_animated_css_properties(); effect->update_computed_properties(); + } } } m_needs_animated_style_update = false;