Enable animVal support for SVGAnimatedPreserveAspectRatio
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2012 13:14:20 +0000 (13:14 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2012 13:14:20 +0000 (13:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82326

Reviewed by Zoltan Herczeg.

Source/WebCore:

Enable animVal support for SVGAnimatedPreserveAspectRatio. Very simple now that everything is prepared.
All we have to do is add startAnimValAnimation/etc. methods to SVGAnimatedPreserveAspectRatioAnimator.

Modernize SVGPreserveAspectRatio, align parsing this object from String, with the other SVG DOM primitives,
who supply a "void parse(const String&)" method, for this task.

Extended existing tests to cover this.

* svg/SVGAnimatedPreserveAspectRatio.cpp:
(WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString):
(WebCore::SVGAnimatedPreserveAspectRatioAnimator::startAnimValAnimation):
(WebCore::SVGAnimatedPreserveAspectRatioAnimator::stopAnimValAnimation):
(WebCore::SVGAnimatedPreserveAspectRatioAnimator::resetAnimValToBaseVal):
(WebCore::SVGAnimatedPreserveAspectRatioAnimator::animValWillChange):
(WebCore::SVGAnimatedPreserveAspectRatioAnimator::animValDidChange):
* svg/SVGAnimatedPreserveAspectRatio.h:
(SVGAnimatedPreserveAspectRatioAnimator):
* svg/SVGAnimatedType.cpp:
(WebCore::SVGAnimatedType::valueAsString):
(WebCore::SVGAnimatedType::setValueAsString):
(WebCore::SVGAnimatedType::supportsAnimVal):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::parseAttribute):
* svg/SVGFitToViewBox.cpp:
(WebCore::SVGFitToViewBox::parseAttribute):
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::parseAttribute):
* svg/SVGPreserveAspectRatio.cpp:
(WebCore::SVGPreserveAspectRatio::parse):
(WebCore):
* svg/SVGPreserveAspectRatio.h:
(SVGPreserveAspectRatio):
* svg/SVGViewSpec.cpp:
(WebCore::SVGViewSpec::setPreserveAspectRatioString):
(WebCore::SVGViewSpec::parseViewSpec):

LayoutTests:

Extend SVGAnimatedPreserveAspectRatio tests to cover animVal support.

* svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js:
(sample1):
(sample2):
(sample3):
* svg/animations/svgPreserveAspectRatio-animation-1-expected.txt:
* svg/dom/preserve-aspect-ratio-parser-expected.txt:
* svg/dom/preserve-aspect-ratio-parser.html: Parsing errors now yield to 'unknown' pAR values, as desired.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js
LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1-expected.txt
LayoutTests/svg/dom/preserve-aspect-ratio-parser-expected.txt
LayoutTests/svg/dom/preserve-aspect-ratio-parser.html
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp
Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h
Source/WebCore/svg/SVGAnimatedType.cpp
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFitToViewBox.cpp
Source/WebCore/svg/SVGImageElement.cpp
Source/WebCore/svg/SVGPreserveAspectRatio.cpp
Source/WebCore/svg/SVGPreserveAspectRatio.h
Source/WebCore/svg/SVGViewSpec.cpp

index b957386..e1e5d3b 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-27  Nikolas Zimmermann  <nzimmermann@rim.com>
+
+        Enable animVal support for SVGAnimatedPreserveAspectRatio
+        https://bugs.webkit.org/show_bug.cgi?id=82326
+
+        Reviewed by Zoltan Herczeg.
+
+        Extend SVGAnimatedPreserveAspectRatio tests to cover animVal support.
+
+        * svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js:
+        (sample1):
+        (sample2):
+        (sample3):
+        * svg/animations/svgPreserveAspectRatio-animation-1-expected.txt:
+        * svg/dom/preserve-aspect-ratio-parser-expected.txt:
+        * svg/dom/preserve-aspect-ratio-parser.html: Parsing errors now yield to 'unknown' pAR values, as desired.
+
 2012-03-28  Alexis Menard  <alexis.menard@openbossa.org>
 
         Speed up updates of existing CSS properties from JS.
