2011-06-17 Dirk Schulze <krit@webkit.org>
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jun 2011 05:30:53 +0000 (05:30 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jun 2011 05:30:53 +0000 (05:30 +0000)
        Reviewed by Rob Buis.

        SVGAnimation should use direct unit animation for SVGAngle
        https://bugs.webkit.org/show_bug.cgi?id=62807

        Tests animation of SVGAngle with different units.

        * svg/animations/script-tests/svgangle-animation-deg-to-grad.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/script-tests/svgangle-animation-deg-to-rad.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/script-tests/svgangle-animation-grad-to-deg.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/script-tests/svgangle-animation-grad-to-rad.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/script-tests/svgangle-animation-rad-to-deg.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/script-tests/svgangle-animation-rad-to-grad.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/svgangle-animation-deg-to-grad-expected.txt: Added.
        * svg/animations/svgangle-animation-deg-to-grad.html: Added.
        * svg/animations/svgangle-animation-deg-to-rad-expected.txt: Added.
        * svg/animations/svgangle-animation-deg-to-rad.html: Added.
        * svg/animations/svgangle-animation-grad-to-deg-expected.txt: Added.
        * svg/animations/svgangle-animation-grad-to-deg.html: Added.
        * svg/animations/svgangle-animation-grad-to-rad-expected.txt: Added.
        * svg/animations/svgangle-animation-grad-to-rad.html: Added.
        * svg/animations/svgangle-animation-rad-to-deg-expected.txt: Added.
        * svg/animations/svgangle-animation-rad-to-deg.html: Added.
        * svg/animations/svgangle-animation-rad-to-grad-expected.txt: Added.
        * svg/animations/svgangle-animation-rad-to-grad.html: Added.
2011-06-17  Dirk Schulze  <krit@webkit.org>

        Reviewed by Rob Buis.

        SVGAnimation should use direct unit animation for SVGAngle
        https://bugs.webkit.org/show_bug.cgi?id=62807

        Follow up of "SVGAnimation should use direct unit animation for SVGLength": https://bugs.webkit.org/show_bug.cgi?id=61368
        This patch continues the conversion to the new concept of SVGAnimatorFactory with SVGAngle. We can animate the SVG primitive datatype SVGAngle
        with different unit types now.
        Removed number and unit parser from SVGAnimateElement. This is not needed anymore.

        Tests: svg/animations/svgangle-animation-deg-to-grad.html
               svg/animations/svgangle-animation-deg-to-rad.html
               svg/animations/svgangle-animation-grad-to-deg.html
               svg/animations/svgangle-animation-grad-to-rad.html
               svg/animations/svgangle-animation-rad-to-deg.html
               svg/animations/svgangle-animation-rad-to-grad.html

        * CMakeLists.txt: Added SVGAnimatedAngle.cpp.
        * GNUmakefile.list.am: Ditto.
        * WebCore.gypi: Ditto.
        * WebCore.pro: Ditto.
        * WebCore.xcodeproj/project.pbxproj: Ditto.
        * svg/SVGAllInOne.cpp: Ditto.
        * svg/SVGAnimateElement.cpp: Make use of SVGAnimator for AnimatedAngle.
        (WebCore::SVGAnimateElement::SVGAnimateElement):
        (WebCore::SVGAnimateElement::determineAnimatedAttributeType): Ditto.
        (WebCore::SVGAnimateElement::calculateAnimatedValue): Ditto.
        (WebCore::SVGAnimateElement::calculateFromAndToValues): Ditto.
        (WebCore::SVGAnimateElement::calculateFromAndByValues): Ditto.
        (WebCore::SVGAnimateElement::resetToBaseValue): Ditto.
        (WebCore::SVGAnimateElement::applyResultsToTarget): Ditto.
        (WebCore::SVGAnimateElement::calculateDistance): Ditto.
        * svg/SVGAnimateElement.h:
        * svg/SVGAnimatedAngle.cpp: Added. Added SVGAnimatedAngleAnimator for animation of SVGAngles.
        (WebCore::SVGAnimatedAngleAnimator::SVGAnimatedAngleAnimator):
        (WebCore::sharedSVGAngle):
        (WebCore::SVGAnimatedAngleAnimator::constructFromString):
        (WebCore::SVGAnimatedAngleAnimator::calculateFromAndToValues):
        (WebCore::SVGAnimatedAngleAnimator::calculateFromAndByValues):
        (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue):
        (WebCore::SVGAnimatedAngleAnimator::calculateDistance):
        * svg/SVGAnimatedAngle.h:
        (WebCore::SVGAnimatedAngleAnimator::~SVGAnimatedAngleAnimator):
        * svg/SVGAnimatedLength.cpp:
        (WebCore::sharedSVGLength): Use an ExceptionCode for SVGLength::setValueAsString.
        * svg/SVGAnimatedType.h:
        (WebCore::SVGAnimatedType::create):
        (WebCore::SVGAnimatedType::createAngle):
        (WebCore::SVGAnimatedType::createLength):
        (WebCore::SVGAnimatedType::~SVGAnimatedType):
        (WebCore::SVGAnimatedType::angle):
        (WebCore::SVGAnimatedType::valueAsString):
        (WebCore::SVGAnimatedType::setValueAsString):
        (WebCore::SVGAnimatedType::SVGAnimatedType):
        * svg/SVGAnimatorFactory.h:
        (WebCore::SVGAnimatorFactory::create):
        * svg/SVGLength.cpp:
        (WebCore::SVGLength::setValueAsString): Added an ExceptionCode for consistency reasons and as preparation for future error handling.
        * svg/SVGLength.h:
        * svg/SVGParserUtilities.cpp:
        (WebCore::parseNumberFromString): Added number parser for String objects.
        * svg/SVGParserUtilities.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@89187 268f45cc-cd09-0410-ab3c-d52691b4dbfc

37 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/animations/script-tests/svgangle-animation-deg-to-grad.js [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/svgangle-animation-deg-to-rad.js [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/svgangle-animation-grad-to-deg.js [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/svgangle-animation-grad-to-rad.js [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/svgangle-animation-rad-to-deg.js [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/svgangle-animation-rad-to-grad.js [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-deg-to-grad-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-deg-to-grad.html [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-deg-to-rad-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-deg-to-rad.html [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-grad-to-deg-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-grad-to-deg.html [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-grad-to-rad-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-grad-to-rad.html [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-rad-to-deg-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-rad-to-deg.html [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-rad-to-grad-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/svgangle-animation-rad-to-grad.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/svg/SVGAllInOne.cpp
Source/WebCore/svg/SVGAnimateElement.cpp
Source/WebCore/svg/SVGAnimateElement.h
Source/WebCore/svg/SVGAnimatedAngle.cpp [new file with mode: 0644]
Source/WebCore/svg/SVGAnimatedAngle.h
Source/WebCore/svg/SVGAnimatedLength.cpp
Source/WebCore/svg/SVGAnimatedType.h
Source/WebCore/svg/SVGAnimatorFactory.h
Source/WebCore/svg/SVGLength.cpp
Source/WebCore/svg/SVGLength.h
Source/WebCore/svg/SVGParserUtilities.cpp
Source/WebCore/svg/SVGParserUtilities.h

index a1a1d21..0e62874 100644 (file)
@@ -1,3 +1,55 @@
+2011-06-17  Dirk Schulze  <krit@webkit.org>
+
+        Reviewed by Rob Buis.
+
+        SVGAnimation should use direct unit animation for SVGAngle
+        https://bugs.webkit.org/show_bug.cgi?id=62807
+
+        Tests animation of SVGAngle with different units.
+
+        * svg/animations/script-tests/svgangle-animation-deg-to-grad.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/svgangle-animation-deg-to-rad.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/svgangle-animation-grad-to-deg.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/svgangle-animation-grad-to-rad.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/svgangle-animation-rad-to-deg.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/script-tests/svgangle-animation-rad-to-grad.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/svgangle-animation-deg-to-grad-expected.txt: Added.
+        * svg/animations/svgangle-animation-deg-to-grad.html: Added.
+        * svg/animations/svgangle-animation-deg-to-rad-expected.txt: Added.
+        * svg/animations/svgangle-animation-deg-to-rad.html: Added.
+        * svg/animations/svgangle-animation-grad-to-deg-expected.txt: Added.
+        * svg/animations/svgangle-animation-grad-to-deg.html: Added.
+        * svg/animations/svgangle-animation-grad-to-rad-expected.txt: Added.
+        * svg/animations/svgangle-animation-grad-to-rad.html: Added.
+        * svg/animations/svgangle-animation-rad-to-deg-expected.txt: Added.
+        * svg/animations/svgangle-animation-rad-to-deg.html: Added.
+        * svg/animations/svgangle-animation-rad-to-grad-expected.txt: Added.
+        * svg/animations/svgangle-animation-rad-to-grad.html: Added.
+
 2011-06-17  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/svg/animations/script-tests/svgangle-animation-deg-to-grad.js b/LayoutTests/svg/animations/script-tests/svgangle-animation-deg-to-grad.js
new file mode 100644 (file)
index 0000000..f2c9724
--- /dev/null
@@ -0,0 +1,74 @@
+description("Tests SVGAngle animation from deg to grad.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+
+var marker = createSVGElement("marker");
+marker.setAttribute("id", "marker");
+marker.setAttribute("viewBox", "0 0 10 10");
+marker.setAttribute("markerWidth", "4");
+marker.setAttribute("markerHeight", "3");
+marker.setAttribute("markerUnits", "strokeWidth");
+marker.setAttribute("refX", "1");
+marker.setAttribute("refY", "5");
+marker.setAttribute("orient", "0deg");
+defs.appendChild(marker);
+
+var polyline = createSVGElement("polyline");
+polyline.setAttribute("id", "polyline");
+polyline.setAttribute("points", "0,0 10,5 0,10 1,5");
+polyline.setAttribute("fill", "green");
+marker.appendChild(polyline);
+
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M45,50 L55,50");
+path.setAttribute("stroke-width","10");
+path.setAttribute("stroke", "green");
+path.setAttribute("marker-end", "url(#marker)");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "orient");
+animate.setAttribute("begin", "path.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0deg");
+animate.setAttribute("to", "200grad");
+marker.appendChild(animate);
+rootSVGElement.appendChild(defs);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("marker.orientAngle.animVal.value", "0");
+    shouldBe("marker.orientAngle.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "90", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "90", 0.1);
+}
+
+function sample3() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "180", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "180", 0.1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "marker", sample1],
+        ["animation", 2.0,    "marker", sample2],
+        ["animation", 3.9999, "marker", sample3],
+        ["animation", 4.0 ,   "marker", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/svgangle-animation-deg-to-rad.js b/LayoutTests/svg/animations/script-tests/svgangle-animation-deg-to-rad.js
new file mode 100644 (file)
index 0000000..3dd2acb
--- /dev/null
@@ -0,0 +1,74 @@
+description("Tests SVGAngle animation from deg to rad.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+
+var marker = createSVGElement("marker");
+marker.setAttribute("id", "marker");
+marker.setAttribute("viewBox", "0 0 10 10");
+marker.setAttribute("markerWidth", "4");
+marker.setAttribute("markerHeight", "3");
+marker.setAttribute("markerUnits", "strokeWidth");
+marker.setAttribute("refX", "1");
+marker.setAttribute("refY", "5");
+marker.setAttribute("orient", "0deg");
+defs.appendChild(marker);
+
+var polyline = createSVGElement("polyline");
+polyline.setAttribute("id", "polyline");
+polyline.setAttribute("points", "0,0 10,5 0,10 1,5");
+polyline.setAttribute("fill", "green");
+marker.appendChild(polyline);
+
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M45,50 L55,50");
+path.setAttribute("stroke-width","10");
+path.setAttribute("stroke", "green");
+path.setAttribute("marker-end", "url(#marker)");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "orient");
+animate.setAttribute("begin", "path.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0deg");
+animate.setAttribute("to", "3.14159265rad");
+marker.appendChild(animate);
+rootSVGElement.appendChild(defs);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("marker.orientAngle.animVal.value", "0");
+    shouldBe("marker.orientAngle.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "90", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "90", 0.1);
+}
+
+function sample3() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "180", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "180", 0.1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "marker", sample1],
+        ["animation", 2.0,    "marker", sample2],
+        ["animation", 3.9999, "marker", sample3],
+        ["animation", 4.0 ,   "marker", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/svgangle-animation-grad-to-deg.js b/LayoutTests/svg/animations/script-tests/svgangle-animation-grad-to-deg.js
new file mode 100644 (file)
index 0000000..82fc8c3
--- /dev/null
@@ -0,0 +1,74 @@
+description("Tests SVGAngle animation from grad to deg.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+
+var marker = createSVGElement("marker");
+marker.setAttribute("id", "marker");
+marker.setAttribute("viewBox", "0 0 10 10");
+marker.setAttribute("markerWidth", "4");
+marker.setAttribute("markerHeight", "3");
+marker.setAttribute("markerUnits", "strokeWidth");
+marker.setAttribute("refX", "1");
+marker.setAttribute("refY", "5");
+marker.setAttribute("orient", "0deg");
+defs.appendChild(marker);
+
+var polyline = createSVGElement("polyline");
+polyline.setAttribute("id", "polyline");
+polyline.setAttribute("points", "0,0 10,5 0,10 1,5");
+polyline.setAttribute("fill", "green");
+marker.appendChild(polyline);
+
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M45,50 L55,50");
+path.setAttribute("stroke-width","10");
+path.setAttribute("stroke", "green");
+path.setAttribute("marker-end", "url(#marker)");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "orient");
+animate.setAttribute("begin", "path.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0grad");
+animate.setAttribute("to", "180deg");
+marker.appendChild(animate);
+rootSVGElement.appendChild(defs);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("marker.orientAngle.animVal.value", "0");
+    shouldBe("marker.orientAngle.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "90", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "90", 0.1);
+}
+
+function sample3() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "180", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "180", 0.1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "marker", sample1],
+        ["animation", 2.0,    "marker", sample2],
+        ["animation", 3.9999, "marker", sample3],
+        ["animation", 4.0 ,   "marker", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/svgangle-animation-grad-to-rad.js b/LayoutTests/svg/animations/script-tests/svgangle-animation-grad-to-rad.js
new file mode 100644 (file)
index 0000000..1c5206d
--- /dev/null
@@ -0,0 +1,74 @@
+description("Tests SVGAngle animation from grad to rad.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+
+var marker = createSVGElement("marker");
+marker.setAttribute("id", "marker");
+marker.setAttribute("viewBox", "0 0 10 10");
+marker.setAttribute("markerWidth", "4");
+marker.setAttribute("markerHeight", "3");
+marker.setAttribute("markerUnits", "strokeWidth");
+marker.setAttribute("refX", "1");
+marker.setAttribute("refY", "5");
+marker.setAttribute("orient", "0deg");
+defs.appendChild(marker);
+
+var polyline = createSVGElement("polyline");
+polyline.setAttribute("id", "polyline");
+polyline.setAttribute("points", "0,0 10,5 0,10 1,5");
+polyline.setAttribute("fill", "green");
+marker.appendChild(polyline);
+
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M45,50 L55,50");
+path.setAttribute("stroke-width","10");
+path.setAttribute("stroke", "green");
+path.setAttribute("marker-end", "url(#marker)");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "orient");
+animate.setAttribute("begin", "path.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0grad");
+animate.setAttribute("to", "3.14159265rad");
+marker.appendChild(animate);
+rootSVGElement.appendChild(defs);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("marker.orientAngle.animVal.value", "0");
+    shouldBe("marker.orientAngle.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "90", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "90", 0.1);
+}
+
+function sample3() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "180", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "180", 0.1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "marker", sample1],
+        ["animation", 2.0,    "marker", sample2],
+        ["animation", 3.9999, "marker", sample3],
+        ["animation", 4.0 ,   "marker", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/svgangle-animation-rad-to-deg.js b/LayoutTests/svg/animations/script-tests/svgangle-animation-rad-to-deg.js
new file mode 100644 (file)
index 0000000..4555809
--- /dev/null
@@ -0,0 +1,74 @@
+description("Tests SVGAngle animation from rad to deg.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+
+var marker = createSVGElement("marker");
+marker.setAttribute("id", "marker");
+marker.setAttribute("viewBox", "0 0 10 10");
+marker.setAttribute("markerWidth", "4");
+marker.setAttribute("markerHeight", "3");
+marker.setAttribute("markerUnits", "strokeWidth");
+marker.setAttribute("refX", "1");
+marker.setAttribute("refY", "5");
+marker.setAttribute("orient", "0deg");
+defs.appendChild(marker);
+
+var polyline = createSVGElement("polyline");
+polyline.setAttribute("id", "polyline");
+polyline.setAttribute("points", "0,0 10,5 0,10 1,5");
+polyline.setAttribute("fill", "green");
+marker.appendChild(polyline);
+
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M45,50 L55,50");
+path.setAttribute("stroke-width","10");
+path.setAttribute("stroke", "green");
+path.setAttribute("marker-end", "url(#marker)");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "orient");
+animate.setAttribute("begin", "path.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0rad");
+animate.setAttribute("to", "180deg");
+marker.appendChild(animate);
+rootSVGElement.appendChild(defs);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("marker.orientAngle.animVal.value", "0");
+    shouldBe("marker.orientAngle.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "90", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "90", 0.1);
+}
+
+function sample3() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "180", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "180", 0.1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "marker", sample1],
+        ["animation", 2.0,    "marker", sample2],
+        ["animation", 3.9999, "marker", sample3],
+        ["animation", 4.0 ,   "marker", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/script-tests/svgangle-animation-rad-to-grad.js b/LayoutTests/svg/animations/script-tests/svgangle-animation-rad-to-grad.js
new file mode 100644 (file)
index 0000000..db78896
--- /dev/null
@@ -0,0 +1,74 @@
+description("Tests SVGAngle animation from rad to grad.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+
+var marker = createSVGElement("marker");
+marker.setAttribute("id", "marker");
+marker.setAttribute("viewBox", "0 0 10 10");
+marker.setAttribute("markerWidth", "4");
+marker.setAttribute("markerHeight", "3");
+marker.setAttribute("markerUnits", "strokeWidth");
+marker.setAttribute("refX", "1");
+marker.setAttribute("refY", "5");
+marker.setAttribute("orient", "0deg");
+defs.appendChild(marker);
+
+var polyline = createSVGElement("polyline");
+polyline.setAttribute("id", "polyline");
+polyline.setAttribute("points", "0,0 10,5 0,10 1,5");
+polyline.setAttribute("fill", "green");
+marker.appendChild(polyline);
+
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M45,50 L55,50");
+path.setAttribute("stroke-width","10");
+path.setAttribute("stroke", "green");
+path.setAttribute("marker-end", "url(#marker)");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "orient");
+animate.setAttribute("begin", "path.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0rad");
+animate.setAttribute("to", "200grad");
+marker.appendChild(animate);
+rootSVGElement.appendChild(defs);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("marker.orientAngle.animVal.value", "0");
+    shouldBe("marker.orientAngle.baseVal.value", "0");
+}
+
+function sample2() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "90", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "90", 0.1);
+}
+
+function sample3() {
+    shouldBeCloseEnough("marker.orientAngle.animVal.value", "180", 0.1);
+    shouldBeCloseEnough("marker.orientAngle.baseVal.value", "180", 0.1);
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 0.0,    "marker", sample1],
+        ["animation", 2.0,    "marker", sample2],
+        ["animation", 3.9999, "marker", sample3],
+        ["animation", 4.0 ,   "marker", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
diff --git a/LayoutTests/svg/animations/svgangle-animation-deg-to-grad-expected.txt b/LayoutTests/svg/animations/svgangle-animation-deg-to-grad-expected.txt
new file mode 100644 (file)
index 0000000..df5a9a1
--- /dev/null
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Tests SVGAngle animation from deg to grad.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS marker.orientAngle.animVal.value is 90
+PASS marker.orientAngle.baseVal.value is 90
+PASS marker.orientAngle.animVal.value is 180
+PASS marker.orientAngle.baseVal.value is 180
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/svgangle-animation-deg-to-grad.html b/LayoutTests/svg/animations/svgangle-animation-deg-to-grad.html
new file mode 100644 (file)
index 0000000..b6fd5b2
--- /dev/null
@@ -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/svgangle-animation-deg-to-grad.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/svgangle-animation-deg-to-rad-expected.txt b/LayoutTests/svg/animations/svgangle-animation-deg-to-rad-expected.txt
new file mode 100644 (file)
index 0000000..c4f2268
--- /dev/null
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Tests SVGAngle animation from deg to rad.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS marker.orientAngle.animVal.value is 90
+PASS marker.orientAngle.baseVal.value is 90
+PASS marker.orientAngle.animVal.value is 180
+PASS marker.orientAngle.baseVal.value is 180
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/svgangle-animation-deg-to-rad.html b/LayoutTests/svg/animations/svgangle-animation-deg-to-rad.html
new file mode 100644 (file)
index 0000000..c47658d
--- /dev/null
@@ -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/svgangle-animation-deg-to-rad.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/svgangle-animation-grad-to-deg-expected.txt b/LayoutTests/svg/animations/svgangle-animation-grad-to-deg-expected.txt
new file mode 100644 (file)
index 0000000..8973ac0
--- /dev/null
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Tests SVGAngle animation from grad to deg.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS marker.orientAngle.animVal.value is 90
+PASS marker.orientAngle.baseVal.value is 90
+PASS marker.orientAngle.animVal.value is 180
+PASS marker.orientAngle.baseVal.value is 180
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/svgangle-animation-grad-to-deg.html b/LayoutTests/svg/animations/svgangle-animation-grad-to-deg.html
new file mode 100644 (file)
index 0000000..2842592
--- /dev/null
@@ -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/svgangle-animation-grad-to-deg.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/svgangle-animation-grad-to-rad-expected.txt b/LayoutTests/svg/animations/svgangle-animation-grad-to-rad-expected.txt
new file mode 100644 (file)
index 0000000..fe0e6db
--- /dev/null
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Tests SVGAngle animation from grad to rad.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS marker.orientAngle.animVal.value is 90
+PASS marker.orientAngle.baseVal.value is 90
+PASS marker.orientAngle.animVal.value is 180
+PASS marker.orientAngle.baseVal.value is 180
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/svgangle-animation-grad-to-rad.html b/LayoutTests/svg/animations/svgangle-animation-grad-to-rad.html
new file mode 100644 (file)
index 0000000..5260b0d
--- /dev/null
@@ -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/svgangle-animation-grad-to-rad.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/svgangle-animation-rad-to-deg-expected.txt b/LayoutTests/svg/animations/svgangle-animation-rad-to-deg-expected.txt
new file mode 100644 (file)
index 0000000..8b6c151
--- /dev/null
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Tests SVGAngle animation from rad to deg.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS marker.orientAngle.animVal.value is 90
+PASS marker.orientAngle.baseVal.value is 90
+PASS marker.orientAngle.animVal.value is 180
+PASS marker.orientAngle.baseVal.value is 180
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/svgangle-animation-rad-to-deg.html b/LayoutTests/svg/animations/svgangle-animation-rad-to-deg.html
new file mode 100644 (file)
index 0000000..ac04cbe
--- /dev/null
@@ -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/svgangle-animation-rad-to-deg.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/svg/animations/svgangle-animation-rad-to-grad-expected.txt b/LayoutTests/svg/animations/svgangle-animation-rad-to-grad-expected.txt
new file mode 100644 (file)
index 0000000..fd0a94b
--- /dev/null
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Tests SVGAngle animation from rad to grad.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS marker.orientAngle.animVal.value is 90
+PASS marker.orientAngle.baseVal.value is 90
+PASS marker.orientAngle.animVal.value is 180
+PASS marker.orientAngle.baseVal.value is 180
+PASS marker.orientAngle.animVal.value is 0
+PASS marker.orientAngle.baseVal.value is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/animations/svgangle-animation-rad-to-grad.html b/LayoutTests/svg/animations/svgangle-animation-rad-to-grad.html
new file mode 100644 (file)
index 0000000..8834cc4
--- /dev/null
@@ -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/svgangle-animation-rad-to-grad.js"></script>
+</body>
+</html>
index 67f9dde..219206a 100644 (file)
@@ -1652,6 +1652,7 @@ IF (ENABLE_SVG)
         svg/SVGAltGlyphElement.cpp
         svg/SVGAngle.cpp
         svg/SVGAnimateColorElement.cpp
+        svg/SVGAnimatedAngle.cpp
         svg/SVGAnimatedLength.cpp
         svg/SVGAnimateElement.cpp
         svg/SVGAnimateMotionElement.cpp
index c6df6b3..9e77111 100644 (file)
@@ -1,3 +1,68 @@
+2011-06-17  Dirk Schulze  <krit@webkit.org>
+
+        Reviewed by Rob Buis.
+
+        SVGAnimation should use direct unit animation for SVGAngle
+        https://bugs.webkit.org/show_bug.cgi?id=62807
+
+        Follow up of "SVGAnimation should use direct unit animation for SVGLength": https://bugs.webkit.org/show_bug.cgi?id=61368
+        This patch continues the conversion to the new concept of SVGAnimatorFactory with SVGAngle. We can animate the SVG primitive datatype SVGAngle
+        with different unit types now.
+        Removed number and unit parser from SVGAnimateElement. This is not needed anymore.
+
+        Tests: svg/animations/svgangle-animation-deg-to-grad.html
+               svg/animations/svgangle-animation-deg-to-rad.html
+               svg/animations/svgangle-animation-grad-to-deg.html
+               svg/animations/svgangle-animation-grad-to-rad.html
+               svg/animations/svgangle-animation-rad-to-deg.html
+               svg/animations/svgangle-animation-rad-to-grad.html
+
+        * CMakeLists.txt: Added SVGAnimatedAngle.cpp.
+        * GNUmakefile.list.am: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.pro: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * svg/SVGAllInOne.cpp: Ditto.
+        * svg/SVGAnimateElement.cpp: Make use of SVGAnimator for AnimatedAngle.
+        (WebCore::SVGAnimateElement::SVGAnimateElement):
+        (WebCore::SVGAnimateElement::determineAnimatedAttributeType): Ditto.
+        (WebCore::SVGAnimateElement::calculateAnimatedValue): Ditto.
+        (WebCore::SVGAnimateElement::calculateFromAndToValues): Ditto.
+        (WebCore::SVGAnimateElement::calculateFromAndByValues): Ditto.
+        (WebCore::SVGAnimateElement::resetToBaseValue): Ditto.
+        (WebCore::SVGAnimateElement::applyResultsToTarget): Ditto.
+        (WebCore::SVGAnimateElement::calculateDistance): Ditto.
+        * svg/SVGAnimateElement.h:
+        * svg/SVGAnimatedAngle.cpp: Added. Added SVGAnimatedAngleAnimator for animation of SVGAngles.
+        (WebCore::SVGAnimatedAngleAnimator::SVGAnimatedAngleAnimator):
+        (WebCore::sharedSVGAngle):
+        (WebCore::SVGAnimatedAngleAnimator::constructFromString):
+        (WebCore::SVGAnimatedAngleAnimator::calculateFromAndToValues):
+        (WebCore::SVGAnimatedAngleAnimator::calculateFromAndByValues):
+        (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue):
+        (WebCore::SVGAnimatedAngleAnimator::calculateDistance):
+        * svg/SVGAnimatedAngle.h:
+        (WebCore::SVGAnimatedAngleAnimator::~SVGAnimatedAngleAnimator):
+        * svg/SVGAnimatedLength.cpp:
+        (WebCore::sharedSVGLength): Use an ExceptionCode for SVGLength::setValueAsString.
+        * svg/SVGAnimatedType.h:
+        (WebCore::SVGAnimatedType::create):
+        (WebCore::SVGAnimatedType::createAngle):
+        (WebCore::SVGAnimatedType::createLength):
+        (WebCore::SVGAnimatedType::~SVGAnimatedType):
+        (WebCore::SVGAnimatedType::angle):
+        (WebCore::SVGAnimatedType::valueAsString):
+        (WebCore::SVGAnimatedType::setValueAsString):
+        (WebCore::SVGAnimatedType::SVGAnimatedType):
+        * svg/SVGAnimatorFactory.h:
+        (WebCore::SVGAnimatorFactory::create):
+        * svg/SVGLength.cpp:
+        (WebCore::SVGLength::setValueAsString): Added an ExceptionCode for consistency reasons and as preparation for future error handling.
+        * svg/SVGLength.h:
+        * svg/SVGParserUtilities.cpp:
+        (WebCore::parseNumberFromString): Added number parser for String objects.
+        * svg/SVGParserUtilities.h:
+
 2011-06-17  Anna Cavender  <annacc@chromium.org>
 
         Reviewed by Eric Carlson.
index 0136c89..07ad7ed 100644 (file)
@@ -3335,6 +3335,7 @@ webcore_sources += \
        Source/WebCore/svg/SVGAngle.h \
        Source/WebCore/svg/SVGAnimateColorElement.cpp \
        Source/WebCore/svg/SVGAnimateColorElement.h \
+       Source/WebCore/svg/SVGAnimatedAngle.cpp \
        Source/WebCore/svg/SVGAnimatedAngle.h \
        Source/WebCore/svg/SVGAnimatedBoolean.h \
        Source/WebCore/svg/SVGAnimatedEnumeration.h \
index 153df32..0f77517 100644 (file)
             'svg/SVGAngle.cpp',
             'svg/SVGAnimateColorElement.cpp',
             'svg/SVGAnimateColorElement.h',
+            'svg/SVGAnimatedAngle.cpp',
             'svg/SVGAnimatedLength.cpp',
             'svg/SVGAnimateElement.cpp',
             'svg/SVGAnimateElement.h',
index c7ab2c7..aa8fca5 100644 (file)
@@ -3292,6 +3292,7 @@ contains(DEFINES, ENABLE_SVG=1) {
               svg/SVGAltGlyphElement.cpp \
               svg/SVGAngle.cpp \
               svg/SVGAnimateColorElement.cpp \
+              svg/SVGAnimatedAngle.cpp \
               svg/SVGAnimatedLength.cpp \
               svg/SVGAnimateElement.cpp \
               svg/SVGAnimateMotionElement.cpp \
index f46b42e..96f954a 100644 (file)
                4358E8811360A31700E4748C /* FEDropShadow.h in Headers */ = {isa = PBXBuildFile; fileRef = 4358E87F1360A31700E4748C /* FEDropShadow.h */; };
                4358E8851360A33B00E4748C /* SVGFEDropShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4358E8821360A33B00E4748C /* SVGFEDropShadowElement.cpp */; };
                4358E8861360A33B00E4748C /* SVGFEDropShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4358E8831360A33B00E4748C /* SVGFEDropShadowElement.h */; };
+               4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */; };
                436708C112D9CA4B00044234 /* RenderSVGBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088212D9CA4A00044234 /* RenderSVGBlock.h */; };
                436708C312D9CA4B00044234 /* RenderSVGContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088412D9CA4A00044234 /* RenderSVGContainer.h */; };
                436708C512D9CA4B00044234 /* RenderSVGGradientStop.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088612D9CA4A00044234 /* RenderSVGGradientStop.h */; };
                4358E8821360A33B00E4748C /* SVGFEDropShadowElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFEDropShadowElement.cpp; sourceTree = "<group>"; };
                4358E8831360A33B00E4748C /* SVGFEDropShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFEDropShadowElement.h; sourceTree = "<group>"; };
                4358E8841360A33B00E4748C /* SVGFEDropShadowElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGFEDropShadowElement.idl; sourceTree = "<group>"; };
+               4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedAngle.cpp; sourceTree = "<group>"; };
                4367088112D9CA4A00044234 /* RenderSVGBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGBlock.cpp; sourceTree = "<group>"; };
                4367088212D9CA4A00044234 /* RenderSVGBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGBlock.h; sourceTree = "<group>"; };
                4367088312D9CA4A00044234 /* RenderSVGContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGContainer.cpp; sourceTree = "<group>"; };
                                B22277E30D00BF1F0071B782 /* SVGAnimateColorElement.cpp */,
                                B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */,
                                B22277E50D00BF1F0071B782 /* SVGAnimateColorElement.idl */,
+                               4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */,
                                087B84951272CEC700A14417 /* SVGAnimatedAngle.h */,
                                B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */,
                                085797081278394C00A8EC5F /* SVGAnimatedBoolean.h */,
                                B1AD4E6A13A12A0B00846B27 /* TextTrackCueList.cpp in Sources */,
                                B1AD4E7313A12A4600846B27 /* CueLoader.cpp in Sources */,
                                B1AD4E7B13A12A7200846B27 /* CueParser.cpp in Sources */,
+                               4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 662220d..48a0048 100644 (file)
@@ -30,6 +30,7 @@
 #include "SVGAltGlyphElement.cpp"
 #include "SVGAngle.cpp"
 #include "SVGAnimateColorElement.cpp"
+#include "SVGAnimatedAngle.cpp"
 #include "SVGAnimatedLength.cpp"
 #include "SVGAnimateElement.cpp"
 #include "SVGAnimateMotionElement.cpp"
index d0fc484..534235c 100644 (file)
@@ -50,7 +50,7 @@ SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, Document* doc
     , m_animatedAttributeType(AnimatedString)
     , m_fromNumber(0)
     , m_toNumber(0)
-    , m_animatedNumber(numeric_limits<double>::infinity())
+    , m_animatedNumber(numeric_limits<float>::infinity())
     , m_animatedPathPointer(0)
 {
     ASSERT(hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::setTag) || hasTagName(SVGNames::animateColorTag));
@@ -65,30 +65,6 @@ SVGAnimateElement::~SVGAnimateElement()
 {
 }
 
-static bool parseNumberValueAndUnit(const String& in, double& value, String& unit)
-{
-    // FIXME: These are from top of my head, figure out all property types that can be animated as numbers.
-    unsigned unitLength = 0;
-    String parse = in.stripWhiteSpace();
-    if (parse.endsWith("%"))
-        unitLength = 1;
-    else if (parse.endsWith("deg") || parse.endsWith("rad"))
-        unitLength = 3;
-    else if (parse.endsWith("grad"))
-        unitLength = 4;
-    String newUnit = parse.right(unitLength);
-    String number = parse.left(parse.length() - unitLength);
-    if ((!unit.isEmpty() && newUnit != unit) || number.isEmpty())
-        return false;
-    UChar last = number[number.length() - 1];
-    if (last < '0' || last > '9')
-        return false;
-    unit = newUnit;
-    bool ok;
-    value = number.toDouble(&ok);
-    return ok;
-}
-
 void SVGAnimateElement::adjustForCurrentColor(SVGElement* targetElement, Color& color)
 {
     ASSERT(targetElement);
@@ -140,6 +116,8 @@ AnimatedAttributeType SVGAnimateElement::determineAnimatedAttributeType(SVGEleme
     // FIXME: We need type specific animations in the future. Many animations marked as AnimatedString today will
     // support continuous animations.
     switch (type) {
+    case AnimatedAngle:
+        return AnimatedAngle;
     case AnimatedBoolean:
     case AnimatedEnumeration:
     case AnimatedNumberList:
@@ -151,7 +129,6 @@ AnimatedAttributeType SVGAnimateElement::determineAnimatedAttributeType(SVGEleme
         return AnimatedString;
     case AnimatedLength:
         return AnimatedLength;
-    case AnimatedAngle:
     case AnimatedInteger:
     case AnimatedNumber:
         return AnimatedNumber;
@@ -201,17 +178,17 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
         if (m_fromPropertyValueType == InheritValue) {
             String fromNumberString;
             adjustForInheritance(targetElement, attributeName(), fromNumberString);
-            if (!parseNumberValueAndUnit(fromNumberString, m_fromNumber, m_numberUnit))
+            if (!parseNumberFromString(fromNumberString, m_fromNumber, false))
                 return;
         }
         if (m_toPropertyValueType == InheritValue) {
             String toNumberString;
             adjustForInheritance(targetElement, attributeName(), toNumberString);
-            if (!parseNumberValueAndUnit(toNumberString, m_toNumber, m_numberUnit))
+            if (!parseNumberFromString(toNumberString, m_toNumber, false))
                 return;
         }
 
-        double number;
+        float number;
         if (calcMode() == CalcModeDiscrete)
             number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber;
         else
@@ -309,6 +286,7 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
         }
         return;
     }
+    case AnimatedAngle:
     case AnimatedLength: {
         ASSERT(m_animator);
         ASSERT(results->m_animatedType);
@@ -380,10 +358,9 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const
         break;
     }
     case AnimatedNumber: {
-        m_numberUnit = String();
-        if (parseNumberValueAndUnit(toString, m_toNumber, m_numberUnit)) {
+        if (parseNumberFromString(toString, m_toNumber, false)) {
             // For to-animations the from number is calculated later
-            if (animationMode() == ToAnimation || parseNumberValueAndUnit(fromString, m_fromNumber, m_numberUnit))
+            if (animationMode() == ToAnimation || parseNumberFromString(fromString, m_fromNumber, false))
                 return true;
         }
         break;
@@ -408,10 +385,10 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const
         }
         break;
     }
-    case AnimatedLength: {
+    case AnimatedAngle:
+    case AnimatedLength:
         ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
         return true;
-    }
     default:
         break;
     }
@@ -449,17 +426,15 @@ bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const
             return false;
         return true;
     }
-    case AnimatedLength: {
+    case AnimatedAngle:
+    case AnimatedLength:
         ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
         return true;
-
-    }
     default:
-        m_numberUnit = String();
         m_fromNumber = 0;
-        if (!fromString.isEmpty() && !parseNumberValueAndUnit(fromString, m_fromNumber, m_numberUnit))
+        if (!fromString.isEmpty() && !parseNumberFromString(fromString, m_fromNumber, false))
             return false;
-        if (!parseNumberValueAndUnit(byString, m_toNumber, m_numberUnit))
+        if (!parseNumberFromString(byString, m_toNumber, false))
             return false;
         m_toNumber += m_fromNumber;
     }
@@ -484,10 +459,9 @@ void SVGAnimateElement::resetToBaseValue(const String& baseString)
     case AnimatedNumber:
         if (baseString.isEmpty()) {
             m_animatedNumber = 0;
-            m_numberUnit = String();
             return;
         }
-        if (parseNumberValueAndUnit(baseString, m_animatedNumber, m_numberUnit))
+        if (parseNumberFromString(baseString, m_animatedNumber, false))
             return;
         break;
     case AnimatedPath: {
@@ -500,8 +474,12 @@ void SVGAnimateElement::resetToBaseValue(const String& baseString)
     case AnimatedPoints:
         m_animatedPoints.clear();
         return;
+    case AnimatedAngle:
     case AnimatedLength: {
-        m_animatedType = ensureAnimator()->constructFromString(baseString);
+        if (!m_animatedType)
+            m_animatedType = ensureAnimator()->constructFromString(baseString);
+        else
+            m_animatedType->setValueAsString(attributeName(), baseString);
         return;
     }
     default:
@@ -513,11 +491,14 @@ void SVGAnimateElement::resetToBaseValue(const String& baseString)
 void SVGAnimateElement::applyResultsToTarget()
 {
     String valueToApply;
-    if (m_animatedAttributeType == AnimatedColor)
+    switch (m_animatedAttributeType) {
+    case AnimatedColor:
         valueToApply = m_animatedColor.serialized();
-    else if (m_animatedAttributeType == AnimatedNumber)
-        valueToApply = String::number(m_animatedNumber) + m_numberUnit;
-    else if (m_animatedAttributeType == AnimatedPath) {
+        break;
+    case AnimatedNumber:
+        valueToApply = String::number(m_animatedNumber);
+        break;
+    case AnimatedPath: {
         if (!m_animatedPathPointer || m_animatedPathPointer->isEmpty())
             valueToApply = m_animatedString;
         else {
@@ -528,13 +509,18 @@ void SVGAnimateElement::applyResultsToTarget()
             SVGPathParserFactory* factory = SVGPathParserFactory::self();
             factory->buildStringFromByteStream(m_animatedPathPointer, valueToApply, UnalteredParsing);
         }
-    } else if (m_animatedAttributeType == AnimatedPoints)
+        break;
+    }
+    case AnimatedPoints:
         valueToApply = m_animatedPoints.isEmpty() ? m_animatedString : m_animatedPoints.valueAsString();
-    else if (m_animatedAttributeType == AnimatedLength)
-        valueToApply = m_animatedType->length().valueAsString();
-    else
+        break;
+    case AnimatedAngle:
+    case AnimatedLength:
+        valueToApply = m_animatedType->valueAsString();
+        break;
+    default:
         valueToApply = m_animatedString;
-    
+    }
     setTargetAttributeAnimatedValue(valueToApply);
 }
     
@@ -545,14 +531,13 @@ float SVGAnimateElement::calculateDistance(const String& fromString, const Strin
         return -1;
     m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
     if (m_animatedAttributeType == AnimatedNumber) {
-        double from;
-        double to;
-        String unit;
-        if (!parseNumberValueAndUnit(fromString, from, unit))
+        float from;
+        float to;
+        if (!parseNumberFromString(fromString, from, false))
             return -1;
-        if (!parseNumberValueAndUnit(toString, to, unit))
+        if (!parseNumberFromString(toString, to, false))
             return -1;
-        return narrowPrecisionToFloat(fabs(to - from));
+        return fabs(to - from);
     }
     if (m_animatedAttributeType == AnimatedColor) {
         Color from = SVGColor::colorFromRGBColorString(fromString);
@@ -563,7 +548,7 @@ float SVGAnimateElement::calculateDistance(const String& fromString, const Strin
             return -1;
         return ColorDistance(from, to).distance();
     }
-    if (m_animatedAttributeType == AnimatedLength)
+    if (m_animatedAttributeType == AnimatedAngle || m_animatedAttributeType == AnimatedLength)
         return ensureAnimator()->calculateDistance(this, fromString, toString);
     return -1;
 }
index ee492e6..dc02974 100644 (file)
@@ -72,10 +72,9 @@ private:
 
     AnimatedPropertyValueType m_fromPropertyValueType;
     AnimatedPropertyValueType m_toPropertyValueType;
-    double m_fromNumber;
-    double m_toNumber;
-    double m_animatedNumber;
-    String m_numberUnit;
+    float m_fromNumber;
+    float m_toNumber;
+    float m_animatedNumber;
     Color m_fromColor;
     Color m_toColor;
     Color m_animatedColor;
diff --git a/Source/WebCore/svg/SVGAnimatedAngle.cpp b/Source/WebCore/svg/SVGAnimatedAngle.cpp
new file mode 100644 (file)
index 0000000..eeee765
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimatedAngle.h"
+
+namespace WebCore {
+
+SVGAnimatedAngleAnimator::SVGAnimatedAngleAnimator(SVGElement* contextElement, const QualifiedName&)
+    : SVGAnimatedTypeAnimator(AnimatedAngle, contextElement)
+{
+}
+
+static inline SVGAngle& sharedSVGAngle(const String& valueAsString)
+{
+    DEFINE_STATIC_LOCAL(SVGAngle, sharedAngle, ());
+    ExceptionCode ec = 0;
+    sharedAngle.setValueAsString(valueAsString, ec);
+    ASSERT(!ec);
+    return sharedAngle;
+}
+
+PassOwnPtr<SVGAnimatedType> SVGAnimatedAngleAnimator::constructFromString(const String& string)
+{
+    OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createAngle(new SVGAngle());
+    ExceptionCode ec = 0;
+    animatedType->angle().setValueAsString(string, ec);
+    ASSERT(!ec);
+    return animatedType.release();
+}
+
+void SVGAnimatedAngleAnimator::calculateFromAndToValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& toString)
+{
+    from = constructFromString(fromString);
+    to = constructFromString(toString);
+}
+
+void SVGAnimatedAngleAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& byString)
+{
+    ASSERT(m_contextElement);
+    
+    from = constructFromString(fromString);
+    to = constructFromString(byString);
+    
+    SVGAngle& fromAngle = from->angle();
+    SVGAngle& toAngle = to->angle();
+    toAngle.setValue(toAngle.value() + fromAngle.value());
+}
+
+void SVGAnimatedAngleAnimator::calculateAnimatedValue(SVGSMILElement* smilElement, float percentage, unsigned repeatCount,
+                                                      OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, OwnPtr<SVGAnimatedType>& animated,
+                                                      bool fromPropertyInherits, bool toPropertyInherits)
+{
+    ASSERT(smilElement);
+    ASSERT(m_contextElement);
+    SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(smilElement);
+    
+    AnimationMode animationMode = animationElement->animationMode();
+    // To animation uses contributions from the lower priority animations as the base value.
+    // FIXME: Avoid string parsing.
+    if (animationMode == ToAnimation)
+        from = constructFromString(animated->angle().valueAsString());
+    
+    // Replace 'inherit' by their computed property values.
+    float number;
+    float fromAngle = from->angle().value();
+    float toAngle = to->angle().value();
+    
+    if (fromPropertyInherits) {
+        String fromAngleString;
+        animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), fromAngleString);
+        fromAngle = sharedSVGAngle(fromAngleString).value();
+    }
+    if (toPropertyInherits) {
+        String toAngleString;
+        animationElement->adjustForInheritance(m_contextElement, animationElement->attributeName(), toAngleString);
+        toAngle = sharedSVGAngle(toAngleString).value(); 
+    }
+    
+    if (animationElement->calcMode() == CalcModeDiscrete)
+        number = percentage < 0.5f ? fromAngle : toAngle;
+    else
+        number = (toAngle - fromAngle) * percentage + fromAngle;
+    
+    // FIXME: This is not correct for values animation.
+    if (animationElement->isAccumulated() && repeatCount)
+        number += toAngle * repeatCount;
+    SVGAngle& animatedSVGAngle = animated->angle();
+    if (animationElement->isAdditive() && animationMode != ToAnimation) {
+        float animatedSVGAngleValue = animatedSVGAngle.value();
+        animatedSVGAngleValue += number;
+        animatedSVGAngle.setValue(animatedSVGAngleValue);
+    } else
+        animatedSVGAngle.setValue(number);
+}
+
+float SVGAnimatedAngleAnimator::calculateDistance(SVGSMILElement*, const String& fromString, const String& toString)
+{
+    ExceptionCode ec = 0;
+    SVGAngle from = SVGAngle();
+    from.setValueAsString(fromString, ec);
+    ASSERT(!ec);
+    SVGAngle to = SVGAngle();
+    to.setValueAsString(toString, ec);
+    ASSERT(!ec);
+    return fabsf(to.value() - from.value());
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)
index a4ded8f..1899878 100644 (file)
@@ -22,6 +22,7 @@
 
 #if ENABLE(SVG)
 #include "SVGAngle.h"
+#include "SVGAnimateElement.h"
 #include "SVGAnimatedPropertyTearOff.h"
 
 namespace WebCore {
@@ -35,7 +36,24 @@ DECLARE_ANIMATED_PROPERTY(SVGAnimatedAngle, SVGAngle, UpperProperty, LowerProper
 #define DEFINE_ANIMATED_ANGLE_MULTIPLE_WRAPPERS(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, UpperProperty, LowerProperty) \
 DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, SVGAnimatedAngle, SVGAngle, UpperProperty, LowerProperty)
 
+#if ENABLE(SVG_ANIMATION)
+class SVGAnimatedAngleAnimator : public SVGAnimatedTypeAnimator {
+    
+public:
+    SVGAnimatedAngleAnimator(SVGElement* contextElement, const QualifiedName&);
+    virtual ~SVGAnimatedAngleAnimator() { }
+    
+    virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&);
+    
+    virtual void calculateFromAndToValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& toString);
+    virtual void calculateFromAndByValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& byString);
+    virtual void calculateAnimatedValue(SVGSMILElement*, float percentage, unsigned repeatCount,
+                                        OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, OwnPtr<SVGAnimatedType>& animatedValue,
+                                        bool fromPropertyInherits, bool toPropertyInherits);
+    virtual float calculateDistance(SVGSMILElement*, const String& fromString, const String& toString);
+};
 } // namespace WebCore
 
