Title: [285728] trunk
Revision
285728
Author
[email protected]
Date
2021-11-12 09:40:47 -0800 (Fri, 12 Nov 2021)

Log Message

[Web Animations] Accelerated animations with a single keyframe don't account for prior forward-filling animations
https://bugs.webkit.org/show_bug.cgi?id=233041
<rdar://problem/85236241>

Reviewed by Dean Jackson.

Source/WebCore:

Test: webanimations/accelerated-animation-after-forward-filling-animation.html

When starting an accelerated animation, we would fill any implicit keyframes based on the unanimated style.
We now also apply all animations below this animation in the target's effect stack such that a previous
forward-filling animation is accounted for.

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::applyPendingAcceleratedActions):

LayoutTests:

Add a new test that runs a forward-filling animation for `transform`, waits for its completion,
then runs another `transform` animation with an implicit initial keyframe, ensuring that the
result of the first forward-filling animation is accounted for when computing the initial
keyframe.

This test would fail prior to this patch.

* webanimations/accelerated-animation-after-forward-filling-animation-expected.html: Added.
* webanimations/accelerated-animation-after-forward-filling-animation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285727 => 285728)


--- trunk/LayoutTests/ChangeLog	2021-11-12 17:37:01 UTC (rev 285727)
+++ trunk/LayoutTests/ChangeLog	2021-11-12 17:40:47 UTC (rev 285728)
@@ -1,3 +1,21 @@
+2021-11-12  Antoine Quint  <[email protected]>
+
+        [Web Animations] Accelerated animations with a single keyframe don't account for prior forward-filling animations
+        https://bugs.webkit.org/show_bug.cgi?id=233041
+        <rdar://problem/85236241>
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that runs a forward-filling animation for `transform`, waits for its completion,
+        then runs another `transform` animation with an implicit initial keyframe, ensuring that the
+        result of the first forward-filling animation is accounted for when computing the initial
+        keyframe.
+
+        This test would fail prior to this patch.
+
+        * webanimations/accelerated-animation-after-forward-filling-animation-expected.html: Added.
+        * webanimations/accelerated-animation-after-forward-filling-animation.html: Added.
+
 2021-11-12  Patrick Angle  <[email protected]>
 
         Web Inspector: Mark inspector/page/setShowPaintRects.html as flakey in test expectations for Mac

Added: trunk/LayoutTests/webanimations/accelerated-animation-after-forward-filling-animation-expected.html (0 => 285728)


--- trunk/LayoutTests/webanimations/accelerated-animation-after-forward-filling-animation-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/accelerated-animation-after-forward-filling-animation-expected.html	2021-11-12 17:40:47 UTC (rev 285728)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<body>
+<style>
+
+    #target {
+        position: absolute;
+        left: 0;
+        top: 0;
+        width: 100px;
+        height: 100px;
+        background-color: black;
+        transform: translateX(100px);
+    }
+
+</style>
+<div id="target"></div>
+</body>

Added: trunk/LayoutTests/webanimations/accelerated-animation-after-forward-filling-animation.html (0 => 285728)


--- trunk/LayoutTests/webanimations/accelerated-animation-after-forward-filling-animation.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/accelerated-animation-after-forward-filling-animation.html	2021-11-12 17:40:47 UTC (rev 285728)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<body>
+<style>
+
+    #target {
+        position: absolute;
+        left: 0;
+        top: 0;
+        width: 100px;
+        height: 100px;
+        background-color: black;
+    }
+
+</style>
+<div id="target"></div>
+<script>
+
+(async () => {
+    if (window.testRunner)
+        window.testRunner.waitUntilDone();
+
+    const target = document.getElementById("target");
+
+    // Start a forward-filling accelerated animation.
+    const fillingAnimation = target.animate({ transform: "translateX(100px)" }, { duration: 1, fill: "forwards" });
+    await fillingAnimation.finished;
+
+    // Start another animation with an implicit from keyframe.
+    const animation = target.animate({ transform: "translateY(1px)" }, { duration: 1000 * 1000 });
+
+    // Wait two frames for the accelerated animation to be committed.
+    await animation.ready;
+    await new Promise(requestAnimationFrame);
+    await new Promise(requestAnimationFrame);
+
+    if (window.testRunner)
+        window.testRunner.notifyDone();
+})();
+
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (285727 => 285728)


--- trunk/Source/WebCore/ChangeLog	2021-11-12 17:37:01 UTC (rev 285727)
+++ trunk/Source/WebCore/ChangeLog	2021-11-12 17:40:47 UTC (rev 285728)
@@ -1,3 +1,20 @@
+2021-11-12  Antoine Quint  <[email protected]>
+
+        [Web Animations] Accelerated animations with a single keyframe don't account for prior forward-filling animations
+        https://bugs.webkit.org/show_bug.cgi?id=233041
+        <rdar://problem/85236241>
+
+        Reviewed by Dean Jackson.
+
+        Test: webanimations/accelerated-animation-after-forward-filling-animation.html
+
+        When starting an accelerated animation, we would fill any implicit keyframes based on the unanimated style.
+        We now also apply all animations below this animation in the target's effect stack such that a previous
+        forward-filling animation is accounted for.
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::applyPendingAcceleratedActions):
+
 2021-11-12  Wenson Hsieh  <[email protected]>
 
         Move subtree update logic in ImageOverlay::updateWithTextRecognitionResult() into a separate helper

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (285727 => 285728)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2021-11-12 17:37:01 UTC (rev 285727)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2021-11-12 17:40:47 UTC (rev 285728)
@@ -1788,9 +1788,22 @@
         auto* lastStyleChangeEventStyle = m_target->lastStyleChangeEventStyle(m_pseudoId);
         ASSERT(lastStyleChangeEventStyle);
 
+        // We need to resolve all animations up to this point to ensure any forward-filling
+        // effect is accounted for when computing the "from" value for the accelerated animation.
+        auto underlyingStyle = RenderStyle::clonePtr(*lastStyleChangeEventStyle);
+        auto* effectStack = m_target->keyframeEffectStack(m_pseudoId);
+        ASSERT(effectStack);
+
+        for (const auto& effect : effectStack->sortedEffects()) {
+            if (this == effect.get())
+                break;
+            if (auto progress = effect->getComputedTiming().progress)
+                effect->setAnimatedPropertiesInStyle(*underlyingStyle, *progress);
+        }
+
         KeyframeList explicitKeyframes(m_blendingKeyframes.animationName());
         explicitKeyframes.copyKeyframes(m_blendingKeyframes);
-        explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), lastStyleChangeEventStyle, nullptr);
+        explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), underlyingStyle.get(), nullptr);
         return renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), explicitKeyframes) ? RunningAccelerated::Yes : RunningAccelerated::No;
     };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to