Title: [158405] trunk
Revision
158405
Author
[email protected]
Date
2013-10-31 16:23:11 -0700 (Thu, 31 Oct 2013)

Log Message

Correct the elapsedTime calculation in SVG animations
https://bugs.webkit.org/show_bug.cgi?id=119289

Patch by Youenn Fablet <[email protected]> on 2013-10-31
Reviewed by Brent Fulgham.

Merged from Blink: https://chromium.googlesource.com/chromium/blink/+/338f9badca7fb7880abdb0cecd5f02493c1f7d2e

Source/WebCore:

Test: svg/animations/getCurrentTime-pause-unpause.html

* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::SMILTimeContainer):
(WebCore::SMILTimeContainer::elapsed):
(WebCore::SMILTimeContainer::begin):
(WebCore::SMILTimeContainer::pause):
(WebCore::SMILTimeContainer::resume):
(WebCore::SMILTimeContainer::setElapsed):
* svg/animation/SMILTimeContainer.h:

LayoutTests:

* svg/animations/getCurrentTime-pause-unpause-expected.txt: Added.
* svg/animations/getCurrentTime-pause-unpause.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (158404 => 158405)


--- trunk/LayoutTests/ChangeLog	2013-10-31 23:12:10 UTC (rev 158404)
+++ trunk/LayoutTests/ChangeLog	2013-10-31 23:23:11 UTC (rev 158405)
@@ -1,3 +1,15 @@
+2013-10-31  Youenn Fablet  <[email protected]>
+
+        Correct the elapsedTime calculation in SVG animations
+        https://bugs.webkit.org/show_bug.cgi?id=119289
+
+        Reviewed by Brent Fulgham.
+
+        Merged from Blink: https://chromium.googlesource.com/chromium/blink/+/338f9badca7fb7880abdb0cecd5f02493c1f7d2e
+
+        * svg/animations/getCurrentTime-pause-unpause-expected.txt: Added.
+        * svg/animations/getCurrentTime-pause-unpause.html: Added.
+
 2013-10-30  Oliver Hunt  <[email protected]>
 
         Implement ES6 Math functions

Added: trunk/LayoutTests/svg/animations/getCurrentTime-pause-unpause-expected.txt (0 => 158405)


--- trunk/LayoutTests/svg/animations/getCurrentTime-pause-unpause-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/getCurrentTime-pause-unpause-expected.txt	2013-10-31 23:23:11 UTC (rev 158405)
@@ -0,0 +1,4 @@
+PASS svg.getCurrentTime() is 0
+PASS svg.getCurrentTime() is 0.05
+PASS svg.getCurrentTime() is 0.05
+

Added: trunk/LayoutTests/svg/animations/getCurrentTime-pause-unpause.html (0 => 158405)


--- trunk/LayoutTests/svg/animations/getCurrentTime-pause-unpause.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/getCurrentTime-pause-unpause.html	2013-10-31 23:23:11 UTC (rev 158405)
@@ -0,0 +1,51 @@
+    <!DOCTYPE html>
+    <!--This tests svg.getCurrentTime() when SVG animation is paused and unpaused.
+    Sequence of steps are,
+    1. Pause the SVG animation at the beginning.
+    2. 10 msec delay
+    3. Test 1,  measure the currentTime which should still be 0.
+    4. Unpause the SVG animation
+    5. 50 msec delay
+    6. Test 2,  measure the currentTime which should be .05 sec.
+    7. Pause the SVG animation
+    8. 50 msec delay
+    9. Test 3, measure the currentTime which should still be .05 sec.
+    -->
+    <html>
+    <script src=""
+    <script src=""
+    <script>
+      function load() {
+        if (window.testRunner) {
+          testRunner.dumpAsText();
+          testRunner.waitUntilDone();
+        }
+       
+        svg = document.getElementById("svg");
+        rect = document.getElementById("rect");
+       
+        svg.pauseAnimations();
+        setTimeout(function() {
+          shouldBeCloseEnough("svg.getCurrentTime()", "0", 0.01);
+          svg.unpauseAnimations();
+          setTimeout(function() {
+            shouldBeCloseEnough("svg.getCurrentTime()", "0.05", 0.02);
+            svg.pauseAnimations();
+            setTimeout(function() {
+              shouldBeCloseEnough("svg.getCurrentTime()", "0.05", 0.02);
+              if (window.testRunner)
+                testRunner.notifyDone();
+            }, 50);
+          }, 50);
+        }, 10);
+      }
+    </script>
+    <head><title>svg.getCurrentTime() when SVG animation is paused and unpaused</title></head>
+    <body _onload_="load()">
+      <svg id="svg" xmlns="http://www.w3.org/2000/svg">
+        <rect id="rect" fill="green" width="20" height="20">
+          <animate attributeName="x" from="0" to="200" begin="0s" dur="3s"></animate>
+        </rect>
+      </svg>
+    </body>
+    </html>