index 0bf4228..02adaef 100644 (file)
@@ -26,16 +26,25 @@ rootSVGElement.appendChild(animate);
 function sample1() {
     shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN");
     shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
+
+    shouldBe("rootSVGElement.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN");
+    shouldBe("rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
 }
 
 function sample2() {
     shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN");
     shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
+
+    shouldBe("rootSVGElement.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN");
+    shouldBe("rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
 }
 
 function sample3() {
     shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID");
     shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
+
+    shouldBe("rootSVGElement.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN");
+    shouldBe("rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
 }
 
 function executeTest() {
index 8cc57b4..9f332ef 100644 (file)
@@ -7,12 +7,20 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
+PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
+PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN
 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
+PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
+PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID
 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE
+PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
+PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
+PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
+PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
 PASS successfullyParsed is true
 
 TEST COMPLETE
index d70384c..8e4764c 100644 (file)
@@ -310,46 +310,46 @@ PASS imageElement.preserveAspectRatio.baseVal.align is 2
 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
 
 Test string: 'slice'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
-Strings that fail to parse, and hence parse as "none".
+Strings that fail to parse, and hence parse as unknown
 
 Test string: ''
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'defer'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'meet'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'slice'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'xminymin'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'refer xMinYMin slice'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'xMinYMin defer'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'slice xMinYMin'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 Test string: 'xMinYMin¬†'
-PASS imageElement.preserveAspectRatio.baseVal.align is 1
-PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1
+PASS imageElement.preserveAspectRatio.baseVal.align is 0
+PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0
 
 PASS successfullyParsed is true
 
index a65b68e..f25eb7c 100644 (file)
@@ -112,20 +112,20 @@ parsePreserveAspectRatio("xMinYMin", 2, 1);
 parsePreserveAspectRatio("none slice", 1, 1);
 
 parsePreserveAspectRatio("xMinYMin", 2, 1);
-parsePreserveAspectRatio("slice", 1, 1);
+parsePreserveAspectRatio("slice", 0, 0);
 
-debug('Strings that fail to parse, and hence parse as "none".');
+debug('Strings that fail to parse, and hence parse as unknown');
 debug('');
 
-parsePreserveAspectRatio("", 1, 1);
-parsePreserveAspectRatio("defer", 1, 1);
-parsePreserveAspectRatio("meet", 1, 1);
-parsePreserveAspectRatio("slice", 1, 1);
-parsePreserveAspectRatio("xminymin", 1, 1);
-parsePreserveAspectRatio("refer xMinYMin slice", 1, 1);
-parsePreserveAspectRatio("xMinYMin defer", 1, 1);
-parsePreserveAspectRatio("slice xMinYMin", 1, 1);
-parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(0xa0), 1, 1);
+parsePreserveAspectRatio("", 0, 0);
+parsePreserveAspectRatio("defer", 0, 0);
+parsePreserveAspectRatio("meet", 0, 0);
+parsePreserveAspectRatio("slice", 0, 0);
+parsePreserveAspectRatio("xminymin", 0, 0);
+parsePreserveAspectRatio("refer xMinYMin slice", 0, 0);
+parsePreserveAspectRatio("xMinYMin defer", 0, 0);
+parsePreserveAspectRatio("slice xMinYMin", 0, 0);
+parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(0xa0), 0, 0);
 
 
 </script>
index 960344a..d5c654d 100644 (file)
@@ -1,3 +1,46 @@
+2012-03-27  Nikolas Zimmermann  <nzimmermann@rim.com>
+
+        Enable animVal support for SVGAnimatedPreserveAspectRatio
+        https://bugs.webkit.org/show_bug.cgi?id=82326
+
+        Reviewed by Zoltan Herczeg.
+
+        Enable animVal support for SVGAnimatedPreserveAspectRatio. Very simple now that everything is prepared.
+        All we have to do is add startAnimValAnimation/etc. methods to SVGAnimatedPreserveAspectRatioAnimator.
+
+        Modernize SVGPreserveAspectRatio, align parsing this object from String, with the other SVG DOM primitives,
+        who supply a "void parse(const String&)" method, for this task.
+
+        Extended existing tests to cover this.
+
+        * svg/SVGAnimatedPreserveAspectRatio.cpp:
+        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString):
+        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::startAnimValAnimation):
+        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::stopAnimValAnimation):
+        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::resetAnimValToBaseVal):
+        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::animValWillChange):
+        (WebCore::SVGAnimatedPreserveAspectRatioAnimator::animValDidChange):
+        * svg/SVGAnimatedPreserveAspectRatio.h:
+        (SVGAnimatedPreserveAspectRatioAnimator):
+        * svg/SVGAnimatedType.cpp:
+        (WebCore::SVGAnimatedType::valueAsString):
+        (WebCore::SVGAnimatedType::setValueAsString):
+        (WebCore::SVGAnimatedType::supportsAnimVal):
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::parseAttribute):
+        * svg/SVGFitToViewBox.cpp:
+        (WebCore::SVGFitToViewBox::parseAttribute):
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::parseAttribute):
+        * svg/SVGPreserveAspectRatio.cpp:
+        (WebCore::SVGPreserveAspectRatio::parse):
+        (WebCore):
+        * svg/SVGPreserveAspectRatio.h:
+        (SVGPreserveAspectRatio):
+        * svg/SVGViewSpec.cpp:
+        (WebCore::SVGViewSpec::setPreserveAspectRatioString):
+        (WebCore::SVGViewSpec::parseViewSpec):
+
 2012-03-28  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: [v8] inspection of CanvasPixelArray is slow.
