Title: [113008] trunk
Revision
113008
Author
[email protected]
Date
2012-04-03 03:36:01 -0700 (Tue, 03 Apr 2012)

Log Message

Animate animatedPoints instead of points for SVGPoly*Elements
https://bugs.webkit.org/show_bug.cgi?id=82844

Reviewed by Dirk Schulze.

Source/WebCore:

When the points attribute of a SVGPoly*Element is animated, we should animate
the 'animatedPoints' SVG DOM property, not the 'points' property, which corresponds
to the "baseVal". Fix that, now only the 'd' attribute for SVGPathElement is incorrect,
everything else is moved to the new animVal concept!

* svg/SVGAnimatedPointList.cpp:
(WebCore::SVGAnimatedPointListAnimator::startAnimValAnimation):
(WebCore::SVGAnimatedPointListAnimator::stopAnimValAnimation):
(WebCore::SVGAnimatedPointListAnimator::resetAnimValToBaseVal):
(WebCore::SVGAnimatedPointListAnimator::animValWillChange):
(WebCore::SVGAnimatedPointListAnimator::animValDidChange):
* svg/SVGAnimatedPointList.h:
(SVGAnimatedPointListAnimator):
* svg/SVGAnimatedType.cpp:
(WebCore::SVGAnimatedType::valueAsString):
(WebCore::SVGAnimatedType::setValueAsString):
(WebCore::SVGAnimatedType::supportsAnimVal):
* svg/SVGPolyElement.cpp:
(WebCore::SVGPolyElement::parseAttribute):
(WebCore::SVGPolyElement::lookupOrCreatePointsWrapper):
(WebCore::SVGPolyElement::points):
(WebCore::SVGPolyElement::animatedPoints):

LayoutTests:

Update SVGPointList animation tests, verifying that animatedPoints is animated, and not points.

* svg/animations/script-tests/svgpointlist-animation-1.js:
(sample1):
(sample2):
(sample3):
* svg/animations/script-tests/svgpointlist-animation-2.js:
(sample1):
(sample2):
(sample3):
* svg/animations/svgpointlist-animation-1-expected.txt:
* svg/animations/svgpointlist-animation-2-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (113007 => 113008)


--- trunk/LayoutTests/ChangeLog	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/LayoutTests/ChangeLog	2012-04-03 10:36:01 UTC (rev 113008)
@@ -1,3 +1,23 @@
+2012-04-01  Nikolas Zimmermann  <[email protected]>
+
+        Animate animatedPoints instead of points for SVGPoly*Elements
+        https://bugs.webkit.org/show_bug.cgi?id=82844
+
+        Reviewed by Dirk Schulze.
+
+        Update SVGPointList animation tests, verifying that animatedPoints is animated, and not points.
+
+        * svg/animations/script-tests/svgpointlist-animation-1.js:
+        (sample1):
+        (sample2):
+        (sample3):
+        * svg/animations/script-tests/svgpointlist-animation-2.js:
+        (sample1):
+        (sample2):
+        (sample3):
+        * svg/animations/svgpointlist-animation-1-expected.txt:
+        * svg/animations/svgpointlist-animation-2-expected.txt:
+
 2012-04-03  Philippe Normand  <[email protected]>
 
         [GTK] media/video-volume.html fails on 32-bits debug

Modified: trunk/LayoutTests/svg/animations/script-tests/svgpointlist-animation-1.js (113007 => 113008)


