REGRESSION (r187121): Delayed instantaneous animations not honouring ' forwards'...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Oct 2015 01:33:02 +0000 (01:33 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Oct 2015 01:33:02 +0000 (01:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150326

Reviewed by Darin Adler.

Source/WebCore:

With a zero-duration, delayed fill-forwards animation, we'd end up trying
to interpolate between the last and first keyframes, and picking the first
because AnimationBase::progress() had a special case for zero duration. Removing
this check fixes the bug.

Test: animations/fill-mode-forwards-zero-duration.html

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::progress):

LayoutTests:

Test with a zero-duration, delayed fill-forwards animation.

* animations/fill-mode-forwards-zero-duration-expected.txt: Added.
* animations/fill-mode-forwards-zero-duration.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/animations/fill-mode-forwards-zero-duration-expected.txt [new file with mode: 0644]
LayoutTests/animations/fill-mode-forwards-zero-duration.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/animation/AnimationBase.cpp

index a3611f7..f24d216 100644 (file)
@@ -1,3 +1,15 @@
+2015-10-24  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (r187121): Delayed instantaneous animations not honouring ' forwards' fill-mode
+        https://bugs.webkit.org/show_bug.cgi?id=150326
+
+        Reviewed by Darin Adler.
+        
+        Test with a zero-duration, delayed fill-forwards animation.
+
+        * animations/fill-mode-forwards-zero-duration-expected.txt: Added.
+        * animations/fill-mode-forwards-zero-duration.html: Added.
+
 2015-10-23  Chris Dumez  <cdumez@apple.com>
 
         RadioNodeList should be exposed on Window
diff --git a/LayoutTests/animations/fill-mode-forwards-zero-duration-expected.txt b/LayoutTests/animations/fill-mode-forwards-zero-duration-expected.txt
new file mode 100644 (file)
index 0000000..df411d0
--- /dev/null
@@ -0,0 +1,4 @@
+Fill-forwards state should be the last keyframe state, even with a zero-duration animation.
+
+PASS - "left" property for "box1" element at 1s saw something close to: 100
+
diff --git a/LayoutTests/animations/fill-mode-forwards-zero-duration.html b/LayoutTests/animations/fill-mode-forwards-zero-duration.html
new file mode 100644 (file)
index 0000000..831d5f9
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    #box1 {
+      position: relative;
+      left: 10px;
+      top: 10px;
+      height: 100px;
+      width: 100px;
+      background-color: blue;
+      animation-fill-mode: forwards;
+      animation: anim1 0 2s linear;
+    }
+    @keyframes anim1 {
+        from { left: 400px; }
+        25%  { left: 0px; }
+        51%  { left: 250px; }
+        to   { left: 100px; }
+    }
+  </style>
+  <script src="resources/animation-test-helpers.js"></script>
+  <script>
+
+    const expectedValues = [
+      // [animation-name, time, element-id, property, expected-value, tolerance]
+      ["anim1", 1, "box1", "left", 100, 2],
+    ];
+
+    runAnimationTest(expectedValues);
+  </script>
+</head>
+<body>
+<p>Fill-forwards state should be the last keyframe state, even with a zero-duration animation.</p>
+<div id="box1"></div>
+<div id="result"></div>
+</body>
+</html>
index bfd861e..bc88118 100644 (file)
@@ -1,3 +1,20 @@
+2015-10-24  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (r187121): Delayed instantaneous animations not honouring ' forwards' fill-mode
+        https://bugs.webkit.org/show_bug.cgi?id=150326
+
+        Reviewed by Darin Adler.
+        
+        With a zero-duration, delayed fill-forwards animation, we'd end up trying
+        to interpolate between the last and first keyframes, and picking the first
+        because AnimationBase::progress() had a special case for zero duration. Removing
+        this check fixes the bug.
+
+        Test: animations/fill-mode-forwards-zero-duration.html
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::progress):
+
 2015-10-23  Chris Dumez  <cdumez@apple.com>
 
         RadioNodeList should be exposed on Window
index 5ddea0e..6756e32 100644 (file)
@@ -459,7 +459,7 @@ void AnimationBase::updateStateMachine(AnimationStateInput input, double param)
             break;
     }
 }
-    
+
 void AnimationBase::fireAnimationEventsIfNeeded()
 {
     if (!m_compositeAnimation)
@@ -621,8 +621,8 @@ double AnimationBase::progress(double scale, double offset, const TimingFunction
     if (preActive())
         return 0;
 
-    if (postActive() || !m_animation->duration())
-        return 1.0;
+    if (postActive())
+        return 1;
 
     double elapsedTime = getElapsedTime();