Fix bug where animations failed to start
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2012 12:56:13 +0000 (12:56 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2012 12:56:13 +0000 (12:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89943

Reviewed by Nikolas Zimmermann.

Source/WebCore:

The unpause code previously checked that the animations had not started
before un-setting the pause state. This meant that if an animation was
paused and unpaused before the animations started, it would remain in the
paused state. This patch simply reorders the unpause logic to fix this bug.

Test: svg/custom/animate-initial-pause-unpause.html

* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::resume):

LayoutTests:

* svg/custom/animate-initial-pause-unpause-expected.txt: Added.
* svg/custom/animate-initial-pause-unpause.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/animate-initial-pause-unpause-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/animate-initial-pause-unpause.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/animation/SMILTimeContainer.cpp

index f368a06..a31d9ce 100644 (file)
@@ -1,3 +1,13 @@
+2012-06-26  Philip Rogers  <pdr@google.com>
+
+        Fix bug where animations failed to start
+        https://bugs.webkit.org/show_bug.cgi?id=89943
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/custom/animate-initial-pause-unpause-expected.txt: Added.
+        * svg/custom/animate-initial-pause-unpause.html: Added.
+
 2012-06-26  Thiago Marcos P. Santos  <thiago.santos@intel.com>
 
         [EFL] Gardening of new passing tests
diff --git a/LayoutTests/svg/custom/animate-initial-pause-unpause-expected.txt b/LayoutTests/svg/custom/animate-initial-pause-unpause-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/svg/custom/animate-initial-pause-unpause.html b/LayoutTests/svg/custom/animate-initial-pause-unpause.html
new file mode 100644 (file)
index 0000000..f975c3e
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+    Test for WK89943: pausing and unpausing an animation before it starts should have no effect.
+-->
+<body>
+    <svg id="svg" width="400" height="400">
+        <rect x="0" y="0" width="100" height="100" fill="red"/>
+        <rect id="rect" x="100" y="0" width="100" height="100" fill="green">
+            <set attributeName="x" to="0" begin="0.01s" 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.unpauseAnimations();
+
+        setTimeout(function() {
+            if (rect.x.animVal.value == 0)
+                document.body.innerHTML = "PASS";
+            else
+                document.body.innerHTML = "FAIL : rect.x.animVal.value was " + rect.x.animVal.value + " but we expected 0.";
+
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, 50);
+    </script>
+</body>
+</html>
index 6021f43..c3df106 100755 (executable)
@@ -1,3 +1,20 @@
+2012-06-26  Philip Rogers  <pdr@google.com>
+
+        Fix bug where animations failed to start
+        https://bugs.webkit.org/show_bug.cgi?id=89943
+
+        Reviewed by Nikolas Zimmermann.
+
+        The unpause code previously checked that the animations had not started
+        before un-setting the pause state. This meant that if an animation was
+        paused and unpaused before the animations started, it would remain in the
+        paused state. This patch simply reorders the unpause logic to fix this bug.
+
+        Test: svg/custom/animate-initial-pause-unpause.html
+
+        * svg/animation/SMILTimeContainer.cpp:
+        (WebCore::SMILTimeContainer::resume):
+
 2012-06-26  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: popover is not shown for detached DOM nodes, not referenced directly from JS
index 6b15787..b032f31 100644 (file)
@@ -112,10 +112,11 @@ void SMILTimeContainer::pause()
 
 void SMILTimeContainer::resume()
 {
-    if (!m_beginTime)
-        return;
     ASSERT(isPaused());
-    m_accumulatedPauseTime += currentTime() - m_pauseTime;
+
+    if (m_beginTime)
+        m_accumulatedPauseTime += currentTime() - m_pauseTime;
+
     m_pauseTime = 0;
     startTimer(0);
 }