Fix rewinding of SVG animations
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jun 2012 10:31:06 +0000 (10:31 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jun 2012 10:31:06 +0000 (10:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89846

Reviewed by Nikolas Zimmermann.

Source/WebCore:

r116451 introduced an optimization to only clear non-freeze animations when
calling setCurrentTime (via reset()). This causes fill=freeze animations to
not clear which breaks rewinding of an animation.

In the presence of multiple animations, we reset the first animation to the
base value and accumulate all results into that; this masked the problem because
2 animations were required to hit the bug (our tests primarily cover just 1).

Test: svg/animations/animate-reset-freeze.html

* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::reset):

LayoutTests:

* svg/animations/animate-reset-freeze-expected.txt: Added.
* svg/animations/animate-reset-freeze.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/animations/animate-reset-freeze-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/animate-reset-freeze.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/animation/SVGSMILElement.cpp

index eca8c97..39bc750 100644 (file)
@@ -1,3 +1,13 @@
+2012-06-25  Philip Rogers  <pdr@google.com>
+
+        Fix rewinding of SVG animations
+        https://bugs.webkit.org/show_bug.cgi?id=89846
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/animations/animate-reset-freeze-expected.txt: Added.
+        * svg/animations/animate-reset-freeze.html: Added.
+
 2012-06-25  Kent Tamura  <tkent@chromium.org>
 
         Change the serialization format of form control state to make the code simple
diff --git a/LayoutTests/svg/animations/animate-reset-freeze-expected.txt b/LayoutTests/svg/animations/animate-reset-freeze-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/svg/animations/animate-reset-freeze.html b/LayoutTests/svg/animations/animate-reset-freeze.html
new file mode 100644 (file)
index 0000000..89ad28f
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+    <head>
+        <!--
+        Test for WK89846: Animations should be rewindable even with existing fill=freeze animations.
+        If this test passes, only the word "PASS" will be visible.
+        -->
+        <script src="../../fast/js/resources/js-test-pre.js"></script>
+    </head>
+    <body>
+        <svg id="svg" width="500" height="500">
+            <rect x="0" y="0" width="100" height="100" fill="red"/>
+            <rect id="rect" x="0" y="0" width="100" height="100" fill="blue">
+                <set attributeName="x" to="100" begin="4s" fill="freeze"></set>
+                <set attributeName="x" to="200" begin="1s" dur="1s" fill="freeze">
+            </rect>
+        </svg>
+        <script>
+            if (window.testRunner) {
+                testRunner.waitUntilDone();
+                testRunner.dumpAsText();
+            }
+
+            var svg = document.getElementById('svg');
+            var rect = document.getElementById('rect');
+            svg.pauseAnimations();
+            svg.setCurrentTime(100);
+
+            setTimeout(function() {
+                svg.setCurrentTime(0);
+                if (rect.x.animVal.value != 0)
+                    document.body.innerHTML = "FAIL: rect.x.animVal.value was " + rect.x.animVal.value + ", expected 0";
+                else
+                    document.body.innerHTML = "PASS";
+
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, 1);
+        </script>
+    </body>
+</html>
index 4a4f84d..94ec3ea 100644 (file)
@@ -1,3 +1,23 @@
+2012-06-25  Philip Rogers  <pdr@google.com>
+
+        Fix rewinding of SVG animations
+        https://bugs.webkit.org/show_bug.cgi?id=89846
+
+        Reviewed by Nikolas Zimmermann.
+
+        r116451 introduced an optimization to only clear non-freeze animations when
+        calling setCurrentTime (via reset()). This causes fill=freeze animations to
+        not clear which breaks rewinding of an animation.
+
+        In the presence of multiple animations, we reset the first animation to the
+        base value and accumulate all results into that; this masked the problem because
+        2 animations were required to hit the bug (our tests primarily cover just 1).
+
+        Test: svg/animations/animate-reset-freeze.html
+
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::reset):
+
 2012-06-25  Kent Tamura  <tkent@chromium.org>
 
         Change the serialization format of form control state to make the code simple
index 2781d2f..4ff02e3 100644 (file)
@@ -178,9 +178,7 @@ static inline void clearTimesWithDynamicOrigins(Vector<SMILTimeWithOrigin>& time
 
 void SVGSMILElement::reset()
 {
-    // Don't clear the animated type if we're frozen, only take action here if we're active.
-    if (m_activeState == Active)
-        clearAnimatedType(m_targetElement);
+    clearAnimatedType(m_targetElement);
 
     m_activeState = Inactive;
     m_isWaitingForFirstInterval = true;