LibWeb: Always update computed properties for finished animations

If an animation got to its finished state before its target's computed
properties could be updated, we would end up with invalid styles. Do not
skip finished animations, but prevent effect invalidation on timeline
updates if the animation is already finished.

This fixes the CI flake on WPT test
`css/css-transitions/inherit-height-transition.html`.
This commit is contained in:
Jelle Raaijmakers 2025-08-26 14:23:30 +02:00 committed by Jelle Raaijmakers
commit 84c4eb7aa9
Notes: github-actions[bot] 2025-08-26 16:49:03 +00:00
3 changed files with 10 additions and 10 deletions

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2023-2024, Matthew Olsson <mattco@serenityos.org>. * Copyright (c) 2023-2024, Matthew Olsson <mattco@serenityos.org>.
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -934,7 +935,9 @@ GC::Ptr<DOM::Document> Animation::document_for_timing() const
void Animation::notify_timeline_time_did_change() void Animation::notify_timeline_time_did_change()
{ {
update_finished_state(DidSeek::No, SynchronouslyNotify::Yes); // Update finished state if not already finished; prevents recurring invalidation when the timeline updates.
if (!m_is_finished)
update_finished_state(DidSeek::No, SynchronouslyNotify::Yes);
// Act on the pending play or pause task // Act on the pending play or pause task
if (m_pending_play_task == TaskState::Scheduled) { if (m_pending_play_task == TaskState::Scheduled) {
@ -1330,13 +1333,11 @@ GC::Ref<WebIDL::Promise> Animation::current_finished_promise() const
void Animation::invalidate_effect() void Animation::invalidate_effect()
{ {
if (!m_effect) { if (!m_effect)
return; return;
}
if (auto* target = m_effect->target(); target) { if (auto* target = m_effect->target())
target->document().set_needs_animated_style_update(); target->document().set_needs_animated_style_update();
}
} }
Animation::Animation(JS::Realm& realm) Animation::Animation(JS::Realm& realm)

View file

@ -1574,11 +1574,10 @@ void Document::update_animated_style_if_needed()
for (auto& timeline : m_associated_animation_timelines) { for (auto& timeline : m_associated_animation_timelines) {
for (auto& animation : timeline->associated_animations()) { for (auto& animation : timeline->associated_animations()) {
if (animation->is_idle() || animation->is_finished()) if (animation->is_idle())
continue; continue;
if (auto effect = animation->effect()) { if (auto effect = animation->effect())
effect->update_computed_properties(context); effect->update_computed_properties(context);
}
} }
} }

View file

@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests Found 1 tests
1 Fail 1 Pass
Fail Mid-transition transition changes affect subsequent transitions Pass Mid-transition transition changes affect subsequent transitions