[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

krit at webkit.org krit at webkit.org
Mon Feb 21 00:02:18 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 46b465c4d3f11059ba1f1953db4b3c88f7c4b191
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 27 19:23:44 2011 +0000

    2011-01-27  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG animation doesn't support calcMode discrete for number and color values.
            https://bugs.webkit.org/show_bug.cgi?id=53189
    
            Add support for calcMode discrete on number and color animation.
    
            Tests: svg/animations/animate-color-calcMode-discrete.html
                   svg/animations/animate-number-calcMode-discrete.html
    
            * svg/SVGAnimateElement.cpp:
            (WebCore::SVGAnimateElement::calculateAnimatedValue):
    2011-01-27  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG animation doesn't support calcMode discrete for number and color values.
            https://bugs.webkit.org/show_bug.cgi?id=53189
    
            Test for correct behavior on animating numbers and colors with calcMode discrete.
    
            * svg/animations/animate-color-calcMode-discrete-expected.txt: Added.
            * svg/animations/animate-color-calcMode-discrete.html: Added.
            * svg/animations/animate-number-calcMode-discrete-expected.txt: Added.
            * svg/animations/animate-number-calcMode-discrete.html: Added.
            * svg/animations/script-tests/animate-color-calcMode-discrete.js: Added.
            (sample1):
            (sample2):
            (executeTest):
            * svg/animations/script-tests/animate-number-calcMode-discrete.js: Added.
            (sample1):
            (sample2):
            (executeTest):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76819 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5a1a8be..38671cd 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,25 @@
+2011-01-27  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG animation doesn't support calcMode discrete for number and color values.
+        https://bugs.webkit.org/show_bug.cgi?id=53189
+
+        Test for correct behavior on animating numbers and colors with calcMode discrete.
+
+        * svg/animations/animate-color-calcMode-discrete-expected.txt: Added.
+        * svg/animations/animate-color-calcMode-discrete.html: Added.
+        * svg/animations/animate-number-calcMode-discrete-expected.txt: Added.
+        * svg/animations/animate-number-calcMode-discrete.html: Added.
+        * svg/animations/script-tests/animate-color-calcMode-discrete.js: Added.
+        (sample1):
+        (sample2):
+        (executeTest):
+        * svg/animations/script-tests/animate-number-calcMode-discrete.js: Added.
+        (sample1):
+        (sample2):
+        (executeTest):
+
 2011-01-27  Ryosuke Niwa  <rniwa at webkit.org>
 
         Unreviewed Chromium test expectation update for video tests.
diff --git a/LayoutTests/svg/animations/animate-color-calcMode-discrete-expected.txt b/LayoutTests/svg/animations/animate-color-calcMode-discrete-expected.txt
new file mode 100644
index 0000000..8ba4c3b
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-color-calcMode-discrete-expected.txt
@@ -0,0 +1,17 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode discrete with from-to animation on colors. 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 document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(255, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(255, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-color-calcMode-discrete.html b/LayoutTests/svg/animations/animate-color-calcMode-discrete.html
new file mode 100644
index 0000000..e72fe22
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-color-calcMode-discrete.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-color-calcMode-discrete.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/animate-number-calcMode-discrete-expected.txt b/LayoutTests/svg/animations/animate-number-calcMode-discrete-expected.txt
new file mode 100644
index 0000000..3abe37f
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-number-calcMode-discrete-expected.txt
@@ -0,0 +1,16 @@
+SVG 1.1 dynamic animation tests
+
+Test calcMode discrete with from-to animation on numbers. 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.baseVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.baseVal.value is 0
+PASS rect.x.baseVal.value is 0
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/animate-number-calcMode-discrete.html b/LayoutTests/svg/animations/animate-number-calcMode-discrete.html
new file mode 100644
index 0000000..8dada85
--- /dev/null
+++ b/LayoutTests/svg/animations/animate-number-calcMode-discrete.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-number-calcMode-discrete.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/script-tests/animate-color-calcMode-discrete.js b/LayoutTests/svg/animations/script-tests/animate-color-calcMode-discrete.js
new file mode 100644
index 0000000..3c10013
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-color-calcMode-discrete.js
@@ -0,0 +1,50 @@
+description("Test calcMode discrete with from-to animation on colors. 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("width", "100");
+rect.setAttribute("height", "100");
+rect.setAttribute("color", "rgb(0,255,255)");
+rect.setAttribute("fill", "currentColor");
+rect.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "color");
+animate.setAttribute("from", "rgb(255,0,0)");
+animate.setAttribute("to", "rgb(0,255,255)");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("calcMode", "discrete");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBeEqualToString("document.defaultView.getComputedStyle(rect).getPropertyValue('color')", "rgb(255, 0, 0)");
+}
+
+function sample2() {
+    shouldBeEqualToString("document.defaultView.getComputedStyle(rect).getPropertyValue('color')", "rgb(0, 255, 255)");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample2],
+        ["animation", 0.001,  "rect", sample1],
+        ["animation", 1.0,    "rect", sample1],
+        ["animation", 3.0,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample2],
+        ["animation", 4.0 ,   "rect", sample2]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/animate-number-calcMode-discrete.js b/LayoutTests/svg/animations/script-tests/animate-number-calcMode-discrete.js
new file mode 100644
index 0000000..7661215
--- /dev/null
+++ b/LayoutTests/svg/animations/script-tests/animate-number-calcMode-discrete.js
@@ -0,0 +1,50 @@
+description("Test calcMode discrete with from-to animation on numbers. 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("calcMode", "discrete");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // FIXME: Add animVal support. Animates baseVal at the moment.
+    // Check initial/end conditions
+    shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+    shouldBe("rect.x.baseVal.value", "0");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 1.0,    "rect", sample1],
+        ["animation", 3.0,    "rect", sample2],
+        ["animation", 3.9999, "rect", sample2],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 98a6932..cb0e415 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-27  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG animation doesn't support calcMode discrete for number and color values.
+        https://bugs.webkit.org/show_bug.cgi?id=53189
+
+        Add support for calcMode discrete on number and color animation.
+
+        Tests: svg/animations/animate-color-calcMode-discrete.html
+               svg/animations/animate-number-calcMode-discrete.html
+
+        * svg/SVGAnimateElement.cpp:
+        (WebCore::SVGAnimateElement::calculateAnimatedValue):
+
 2011-01-26  Zhenyao Mo  <zmo at google.com>
 
         Reviewed by Kenneth Russell.
diff --git a/Source/WebCore/svg/SVGAnimateElement.cpp b/Source/WebCore/svg/SVGAnimateElement.cpp
index 67f53e4..55619e6 100644
--- a/Source/WebCore/svg/SVGAnimateElement.cpp
+++ b/Source/WebCore/svg/SVGAnimateElement.cpp
@@ -100,6 +100,9 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
 {
     ASSERT(percentage >= 0.f && percentage <= 1.f);
     ASSERT(resultElement);
+    bool isInFirstHalfOfAnimation = percentage < 0.5;
+    AnimationMode animationMode = this->animationMode();
+    
     if (hasTagName(SVGNames::setTag))
         percentage = 1.f;
     if (!resultElement->hasTagName(SVGNames::animateTag) && !resultElement->hasTagName(SVGNames::animateColorTag) 
@@ -111,32 +114,40 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
         return;
     if (m_propertyType == NumberProperty) {
         // To animation uses contributions from the lower priority animations as the base value.
-        if (animationMode() == ToAnimation)
+        if (animationMode == ToAnimation)
             m_fromNumber = results->m_animatedNumber;
-    
-        double number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;
+        
+        double number;
+        if (calcMode() == CalcModeDiscrete)
+            number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber;
+        else
+            number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;
 
         // FIXME: This is not correct for values animation.
         if (isAccumulated() && repeat)
             number += m_toNumber * repeat;
-        if (isAdditive() && animationMode() != ToAnimation)
+        if (isAdditive() && animationMode != ToAnimation)
             results->m_animatedNumber += number;
         else 
             results->m_animatedNumber = number;
         return;
     } 
     if (m_propertyType == ColorProperty) {
-        if (animationMode() == ToAnimation)
+        if (animationMode == ToAnimation)
             m_fromColor = results->m_animatedColor;
-        Color color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor);
+        Color color;
+        if (calcMode() == CalcModeDiscrete)
+            color = isInFirstHalfOfAnimation ? m_fromColor : m_toColor;
+        else
+            color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor);
+
         // FIXME: Accumulate colors.
-        if (isAdditive() && animationMode() != ToAnimation)
+        if (isAdditive() && animationMode != ToAnimation)
             results->m_animatedColor = ColorDistance::addColorsAndClamp(results->m_animatedColor, color);
         else
             results->m_animatedColor = color;
         return;
     }
-    AnimationMode animationMode = this->animationMode();
     if (m_propertyType == PathProperty) {
         if (animationMode == ToAnimation) {
             ASSERT(results->m_animatedPathPointer);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list