Title: [234279] trunk
Revision
234279
Author
[email protected]
Date
2018-07-26 15:16:28 -0700 (Thu, 26 Jul 2018)

Log Message

[Web Animations] Accelerated animations don't respect a positive delay value
https://bugs.webkit.org/show_bug.cgi?id=186930
<rdar://problem/41393393>

Reviewed by Dean Jackson.

Source/WebCore:

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

We would mistakenly clear the list of pending accelerated actions in KeyframeEffectReadOnly::applyPendingAcceleratedActions()
even if we failed to proceed because of the target element's renderer not being composited yet. Now, we clear the list after
we've established we can apply them, and if we can't we inform the animation with a call to acceleratedStateDidChange() which
will in turn call into the document timeline so that we may consider these animations on the next tick.

For this to work correctly we must make a change to DocumentTimeline::applyPendingAcceleratedAnimations() which only cleared
its list of pending accelerated animations _after_ iterating through them, which would be problematic since we would now add
animations to this list. That list is now copied and cleared prior to iterating through its members.

We also fix the naming of the m_pendingAcceleratedActions copy in KeyframeEffectReadOnly::applyPendingAcceleratedActions()
to have a more similar name.

* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::applyPendingAcceleratedAnimations):
* animation/KeyframeEffectReadOnly.cpp:
(WebCore::KeyframeEffectReadOnly::applyPendingAcceleratedActions):

LayoutTests:

Creating a new test that runs an accelerated animation on a non-positioned element with a small
positive delay. Prior to this patch, the element would move slightly when the delay elapses but
wouldn't animate towards the target value. With this patch, it animatea correctly. To check
that it does animate, we add a cache over the element except for the first 25px which is the area
within which it might have moved prior to this patch. This way the test only passes if the element
is fully hidden by the cache.

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234278 => 234279)


--- trunk/LayoutTests/ChangeLog	2018-07-26 22:00:03 UTC (rev 234278)
+++ trunk/LayoutTests/ChangeLog	2018-07-26 22:16:28 UTC (rev 234279)
@@ -1,3 +1,21 @@
+2018-07-26  Antoine Quint  <[email protected]>
+
+        [Web Animations] Accelerated animations don't respect a positive delay value
+        https://bugs.webkit.org/show_bug.cgi?id=186930
+        <rdar://problem/41393393>
+
+        Reviewed by Dean Jackson.
+
+        Creating a new test that runs an accelerated animation on a non-positioned element with a small
+        positive delay. Prior to this patch, the element would move slightly when the delay elapses but
+        wouldn't animate towards the target value. With this patch, it animatea correctly. To check
+        that it does animate, we add a cache over the element except for the first 25px which is the area
+        within which it might have moved prior to this patch. This way the test only passes if the element
+        is fully hidden by the cache.
+
+        * webanimations/accelerated-animation-with-delay-expected.html: Added.
+        * webanimations/accelerated-animation-with-delay.html: Added.
+
 2018-07-26  Basuke Suzuki  <[email protected]>
 
         [Curl] Test gardening

Added: trunk/LayoutTests/webanimations/accelerated-animation-with-delay-expected.html (0 => 234279)


--- trunk/LayoutTests/webanimations/accelerated-animation-with-delay-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/accelerated-animation-with-delay-expected.html	2018-07-26 22:16:28 UTC (rev 234279)
@@ -0,0 +1 @@
+<div style="position: absolute; left: 25px; top: 0; width: 775px; height: 100px; background-color: black;"></div>

Added: trunk/LayoutTests/webanimations/accelerated-animation-with-delay.html (0 => 234279)