index ce3a6ed..a62881c 100644 (file)
@@ -34,10 +34,35 @@ SVGAnimatedPreserveAspectRatioAnimator::SVGAnimatedPreserveAspectRatioAnimator(S
 PassOwnPtr<SVGAnimatedType> SVGAnimatedPreserveAspectRatioAnimator::constructFromString(const String& string)
 {
     OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createPreserveAspectRatio(new SVGPreserveAspectRatio);
-    SVGPreserveAspectRatio::parsePreserveAspectRatio(animatedType.get(), string);
+    animatedType->preserveAspectRatio().parse(string);
     return animatedType.release();
 }
 
+PassOwnPtr<SVGAnimatedType> SVGAnimatedPreserveAspectRatioAnimator::startAnimValAnimation(const Vector<SVGAnimatedProperty*>& properties)
+{
+    return SVGAnimatedType::createPreserveAspectRatio(constructFromOneBaseValue<SVGPreserveAspectRatio, SVGAnimatedPreserveAspectRatio>(properties));
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::stopAnimValAnimation(const Vector<SVGAnimatedProperty*>& properties)
+{
+    SVGAnimatedTypeAnimator::stopAnimValAnimationForType<SVGAnimatedPreserveAspectRatio>(properties);
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::resetAnimValToBaseVal(const Vector<SVGAnimatedProperty*>& properties, SVGAnimatedType* type)
+{
+    resetFromOneBaseValue<SVGPreserveAspectRatio, SVGAnimatedPreserveAspectRatio>(properties, type, &SVGAnimatedType::preserveAspectRatio);
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::animValWillChange(const Vector<SVGAnimatedProperty*>& properties)
+{
+    animValWillChangeForType<SVGAnimatedPreserveAspectRatio>(properties);
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::animValDidChange(const Vector<SVGAnimatedProperty*>& properties)
+{
+    animValDidChangeForType<SVGAnimatedPreserveAspectRatio>(properties);
+}
+
 void SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndToValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& toString)
 {
     ASSERT(m_contextElement);
index c40184c..f5a752b 100644 (file)
@@ -45,7 +45,12 @@ public:
     virtual ~SVGAnimatedPreserveAspectRatioAnimator() { }
     
     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,
index 0b8d05a..12f0680 100644 (file)
@@ -340,6 +340,10 @@ String SVGAnimatedType::valueAsString()
     case AnimatedColor:
         ASSERT(m_data.color);
         return m_data.color->serialized();
+    case AnimatedEnumeration:
+        // FIXME: AnimatedEnumeration is left todo.
+        ASSERT_NOT_REACHED();
+        break;
     case AnimatedInteger:
         ASSERT(m_data.integer);
         return String::number(*m_data.integer);
@@ -383,10 +387,6 @@ String SVGAnimatedType::valueAsString()
      case AnimatedTransformList:
         ASSERT(m_data.transformList);
         return m_data.transformList->valueAsString();
-    case AnimatedEnumeration:
-        // FIXME: AnimatedEnumeration is left todo.
-        ASSERT_NOT_REACHED();
-        break;
     case AnimatedUnknown:
         break;
     }
@@ -431,10 +431,6 @@ bool SVGAnimatedType::setValueAsString(const QualifiedName& attrName, const Stri
         m_data.pointList->clear();
         pointsListFromSVGData(*m_data.pointList, value);
         break;
-    case AnimatedPreserveAspectRatio:
-        ASSERT(m_data.preserveAspectRatio);
-        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
-        break;
     case AnimatedRect:
         ASSERT(m_data.rect);
         parseRect(value, *m_data.rect);
@@ -447,10 +443,11 @@ bool SVGAnimatedType::setValueAsString(const QualifiedName& attrName, const Stri
     // These types don't appear in the table in SVGStyledElement::cssPropertyToTypeMap() and thus don't need setValueAsString() support. 
     case AnimatedAngle:
     case AnimatedBoolean:
-    case AnimatedNumberList:
-    case AnimatedNumberOptionalNumber:
     case AnimatedInteger:
     case AnimatedIntegerOptionalInteger:
+    case AnimatedNumberList:
+    case AnimatedNumberOptionalNumber:
+    case AnimatedPreserveAspectRatio:
     case AnimatedTransformList:
     case AnimatedUnknown:
         // Only SVG DOM animations use these property types - that means setValueAsString() is never used for those.
@@ -468,7 +465,6 @@ void SVGAnimatedType::setPreserveAspectRatioBaseValue(const SVGPreserveAspectRat
 
 bool SVGAnimatedType::supportsAnimVal(AnimatedPropertyType type)
 {
-    // FIXME: This lists the current state of our animVal support.
     switch (type) {
     case AnimatedAngle:
     case AnimatedBoolean:
@@ -479,15 +475,20 @@ bool SVGAnimatedType::supportsAnimVal(AnimatedPropertyType type)
     case AnimatedNumber:
     case AnimatedNumberList:
     case AnimatedNumberOptionalNumber:
+    case AnimatedPreserveAspectRatio:
     case AnimatedRect:
     case AnimatedString:
     case AnimatedTransformList:
         return true;
+
+    // Types only used for CSS property animations.
     case AnimatedColor:
+        return false;
+
+    // FIXME: Handle the remaining types in animVal concept.
     case AnimatedEnumeration:
     case AnimatedPath:
     case AnimatedPoints:
-    case AnimatedPreserveAspectRatio:
     case AnimatedUnknown:
         return false;
     }
index 8d5d197..d209747 100644 (file)
@@ -133,9 +133,10 @@ void SVGFEImageElement::parseAttribute(Attribute* attr)
         return;
     }
 
-    const AtomicString& value = attr->value();
     if (attr->name() == SVGNames::preserveAspectRatioAttr) {
-        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
+        SVGPreserveAspectRatio preserveAspectRatio;
+        preserveAspectRatio.parse(attr->value());
+        setPreserveAspectRatioBaseValue(preserveAspectRatio);
         return;
     }
 
index b548c54..929167c 100644 (file)
@@ -97,7 +97,9 @@ bool SVGFitToViewBox::parseAttribute(Document* document, Attribute* attr)
         setViewBoxBaseValue(viewBox);
         return true;
     } else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
-        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value());
+        SVGPreserveAspectRatio preserveAspectRatio;
+        preserveAspectRatio.parse(attr->value());
+        setPreserveAspectRatioBaseValue(preserveAspectRatio);
         return true;
     }
 
index a50e762..904a270 100644 (file)
@@ -118,9 +118,11 @@ void SVGImageElement::parseAttribute(Attribute* attr)
         setXBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError));
     else if (attr->name() == SVGNames::yAttr)
         setYBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError));