--- trunk/LayoutTests/svg/animations/script-tests/svgpointlist-animation-1.js	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/LayoutTests/svg/animations/script-tests/svgpointlist-animation-1.js	2012-04-03 10:36:01 UTC (rev 113008)
@@ -21,26 +21,29 @@
 // Setup animation test
 function sample1() {
     // Check initial/end conditions
-    shouldBeCloseEnough("poly.points.getItem(2).x", "200");
-    shouldBeCloseEnough("poly.points.getItem(2).y", "200");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "200");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "200");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "200");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "200");
+
+    shouldBe("poly.points.getItem(2).x", "200");
+    shouldBe("poly.points.getItem(2).y", "200");
 }
 
 function sample2() {
     // Check half-time conditions
-    shouldBeCloseEnough("poly.points.getItem(2).x", "150");
-    shouldBeCloseEnough("poly.points.getItem(2).y", "150");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "250");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "250");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "150");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "150");
+
+    shouldBe("poly.points.getItem(2).x", "200");
+    shouldBe("poly.points.getItem(2).y", "200");
 }
 
 function sample3() {
     // Check just before-end conditions
-    shouldBeCloseEnough("poly.points.getItem(2).x", "100");
-    shouldBeCloseEnough("poly.points.getItem(2).y", "100");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "300");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "300");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "100");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "100");
+
+    shouldBe("poly.points.getItem(2).x", "200");
+    shouldBe("poly.points.getItem(2).y", "200");
 }
 
 function executeTest() {

Modified: trunk/LayoutTests/svg/animations/script-tests/svgpointlist-animation-2.js (113007 => 113008)


--- trunk/LayoutTests/svg/animations/script-tests/svgpointlist-animation-2.js	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/LayoutTests/svg/animations/script-tests/svgpointlist-animation-2.js	2012-04-03 10:36:01 UTC (rev 113008)
@@ -21,26 +21,29 @@
 // Setup animation test
 function sample1() {
     // Check initial/end conditions
-    shouldBeCloseEnough("poly.points.getItem(2).x", "200");
-    shouldBeCloseEnough("poly.points.getItem(2).y", "200");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "200");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "200");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "200");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "200");
+
+    shouldBe("poly.points.getItem(2).x", "200");
+    shouldBe("poly.points.getItem(2).y", "200");
 }
 
 function sample2() {
     // Check half-time conditions
-    shouldBeCloseEnough("poly.points.getItem(2).x", "250");
-    shouldBeCloseEnough("poly.points.getItem(2).y", "250");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "250");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "250");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "250");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "250");
+
+    shouldBe("poly.points.getItem(2).x", "200");
+    shouldBe("poly.points.getItem(2).y", "200");
 }
 
 function sample3() {
     // Check just before-end conditions
-    shouldBeCloseEnough("poly.points.getItem(2).x", "300");
-    shouldBeCloseEnough("poly.points.getItem(2).y", "300");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "300");
-    // shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "300");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "300");
+    shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "300");
+
+    shouldBe("poly.points.getItem(2).x", "200");
+    shouldBe("poly.points.getItem(2).y", "200");
 }
 
 function executeTest() {

Modified: trunk/LayoutTests/svg/animations/svgpointlist-animation-1-expected.txt (113007 => 113008)


--- trunk/LayoutTests/svg/animations/svgpointlist-animation-1-expected.txt	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/LayoutTests/svg/animations/svgpointlist-animation-1-expected.txt	2012-04-03 10:36:01 UTC (rev 113008)
@@ -5,14 +5,22 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS poly.animatedPoints.getItem(2).x is 200
+PASS poly.animatedPoints.getItem(2).y is 200
 PASS poly.points.getItem(2).x is 200
 PASS poly.points.getItem(2).y is 200
-PASS poly.points.getItem(2).x is 150
-PASS poly.points.getItem(2).y is 150
-PASS poly.points.getItem(2).x is 100
-PASS poly.points.getItem(2).y is 100
+PASS poly.animatedPoints.getItem(2).x is 150
+PASS poly.animatedPoints.getItem(2).y is 150
 PASS poly.points.getItem(2).x is 200
 PASS poly.points.getItem(2).y is 200
+PASS poly.animatedPoints.getItem(2).x is 100
+PASS poly.animatedPoints.getItem(2).y is 100
+PASS poly.points.getItem(2).x is 200
+PASS poly.points.getItem(2).y is 200
+PASS poly.animatedPoints.getItem(2).x is 200
+PASS poly.animatedPoints.getItem(2).y is 200
+PASS poly.points.getItem(2).x is 200
+PASS poly.points.getItem(2).y is 200
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/svg/animations/svgpointlist-animation-2-expected.txt (113007 => 113008)


--- trunk/LayoutTests/svg/animations/svgpointlist-animation-2-expected.txt	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/LayoutTests/svg/animations/svgpointlist-animation-2-expected.txt	2012-04-03 10:36:01 UTC (rev 113008)
@@ -5,14 +5,22 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS poly.animatedPoints.getItem(2).x is 200
+PASS poly.animatedPoints.getItem(2).y is 200
 PASS poly.points.getItem(2).x is 200
 PASS poly.points.getItem(2).y is 200
-PASS poly.points.getItem(2).x is 250
-PASS poly.points.getItem(2).y is 250
-PASS poly.points.getItem(2).x is 300
-PASS poly.points.getItem(2).y is 300
+PASS poly.animatedPoints.getItem(2).x is 250
+PASS poly.animatedPoints.getItem(2).y is 250
 PASS poly.points.getItem(2).x is 200
 PASS poly.points.getItem(2).y is 200
+PASS poly.animatedPoints.getItem(2).x is 300
+PASS poly.animatedPoints.getItem(2).y is 300
+PASS poly.points.getItem(2).x is 200
+PASS poly.points.getItem(2).y is 200
+PASS poly.animatedPoints.getItem(2).x is 200
+PASS poly.animatedPoints.getItem(2).y is 200
+PASS poly.points.getItem(2).x is 200
+PASS poly.points.getItem(2).y is 200
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (113007 => 113008)


--- trunk/Source/WebCore/ChangeLog	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/Source/WebCore/ChangeLog	2012-04-03 10:36:01 UTC (rev 113008)
@@ -1,3 +1,33 @@
+2012-04-01  Nikolas Zimmermann  <[email protected]>
+
+        Animate animatedPoints instead of points for SVGPoly*Elements
+        https://bugs.webkit.org/show_bug.cgi?id=82844
+
+        Reviewed by Dirk Schulze.
+
+        When the points attribute of a SVGPoly*Element is animated, we should animate
+        the 'animatedPoints' SVG DOM property, not the 'points' property, which corresponds
+        to the "baseVal". Fix that, now only the 'd' attribute for SVGPathElement is incorrect,
+        everything else is moved to the new animVal concept!
+
+        * svg/SVGAnimatedPointList.cpp:
+        (WebCore::SVGAnimatedPointListAnimator::startAnimValAnimation):
+        (WebCore::SVGAnimatedPointListAnimator::stopAnimValAnimation):
+        (WebCore::SVGAnimatedPointListAnimator::resetAnimValToBaseVal):
+        (WebCore::SVGAnimatedPointListAnimator::animValWillChange):
+        (WebCore::SVGAnimatedPointListAnimator::animValDidChange):
+        * svg/SVGAnimatedPointList.h:
+        (SVGAnimatedPointListAnimator):
+        * svg/SVGAnimatedType.cpp:
+        (WebCore::SVGAnimatedType::valueAsString):
+        (WebCore::SVGAnimatedType::setValueAsString):
+        (WebCore::SVGAnimatedType::supportsAnimVal):
+        * svg/SVGPolyElement.cpp:
+        (WebCore::SVGPolyElement::parseAttribute):
+        (WebCore::SVGPolyElement::lookupOrCreatePointsWrapper):
+        (WebCore::SVGPolyElement::points):
+        (WebCore::SVGPolyElement::animatedPoints):
+
 2012-04-03  Nikolas Zimmermann  <[email protected]>
 
         Not reviewed. Next chromium build fix, this time for real :-)