--- trunk/LayoutTests/webanimations/accelerated-animation-with-delay.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/accelerated-animation-with-delay.html	2018-07-26 22:16:28 UTC (rev 234279)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<body>
+<style>
+    
+    body {
+        margin: 0;
+    }
+    
+    div {
+        height: 100px;
+    }
+
+    #target {
+        left: 0;
+        width: 100px;
+        background-color: red;
+    }
+
+    #cache {
+        top: 0;
+        left: 25px;
+        width: 775px;
+        position: absolute;
+        background-color: black;
+    }
+
+</style>
+<div id="target"></div>
+<div id="cache"></div>
+<script>
+
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+document.getElementById("target").animate({ transform: "translateX(700px)" }, { delay: 10, duration: 1000 })
+requestAnimationFrame(() => {
+    setTimeout(() => {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, 100);
+});
+
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (234278 => 234279)


--- trunk/Source/WebCore/ChangeLog	2018-07-26 22:00:03 UTC (rev 234278)
+++ trunk/Source/WebCore/ChangeLog	2018-07-26 22:16:28 UTC (rev 234279)
@@ -1,3 +1,30 @@
+2018-07-26  Antoine Quint  <[email protected]>
+
+        [Web Animations] Accelerated animations don't respect a positive delay value
+        https://bugs.webkit.org/show_bug.cgi?id=186930
+        <rdar://problem/41393393>
+
+        Reviewed by Dean Jackson.
+
+        Test: webanimations/accelerated-animation-with-delay.html
+
+        We would mistakenly clear the list of pending accelerated actions in KeyframeEffectReadOnly::applyPendingAcceleratedActions()
+        even if we failed to proceed because of the target element's renderer not being composited yet. Now, we clear the list after
+        we've established we can apply them, and if we can't we inform the animation with a call to acceleratedStateDidChange() which
+        will in turn call into the document timeline so that we may consider these animations on the next tick.
+
+        For this to work correctly we must make a change to DocumentTimeline::applyPendingAcceleratedAnimations() which only cleared
+        its list of pending accelerated animations _after_ iterating through them, which would be problematic since we would now add
+        animations to this list. That list is now copied and cleared prior to iterating through its members.
+
+        We also fix the naming of the m_pendingAcceleratedActions copy in KeyframeEffectReadOnly::applyPendingAcceleratedActions()
+        to have a more similar name.
+
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::applyPendingAcceleratedAnimations):
+        * animation/KeyframeEffectReadOnly.cpp:
+        (WebCore::KeyframeEffectReadOnly::applyPendingAcceleratedActions):
+
 2018-07-26  Ross Kirsling  <[email protected]>
 
         String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (234278 => 234279)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2018-07-26 22:00:03 UTC (rev 234278)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2018-07-26 22:16:28 UTC (rev 234279)
@@ -397,8 +397,11 @@
 
 void DocumentTimeline::applyPendingAcceleratedAnimations()
 {
+    auto acceleratedAnimationsPendingRunningStateChange = m_acceleratedAnimationsPendingRunningStateChange;
+    m_acceleratedAnimationsPendingRunningStateChange.clear();
+
     bool hasForcedLayout = false;
-    for (auto& animation : m_acceleratedAnimationsPendingRunningStateChange) {
+    for (auto& animation : acceleratedAnimationsPendingRunningStateChange) {
         if (!hasForcedLayout) {
             auto* effect = animation->effect();
             if (is<KeyframeEffectReadOnly>(effect))
@@ -406,8 +409,6 @@
         }
         animation->applyPendingAcceleratedActions();
     }
-
-    m_acceleratedAnimationsPendingRunningStateChange.clear();
 }
 
 bool DocumentTimeline::resolveAnimationsForElement(Element& element, RenderStyle& targetStyle)

Modified: trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp (234278 => 234279)


--- trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp	2018-07-26 22:00:03 UTC (rev 234278)
+++ trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp	2018-07-26 22:16:28 UTC (rev 234279)
@@ -1264,16 +1264,18 @@
     // pending accelerated actions.
     m_needsForcedLayout = false;
 
-    auto pendingAccelerationActions = m_pendingAcceleratedActions;
-    m_pendingAcceleratedActions.clear();
-
-    if (pendingAccelerationActions.isEmpty())
+    if (m_pendingAcceleratedActions.isEmpty())
         return;
 
     auto* renderer = this->renderer();
-    if (!renderer || !renderer->isComposited())
+    if (!renderer || !renderer->isComposited()) {
+        animation()->acceleratedStateDidChange();
         return;
+    }
 
+    auto pendingAcceleratedActions = m_pendingAcceleratedActions;
+    m_pendingAcceleratedActions.clear();
+
     auto* compositedRenderer = downcast<RenderBoxModelObject>(renderer);
 
     auto currentTime = animation()->currentTime();
@@ -1284,7 +1286,7 @@
     if (timing()->delay() < 0_s)
         timeOffset = -timing()->delay().seconds();
 
-    for (const auto& action : pendingAccelerationActions) {
+    for (const auto& action : pendingAcceleratedActions) {
         switch (action) {
         case AcceleratedAction::Play:
             if (!compositedRenderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer().ptr(), m_blendingKeyframes)) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to