Title: [93938] trunk
Revision
93938
Author
[email protected]
Date
2011-08-27 11:09:08 -0700 (Sat, 27 Aug 2011)

Log Message

Patch by Young Han Lee <[email protected]> on 2011-08-27
Reviewed by Dirk Schulze.

SVG animation fill="freeze" doesn't set baseVal to current animVal if animation stops before reaching the end
https://bugs.webkit.org/show_bug.cgi?id=63553

calculateAnimationPercentAndRepeat() is returning 1, which means 100%, whenever
elapsed >= m_intervalEnd, but this is wrong because m_intervalEnd can be in the middle
of the animation duration. (e.g. begin="0s" end="2s" dur="3s")

This change makes the function return the animations's true progress instead of 100%
when the animation ends.

Source/WebCore:

Test: svg/animations/animate-end-attribute.html

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

LayoutTests:

* svg/animations/animate-end-attribute-expected.txt: Added.
* svg/animations/animate-end-attribute.html: Added.
* svg/animations/script-tests/animate-end-attribute.js: Added.
(sample1):
(sample2):
(sample3):
(executeTest):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93937 => 93938)


--- trunk/LayoutTests/ChangeLog	2011-08-27 11:06:22 UTC (rev 93937)
+++ trunk/LayoutTests/ChangeLog	2011-08-27 18:09:08 UTC (rev 93938)
@@ -1,3 +1,25 @@
+2011-08-27  Young Han Lee  <[email protected]>
+
+        Reviewed by Dirk Schulze.
+
+        SVG animation fill="freeze" doesn't set baseVal to current animVal if animation stops before reaching the end
+        https://bugs.webkit.org/show_bug.cgi?id=63553
+
+        calculateAnimationPercentAndRepeat() is returning 1, which means 100%, whenever
+        elapsed >= m_intervalEnd, but this is wrong because m_intervalEnd can be in the middle
+        of the animation duration. (e.g. begin="0s" end="2s" dur="3s")
+
+        This change makes the function return the animations's true progress instead of 100%
+        when the animation ends.
+
+        * svg/animations/animate-end-attribute-expected.txt: Added.
+        * svg/animations/animate-end-attribute.html: Added.
+        * svg/animations/script-tests/animate-end-attribute.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+
 2011-08-27  Jarred Nicholls  <[email protected]>
 
         [Qt] Need spin-button implementation

Added: trunk/LayoutTests/svg/animations/animate-end-attribute-expected.txt (0 => 93938)


--- trunk/LayoutTests/svg/animations/animate-end-attribute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/animate-end-attribute-expected.txt	2011-08-27 18:09:08 UTC (rev 93938)
@@ -0,0 +1,10 @@
+SVG 1.1 dynamic animation tests
+
+PASS rect.x.baseVal.value is 100
+PASS rect.x.baseVal.value is 50
+PASS rect.x.baseVal.value is 200
+PASS rect.x.baseVal.value is 200
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/animations/animate-end-attribute.html (0 => 93938)


--- trunk/LayoutTests/svg/animations/animate-end-attribute.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/animate-end-attribute.html	2011-08-27 18:09:08 UTC (rev 93938)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/svg/animations/script-tests/animate-end-attribute.js (0 => 93938)


--- trunk/LayoutTests/svg/animations/script-tests/animate-end-attribute.js	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/animate-end-attribute.js	2011-08-27 18:09:08 UTC (rev 93938)
@@ -0,0 +1,50 @@
+createSVGTestCase();
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("x", "100");
+rect.setAttribute("width", "100");
+rect.setAttribute("height", "100");
+rect.setAttribute("fill", "green");
+rect.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "x");
+animate.setAttribute("values", "0;300");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "3s");
+animate.setAttribute("end", "click+2s");
+animate.setAttribute("fill", "freeze");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    shouldBe("rect.x.baseVal.value", "50");
+}
+
+function sample3() {
+    shouldBeCloseEnough("rect.x.baseVal.value", "200", 1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 0.5,    "rect", sample2],
+        ["animation", 2.0,    "rect", sample3],
+        ["animation", 3.0,    "rect", sample3]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (93937 => 93938)


--- trunk/Source/WebCore/ChangeLog	2011-08-27 11:06:22 UTC (rev 93937)
+++ trunk/Source/WebCore/ChangeLog	2011-08-27 18:09:08 UTC (rev 93938)
@@ -1,3 +1,22 @@
+2011-08-27  Young Han Lee  <[email protected]>
+
+        Reviewed by Dirk Schulze.
+
+        SVG animation fill="freeze" doesn't set baseVal to current animVal if animation stops before reaching the end
+        https://bugs.webkit.org/show_bug.cgi?id=63553
+
+        calculateAnimationPercentAndRepeat() is returning 1, which means 100%, whenever
+        elapsed >= m_intervalEnd, but this is wrong because m_intervalEnd can be in the middle
+        of the animation duration. (e.g. begin="0s" end="2s" dur="3s")
+
+        This change makes the function return the animations's true progress instead of 100%
+        when the animation ends.
+
+        Test: svg/animations/animate-end-attribute.html
+
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::calculateAnimationPercentAndRepeat):
+
 2011-08-27  Jarred Nicholls  <[email protected]>
 
         [Qt] Need spin-button implementation

Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (93937 => 93938)


--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2011-08-27 11:06:22 UTC (rev 93937)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2011-08-27 18:09:08 UTC (rev 93938)
@@ -856,6 +856,11 @@
         repeat = static_cast<unsigned>(repeatingDuration.value() / simpleDuration.value());
         if (fmod(repeatingDuration.value(), !simpleDuration.value()))
             repeat--;
+
+        SMILTime simpleEndTime = fmod(m_intervalEnd.value() - m_intervalBegin.value(), simpleDuration.value());
+        if (simpleEndTime.value())
+            return narrowPrecisionToFloat(simpleEndTime.value() / simpleDuration.value());
+
         return 1.f;
     }
     repeat = static_cast<unsigned>(activeTime.value() / simpleDuration.value());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to