Diff
Copied: branches/chromium/1271/LayoutTests/svg/animations/animate-css-xml-attributeType-expected.txt (from rev 130777, trunk/LayoutTests/svg/animations/animate-css-xml-attributeType-expected.txt) (0 => 131767)
--- branches/chromium/1271/LayoutTests/svg/animations/animate-css-xml-attributeType-expected.txt (rev 0)
+++ branches/chromium/1271/LayoutTests/svg/animations/animate-css-xml-attributeType-expected.txt 2012-10-18 17:10:14 UTC (rev 131767)
@@ -0,0 +1,20 @@
+SVG 1.1 dynamic animation tests
+
+Tests that XML and CSS attributeTypes can be switched between.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.x.animVal.value is 100
+PASS rect.x.baseVal.value is 100
+PASS rect.x.animVal.value is 300
+PASS rect.x.animVal.value is 100
+PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0.8
+PASS rect.x.animVal.value is 100
+PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 1.0
+PASS rect.x.animVal.value is 200
+PASS rect.x.baseVal.value is 100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: branches/chromium/1271/LayoutTests/svg/animations/animate-css-xml-attributeType.html (from rev 130777, trunk/LayoutTests/svg/animations/animate-css-xml-attributeType.html) (0 => 131767)
--- branches/chromium/1271/LayoutTests/svg/animations/animate-css-xml-attributeType.html (rev 0)
+++ branches/chromium/1271/LayoutTests/svg/animations/animate-css-xml-attributeType.html 2012-10-18 17:10:14 UTC (rev 131767)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body _onload_="runSMILTest()">
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>
Copied: branches/chromium/1271/LayoutTests/svg/animations/invalid-css-attribute-crash-expected.svg (from rev 130777, trunk/LayoutTests/svg/animations/invalid-css-attribute-crash-expected.svg) (0 => 131767)
--- branches/chromium/1271/LayoutTests/svg/animations/invalid-css-attribute-crash-expected.svg (rev 0)
+++ branches/chromium/1271/LayoutTests/svg/animations/invalid-css-attribute-crash-expected.svg 2012-10-18 17:10:14 UTC (rev 131767)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<text x="5" y="20">This test passes if it does not CRASH.</text>
+</svg>
Copied: branches/chromium/1271/LayoutTests/svg/animations/invalid-css-attribute-crash.svg (from rev 130777, trunk/LayoutTests/svg/animations/invalid-css-attribute-crash.svg) (0 => 131767)
--- branches/chromium/1271/LayoutTests/svg/animations/invalid-css-attribute-crash.svg (rev 0)
+++ branches/chromium/1271/LayoutTests/svg/animations/invalid-css-attribute-crash.svg 2012-10-18 17:10:14 UTC (rev 131767)
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<!-- Test for WK94569: Passes if there is no crash in animating non-CSS animations with attributeType=CSS. -->
+<text x="5" y="20">This test passes if it does not CRASH.</text>
+<feConvolveMatrix>
+<set attributeName="result" attributeType="CSS" to="inherit"></set>
+</feConvolveMatrix>
+</svg>
Copied: branches/chromium/1271/LayoutTests/svg/animations/script-tests/animate-css-xml-attributeType.js (from rev 130777, trunk/LayoutTests/svg/animations/script-tests/animate-css-xml-attributeType.js) (0 => 131767)
--- branches/chromium/1271/LayoutTests/svg/animations/script-tests/animate-css-xml-attributeType.js (rev 0)
+++ branches/chromium/1271/LayoutTests/svg/animations/script-tests/animate-css-xml-attributeType.js 2012-10-18 17:10:14 UTC (rev 131767)
@@ -0,0 +1,77 @@
+description("Tests that XML and CSS attributeTypes can be switched between.");
+createSVGTestCase();
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("x", "100");
+rect.setAttribute("width", "100");
+rect.setAttribute("height", "100");
+rect.setAttribute("fill", "green");
+rect.setAttribute("onclick", "executeTest()");
+
+var set = createSVGElement("set");
+set.setAttribute("id", "set");
+set.setAttribute("attributeName", "x");
+set.setAttribute("attributeType", "XML");
+set.setAttribute("to", "300");
+set.setAttribute("begin", "click");
+rect.appendChild(set);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+ shouldBeCloseEnough("rect.x.animVal.value", "100");
+ shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+ shouldBeCloseEnough("rect.x.animVal.value", "300");
+ // change the animationType to CSS which is invalid.
+ set.setAttribute("attributeType", "CSS");
+}
+
+function sample3() {
+ // verify that the animation resets.
+ shouldBeCloseEnough("rect.x.animVal.value", "100");
+ // change the animation to a CSS animatable value.
+ set.setAttribute("attributeName", "opacity");
+ set.setAttribute("to", "0.8");
+}
+
+function sample4() {
+ shouldBeCloseEnough("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0.8");
+ // change the animation to a non-CSS animatable value.
+ set.setAttribute("attributeName", "x");
+ set.setAttribute("to", "200");
+}
+
+function sample5() {
+ // verify that the animation does not run.
+ shouldBeCloseEnough("rect.x.animVal.value", "100");
+ shouldBeCloseEnough("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "1.0");
+ // change the animationType to XML which is valid.
+ set.setAttribute("attributeType", "XML");
+}
+
+function sample6() {
+ shouldBeCloseEnough("rect.x.animVal.value", "200");
+ shouldBe("rect.x.baseVal.value", "100");
+}
+
+function executeTest() {
+ const expectedValues = [
+ // [animationId, time, sampleCallback]
+ ["set", 0.0, sample1],
+ ["set", 0.5, sample2],
+ ["set", 1.0, sample3],
+ ["set", 1.5, sample4],
+ ["set", 2.0, sample5],
+ ["set", 2.5, sample6]
+ ];
+
+ runAnimationTest(expectedValues);
+}
+
+window.clickX = 150;
+var successfullyParsed = true;
Modified: branches/chromium/1271/Source/WebCore/svg/SVGAnimateElement.cpp (131766 => 131767)
--- branches/chromium/1271/Source/WebCore/svg/SVGAnimateElement.cpp 2012-10-18 17:08:41 UTC (rev 131766)
+++ branches/chromium/1271/Source/WebCore/svg/SVGAnimateElement.cpp 2012-10-18 17:10:14 UTC (rev 131767)
@@ -56,8 +56,8 @@
SVGElement* targetElement = this->targetElement();
if (!targetElement)
return false;
-
- return m_animatedPropertyType != AnimatedUnknown;
+
+ return m_animatedPropertyType != AnimatedUnknown && !hasInvalidCSSAttributeType();
}
AnimatedPropertyType SVGAnimateElement::determineAnimatedPropertyType(SVGElement* targetElement) const
@@ -398,7 +398,7 @@
void SVGAnimateElement::targetElementWillChange(SVGElement* currentTarget, SVGElement* newTarget)
{
- SVGSMILElement::targetElementWillChange(currentTarget, newTarget);
+ SVGAnimationElement::targetElementWillChange(currentTarget, newTarget);
ASSERT(!m_animatedType);
m_fromType.clear();
Modified: branches/chromium/1271/Source/WebCore/svg/SVGAnimationElement.cpp (131766 => 131767)
--- branches/chromium/1271/Source/WebCore/svg/SVGAnimationElement.cpp 2012-10-18 17:08:41 UTC (rev 131766)
+++ branches/chromium/1271/Source/WebCore/svg/SVGAnimationElement.cpp 2012-10-18 17:10:14 UTC (rev 131767)
@@ -55,6 +55,8 @@
, m_fromPropertyValueType(RegularPropertyValue)
, m_toPropertyValueType(RegularPropertyValue)
, m_animationValid(false)
+ , m_attributeType(AttributeTypeAuto)
+ , m_hasInvalidCSSAttributeType(false)
{
registerAnimatedPropertiesForSVGAnimationElement();
}
@@ -145,6 +147,7 @@
supportedAttributes.add(SVGNames::keyTimesAttr);
supportedAttributes.add(SVGNames::keyPointsAttr);
supportedAttributes.add(SVGNames::keySplinesAttr);
+ supportedAttributes.add(SVGNames::attributeTypeAttr);
}
return supportedAttributes.contains<QualifiedName, SVGAttributeHashTranslator>(attrName);
}
@@ -185,6 +188,11 @@
return;
}
+ if (attribute.name() == SVGNames::attributeTypeAttr) {
+ setAttributeType(attribute.value());
+ return;
+ }
+
if (SVGTests::parseAttribute(attribute))
return;
if (SVGExternalResourcesRequired::parseAttribute(attribute))
@@ -281,16 +289,17 @@
return hasTagName(SVGNames::animateMotionTag) ? CalcModePaced : CalcModeLinear;
}
-SVGAnimationElement::AttributeType SVGAnimationElement::attributeType() const
-{
+void SVGAnimationElement::setAttributeType(const AtomicString& attributeType)
+{
DEFINE_STATIC_LOCAL(const AtomicString, css, ("CSS"));
DEFINE_STATIC_LOCAL(const AtomicString, xml, ("XML"));
- const AtomicString& value = fastGetAttribute(SVGNames::attributeTypeAttr);
- if (value == css)
- return AttributeTypeCSS;
- if (value == xml)
- return AttributeTypeXML;
- return AttributeTypeAuto;
+ if (attributeType == css)
+ m_attributeType = AttributeTypeCSS;
+ else if (attributeType == xml)
+ m_attributeType = AttributeTypeXML;
+ else
+ m_attributeType = AttributeTypeAuto;
+ checkInvalidCSSAttributeType(targetElement(DoNotResolveNewTarget));
}
String SVGAnimationElement::toValue() const
@@ -648,6 +657,25 @@
m_toPropertyValueType = InheritValue;
}
+void SVGAnimationElement::targetElementWillChange(SVGElement* currentTarget, SVGElement* newTarget)
+{
+ SVGSMILElement::targetElementWillChange(currentTarget, newTarget);
+
+ checkInvalidCSSAttributeType(newTarget);
}
+void SVGAnimationElement::setAttributeName(const QualifiedName& attributeName)
+{
+ SVGSMILElement::setAttributeName(attributeName);
+
+ checkInvalidCSSAttributeType(targetElement(DoNotResolveNewTarget));
+}
+
+void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target)
+{
+ m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attributeType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeName());
+}
+
+}
+
#endif // ENABLE(SVG)
Modified: branches/chromium/1271/Source/WebCore/svg/SVGAnimationElement.h (131766 => 131767)
--- branches/chromium/1271/Source/WebCore/svg/SVGAnimationElement.h 2012-10-18 17:08:41 UTC (rev 131766)
+++ branches/chromium/1271/Source/WebCore/svg/SVGAnimationElement.h 2012-10-18 17:10:14 UTC (rev 131767)
@@ -183,7 +183,7 @@
AttributeTypeXML,
AttributeTypeAuto
};
- AttributeType attributeType() const;
+ AttributeType attributeType() const { return m_attributeType; }
String toValue() const;
String byValue() const;
@@ -198,9 +198,16 @@
AnimatedPropertyValueType m_fromPropertyValueType;
AnimatedPropertyValueType m_toPropertyValueType;
+ virtual void targetElementWillChange(SVGElement* currentTarget, SVGElement* oldTarget) OVERRIDE;
+ bool hasInvalidCSSAttributeType() const { return m_hasInvalidCSSAttributeType; }
+
private:
virtual void animationAttributeChanged() OVERRIDE;
+ virtual void setAttributeName(const QualifiedName&) OVERRIDE;
+ void setAttributeType(const AtomicString&);
+ void checkInvalidCSSAttributeType(SVGElement*);
+
virtual bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) = 0;
virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
@@ -230,12 +237,14 @@
bool m_animationValid;
+ AttributeType m_attributeType;
Vector<String> m_values;
Vector<float> m_keyTimes;
Vector<float> m_keyPoints;
Vector<UnitBezier> m_keySplines;
String m_lastValuesAnimationFrom;
String m_lastValuesAnimationTo;
+ bool m_hasInvalidCSSAttributeType;
};
} // namespace WebCore
Modified: branches/chromium/1271/Source/WebCore/svg/animation/SVGSMILElement.cpp (131766 => 131767)
--- branches/chromium/1271/Source/WebCore/svg/animation/SVGSMILElement.cpp 2012-10-18 17:08:41 UTC (rev 131766)
+++ branches/chromium/1271/Source/WebCore/svg/animation/SVGSMILElement.cpp 2012-10-18 17:10:14 UTC (rev 131767)
@@ -549,12 +549,12 @@
m_timeContainer->schedule(this);
}
-SVGElement* SVGSMILElement::targetElement()
+SVGElement* SVGSMILElement::targetElement(ResolveTarget resolveTarget)
{
if (m_targetElement)
return m_targetElement;
- if (!inDocument())
+ if (!inDocument() || resolveTarget == DoNotResolveNewTarget)
return 0;
String href = ""
Modified: branches/chromium/1271/Source/WebCore/svg/animation/SVGSMILElement.h (131766 => 131767)
--- branches/chromium/1271/Source/WebCore/svg/animation/SVGSMILElement.h 2012-10-18 17:08:41 UTC (rev 131766)
+++ branches/chromium/1271/Source/WebCore/svg/animation/SVGSMILElement.h 2012-10-18 17:10:14 UTC (rev 131767)
@@ -55,7 +55,7 @@
SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
- SVGElement* targetElement();
+ SVGElement* targetElement(ResolveTarget = ResolveNewTarget);
void resetTargetElement();
const QualifiedName& attributeName() const { return m_attributeName; }
@@ -118,6 +118,7 @@
// Sub-classes may need to take action when the target is changed.
virtual void targetElementWillChange(SVGElement* currentTarget, SVGElement* newTarget);
+ virtual void setAttributeName(const QualifiedName&);
private:
virtual void startedActiveInterval() = 0;