+#endif // ENABLE(SVG_ANIMATION)
 #endif // ENABLE(SVG)
 #endif
index 4a1efdd..1886817 100644 (file)
@@ -33,7 +33,9 @@ SVGAnimatedLengthAnimator::SVGAnimatedLengthAnimator(SVGElement* contextElement,
 static inline SVGLength& sharedSVGLength(SVGLengthMode mode, const String& valueAsString)
 {
     DEFINE_STATIC_LOCAL(SVGLength, sharedLength, ());
-    sharedLength.setValueAsString(valueAsString, mode);
+    ExceptionCode ec = 0;
+    sharedLength.setValueAsString(valueAsString, mode, ec);
+    ASSERT(!ec);
     return sharedLength;
 }
 
index a3e4b30..1cd70a4 100644 (file)
@@ -21,7 +21,7 @@
 #define SVGAnimatedType_h
 
 #if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
-#include "SVGAnimateElement.h"
+#include "SVGAngle.h"
 #include "SVGElement.h"
 #include "SVGLength.h"
 
@@ -30,30 +30,95 @@ namespace WebCore {
 class SVGAnimatedType {
     WTF_MAKE_FAST_ALLOCATED;
 public:
+    static PassOwnPtr<SVGAnimatedType> create(AnimatedAttributeType type)
+    {
+        return adoptPtr(new SVGAnimatedType(type));
+    }
+
+    static PassOwnPtr<SVGAnimatedType> createAngle(SVGAngle* angle)
+    {
+        ASSERT(angle);
+        OwnPtr<SVGAnimatedType> animatedType = create(AnimatedAngle);
+        animatedType->m_data.angle = angle;
+        return animatedType.release();
+    }
+
     static PassOwnPtr<SVGAnimatedType> createLength(SVGLength* length)
     {
-        return adoptPtr(new SVGAnimatedType(AnimatedLength, length));
+        ASSERT(length);
+        OwnPtr<SVGAnimatedType> animatedType = create(AnimatedLength);
+        animatedType->m_data.length = length;
+        return animatedType.release();
     }
 
     virtual ~SVGAnimatedType()
     {
-        ASSERT(m_type == AnimatedLength);
-        delete m_data.length;
+        switch (m_type) {
+        case AnimatedAngle:
+            delete m_data.angle;
+            break;
+        case AnimatedLength:
+            delete m_data.length;
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+        }
     }
     
     AnimatedAttributeType type() const { return m_type; }
-    
+
+    SVGAngle& angle()
+    {
+        ASSERT(m_type == AnimatedAngle);
+        return *m_data.angle;
+    }
+
     SVGLength& length()
     {
         ASSERT(m_type == AnimatedLength);
         return *m_data.length;
     }
     
+    String valueAsString()
+    {
+        switch (m_type) {
+        case AnimatedAngle:
+            ASSERT(m_data.angle);
+            return m_data.angle->valueAsString();
+        case AnimatedLength:
+            ASSERT(m_data.length);
+            return m_data.length->valueAsString();
+        default:
+            break;
+        }
+        ASSERT_NOT_REACHED();
+        return String();
+    }
+    
+    bool setValueAsString(const QualifiedName& attrName, const String& value)
+    {
+        ExceptionCode ec = 0;
+        switch (m_type) {
+        case AnimatedAngle:
+            ASSERT(m_data.angle);
+            m_data.angle->setValueAsString(value, ec);
+            break;
+        case AnimatedLength:
+            ASSERT(m_data.length);
+            m_data.length->setValueAsString(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName), ec);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+        }
+        return !ec;
+    }
+    
 private:
-    SVGAnimatedType(AnimatedAttributeType type, SVGLength* length)
+    SVGAnimatedType(AnimatedAttributeType type)
         : m_type(type)
     {
-        m_data.length = length;
     }
     
     AnimatedAttributeType m_type;
@@ -65,6 +130,7 @@ private:
         }
         
         // FIXME: More SVG primitive types need to be added step by step.
+        SVGAngle* angle;
         SVGLength* length;
     } m_data;
 };