Modified: trunk/Source/WebCore/svg/SVGAnimatedPointList.cpp (113007 => 113008)


--- trunk/Source/WebCore/svg/SVGAnimatedPointList.cpp	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/Source/WebCore/svg/SVGAnimatedPointList.cpp	2012-04-03 10:36:01 UTC (rev 113008)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ * Copyright (C) Research In Motion Limited 2011, 2012. 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
@@ -40,6 +40,31 @@
     return animtedType.release();
 }
 
+PassOwnPtr<SVGAnimatedType> SVGAnimatedPointListAnimator::startAnimValAnimation(const Vector<SVGAnimatedProperty*>& properties)
+{
+    return SVGAnimatedType::createPointList(constructFromBaseValue<SVGAnimatedPointList>(properties));
+}
+
+void SVGAnimatedPointListAnimator::stopAnimValAnimation(const Vector<SVGAnimatedProperty*>& properties)
+{
+    stopAnimValAnimationForType<SVGAnimatedPointList>(properties);
+}
+
+void SVGAnimatedPointListAnimator::resetAnimValToBaseVal(const Vector<SVGAnimatedProperty*>& properties, SVGAnimatedType* type)
+{
+    resetFromBaseValue<SVGAnimatedPointList>(properties, type, &SVGAnimatedType::pointList);
+}
+
+void SVGAnimatedPointListAnimator::animValWillChange(const Vector<SVGAnimatedProperty*>& properties)
+{
+    animValWillChangeForType<SVGAnimatedPointList>(properties);
+}
+
+void SVGAnimatedPointListAnimator::animValDidChange(const Vector<SVGAnimatedProperty*>& properties)
+{
+    animValDidChangeForType<SVGAnimatedPointList>(properties);
+}
+
 void SVGAnimatedPointListAnimator::calculateFromAndToValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& toString)
 {
     from = constructFromString(fromString);

Modified: trunk/Source/WebCore/svg/SVGAnimatedPointList.h (113007 => 113008)


--- trunk/Source/WebCore/svg/SVGAnimatedPointList.h	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/Source/WebCore/svg/SVGAnimatedPointList.h	2012-04-03 10:36:01 UTC (rev 113008)
@@ -21,19 +21,28 @@
 #define SVGAnimatedPointList_h
 
 #if ENABLE(SVG)
+#include "SVGAnimatedListPropertyTearOff.h"
 #include "SVGAnimatedTypeAnimator.h"
+#include "SVGPointList.h"
 
 namespace WebCore {
+
+typedef SVGAnimatedListPropertyTearOff<SVGPointList> SVGAnimatedPointList;
+
 class SVGAnimationElement;
 
 class SVGAnimatedPointListAnimator : public SVGAnimatedTypeAnimator {
-    
 public:
     SVGAnimatedPointListAnimator(SVGAnimationElement*, SVGElement*);
     virtual ~SVGAnimatedPointListAnimator() { }
     
     virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&);
-    
+    virtual PassOwnPtr<SVGAnimatedType> startAnimValAnimation(const Vector<SVGAnimatedProperty*>&);
+    virtual void stopAnimValAnimation(const Vector<SVGAnimatedProperty*>&);
+    virtual void resetAnimValToBaseVal(const Vector<SVGAnimatedProperty*>&, SVGAnimatedType*);
+    virtual void animValWillChange(const Vector<SVGAnimatedProperty*>&);
+    virtual void animValDidChange(const Vector<SVGAnimatedProperty*>&);
+
     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(float percentage, unsigned repeatCount,

Modified: trunk/Source/WebCore/svg/SVGAnimatedType.cpp (113007 => 113008)


--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp	2012-04-03 10:36:01 UTC (rev 113008)
@@ -360,9 +360,6 @@
         SVGPathParserFactory::self()->buildStringFromByteStream(m_data.path, result, UnalteredParsing);
         return result;
     }
-    case AnimatedPoints:
-        ASSERT(m_data.pointList);
-        return m_data.pointList->valueAsString();
     case AnimatedRect:
         ASSERT(m_data.rect);
         return String::number(m_data.rect->x()) + ' ' + String::number(m_data.rect->y()) + ' '
@@ -379,6 +376,7 @@
     case AnimatedIntegerOptionalInteger:
     case AnimatedNumberList:
     case AnimatedNumberOptionalNumber:
+    case AnimatedPoints:
     case AnimatedPreserveAspectRatio:
     case AnimatedTransformList:
     case AnimatedUnknown:
@@ -418,11 +416,6 @@
         m_data.path = pathByteStream.leakPtr();
         break;
     }
-    case AnimatedPoints:
-        ASSERT(m_data.pointList);
-        m_data.pointList->clear();
-        pointsListFromSVGData(*m_data.pointList, value);
-        break;
     case AnimatedRect:
         ASSERT(m_data.rect);
         parseRect(value, *m_data.rect);
@@ -440,6 +433,7 @@
     case AnimatedIntegerOptionalInteger:
     case AnimatedNumberList:
     case AnimatedNumberOptionalNumber:
+    case AnimatedPoints:
     case AnimatedPreserveAspectRatio:
     case AnimatedTransformList:
     case AnimatedUnknown:
@@ -463,6 +457,7 @@
     case AnimatedNumber:
     case AnimatedNumberList:
     case AnimatedNumberOptionalNumber:
+    case AnimatedPoints:
     case AnimatedPreserveAspectRatio:
     case AnimatedRect:
     case AnimatedString:
@@ -475,7 +470,6 @@
 
     // FIXME: Handle the remaining types in animVal concept.
     case AnimatedPath:
-    case AnimatedPoints:
     case AnimatedUnknown:
         return false;
     }

