[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

krit at webkit.org krit at webkit.org
Wed Dec 22 15:44:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9d4e93469d766f69c67e4a1702bc8edc0143597d
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 11 17:26:26 2010 +0000

    2010-11-11  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVGAnimation calcMode 'spline' should be useable for from-to and from-by animations
            https://bugs.webkit.org/show_bug.cgi?id=49284
    
            Add support for from-to and from-by animations in combination with calcMode 'spline' for SVGAnimations.
    
            Tests: svg/animations/animate-calcMode-spline-by.html
                   svg/animations/animate-calcMode-spline-from-by.html
                   svg/animations/animate-calcMode-spline-from-to.html
                   svg/animations/animate-calcMode-spline-to.html
                   svg/animations/animate-calcMode-spline-values.html
    
            * svg/SVGAnimationElement.cpp:
            (WebCore::SVGAnimationElement::calculateKeyTimesIndex): Added to share more code.
            (WebCore::SVGAnimationElement::calculatePercentFromKeyPoints):
            (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
            (WebCore::SVGAnimationElement::startedActiveInterval):
            (WebCore::SVGAnimationElement::updateAnimation):
            * svg/SVGAnimationElement.h:
    2010-11-11  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVGAnimation calcMode="spline" should use 'to' 'by' animation if no values were specified
            https://bugs.webkit.org/show_bug.cgi?id=49284
    
            Added new SVG animation tests to test calcMode 'spline'.
    
            * svg/animations/animate-calcMode-spline-by-expected.txt: Added.
            * svg/animations/animate-calcMode-spline-by.html: Added.
            * svg/animations/animate-calcMode-spline-from-by-expected.txt: Added.
            * svg/animations/animate-calcMode-spline-from-by.html: Added.
            * svg/animations/animate-calcMode-spline-from-to-expected.txt: Added.
            * svg/animations/animate-calcMode-spline-from-to.html: Added.
            * svg/animations/animate-calcMode-spline-to-expected.txt: Added.
            * svg/animations/animate-calcMode-spline-to.html: Added.
            * svg/animations/animate-calcMode-spline-values-expected.txt: Added.
            * svg/animations/animate-calcMode-spline-values.html: Added.
            * svg/animations/script-tests/animate-calcMode-spline-by.js: Added.
            (sample1):
            (sample2):
            (sample3):
            (executeTest):
            * svg/animations/script-tests/animate-calcMode-spline-from-by.js: Added.
            (sample1):
            (sample2):
            (sample3):
            (executeTest):
            * svg/animations/script-tests/animate-calcMode-spline-from-to.js: Added.
            (sample1):
            (sample2):
            (sample3):
            (executeTest):
            * svg/animations/script-tests/animate-calcMode-spline-to.js: Added.
            (sample1):
            (sample2):
            (sample3):
            (executeTest):
            * svg/animations/script-tests/animate-calcMode-spline-values.js: Added.
            (sample1):
            (sample2):
            (sample3):
            (executeTest):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71828 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6cbfc62..38b595a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,48 @@
+2010-11-11  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVGAnimation calcMode="spline" should use 'to' 'by' animation if no values were specified
+        https://bugs.webkit.org/show_bug.cgi?id=49284
+
+        Added new SVG animation tests to test calcMode 'spline'.
+
+        * svg/animations/animate-calcMode-spline-by-expected.txt: Added.
+        * svg/animations/animate-calcMode-spline-by.html: Added.
+        * svg/animations/animate-calcMode-spline-from-by-expected.txt: Added.
+        * svg/animations/animate-calcMode-spline-from-by.html: Added.
+        * svg/animations/animate-calcMode-spline-from-to-expected.txt: Added.
+        * svg/animations/animate-calcMode-spline-from-to.html: Added.
+        * svg/animations/animate-calcMode-spline-to-expected.txt: Added.
+        * svg/animations/animate-calcMode-spline-to.html: Added.
+        * svg/animations/animate-calcMode-spline-values-expected.txt: Added.
+        * svg/animations/animate-calcMode-spline-values.html: Added.
+        * svg/animations/script-tests/animate-calcMode-spline-by.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/animate-calcMode-spline-from-by.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/animate-calcMode-spline-from-to.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/animate-calcMode-spline-to.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/animate-calcMode-spline-values.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+
 2010-11-11  Chang Shu  <chang.shu at nokia.com>
 
         Reviewed by Csaba Osztrogonác  <ossy at webkit.org>.
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-by-expected.txt b/LayoutTests/svg/animations/animate-calcMode-spline-by-expected.txt
new file mode 100644
index 0000000..2628d72
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-by-expected.txt
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode spline with by animation. You should see a green 100x100 rect and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.animVal.value is almost 18.8, after first half
+PASS rect.x.baseVal.value is almost 18.8, after first half
+PASS rect.x.animVal.value is almost 0, just before-end
+PASS rect.x.baseVal.value is almost 0, just before-end
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-by.html b/LayoutTests/svg/animations/animate-calcMode-spline-by.html
new file mode 100644
index 0000000..8596fda
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-by.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-calcMode-spline-by.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-from-by-expected.txt b/LayoutTests/svg/animations/animate-calcMode-spline-from-by-expected.txt
new file mode 100644
index 0000000..c0bbc24
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-from-by-expected.txt
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode spline with from-by animation. You should see a green 100x100 rect and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.animVal.value is almost 18.8, after first half
+PASS rect.x.baseVal.value is almost 18.8, after first half
+PASS rect.x.animVal.value is almost 0, just before-end
+PASS rect.x.baseVal.value is almost 0, just before-end
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-from-by.html b/LayoutTests/svg/animations/animate-calcMode-spline-from-by.html
new file mode 100644
index 0000000..f07eb87
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-from-by.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-calcMode-spline-from-by.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-from-to-expected.txt b/LayoutTests/svg/animations/animate-calcMode-spline-from-to-expected.txt
new file mode 100644
index 0000000..a6192ca
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-from-to-expected.txt
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode spline with from-to animation. You should see a green 100x100 rect and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.animVal.value is almost 18.8, after first half
+PASS rect.x.baseVal.value is almost 18.8, after first half
+PASS rect.x.animVal.value is almost 0, just before-end
+PASS rect.x.baseVal.value is almost 0, just before-end
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-from-to.html b/LayoutTests/svg/animations/animate-calcMode-spline-from-to.html
new file mode 100644
index 0000000..4111246
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-from-to.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-calcMode-spline-from-to.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-to-expected.txt b/LayoutTests/svg/animations/animate-calcMode-spline-to-expected.txt
new file mode 100644
index 0000000..71e3902
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-to-expected.txt
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode spline with to animation. You should see a green 100x100 rect and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.animVal.value is almost 18.8, after first half
+PASS rect.x.baseVal.value is almost 18.8, after first half
+PASS rect.x.animVal.value is almost 0, just before-end
+PASS rect.x.baseVal.value is almost 0, just before-end
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-to.html b/LayoutTests/svg/animations/animate-calcMode-spline-to.html
new file mode 100644
index 0000000..35f7e50
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-to.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-calcMode-spline-to.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-values-expected.txt b/LayoutTests/svg/animations/animate-calcMode-spline-values-expected.txt
new file mode 100644
index 0000000..f6eaa9a
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-values-expected.txt
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode spline with values animation. You should see a green 100x100 rect and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.animVal.value is almost 18.8, after first half
+PASS rect.x.baseVal.value is almost 18.8, after first half
+PASS rect.x.animVal.value is almost 0, just before-end
+PASS rect.x.baseVal.value is almost 0, just before-end
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-calcMode-spline-values.html b/LayoutTests/svg/animations/animate-calcMode-spline-values.html
new file mode 100644
index 0000000..05a81ab
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-calcMode-spline-values.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
+<script src="resources/SVGAnimationTestCase.js"></script>
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/animate-calcMode-spline-values.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-by.js b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-by.js
new file mode 100644
index 0000000..298b9d8
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-by.js
@@ -0,0 +1,79 @@
+description("Test calcMode spline with by animation. You should see a green 100x100 rect and only PASS messages");
+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("by", "-100");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("keyTimes", "0;1");
+animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
+animate.setAttribute("calcMode", "spline");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.x.animVal.value", "100");
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    var ok = isCloseEnough(rect.x.animVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 51, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 18.8, as expected");
+}
+
+function sample3() {
+    // FIXME: Add animVal support. Animates baseVal at the moment.
+    // shouldBe("rect.x.animVal.value", "0");
+    // shouldBe("rect.x.baseVal.value", "200");
+
+    // Check just before-end conditions
+    var ok = isCloseEnough(rect.x.animVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 0, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 0, as expected");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 2.0,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample3],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-from-by.js b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-from-by.js
new file mode 100644
index 0000000..b2fd9d1
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-from-by.js
@@ -0,0 +1,80 @@
+description("Test calcMode spline with from-by animation. You should see a green 100x100 rect and only PASS messages");
+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("from", "100");
+animate.setAttribute("by", "-100");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("keyTimes", "0;1");
+animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
+animate.setAttribute("calcMode", "spline");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.x.animVal.value", "100");
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    var ok = isCloseEnough(rect.x.animVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 51, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 18.8, as expected");
+}
+
+function sample3() {
+    // FIXME: Add animVal support. Animates baseVal at the moment.
+    // shouldBe("rect.x.animVal.value", "0");
+    // shouldBe("rect.x.baseVal.value", "200");
+
+    // Check just before-end conditions
+    var ok = isCloseEnough(rect.x.animVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 0, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 0, as expected");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 2.0,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample3],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-from-to.js b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-from-to.js
new file mode 100644
index 0000000..b10f9ad
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-from-to.js
@@ -0,0 +1,80 @@
+description("Test calcMode spline with from-to animation. You should see a green 100x100 rect and only PASS messages");
+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("from", "100");
+animate.setAttribute("to", "0");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("keyTimes", "0;1");
+animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
+animate.setAttribute("calcMode", "spline");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.x.animVal.value", "100");
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    var ok = isCloseEnough(rect.x.animVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 51, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 18.8, as expected");
+}
+
+function sample3() {
+    // FIXME: Add animVal support. Animates baseVal at the moment.
+    // shouldBe("rect.x.animVal.value", "0");
+    // shouldBe("rect.x.baseVal.value", "200");
+
+    // Check just before-end conditions
+    var ok = isCloseEnough(rect.x.animVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 0, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 0, as expected");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 2.0,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample3],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-to.js b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-to.js
new file mode 100644
index 0000000..d224958
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-to.js
@@ -0,0 +1,79 @@
+description("Test calcMode spline with to animation. You should see a green 100x100 rect and only PASS messages");
+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("to", "0");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("keyTimes", "0;1");
+animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
+animate.setAttribute("calcMode", "spline");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.x.animVal.value", "100");
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    var ok = isCloseEnough(rect.x.animVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 51, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 18.8, as expected");
+}
+
+function sample3() {
+    // FIXME: Add animVal support. Animates baseVal at the moment.
+    // shouldBe("rect.x.animVal.value", "0");
+    // shouldBe("rect.x.baseVal.value", "200");
+
+    // Check just before-end conditions
+    var ok = isCloseEnough(rect.x.animVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 0, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 0, as expected");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 2,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample3],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-values.js b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-values.js
new file mode 100644
index 0000000..daf15f8
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-calcMode-spline-values.js
@@ -0,0 +1,79 @@
+description("Test calcMode spline with values animation. You should see a green 100x100 rect and only PASS messages");
+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", "100;0");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("keyTimes", "0;1");
+animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
+animate.setAttribute("calcMode", "spline");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.x.animVal.value", "100");
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    var ok = isCloseEnough(rect.x.animVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 51, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 18.8, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 18.8, after first half");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 18.8, as expected");
+}
+
+function sample3() {
+    // FIXME: Add animVal support. Animates baseVal at the moment.
+    // shouldBe("rect.x.animVal.value", "0");
+    // shouldBe("rect.x.baseVal.value", "200");
+
+    // Check just before-end conditions
+    var ok = isCloseEnough(rect.x.animVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.animVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.animVal.value is NOT almost 0, as expected");
+
+    ok = isCloseEnough(rect.x.baseVal.value, 0, 0.01);
+    if (ok)
+        testPassed("rect.x.baseVal.value is almost 0, just before-end");
+    else
+        testFailed("rect.x.baseVal.value is NOT almost 0, as expected");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 2.0,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample3],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3e890ce..167dcd5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-11-11  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVGAnimation calcMode 'spline' should be useable for from-to and from-by animations
+        https://bugs.webkit.org/show_bug.cgi?id=49284
+
+        Add support for from-to and from-by animations in combination with calcMode 'spline' for SVGAnimations.
+
+        Tests: svg/animations/animate-calcMode-spline-by.html
+               svg/animations/animate-calcMode-spline-from-by.html
+               svg/animations/animate-calcMode-spline-from-to.html
+               svg/animations/animate-calcMode-spline-to.html
+               svg/animations/animate-calcMode-spline-values.html
+
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::SVGAnimationElement::calculateKeyTimesIndex): Added to share more code.
+        (WebCore::SVGAnimationElement::calculatePercentFromKeyPoints):
+        (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
+        (WebCore::SVGAnimationElement::startedActiveInterval):
+        (WebCore::SVGAnimationElement::updateAnimation):
+        * svg/SVGAnimationElement.h:
+
 2010-11-10  Chris Marrin  <cmarrin at apple.com>
 
         Reviewed by James Robinson.
diff --git a/WebCore/svg/SVGAnimationElement.cpp b/WebCore/svg/SVGAnimationElement.cpp
index b5eaafc..32b43f2 100644
--- a/WebCore/svg/SVGAnimationElement.cpp
+++ b/WebCore/svg/SVGAnimationElement.cpp
@@ -382,7 +382,18 @@ void SVGAnimationElement::calculateKeyTimesForCalcModePaced()
 }
 
 static inline double solveEpsilon(double duration) { return 1. / (200. * duration); }
-    
+
+unsigned SVGAnimationElement::calculateKeyTimesIndex(float percent) const
+{
+    unsigned index;
+    unsigned keyTimesCount = m_keyTimes.size();
+    for (index = 1; index < keyTimesCount; ++index) {
+        if (m_keyTimes[index] >= percent)
+            break;
+    }
+    return --index;
+}
+
 float SVGAnimationElement::calculatePercentForSpline(float percent, unsigned splineIndex) const
 {
     ASSERT(calcMode() == CalcModeSpline);
@@ -402,13 +413,7 @@ float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const
     ASSERT(keyTimesCount > 1);
     ASSERT(m_keyPoints.size() == keyTimesCount);
 
-    unsigned index;
-    for (index = 1; index < keyTimesCount; ++index) {
-        if (m_keyTimes[index] >= percent)
-            break;
-    }
-    --index;
-
+    unsigned index = calculateKeyTimesIndex(percent);
     float fromPercent = m_keyTimes[index];
     float toPercent = m_keyTimes[index + 1];
     float fromKeyPoint = m_keyPoints[index];
@@ -451,13 +456,7 @@ void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float&
     ASSERT(!keyTimesCount || valuesCount == keyTimesCount);
     ASSERT(!keyTimesCount || (keyTimesCount > 1 && m_keyTimes[0] == 0));
 
-    unsigned index;
-    for (index = 1; index < keyTimesCount; ++index) {
-        if (m_keyTimes[index] >= percent)
-            break;
-    }
-    --index;
-    
+    unsigned index = calculateKeyTimesIndex(percent);
     if (calcMode == CalcModeDiscrete) {
         if (!keyTimesCount) 
             index = percent == 1.0f ? valuesCount - 1 : static_cast<unsigned>(percent * valuesCount);
@@ -510,10 +509,12 @@ void SVGAnimationElement::startedActiveInterval()
     if (hasAttribute(SVGNames::keyPointsAttr) && m_keyPoints.size() != m_keyTimes.size())
         return;
 
+    AnimationMode animationMode = this->animationMode();
     CalcMode calcMode = this->calcMode();
     if (calcMode == CalcModeSpline) {
-        unsigned num = m_keySplines.size() + 1;
-        if ((hasAttribute(SVGNames::keyPointsAttr) && m_keyPoints.size() != num) || m_values.size() != num)
+        unsigned splinesCount = m_keySplines.size() + 1;
+        if ((hasAttribute(SVGNames::keyPointsAttr) && m_keyPoints.size() != splinesCount)
+            || animationMode == ValuesAnimation && m_values.size() != splinesCount)
             return;
     }
 
@@ -521,7 +522,6 @@ void SVGAnimationElement::startedActiveInterval()
     String to = toValue();
     String by = byValue();
     SVGElement* target = targetElement();
-    AnimationMode animationMode = this->animationMode();
     if (animationMode == NoAnimation)
         return;
     if (animationMode == FromToAnimation) {
@@ -558,6 +558,7 @@ void SVGAnimationElement::updateAnimation(float percent, unsigned repeat, SVGSMI
         return;
     
     float effectivePercent;
+    CalcMode mode = calcMode();
     if (animationMode() == ValuesAnimation) {
         String from;
         String to;
@@ -569,9 +570,11 @@ void SVGAnimationElement::updateAnimation(float percent, unsigned repeat, SVGSMI
             m_lastValuesAnimationFrom = from;
             m_lastValuesAnimationTo = to;
         }
-    } else if (!m_keyPoints.isEmpty() && calcMode() != CalcModePaced)
+    } else if (!m_keyPoints.isEmpty() && mode != CalcModePaced)
         effectivePercent = calculatePercentFromKeyPoints(percent);
-    else 
+    else if (m_keyPoints.isEmpty() && mode == CalcModeSpline && m_keyTimes.size() > 1)
+        effectivePercent = calculatePercentForSpline(percent, calculateKeyTimesIndex(percent));
+    else
         effectivePercent = percent;
 
     calculateAnimatedValue(effectivePercent, repeat, resultElement);
diff --git a/WebCore/svg/SVGAnimationElement.h b/WebCore/svg/SVGAnimationElement.h
index 2e11fe6..367e63f 100644
--- a/WebCore/svg/SVGAnimationElement.h
+++ b/WebCore/svg/SVGAnimationElement.h
@@ -104,6 +104,7 @@ namespace WebCore {
         float calculatePercentFromKeyPoints(float percent) const;
         void currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const;
         float calculatePercentForSpline(float percent, unsigned splineIndex) const;
+        unsigned calculateKeyTimesIndex(float percent) const;
         
         // SVGExternalResourcesRequired
         DECLARE_ANIMATED_STATIC_PROPERTY_NEW(SVGAnimationElement, SVGNames::externalResourcesRequiredAttr, bool, ExternalResourcesRequired, externalResourcesRequired)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list