Title: [90219] trunk
Revision
90219
Author
[email protected]
Date
2011-07-01 01:51:28 -0700 (Fri, 01 Jul 2011)

Log Message

2011-07-01  Dirk Schulze  <[email protected]>

        Reviewed by Nikolas Zimmermann.

        SVGAnimatedLengthListAnimator does not take additive="sum" into accout
        https://bugs.webkit.org/show_bug.cgi?id=63705

        Added support for additive animations to SVGAnimatedLengthListAnimator. Don't clear the animatedList if not
        necessary.

        SVGLength unit gets animated as well now. We used to take the unit of 'from' all the time.

        Tests: svg/animations/svglength-animation-unitType.html
               svg/animations/svglengthlist-animation-5.html

        * svg/SVGAnimatedLength.cpp:
        (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue): Code clean-up and support for unit animation.
        * svg/SVGAnimatedLengthList.cpp: Add support for additive animations.
        (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
        * svg/SVGLength.cpp:
        (WebCore::SVGLength::SVGLength):
        (WebCore::SVGLength::setValue): New setValue that gets the LengthType and UnitType as argument for supporting animations of units as well.
        * svg/SVGLength.h:
2011-07-01  Dirk Schulze  <[email protected]>

        Reviewed by Nikolas Zimmermann.

        SVGAnimatedLengthListAnimator does not take additive="sum" into accout
        https://bugs.webkit.org/show_bug.cgi?id=63705

        Tests additive animations for SVGLengthLists as well as unit animations on SVGLength.

        * svg/animations/script-tests/svglength-animation-unitType.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/script-tests/svglengthlist-animation-5.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/svglength-animation-unitType-expected.txt: Added.
        * svg/animations/svglength-animation-unitType.html: Added.
        * svg/animations/svglengthlist-animation-5-expected.txt: Added.
        * svg/animations/svglengthlist-animation-5.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90218 => 90219)


--- trunk/LayoutTests/ChangeLog	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/LayoutTests/ChangeLog	2011-07-01 08:51:28 UTC (rev 90219)
@@ -2,6 +2,30 @@
 
         Reviewed by Nikolas Zimmermann.
 
+        SVGAnimatedLengthListAnimator does not take additive="sum" into accout
+        https://bugs.webkit.org/show_bug.cgi?id=63705
+
+        Tests additive animations for SVGLengthLists as well as unit animations on SVGLength.
+
+        * svg/animations/script-tests/svglength-animation-unitType.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/svglengthlist-animation-5.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/svglength-animation-unitType-expected.txt: Added.
+        * svg/animations/svglength-animation-unitType.html: Added.
+        * svg/animations/svglengthlist-animation-5-expected.txt: Added.
+        * svg/animations/svglengthlist-animation-5.html: Added.
+
+2011-07-01  Dirk Schulze  <[email protected]>
+
+        Reviewed by Nikolas Zimmermann.
+
         SVGAnimatedType should support SVGAnimatedInteger animation
         https://bugs.webkit.org/show_bug.cgi?id=63789
         

Modified: trunk/LayoutTests/platform/wk2/Skipped (90218 => 90219)


--- trunk/LayoutTests/platform/wk2/Skipped	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/LayoutTests/platform/wk2/Skipped	2011-07-01 08:51:28 UTC (rev 90219)
@@ -472,11 +472,13 @@
 svg/animations/svglength-animation-px-to-percentage.html
 svg/animations/svglength-animation-px-to-pt.html
 svg/animations/svglength-animation-px-to-px.html
+svg/animations/svglength-animation-unitType.html
 svg/animations/svglength-animation-values.html
 svg/animations/svglengthlist-animation-1.html
 svg/animations/svglengthlist-animation-2.html
 svg/animations/svglengthlist-animation-3.html
 svg/animations/svglengthlist-animation-4.html
+svg/animations/svglengthlist-animation-5.html
 svg/animations/svgnumber-animation-1.html
 svg/animations/svgnumber-animation-2.html
 svg/animations/svgnumber-animation-3.html

Added: trunk/LayoutTests/svg/animations/script-tests/svglength-animation-unitType.js (0 => 90219)


--- trunk/LayoutTests/svg/animations/script-tests/svglength-animation-unitType.js	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/svglength-animation-unitType.js	2011-07-01 08:51:28 UTC (rev 90219)
@@ -0,0 +1,51 @@
+description("Test change of unit type for SVGLength animation.");
+createSVGTestCase();
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("x", "0");
+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", "width");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "100");
+animate.setAttribute("to", "200px");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.width.animVal.unitType", "SVGLength.SVG_LENGTHTYPE_NUMBER");
+}
+
+function sample2() {
+    shouldBe("rect.width.animVal.unitType", "SVGLength.SVG_LENGTHTYPE_NUMBER");
+}
+
+function sample3() {
+    shouldBe("rect.width.animVal.unitType", "SVGLength.SVG_LENGTHTYPE_PX");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "rect", sample1],
+        ["animation", 1.5,    "rect", sample2],
+        ["animation", 2.5,    "rect", sample3],
+        ["animation", 4.0 ,   "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 30)", 0);
+var successfullyParsed = true;

Added: trunk/LayoutTests/svg/animations/script-tests/svglengthlist-animation-5.js (0 => 90219)


--- trunk/LayoutTests/svg/animations/script-tests/svglengthlist-animation-5.js	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/svglengthlist-animation-5.js	2011-07-01 08:51:28 UTC (rev 90219)
@@ -0,0 +1,59 @@
+description("Test additive='sum' animation of SVGLengthList.");
+createSVGTestCase();
+
+// Setup test document
+var text = createSVGElement("text");
+text.setAttribute("id", "text");
+text.textContent = "ABCD";
+text.setAttribute("x", "50 60 70 80");
+text.setAttribute("y", "50");
+text.setAttribute("onclick", "executeTest()");
+rootSVGElement.appendChild(text);
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "x");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("additive", "sum");
+animate.setAttribute("from", "0 0 0 0");
+animate.setAttribute("to", "20 20 20 20");
+text.appendChild(animate);
+
+// Setup animation test
+function sample1() {
+	shouldBe("text.x.animVal.getItem(0).value", "50");
+	shouldBe("text.x.animVal.getItem(1).value", "60");
+	shouldBe("text.x.animVal.getItem(2).value", "70");
+	shouldBe("text.x.animVal.getItem(3).value", "80");
+}
+
+function sample2() {
+	shouldBe("text.x.animVal.getItem(0).value", "60");
+	shouldBe("text.x.animVal.getItem(1).value", "70");
+	shouldBe("text.x.animVal.getItem(2).value", "80");
+	shouldBe("text.x.animVal.getItem(3).value", "90");
+}
+
+function sample3() {
+	shouldBeCloseEnough("text.x.animVal.getItem(0).value", "70", 0.01);
+	shouldBeCloseEnough("text.x.animVal.getItem(1).value", "80", 0.01);
+	shouldBeCloseEnough("text.x.animVal.getItem(2).value", "90", 0.01);
+	shouldBeCloseEnough("text.x.animVal.getItem(3).value", "100", 0.01);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "text", sample1],
+        ["animation", 2.0,    "text", sample2],
+        ["animation", 3.9999, "text", sample3],
+        ["animation", 4.0 ,   "text", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(51, 49)", 0);
+var successfullyParsed = true;

Added: trunk/LayoutTests/svg/animations/svglength-animation-unitType-expected.txt (0 => 90219)


--- trunk/LayoutTests/svg/animations/svglength-animation-unitType-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/svglength-animation-unitType-expected.txt	2011-07-01 08:51:28 UTC (rev 90219)
@@ -0,0 +1,15 @@
+SVG 1.1 dynamic animation tests
+
+Test change of unit type for SVGLength animation.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.width.animVal.unitType is SVGLength.SVG_LENGTHTYPE_NUMBER
+PASS rect.width.animVal.unitType is SVGLength.SVG_LENGTHTYPE_NUMBER
+PASS rect.width.animVal.unitType is SVGLength.SVG_LENGTHTYPE_PX
+PASS rect.width.animVal.unitType is SVGLength.SVG_LENGTHTYPE_NUMBER
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/animations/svglength-animation-unitType.html (0 => 90219)


--- trunk/LayoutTests/svg/animations/svglength-animation-unitType.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/svglength-animation-unitType.html	2011-07-01 08:51:28 UTC (rev 90219)
@@ -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/svglengthlist-animation-5-expected.txt (0 => 90219)


--- trunk/LayoutTests/svg/animations/svglengthlist-animation-5-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/svglengthlist-animation-5-expected.txt	2011-07-01 08:51:28 UTC (rev 90219)
@@ -0,0 +1,28 @@
+SVG 1.1 dynamic animation tests
+
+ABCD
+Test additive='sum' animation of SVGLengthList.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.x.animVal.getItem(0).value is 50
+PASS text.x.animVal.getItem(1).value is 60
+PASS text.x.animVal.getItem(2).value is 70
+PASS text.x.animVal.getItem(3).value is 80
+PASS text.x.animVal.getItem(0).value is 60
+PASS text.x.animVal.getItem(1).value is 70
+PASS text.x.animVal.getItem(2).value is 80
+PASS text.x.animVal.getItem(3).value is 90
+PASS text.x.animVal.getItem(0).value is 70
+PASS text.x.animVal.getItem(1).value is 80
+PASS text.x.animVal.getItem(2).value is 90
+PASS text.x.animVal.getItem(3).value is 100
+PASS text.x.animVal.getItem(0).value is 50
+PASS text.x.animVal.getItem(1).value is 60
+PASS text.x.animVal.getItem(2).value is 70
+PASS text.x.animVal.getItem(3).value is 80
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/animations/svglengthlist-animation-5.html (0 => 90219)


--- trunk/LayoutTests/svg/animations/svglengthlist-animation-5.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/svglengthlist-animation-5.html	2011-07-01 08:51:28 UTC (rev 90219)
@@ -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>

Modified: trunk/Source/WebCore/ChangeLog (90218 => 90219)


--- trunk/Source/WebCore/ChangeLog	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/Source/WebCore/ChangeLog	2011-07-01 08:51:28 UTC (rev 90219)
@@ -2,6 +2,30 @@
 
         Reviewed by Nikolas Zimmermann.
 
+        SVGAnimatedLengthListAnimator does not take additive="sum" into accout
+        https://bugs.webkit.org/show_bug.cgi?id=63705
+
+        Added support for additive animations to SVGAnimatedLengthListAnimator. Don't clear the animatedList if not
+        necessary.
+
+        SVGLength unit gets animated as well now. We used to take the unit of 'from' all the time.
+
+        Tests: svg/animations/svglength-animation-unitType.html
+               svg/animations/svglengthlist-animation-5.html
+
+        * svg/SVGAnimatedLength.cpp:
+        (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue): Code clean-up and support for unit animation.
+        * svg/SVGAnimatedLengthList.cpp: Add support for additive animations.
+        (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
+        * svg/SVGLength.cpp:
+        (WebCore::SVGLength::SVGLength):
+        (WebCore::SVGLength::setValue): New setValue that gets the LengthType and UnitType as argument for supporting animations of units as well.
+        * svg/SVGLength.h:
+
+2011-07-01  Dirk Schulze  <[email protected]>
+
+        Reviewed by Nikolas Zimmermann.
+
         SVGAnimatedType should support SVGAnimatedInteger animation
         https://bugs.webkit.org/show_bug.cgi?id=63789
         

Modified: trunk/Source/WebCore/svg/SVGAnimatedLength.cpp (90218 => 90219)


--- trunk/Source/WebCore/svg/SVGAnimatedLength.cpp	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/Source/WebCore/svg/SVGAnimatedLength.cpp	2011-07-01 08:51:28 UTC (rev 90219)
@@ -23,6 +23,7 @@
 #include "SVGAnimatedLength.h"
 
 #include "SVGAnimateElement.h"
+#include "SVGAnimatedNumber.h"
 
 namespace WebCore {
 
@@ -79,46 +80,35 @@
 {
     ASSERT(m_animationElement);
     ASSERT(m_contextElement);
+
     SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
-    
     AnimationMode animationMode = animationElement->animationMode();
+
     // To animation uses contributions from the lower priority animations as the base value.
-    // FIXME: Avoid string parsing.
+    SVGLength& animatedSVGLength = animated->length();
+    SVGLength& fromSVGLength = from->length();
     if (animationMode == ToAnimation)
-        from = constructFromString(animated->length().valueAsString());
+        fromSVGLength = animatedSVGLength;
     
     // Replace 'inherit' by their computed property values.
-    float number;
-    float fromLength = from->length().value(m_contextElement);
-    float toLength = to->length().value(m_contextElement);
-    
+    SVGLength& toSVGLength = to->length();
     if (animationElement->fromPropertyValueType() == InheritValue) {
         String fromLengthString;
         animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), fromLengthString);
-        fromLength = sharedSVGLength(m_lengthMode, fromLengthString).value(m_contextElement);
+        fromSVGLength = sharedSVGLength(m_lengthMode, fromLengthString);
     }
     if (animationElement->toPropertyValueType() == InheritValue) {
         String toLengthString;
         animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), toLengthString);
-        toLength = sharedSVGLength(m_lengthMode, toLengthString).value(m_contextElement); 
+        toSVGLength = sharedSVGLength(m_lengthMode, toLengthString); 
     }
     