Modified: trunk/Source/WebCore/svg/SVGPolyElement.cpp (113007 => 113008)


--- trunk/Source/WebCore/svg/SVGPolyElement.cpp	2012-04-03 10:27:09 UTC (rev 113007)
+++ trunk/Source/WebCore/svg/SVGPolyElement.cpp	2012-04-03 10:36:01 UTC (rev 113008)
@@ -28,10 +28,10 @@
 #include "FloatPoint.h"
 #include "RenderSVGPath.h"
 #include "RenderSVGResource.h"
+#include "SVGAnimatedPointList.h"
 #include "SVGElementInstance.h"
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
-#include "SVGPointList.h"
 
 namespace WebCore {
 
@@ -90,8 +90,8 @@
         if (!pointsListFromSVGData(newList, value))
             document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
 
-        if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGPolyElement, SVGAnimatedListPropertyTearOff<SVGPointList>, true>(this, pointsPropertyInfo()))
-            static_cast<SVGAnimatedListPropertyTearOff<SVGPointList>*>(wrapper)->detachListWrappers(newList.size());
+        if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGPolyElement, SVGAnimatedPointList, true>(this, pointsPropertyInfo()))
+            static_cast<SVGAnimatedPointList*>(wrapper)->detachListWrappers(newList.size());
 
         m_points.value = newList;
         return;
@@ -150,20 +150,20 @@
 {
     ASSERT(contextElement);
     SVGPolyElement* ownerType = static_cast<SVGPolyElement*>(contextElement);
-    return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPolyElement, SVGAnimatedListPropertyTearOff<SVGPointList>, SVGPointList, true>
+    return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPolyElement, SVGAnimatedPointList, SVGPointList, true>
            (ownerType, pointsPropertyInfo(), ownerType->m_points.value);
 }
 
 SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::points()
 {
     m_points.shouldSynchronize = true;
-    return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cast<SVGAnimatedListPropertyTearOff<SVGPointList> >(lookupOrCreatePointsWrapper(this))->baseVal());
+    return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cast<SVGAnimatedPointList>(lookupOrCreatePointsWrapper(this))->baseVal());
 }
 
 SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::animatedPoints()
 {
     m_points.shouldSynchronize = true;
-    return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cast<SVGAnimatedListPropertyTearOff<SVGPointList> >(lookupOrCreatePointsWrapper(this))->animVal());
+    return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cast<SVGAnimatedPointList>(lookupOrCreatePointsWrapper(this))->animVal());
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to