Skip to content

Truly independent web browser

LibWeb: Keep hidden animations with finite end times ticking

sideshowbarker91563340c619
diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp
index deee57b7c2a..773179d632f 100644
--- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp
+++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp
@@ -1085,8 +1085,8 @@ bool KeyframeEffect::can_skip_per_frame_style_update() const
// An animation inside a box-less iframe can't affect its embedding document's rendering. Check the containers
// before the target-local cache, since their layout can change without changing the target's style or layout box.
- // Reverse playback still needs ticks to finish when it reaches the start, even with an infinite iteration count.
- if (auto animation = associated_animation(); animation && animation->playback_rate() > 0 && isinf(iteration_count())) {
+ // Reverse playback and effects with a finite end time need ticks to finish, even with an infinite iteration count.
+ if (auto animation = associated_animation(); animation && animation->playback_rate() > 0 && isinf(iteration_count()) && isinf(end_time().value)) {
for (auto navigable = target->document().navigable(); navigable;) {
auto container = navigable->container();
if (!container)
diff --git a/Tests/LibWeb/Text/expected/css/animation-in-display-none-iframe.txt b/Tests/LibWeb/Text/expected/css/animation-in-display-none-iframe.txt
index 7e7083e3252..0c4fd12960e 100644
--- a/Tests/LibWeb/Text/expected/css/animation-in-display-none-iframe.txt
+++ b/Tests/LibWeb/Text/expected/css/animation-in-display-none-iframe.txt
@@ -9,3 +9,4 @@ hidden iframe dispatches iteration event: true
hidden ancestor iframe stops nested animation frame requests: true
showing ancestor iframe resumes nested animation: true
reversed infinite animation can finish while hidden: true
+zero-duration infinite animation finishes after its end delay while hidden: true
diff --git a/Tests/LibWeb/Text/input/css/animation-in-display-none-iframe.html b/Tests/LibWeb/Text/input/css/animation-in-display-none-iframe.html
index cde0e3c04f8..db7f0dab1af 100644
--- a/Tests/LibWeb/Text/input/css/animation-in-display-none-iframe.html
+++ b/Tests/LibWeb/Text/input/css/animation-in-display-none-iframe.html
@@ -85,6 +85,15 @@ asyncTest(async done => {
const finished = reversed.finished.then(() => true);
println(`reversed infinite animation can finish while hidden: ${await Promise.race([finished, new Promise(resolve => setTimeout(() => resolve(false), 2000))])}`);
reversed.cancel();
+
+ const zeroDuration = circle.animate({ strokeDashoffset: ["0", "100"] }, {
+ duration: 0,
+ iterations: Infinity,
+ endDelay: 1000,
+ });
+ const zeroDurationFinished = zeroDuration.finished.then(() => true);
+ println(`zero-duration infinite animation finishes after its end delay while hidden: ${await Promise.race([zeroDurationFinished, new Promise(resolve => setTimeout(() => resolve(false), 2000))])}`);
+ zeroDuration.cancel();
frame.remove();
done();
});