[Web Animations] Positive delays of accelerated animations are not respected
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 19:05:31 +0000 (19:05 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 19:05:31 +0000 (19:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189411
<rdar://problem/44151416>

Reviewed by Dean Jackson.

Source/WebCore:

Test: webanimations/accelerated-animation-with-delay-and-seek.html

We were only accounting for negative delays for accelerated actions. We also were misbehaving
when seeking an animation with a delay (positive or negative) since we wouldn't reset the animation
begin time to be the current time when adjusting its time offset, while the begin time set when
first creating the animation would be set accounting for the time offset.

* animation/KeyframeEffectReadOnly.cpp:
(WebCore::KeyframeEffectReadOnly::applyPendingAcceleratedActions):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::seekCAAnimationOnLayer):

LayoutTests:

Add a test that checks that positive delays are accounted for during accelerated actions, including a seek.

* webanimations/accelerated-animation-with-delay-and-seek-expected.html: Added.
* webanimations/accelerated-animation-with-delay-and-seek.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235854 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webanimations/accelerated-animation-with-delay-and-seek-expected.html [new file with mode: 0644]
LayoutTests/webanimations/accelerated-animation-with-delay-and-seek.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/animation/KeyframeEffectReadOnly.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

index 608c3d6..4646c03 100644 (file)
@@ -1,3 +1,16 @@
+2018-09-10  Antoine Quint  <graouts@apple.com>
+
+        [Web Animations] Positive delays of accelerated animations are not respected
+        https://bugs.webkit.org/show_bug.cgi?id=189411
+        <rdar://problem/44151416>
+
+        Reviewed by Dean Jackson.
+
+        Add a test that checks that positive delays are accounted for during accelerated actions, including a seek.
+
+        * webanimations/accelerated-animation-with-delay-and-seek-expected.html: Added.
+        * webanimations/accelerated-animation-with-delay-and-seek.html: Added.
+
 2018-09-10  Per Arne Vollan  <pvollan@apple.com>
 
         [Windows] Layout Test webanimations/accelerated-transition-interrupted-on-composited-element.html is failing
diff --git a/LayoutTests/webanimations/accelerated-animation-with-delay-and-seek-expected.html b/LayoutTests/webanimations/accelerated-animation-with-delay-and-seek-expected.html
new file mode 100644 (file)
index 0000000..cf518fe
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div {
+    position: absolute;
+    width: 100px;
+    height: 100px;
+    transform: translateX(50px);
+    background-color: black;
+}
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
diff --git a/LayoutTests/webanimations/accelerated-animation-with-delay-and-seek.html b/LayoutTests/webanimations/accelerated-animation-with-delay-and-seek.html
new file mode 100644 (file)
index 0000000..b5fd87a
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+div {
+    position: absolute;
+    width: 100px;
+    height: 100px;
+    background-color: black;
+}
+
+</style>
+</head>
+<body>
+<script>
+
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+const animation = document.body.appendChild(document.createElement("div")).animate({
+    transform: ["translateX(100px)", "none"]
+}, { duration: 10000, delay: 1000 });
+
+requestAnimationFrame(() => {
+    animation.pause();
+    animation.currentTime = 6000;
+    if (window.testRunner)
+        requestAnimationFrame(() => testRunner.notifyDone());
+});
+
+</script>
+</body>
+</html>
index 593804b..39395b6 100644 (file)
@@ -1,3 +1,23 @@
+2018-09-10  Antoine Quint  <graouts@apple.com>
+
+        [Web Animations] Positive delays of accelerated animations are not respected
+        https://bugs.webkit.org/show_bug.cgi?id=189411
+        <rdar://problem/44151416>
+
+        Reviewed by Dean Jackson.
+
+        Test: webanimations/accelerated-animation-with-delay-and-seek.html
+
+        We were only accounting for negative delays for accelerated actions. We also were misbehaving
+        when seeking an animation with a delay (positive or negative) since we wouldn't reset the animation
+        begin time to be the current time when adjusting its time offset, while the begin time set when
+        first creating the animation would be set accounting for the time offset.
+
+        * animation/KeyframeEffectReadOnly.cpp:
+        (WebCore::KeyframeEffectReadOnly::applyPendingAcceleratedActions):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::seekCAAnimationOnLayer):
+
 2018-09-10  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
 
         [WTF] Add Markable<T, Traits>
index 135addd..0fe00d8 100644 (file)
@@ -1279,9 +1279,7 @@ void KeyframeEffectReadOnly::applyPendingAcceleratedActions()
     auto* compositedRenderer = downcast<RenderBoxModelObject>(renderer);
 
     // To simplify the code we use a default of 0s for an unresolved current time since for a Stop action that is acceptable.
-    auto timeOffset = animation()->currentTime().value_or(0_s).seconds();
-    if (timing()->delay() < 0_s)
-        timeOffset = -timing()->delay().seconds();
+    auto timeOffset = animation()->currentTime().value_or(0_s).seconds() - timing()->delay().seconds();
 
     for (const auto& action : pendingAcceleratedActions) {
         switch (action) {
index a47c094..cf1aa41 100644 (file)
@@ -2972,6 +2972,7 @@ void GraphicsLayerCA::seekCAAnimationOnLayer(AnimatedPropertyID property, const
     // Animations on the layer are immutable, so we have to clone and modify.
     RefPtr<PlatformCAAnimation> newAnim = currentAnimation->copy();
 
+    newAnim->setBeginTime(CACurrentMediaTime());
     newAnim->setTimeOffset(timeOffset.seconds());
 
     layer->addAnimationForKey(animationID, *newAnim); // This will replace the running animation.