Modified: trunk/Source/WebCore/ChangeLog (158404 => 158405)


--- trunk/Source/WebCore/ChangeLog	2013-10-31 23:12:10 UTC (rev 158404)
+++ trunk/Source/WebCore/ChangeLog	2013-10-31 23:23:11 UTC (rev 158405)
@@ -1,3 +1,23 @@
+2013-10-31  Youenn Fablet  <[email protected]>
+
+        Correct the elapsedTime calculation in SVG animations
+        https://bugs.webkit.org/show_bug.cgi?id=119289
+
+        Reviewed by Brent Fulgham.
+
+        Merged from Blink: https://chromium.googlesource.com/chromium/blink/+/338f9badca7fb7880abdb0cecd5f02493c1f7d2e
+
+        Test: svg/animations/getCurrentTime-pause-unpause.html
+
+        * svg/animation/SMILTimeContainer.cpp:
+        (WebCore::SMILTimeContainer::SMILTimeContainer):
+        (WebCore::SMILTimeContainer::elapsed):
+        (WebCore::SMILTimeContainer::begin):
+        (WebCore::SMILTimeContainer::pause):
+        (WebCore::SMILTimeContainer::resume):
+        (WebCore::SMILTimeContainer::setElapsed):
+        * svg/animation/SMILTimeContainer.h:
+
 2013-10-31  Andreas Kling  <[email protected]>
 
         Manage line-grid RootInlineBox with unique_ptr.

Modified: trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp (158404 => 158405)


--- trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp	2013-10-31 23:12:10 UTC (rev 158404)
+++ trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp	2013-10-31 23:23:11 UTC (rev 158405)
@@ -43,7 +43,8 @@
 SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner) 
     : m_beginTime(0)
     , m_pauseTime(0)
-    , m_accumulatedPauseTime(0)
+    , m_accumulatedActiveTime(0)
+    , m_resumeTime(0)
     , m_presetStartTime(0)
     , m_documentOrderIndexesDirty(false)
     , m_timer(this, &SMILTimeContainer::timerFired)
@@ -110,7 +111,9 @@
 {
     if (!m_beginTime)
         return 0;
-    return monotonicallyIncreasingTime() - m_beginTime - m_accumulatedPauseTime;
+    if (isPaused())
+        return m_accumulatedActiveTime;
+    return monotonicallyIncreasingTime() + m_accumulatedActiveTime - m_resumeTime;
 }
 
 bool SMILTimeContainer::isActive() const
@@ -135,7 +138,7 @@
 
     // If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began.
     // In this case pass on 'seekToTime=true' to updateAnimations().
-    m_beginTime = now - m_presetStartTime;
+    m_beginTime = m_resumeTime = now - m_presetStartTime;
     updateAnimations(SMILTime(m_presetStartTime), m_presetStartTime ? true : false);
     m_presetStartTime = 0;
 
@@ -148,19 +151,19 @@
 void SMILTimeContainer::pause()
 {
     ASSERT(!isPaused());
+
     m_pauseTime = monotonicallyIncreasingTime();
-
-    if (m_beginTime)
+    if (m_beginTime) {
+        m_accumulatedActiveTime += m_pauseTime - m_resumeTime;
         m_timer.stop();
+    }
 }
 
 void SMILTimeContainer::resume()
 {
     ASSERT(isPaused());
 
-    if (m_beginTime)
-        m_accumulatedPauseTime += monotonicallyIncreasingTime() - m_pauseTime;
-
+    m_resumeTime = monotonicallyIncreasingTime();
     m_pauseTime = 0;
     startTimer(0);
 }
@@ -179,9 +182,11 @@
     double now = monotonicallyIncreasingTime();
     m_beginTime = now - time.value();
 
-    m_accumulatedPauseTime = 0;
-    if (m_pauseTime)
-        m_pauseTime = now;
+    if (m_pauseTime) {
+        m_resumeTime = m_pauseTime = now;
+        m_accumulatedActiveTime = time.value();
+    } else
+        m_resumeTime = m_beginTime;
 
 #ifndef NDEBUG
     m_preventScheduledAnimationsChanges = true;

Modified: trunk/Source/WebCore/svg/animation/SMILTimeContainer.h (158404 => 158405)


--- trunk/Source/WebCore/svg/animation/SMILTimeContainer.h	2013-10-31 23:12:10 UTC (rev 158404)
+++ trunk/Source/WebCore/svg/animation/SMILTimeContainer.h	2013-10-31 23:23:11 UTC (rev 158405)
@@ -78,7 +78,8 @@
 
     double m_beginTime;
     double m_pauseTime;
-    double m_accumulatedPauseTime;
+    double m_accumulatedActiveTime;
+    double m_resumeTime;
     double m_presetStartTime;
 
     bool m_documentOrderIndexesDirty;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to