-    else if (attr->name() == SVGNames::preserveAspectRatioAttr)
-        SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value());
-    else if (attr->name() == SVGNames::widthAttr)
+    else if (attr->name() == SVGNames::preserveAspectRatioAttr) {
+        SVGPreserveAspectRatio preserveAspectRatio;
+        preserveAspectRatio.parse(attr->value());
+        setPreserveAspectRatioBaseValue(preserveAspectRatio);
+    } else if (attr->name() == SVGNames::widthAttr)
         setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths));
     else if (attr->name() == SVGNames::heightAttr)
         setHeightBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError, ForbidNegativeLengths));
index 0e7da00..296702d 100644 (file)
@@ -58,12 +58,16 @@ void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice, Exceptio
     m_meetOrSlice = static_cast<SVGMeetOrSliceType>(meetOrSlice);
 }
 
-SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result)
+void SVGPreserveAspectRatio::parse(const String& value)
 {
-    SVGPreserveAspectRatio aspectRatio;
-    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
-    aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
-    result = false;
+    const UChar* begin = value.characters();
+    parse(begin, begin + value.length(), true);
+}
+
+bool SVGPreserveAspectRatio::parse(const UChar*& currParam, const UChar* end, bool validate)
+{
+    m_align = SVG_PRESERVEASPECTRATIO_NONE;
+    m_meetOrSlice = SVG_MEETORSLICE_MEET;
 
     // FIXME: Rewrite this parser, without gotos!
     if (!skipOptionalSVGSpaces(currParam, end))
@@ -90,25 +94,25 @@ SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UC
             if (currParam[3] == 'n') {
                 if (currParam[6] == 'i') {
                     if (currParam[7] == 'n')
-                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
+                        m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
                     else if (currParam[7] == 'd')
-                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMID;
+                        m_align = SVG_PRESERVEASPECTRATIO_XMINYMID;
                     else
                         goto bailOut;
                 } else if (currParam[6] == 'a' && currParam[7] == 'x')
-                     aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
+                     m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
                 else
                      goto bailOut;
              } else if (currParam[3] == 'd') {
                 if (currParam[6] == 'i') {
                     if (currParam[7] == 'n')
-                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
+                        m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
                     else if (currParam[7] == 'd')
-                        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
+                        m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
                     else
                         goto bailOut;
                 } else if (currParam[6] == 'a' && currParam[7] == 'x')
-                    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
+                    m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
                 else
                     goto bailOut;
             } else
@@ -116,13 +120,13 @@ SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UC
         } else if (currParam[2] == 'a' && currParam[3] == 'x') {
             if (currParam[6] == 'i') {
                 if (currParam[7] == 'n')
-                    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
+                    m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
                 else if (currParam[7] == 'd')
-                    aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
+                    m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
                 else
                     goto bailOut;
             } else if (currParam[6] == 'a' && currParam[7] == 'x')
-                aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
+                m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
             else
                 goto bailOut;
         } else
