Title: [234163] trunk
Revision
234163
Author
[email protected]
Date
2018-07-24 12:30:36 -0700 (Tue, 24 Jul 2018)

Log Message

[Web Animations] Crash when setting "animation: none" after clearing an animation's effect
https://bugs.webkit.org/show_bug.cgi?id=187952

Reviewed by Dean Jackson.

Source/WebCore:

Test: webanimations/setting-css-animation-none-after-clearing-effect.html

We need to ensure that the animation we're trying to remove has not had its effect cleared via the
Web Animations API since its creation before trying to check its phase.

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

LayoutTests:

Add a new test that checks that setting "animation: none" on an element that previously had a valid
CSS animation and for which the effect was set to null does not crash.

* webanimations/setting-css-animation-none-after-clearing-effect-expected.txt: Added.
* webanimations/setting-css-animation-none-after-clearing-effect.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234162 => 234163)


--- trunk/LayoutTests/ChangeLog	2018-07-24 19:29:47 UTC (rev 234162)
+++ trunk/LayoutTests/ChangeLog	2018-07-24 19:30:36 UTC (rev 234163)
@@ -1,5 +1,18 @@
 2018-07-24  Antoine Quint  <[email protected]>
 
+        [Web Animations] Crash when setting "animation: none" after clearing an animation's effect
+        https://bugs.webkit.org/show_bug.cgi?id=187952
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that checks that setting "animation: none" on an element that previously had a valid
+        CSS animation and for which the effect was set to null does not crash.
+
+        * webanimations/setting-css-animation-none-after-clearing-effect-expected.txt: Added.
+        * webanimations/setting-css-animation-none-after-clearing-effect.html: Added.
+
+2018-07-24  Antoine Quint  <[email protected]>
+
         [Web Animations] Crash accessing CSSAnimation::bindingsCurrentTime when effect has been set to null
         https://bugs.webkit.org/show_bug.cgi?id=187950
         <rdar://problem/42515747>

Added: trunk/LayoutTests/webanimations/setting-css-animation-none-after-clearing-effect-expected.txt (0 => 234163)


--- trunk/LayoutTests/webanimations/setting-css-animation-none-after-clearing-effect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webanimations/setting-css-animation-none-after-clearing-effect-expected.txt	2018-07-24 19:30:36 UTC (rev 234163)
@@ -0,0 +1,3 @@
+
+PASS Setting a CSS Animation to 'none' after setting its effect to null does not crash. 
+

Added: trunk/LayoutTests/webanimations/setting-css-animation-none-after-clearing-effect.html (0 => 234163)


--- trunk/LayoutTests/webanimations/setting-css-animation-none-after-clearing-effect.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/setting-css-animation-none-after-clearing-effect.html	2018-07-24 19:30:36 UTC (rev 234163)
@@ -0,0 +1,34 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableWebAnimationsCSSIntegration=true ] -->
+<meta charset=utf-8>
+<title>Crash setting a CSS Animation to "none" after setting its effect to null</title>
+<style>
+    @keyframes animation {
+        from {
+            margin-left: 0px;
+        }
+        to {
+            margin-left: 100px;
+        }
+    }
+</style>
+<body>
+<script src=""
+<script src=""
+<script>
+
+'use strict';
+
+test(t => {
+    const target = document.body.appendChild(document.createElement("div"));
+    target.style.animation = "animation 1s";
+
+    const animations = target.getAnimations();
+    assert_equals(animations.length, 1, "The target element has one animation.");
+
+    animations[0].effect = null;
+
+    target.style.animation = "none";
+}, "Setting a CSS Animation to 'none' after setting its effect to null does not crash.");
+
+</script>
+</body>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (234162 => 234163)


--- trunk/Source/WebCore/ChangeLog	2018-07-24 19:29:47 UTC (rev 234162)
+++ trunk/Source/WebCore/ChangeLog	2018-07-24 19:30:36 UTC (rev 234163)
@@ -1,5 +1,20 @@
 2018-07-24  Antoine Quint  <[email protected]>
 
+        [Web Animations] Crash when setting "animation: none" after clearing an animation's effect
+        https://bugs.webkit.org/show_bug.cgi?id=187952
+
+        Reviewed by Dean Jackson.
+
+        Test: webanimations/setting-css-animation-none-after-clearing-effect.html
+
+        We need to ensure that the animation we're trying to remove has not had its effect cleared via the
+        Web Animations API since its creation before trying to check its phase.
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation):
+
+2018-07-24  Antoine Quint  <[email protected]>
+
         [Web Animations] Crash accessing CSSAnimation::bindingsCurrentTime when effect has been set to null
         https://bugs.webkit.org/show_bug.cgi?id=187950
         <rdar://problem/42515747>

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (234162 => 234163)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2018-07-24 19:29:47 UTC (rev 234162)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2018-07-24 19:30:36 UTC (rev 234163)
@@ -474,11 +474,15 @@
 
 void AnimationTimeline::cancelOrRemoveDeclarativeAnimation(RefPtr<DeclarativeAnimation> animation)
 {
-    auto phase = animation->effect()->phase();
-    if (phase != AnimationEffectReadOnly::Phase::Idle && phase != AnimationEffectReadOnly::Phase::After)
-        animation->cancel();
-    else
-        removeAnimation(animation.releaseNonNull());
+    if (auto* effect = animation->effect()) {
+        auto phase = effect->phase();
+        if (phase != AnimationEffectReadOnly::Phase::Idle && phase != AnimationEffectReadOnly::Phase::After) {
+            animation->cancel();
+            return;
+        }
+    }
+
+    removeAnimation(animation.releaseNonNull());
 }
 
 String AnimationTimeline::description()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to