index 3b1df9f..1ecb0f4 100644 (file)
@@ -21,6 +21,7 @@
 #define SVGAnimatorFactory_h
 
 #if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimatedAngle.h"
 #include "SVGAnimatedLength.h"
 
 namespace WebCore {
@@ -31,6 +32,8 @@ public:
     {
         // FIXME: Add animation support for all SVG units.
         switch (attributeType) {
+        case AnimatedAngle:
+            return adoptPtr(new SVGAnimatedAngleAnimator(contextElement, attributeName));
         case AnimatedLength:
             return adoptPtr(new SVGAnimatedLengthAnimator(contextElement, attributeName));
         default:
index 33c13a0..d3fa279 100644 (file)
@@ -132,13 +132,11 @@ SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString)
     setValueAsString(valueAsString, ec);
 }
     
-void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode)
+void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionCode& ec)
 {
     m_valueInSpecifiedUnits = 0;
     m_unit = storeUnit(mode, LengthTypeNumber);
-    ExceptionCode ec = 0;
     setValueAsString(valueAsString, ec);
-    ASSERT(!ec);
 }
 
 SVGLength::SVGLength(const SVGLength& other)
index 0f9a87c..94f47db 100644 (file)
@@ -88,7 +88,7 @@ public:
 
     String valueAsString() const;
     void setValueAsString(const String&, ExceptionCode&);
-    void setValueAsString(const String&, SVGLengthMode);
+    void setValueAsString(const String&, SVGLengthMode, ExceptionCode&);
     
     void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits, ExceptionCode&);
     void convertToSpecifiedUnits(unsigned short, const SVGElement* context, ExceptionCode&);
index 0405230..c117c7a 100644 (file)
@@ -147,6 +147,13 @@ bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip)
     return genericParseNumber(ptr, end, number, skip);
 }
 
+bool parseNumberFromString(const String& string, float& number, bool skip)
+{
+    const UChar* ptr = string.characters();
+    const UChar* end = ptr + string.length();
+    return genericParseNumber(ptr, end, number, skip);
+}
+
 // only used to parse largeArcFlag and sweepFlag which must be a "0" or "1"
 // and might not have any whitespace/comma after it
 bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag)
index da8ac1f..921da6a 100644 (file)
@@ -33,6 +33,7 @@ namespace WebCore {
 class SVGPointList;
 
 bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true);
+bool parseNumberFromString(const String&, float& number, bool skip = true);
 bool parseNumberOptionalNumber(const String& s, float& h, float& v);
 bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag);