Title: [253901] trunk
Revision
253901
Author
[email protected]
Date
2019-12-24 10:35:47 -0800 (Tue, 24 Dec 2019)

Log Message

[Web Animations] REGRESSION: Changing the animation-duration of a CSS Animation may not resume it
https://bugs.webkit.org/show_bug.cgi?id=205580
<rdar://problem/58127956>

Patch by Antoine Quint <[email protected]> on 2019-12-24
Reviewed by Dean Jackson.

Source/WebCore:

Test: webanimations/css-animation-dynamic-duration-change.html

Setting the animation-duration of an animation will transition the animation back into its idle state
and the "update animations and send events" procedure would remove that animation from the timeline.
It would also remove it from the map that would associate an animation with a given CSS Animation name
so that we would know whether an animation exists for a given animation name when one of the animation's
properties changed. Since that animation was (mistakenly) removed, we would fail to update its timing
and it would never be resumed. We now only update the CSS Animation name to animation map when styles
change.

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::animationWasRemovedFromElement):

LayoutTests:

Add a new test that, by virtue of changing the animation-duration, transitions a CSS Animation from
idle, to running, back to idle and back to running. Prior to this change, the test would not perform
the final play state transition and the it would time out.

* webanimations/css-animation-dynamic-duration-change-expected.txt: Added.
* webanimations/css-animation-dynamic-duration-change.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253900 => 253901)


--- trunk/LayoutTests/ChangeLog	2019-12-24 18:10:53 UTC (rev 253900)
+++ trunk/LayoutTests/ChangeLog	2019-12-24 18:35:47 UTC (rev 253901)
@@ -1,3 +1,18 @@
+2019-12-24  Antoine Quint  <[email protected]>
+
+        [Web Animations] REGRESSION: Changing the animation-duration of a CSS Animation may not resume it
+        https://bugs.webkit.org/show_bug.cgi?id=205580
+        <rdar://problem/58127956>
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that, by virtue of changing the animation-duration, transitions a CSS Animation from
+        idle, to running, back to idle and back to running. Prior to this change, the test would not perform
+        the final play state transition and the it would time out.
+
+        * webanimations/css-animation-dynamic-duration-change-expected.txt: Added.
+        * webanimations/css-animation-dynamic-duration-change.html: Added.
+
 2019-12-24  Youenn Fablet  <[email protected]>
 
         Deny Notification API access for non secure contexts

Added: trunk/LayoutTests/webanimations/css-animation-dynamic-duration-change-expected.txt (0 => 253901)


--- trunk/LayoutTests/webanimations/css-animation-dynamic-duration-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webanimations/css-animation-dynamic-duration-change-expected.txt	2019-12-24 18:35:47 UTC (rev 253901)
@@ -0,0 +1,3 @@
+
+PASS A CSS Animation can be canceled and resumed by modifying its animation-duration. 
+

Added: trunk/LayoutTests/webanimations/css-animation-dynamic-duration-change.html (0 => 253901)


--- trunk/LayoutTests/webanimations/css-animation-dynamic-duration-change.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/css-animation-dynamic-duration-change.html	2019-12-24 18:35:47 UTC (rev 253901)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+#target {
+    width: 100px;
+    height: 100px;
+    background-color: black;
+    animation-name: animation;
+}
+
+#other {
+    width: 100px;
+    height: 100px;
+    background-color: black;
+    animation: animation 0.2s infinite;
+}
+
+#target.animated {
+    animation-duration: 0.2s;
+	animation-iteration-count: infinite;
+}
+
+@keyframes animation {
+    to { margin-left: "100px" };
+}
+
+</style>
+</head>
+<body>
+<script src=""
+<script src=""
+<div id="target"></div>
+<div id="other"></div>
+
+<script>
+
+    async_test(t => {
+
+    const _once_ = { once: true };
+    const target = document.getElementById("target");
+
+    // Start the animation.
+    target.classList.add("animated");
+    target.addEventListener("animationstart", event => {
+        // Now we can cancel this animation.
+        target.classList.remove("animated");
+        target.addEventListener("animationend", event => {
+            // We wait a frame, resume the animation and check it's the same animation.
+            requestAnimationFrame(() => {
+                target.classList.add("animated");
+                target.addEventListener("animationstart", event => t.done(), once);
+            });
+        }, once);
+    }, once);
+
+}, "A CSS Animation can be canceled and resumed by modifying its animation-duration.");
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (253900 => 253901)


--- trunk/Source/WebCore/ChangeLog	2019-12-24 18:10:53 UTC (rev 253900)
+++ trunk/Source/WebCore/ChangeLog	2019-12-24 18:35:47 UTC (rev 253901)
@@ -1,3 +1,24 @@
+2019-12-24  Antoine Quint  <[email protected]>
+
+        [Web Animations] REGRESSION: Changing the animation-duration of a CSS Animation may not resume it
+        https://bugs.webkit.org/show_bug.cgi?id=205580
+        <rdar://problem/58127956>
+
+        Reviewed by Dean Jackson.
+
+        Test: webanimations/css-animation-dynamic-duration-change.html
+
+        Setting the animation-duration of an animation will transition the animation back into its idle state
+        and the "update animations and send events" procedure would remove that animation from the timeline.
+        It would also remove it from the map that would associate an animation with a given CSS Animation name
+        so that we would know whether an animation exists for a given animation name when one of the animation's
+        properties changed. Since that animation was (mistakenly) removed, we would fail to update its timing
+        and it would never be resumed. We now only update the CSS Animation name to animation map when styles
+        change.
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::animationWasRemovedFromElement):
+
 2019-12-24  Youenn Fablet  <[email protected]>
 
         Deny Notification API access for non secure contexts

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (253900 => 253901)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2019-12-24 18:10:53 UTC (rev 253900)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2019-12-24 18:35:47 UTC (rev 253901)
@@ -149,9 +149,11 @@
     removeAnimationFromMapForElement(animation, m_elementToCSSAnimationsMap, element);
     removeAnimationFromMapForElement(animation, m_elementToAnimationsMap, element);
 
-    // Now, if we're dealing with a declarative animation, we remove it from either the m_elementToCSSAnimationByName
-    // or the m_elementToRunningCSSTransitionByCSSPropertyID map, whichever is relevant to this type of animation.
-    if (is<DeclarativeAnimation>(animation))
+    // Now, if we're dealing with a CSS Transition, we remove it from the m_elementToRunningCSSTransitionByCSSPropertyID map.
+    // We don't need to do this for CSS Animations because their timing can be set via CSS to end, which would cause this
+    // function to be called, but they should remain associated with their owning element until this is changed via a call
+    // to the JS API or changing the target element's animation-name property.
+    if (is<CSSTransition>(animation))
         removeDeclarativeAnimationFromListsForOwningElement(animation, element);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to