@@ -141,20 +145,18 @@ SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UC
             if (!skipString(currParam, end, "slice"))
                 goto bailOut;
             skipOptionalSVGSpaces(currParam, end);
-            if (aspectRatio.m_align != SVG_PRESERVEASPECTRATIO_NONE)
-                aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_SLICE;    
+            if (m_align != SVG_PRESERVEASPECTRATIO_NONE)
+                m_meetOrSlice = SVG_MEETORSLICE_SLICE;
         }
     }
 
     if (end != currParam && validate) {
 bailOut:
-        // FIXME: Should the two values be set to UNKNOWN instead?
-        aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE;
-        aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET;
-    } else
-        result = true;
-
-    return aspectRatio;
+        m_align = SVG_PRESERVEASPECTRATIO_UNKNOWN;
+        m_meetOrSlice = SVG_MEETORSLICE_UNKNOWN;
+        return false;
+    }
+    return true;
 }
 
 void SVGPreserveAspectRatio::transformRect(FloatRect& destRect, FloatRect& srcRect)
index 43567ce..ed990c2 100644 (file)
@@ -67,18 +67,8 @@ public:
                            float logicWidth, float logicHeight,
                            float physWidth, float physHeight) const;
 
-    template<class Consumer>
-    static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true)
-    {
-        bool result = false;
-        const UChar* begin = value.characters();
-        const UChar* end = begin + value.length();
-        consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result));
-        return result;
-    }
-
-    // It's recommended to use the method above, only SVGViewSpec needs this parsing method
-    static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result);
+    void parse(const String&);
+    bool parse(const UChar*& currParam, const UChar* end, bool validate);
 
     String valueAsString() const;
 
index d09ea59..415b19e 100644 (file)
@@ -63,7 +63,9 @@ void SVGViewSpec::setViewBoxString(const String& viewBoxStr)
 
 void SVGViewSpec::setPreserveAspectRatioString(const String& preserve)
 {
-    SVGPreserveAspectRatio::parsePreserveAspectRatio(this, preserve);
+    SVGPreserveAspectRatio preserveAspectRatio;
+    preserveAspectRatio.parse(preserve);
+    setPreserveAspectRatioBaseValue(preserveAspectRatio);
 }
 
 void SVGViewSpec::setViewTargetString(const String& viewTargetString)
@@ -140,10 +142,10 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec)
             if (currViewSpec >= end || *currViewSpec != '(')
                 return false;
             currViewSpec++;
-            bool result = false; 
-            setPreserveAspectRatioBaseValue(SVGPreserveAspectRatio::parsePreserveAspectRatio(currViewSpec, end, false, result));
-            if (!result)
+            SVGPreserveAspectRatio preserveAspectRatio;
+            if (!preserveAspectRatio.parse(currViewSpec, end, false))
                 return false;
+            setPreserveAspectRatioBaseValue(preserveAspectRatio);
             if (currViewSpec >= end || *currViewSpec != ')')
                 return false;
             currViewSpec++;