-    if (animationElement->calcMode() == CalcModeDiscrete)
-        number = percentage < 0.5f ? fromLength : toLength;
-    else
-        number = (toLength - fromLength) * percentage + fromLength;
-    
-    // FIXME: This is not correct for values animation.
-    if (animationElement->isAccumulated() && repeatCount)
-        number += toLength * repeatCount;
+    float result = animatedSVGLength.value(m_contextElement);
+    SVGLengthType unitType = percentage < 0.5 ? fromSVGLength.unitType() : toSVGLength.unitType();
+    SVGAnimatedNumberAnimator::calculateAnimatedNumber(animationElement, percentage, repeatCount, result, fromSVGLength.value(m_contextElement), toSVGLength.value(m_contextElement));
+
     ExceptionCode ec = 0;
-    SVGLength& animatedSVGLength = animated->length();
-    if (animationElement->isAdditive() && animationMode != ToAnimation) {
-        float animatedSVGLengthValue = animatedSVGLength.value(m_contextElement);
-        animatedSVGLengthValue += number;
-        animatedSVGLength.setValue(animatedSVGLengthValue, m_contextElement, ec);
-    } else
-        animatedSVGLength.setValue(number, m_contextElement, ec);
+    animatedSVGLength.setValue(m_contextElement, result, m_lengthMode, unitType, ec);
     ASSERT(!ec);
 }
 

Modified: trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp (90218 => 90219)


--- trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp	2011-07-01 08:51:28 UTC (rev 90219)
@@ -111,12 +111,20 @@
         return;
     }
     
-    animatedLengthList.clear();
+    bool animatedListSizeEqual = itemsCount == animatedLengthList.size();
+    if (!animatedListSizeEqual)
+        animatedLengthList.clear();
+    ExceptionCode ec = 0;
     for (unsigned i = 0; i < itemsCount; ++i) {
-        float result = 0;
+        float result = animatedListSizeEqual ? animatedLengthList[i].value(m_contextElement) : 0;
         SVGLengthType unitType = percentage < 0.5 ? fromLengthList[i].unitType() : toLengthList[i].unitType();
         SVGAnimatedNumberAnimator::calculateAnimatedNumber(animationElement, percentage, repeatCount, result, fromLengthList[i].value(m_contextElement), toLengthList[i].value(m_contextElement));
-        animatedLengthList.append(SVGLength(m_contextElement, result, m_lengthMode, unitType));
+        if (!animatedListSizeEqual)
+            animatedLengthList.append(SVGLength(m_contextElement, result, m_lengthMode, unitType));
+        else {
+            animatedLengthList[i].setValue(m_contextElement, result, m_lengthMode, unitType, ec);
+            ASSERT(!ec);
+        }
     }
 }
 

Modified: trunk/Source/WebCore/svg/SVGLength.cpp (90218 => 90219)


--- trunk/Source/WebCore/svg/SVGLength.cpp	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/Source/WebCore/svg/SVGLength.cpp	2011-07-01 08:51:28 UTC (rev 90219)
@@ -141,6 +141,12 @@
     ASSERT(!ec);
 }
 
+SVGLength::SVGLength(const SVGLength& other)
+    : m_valueInSpecifiedUnits(other.m_valueInSpecifiedUnits)
+    , m_unit(other.m_unit)
+{
+}
+
 void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionCode& ec)
 {
     m_valueInSpecifiedUnits = 0;
@@ -148,12 +154,6 @@
     setValueAsString(valueAsString, ec);
 }
 
-SVGLength::SVGLength(const SVGLength& other)
-    : m_valueInSpecifiedUnits(other.m_valueInSpecifiedUnits)
-    , m_unit(other.m_unit)
-{
-}
-
 bool SVGLength::operator==(const SVGLength& other) const
 {
     return m_unit == other.m_unit
@@ -208,6 +208,12 @@
     return 0;
 }
 
+void SVGLength::setValue(const SVGElement* context, float value, SVGLengthMode mode, SVGLengthType unitType, ExceptionCode& ec)
+{
+    m_unit = storeUnit(mode, unitType);
+    setValue(value, context, ec);
+}
+
 void SVGLength::setValue(float value, const SVGElement* context, ExceptionCode& ec)
 {
     switch (extractType(m_unit)) {

Modified: trunk/Source/WebCore/svg/SVGLength.h (90218 => 90219)


--- trunk/Source/WebCore/svg/SVGLength.h	2011-07-01 08:37:49 UTC (rev 90218)
+++ trunk/Source/WebCore/svg/SVGLength.h	2011-07-01 08:51:28 UTC (rev 90219)
@@ -81,6 +81,7 @@
     float value(const SVGElement* context) const;
     float value(const SVGElement* context, ExceptionCode&) const;
     void setValue(float, const SVGElement* context, ExceptionCode&);
+    void setValue(const SVGElement* context, float, SVGLengthMode, SVGLengthType, ExceptionCode&);
 
     float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
     void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value; }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to