Diff
Modified: trunk/LayoutTests/ChangeLog (90581 => 90582)
--- trunk/LayoutTests/ChangeLog 2011-07-07 18:38:18 UTC (rev 90581)
+++ trunk/LayoutTests/ChangeLog 2011-07-07 18:43:44 UTC (rev 90582)
@@ -1,3 +1,20 @@
+2011-07-07 Dirk Schulze <k...@webkit.org>
+
+ Reviewed by Rob Buis.
+
+ SVGAnimatedPath needs fallback for 'by' animation
+ https://bugs.webkit.org/show_bug.cgi?id=63865
+
+ Test fallback to 'to' animation for 'by' animated SVGPath.
+
+ * svg/animations/script-tests/svgpath-animation-1.js: Added.
+ (sample1):
+ (sample2):
+ (sample3):
+ (executeTest):
+ * svg/animations/svgpath-animation-1-expected.txt: Added.
+ * svg/animations/svgpath-animation-1.html: Added.
+
2011-07-07 Gustavo Noronha Silva <g...@gnome.org>
Unreviewed.
Modified: trunk/LayoutTests/platform/wk2/Skipped (90581 => 90582)
--- trunk/LayoutTests/platform/wk2/Skipped 2011-07-07 18:38:18 UTC (rev 90581)
+++ trunk/LayoutTests/platform/wk2/Skipped 2011-07-07 18:43:44 UTC (rev 90582)
@@ -488,6 +488,7 @@
svg/animations/svgnumberoptionalnumber-animation-2.html
svg/animations/svgnumberoptionalnumber-animation-3.html
svg/animations/svgnumberoptionalnumber-animation-4.html
+svg/animations/svgpath-animation-1.html
svg/animations/svgpointlist-animation-1.html
svg/animations/svgpointlist-animation-2.html
svg/animations/svgPreserveAspectRatio-animation-1.html
Added: trunk/LayoutTests/svg/animations/script-tests/svgpath-animation-1.js (0 => 90582)
--- trunk/LayoutTests/svg/animations/script-tests/svgpath-animation-1.js (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/svgpath-animation-1.js 2011-07-07 18:43:44 UTC (rev 90582)
@@ -0,0 +1,53 @@
+description("Test fallback to 'to' animation if user specifies 'by' animation on path. You should see a green 100x100 path and only PASS messages");
+createSVGTestCase();
+// FIXME: We should move to animatePathSegList, once it is implemented.
+
+// Setup test document
+var path = createSVGElement("path");
+path.setAttribute("id", "path");
+path.setAttribute("d", "M 40 40 L 60 40 L 60 60 L 40 60 z");
+path.setAttribute("fill", "green");
+path.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "d");
+animate.setAttribute("from", "M 40 40 L 60 40 L 60 60 L 40 60 z");
+animate.setAttribute("by", "M 0 0 L 100 0 L 100 100 L 0 100 z");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "4s");
+path.appendChild(animate);
+rootSVGElement.appendChild(path);
+
+// Setup animation test
+function sample1() {
+ // Check initial/end conditions
+ shouldBe("path.pathSegList.getItem(0).x", "40");
+ shouldBe("path.pathSegList.getItem(0).y", "40");
+}
+
+function sample2() {
+ shouldBeCloseEnough("path.pathSegList.getItem(0).x", "20", 0.01);
+ shouldBeCloseEnough("path.pathSegList.getItem(0).y", "20", 0.01);
+}
+
+function sample3() {
+ shouldBeCloseEnough("path.pathSegList.getItem(0).x", "0", 0.01);
+ shouldBeCloseEnough("path.pathSegList.getItem(0).y", "0", 0.01);
+}
+
+function executeTest() {
+ const expectedValues = [
+ // [animationId, time, elementId, sampleCallback]
+ ["animation", 0.0, "path", sample1],
+ ["animation", 2.0, "path", sample2],
+ ["animation", 3.9999, "path", sample3],
+ ["animation", 4.0 , "path", sample1]
+ ];
+
+ runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
Added: trunk/LayoutTests/svg/animations/svgpath-animation-1-expected.txt (0 => 90582)
--- trunk/LayoutTests/svg/animations/svgpath-animation-1-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/animations/svgpath-animation-1-expected.txt 2011-07-07 18:43:44 UTC (rev 90582)
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test fallback to 'to' animation if user specifies 'by' animation on path. You should see a green 100x100 path and only PASS messages
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS path.pathSegList.getItem(0).x is 40
+PASS path.pathSegList.getItem(0).y is 40
+PASS path.pathSegList.getItem(0).x is 20
+PASS path.pathSegList.getItem(0).y is 20
+PASS path.pathSegList.getItem(0).x is 0
+PASS path.pathSegList.getItem(0).y is 0
+PASS path.pathSegList.getItem(0).x is 40
+PASS path.pathSegList.getItem(0).y is 40
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/svg/animations/svgpath-animation-1.html (0 => 90582)
--- trunk/LayoutTests/svg/animations/svgpath-animation-1.html (rev 0)
+++ trunk/LayoutTests/svg/animations/svgpath-animation-1.html 2011-07-07 18:43:44 UTC (rev 90582)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (90581 => 90582)
--- trunk/Source/WebCore/ChangeLog 2011-07-07 18:38:18 UTC (rev 90581)
+++ trunk/Source/WebCore/ChangeLog 2011-07-07 18:43:44 UTC (rev 90582)
@@ -1,3 +1,32 @@
+2011-07-07 Dirk Schulze <k...@webkit.org>
+
+ Reviewed by Rob Buis.
+
+ SVGAnimatedPath needs fallback for 'by' animation
+ https://bugs.webkit.org/show_bug.cgi?id=63865
+
+ Added fallback to 'to' animation for 'by' animated SVGAnimatedPathAnimator.
+
+ Clenup of SVGAnimateElement. Removed all switches since we support all AnimatedTypes
+ with the exception of AnimatedEnumeration. AnimatedEnumeration gets animated as AnimatedString at the moment.
+
+ Test: svg/animations/svgpath-animation-1.html
+
+ * svg/SVGAnimateElement.cpp:
+ (WebCore::getPropertyValue):
+ (WebCore::inheritsFromProperty):
+ (WebCore::attributeValueIsCurrentColor):
+ (WebCore::SVGAnimateElement::adjustForCurrentColor):
+ (WebCore::SVGAnimateElement::determineAnimatedAttributeType):
+ (WebCore::SVGAnimateElement::calculateAnimatedValue):
+ (WebCore::SVGAnimateElement::calculateFromAndToValues):
+ (WebCore::SVGAnimateElement::calculateFromAndByValues):
+ (WebCore::SVGAnimateElement::resetToBaseValue):
+ (WebCore::SVGAnimateElement::applyResultsToTarget):
+ (WebCore::SVGAnimateElement::calculateDistance):
+ * svg/SVGAnimatedPath.cpp:
+ (WebCore::SVGAnimatedPathAnimator::calculateFromAndByValues):
+
2011-07-07 Andrey Kosyakov <ca...@chromium.org>
Web Inspector: secure access to extensions API
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.cpp (90581 => 90582)
--- trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-07-07 18:38:18 UTC (rev 90581)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-07-07 18:43:44 UTC (rev 90582)
@@ -56,22 +56,38 @@
{
}
-void SVGAnimateElement::adjustForCurrentColor(SVGElement* targetElement, Color& color)
+static inline void getPropertyValue(SVGElement* svgParent, const QualifiedName& attributeName, String& value)
{
+ ASSERT(svgParent->isStyled());
+ value = computedStyle(svgParent)->getPropertyValue(cssPropertyID(attributeName.localName()));
+}
+
+static bool inheritsFromProperty(SVGElement* targetElement, const QualifiedName& attributeName, const String& value)
+{
ASSERT(targetElement);
+ DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit"));
+ if (value.isEmpty() || value != inherit || !targetElement->isStyled())
+ return false;
+ return SVGStyledElement::isAnimatableCSSProperty(attributeName);
+}
+
+static bool attributeValueIsCurrentColor(const String& value)
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, currentColor, ("currentColor"));
+ return value == currentColor;
+}
+
+void SVGAnimateElement::adjustForCurrentColor(SVGElement* targetElement, Color& color)
+{
+ ASSERT(targetElement);
+
if (RenderObject* targetRenderer = targetElement->renderer())
color = targetRenderer->style()->visitedDependentColor(CSSPropertyColor);
else
color = Color();
}
-static inline void getPropertyValue(SVGElement* svgParent, const QualifiedName& attributeName, String& value)
-{
- ASSERT(svgParent->isStyled());
- value = computedStyle(svgParent)->getPropertyValue(cssPropertyID(attributeName.localName()));
-}
-
void SVGAnimateElement::adjustForInheritance(SVGElement* targetElement, const QualifiedName& attributeName, String& value)
{
// FIXME: At the moment the computed style gets returned as a String and needs to get parsed again.
@@ -101,112 +117,21 @@
ASSERT(targetElement);
AnimatedAttributeType type = targetElement->animatedPropertyTypeForAttribute(attributeName());
- if (type == AnimatedUnknown || (hasTagName(SVGNames::animateColorTag) && type != AnimatedColor))
+ if (hasTagName(SVGNames::animateColorTag) && type != AnimatedColor)
return AnimatedUnknown;
- // FIXME: Animator for AnimatedEnumeration missing.
- switch (type) {
- case AnimatedAngle:
- return AnimatedAngle;
- case AnimatedBoolean:
- return AnimatedBoolean;
- case AnimatedEnumeration:
- case AnimatedString:
+ // FIXME: Animator for AnimatedEnumeration missing. Falling back to String animation.
+ if (type == AnimatedEnumeration)
return AnimatedString;
- case AnimatedColor:
- return AnimatedColor;
- case AnimatedInteger:
- return AnimatedInteger;
- case AnimatedLength:
- return AnimatedLength;
- case AnimatedLengthList:
- return AnimatedLengthList;
- case AnimatedNumber:
- return AnimatedNumber;
- case AnimatedNumberList:
- return AnimatedNumberList;
- case AnimatedNumberOptionalNumber:
- return AnimatedNumberOptionalNumber;
- case AnimatedPath:
- return AnimatedPath;
- case AnimatedPoints:
- return AnimatedPoints;
- case AnimatedPreserveAspectRatio:
- return AnimatedPreserveAspectRatio;
- case AnimatedRect:
- return AnimatedRect;
- case AnimatedTransformList:
- case AnimatedUnknown:
- // Animations of transform lists are not allowed for <animate> or <set>
- // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties
+
+ // Animations of transform lists are not allowed for <animate> or <set>
+ // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties
+ if (type == AnimatedTransformList)
return AnimatedUnknown;
- }
- ASSERT_NOT_REACHED();
- return AnimatedUnknown;
+ return type;
}
-void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement)
-{
- ASSERT(percentage >= 0 && percentage <= 1);
- ASSERT(resultElement);
- SVGElement* targetElement = this->targetElement();
- if (!targetElement)
- return;
-
- if (hasTagName(SVGNames::setTag))
- percentage = 1;
- if (!resultElement->hasTagName(SVGNames::animateTag) && !resultElement->hasTagName(SVGNames::animateColorTag)
- && !resultElement->hasTagName(SVGNames::setTag))
- return;
- SVGAnimateElement* results = static_cast<SVGAnimateElement*>(resultElement);
- // Can't accumulate over a string property.
- if (results->m_animatedAttributeType == AnimatedString && m_animatedAttributeType != AnimatedString)
- return;
- switch (m_animatedAttributeType) {
- case AnimatedAngle:
- case AnimatedBoolean:
- case AnimatedColor:
- case AnimatedInteger:
- case AnimatedLength:
- case AnimatedLengthList:
- case AnimatedNumber:
- case AnimatedNumberList:
- case AnimatedNumberOptionalNumber:
- case AnimatedPath:
- case AnimatedPoints:
- case AnimatedPreserveAspectRatio:
- case AnimatedRect:
- case AnimatedString: {
- ASSERT(m_animator);
- ASSERT(results->m_animatedType);
- // Target element might have changed.
- m_animator->setContextElement(targetElement);
- m_animator->calculateAnimatedValue(percentage, repeat, m_fromType, m_toType, results->m_animatedType);
- return;
- }
- default:
- break;
- }
- ASSERT_NOT_REACHED();
-}
-
-static bool inheritsFromProperty(SVGElement* targetElement, const QualifiedName& attributeName, const String& value)
-{
- ASSERT(targetElement);
- DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit"));
-
- if (value.isEmpty() || value != inherit || !targetElement->isStyled())
- return false;
- return SVGStyledElement::isAnimatableCSSProperty(attributeName);
-}
-
-static bool attributeValueIsCurrentColor(const String& value)
-{
- DEFINE_STATIC_LOCAL(const AtomicString, currentColor, ("currentColor"));
- return value == currentColor;
-}
-
void SVGAnimateElement::determinePropertyValueTypes(const String& from, const String& to)
{
SVGElement* targetElement = this->targetElement();
@@ -226,36 +151,46 @@
m_toPropertyValueType = CurrentColorValue;
}
+void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement)
+{
+ ASSERT(resultElement);
+ ASSERT(percentage >= 0 && percentage <= 1);
+ ASSERT(m_animatedAttributeType != AnimatedEnumeration);
+ ASSERT(m_animatedAttributeType != AnimatedTransformList);
+ ASSERT(m_animatedAttributeType != AnimatedUnknown);
+ ASSERT(m_animator);
+ ASSERT(m_fromType);
+ ASSERT(m_toType);
+
+ SVGAnimateElement* resultAnimationElement = static_cast<SVGAnimateElement*>(resultElement);
+ ASSERT(resultAnimationElement->m_animatedType);
+ ASSERT(resultAnimationElement->m_animatedAttributeType == m_animatedAttributeType);
+ ASSERT(resultAnimationElement->hasTagName(SVGNames::animateTag)
+ || resultAnimationElement->hasTagName(SVGNames::animateColorTag)
+ || resultAnimationElement->hasTagName(SVGNames::setTag));
+
+ if (hasTagName(SVGNames::setTag))
+ percentage = 1;
+
+ SVGElement* targetElement = this->targetElement();
+ if (!targetElement)
+ return;
+
+ // Target element might have changed.
+ m_animator->setContextElement(targetElement);
+ m_animator->calculateAnimatedValue(percentage, repeat, m_fromType, m_toType, resultAnimationElement->m_animatedType);
+}
+
bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const String& toString)
{
SVGElement* targetElement = this->targetElement();
if (!targetElement)
return false;
- // FIXME: Needs more solid way determine target attribute type.
m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
- switch (m_animatedAttributeType) {
- case AnimatedAngle:
- case AnimatedBoolean:
- case AnimatedColor:
- case AnimatedInteger:
- case AnimatedLength:
- case AnimatedLengthList:
- case AnimatedNumber:
- case AnimatedNumberList:
- case AnimatedNumberOptionalNumber:
- case AnimatedPath:
- case AnimatedPoints:
- case AnimatedPreserveAspectRatio:
- case AnimatedRect:
- case AnimatedString:
- ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
- return true;
- default:
- break;
- }
- ASSERT_NOT_REACHED();
- return false;
+
+ ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
+ return true;
}
bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const String& byString)
@@ -266,30 +201,9 @@
ASSERT(!hasTagName(SVGNames::setTag));
m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
- switch (m_animatedAttributeType) {
- case AnimatedAngle:
- case AnimatedBoolean:
- case AnimatedColor:
- case AnimatedInteger:
- case AnimatedLength:
- case AnimatedLengthList:
- case AnimatedNumber:
- case AnimatedNumberList:
- case AnimatedNumberOptionalNumber:
- case AnimatedPoints:
- case AnimatedPreserveAspectRatio:
- case AnimatedRect:
- case AnimatedString:
- ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
- return true;
- case AnimatedPath:
- ASSERT_NOT_REACHED(); // This state is not reachable for now.
- break;
- default:
- break;
- }
- ASSERT_NOT_REACHED();
- return false;
+
+ ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
+ return true;
}
void SVGAnimateElement::resetToBaseValue(const String& baseString)
@@ -297,57 +211,21 @@
SVGElement* targetElement = this->targetElement();
ASSERT(targetElement);
m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
- switch (m_animatedAttributeType) {
- case AnimatedAngle:
- case AnimatedBoolean:
- case AnimatedColor:
- case AnimatedInteger:
- case AnimatedLength:
- case AnimatedLengthList:
- case AnimatedNumber:
- case AnimatedNumberList:
- case AnimatedNumberOptionalNumber:
- case AnimatedPath:
- case AnimatedPoints:
- case AnimatedPreserveAspectRatio:
- case AnimatedRect:
- case AnimatedString: {
- if (!m_animatedType)
- m_animatedType = ensureAnimator()->constructFromString(baseString);
- else
- m_animatedType->setValueAsString(attributeName(), baseString);
- return;
- }
- default:
- break;
- }
- ASSERT_NOT_REACHED();
+
+ if (!m_animatedType)
+ m_animatedType = ensureAnimator()->constructFromString(baseString);
+ else
+ m_animatedType->setValueAsString(attributeName(), baseString);
}
void SVGAnimateElement::applyResultsToTarget()
{
- String valueToApply;
- switch (m_animatedAttributeType) {
- case AnimatedAngle:
- case AnimatedBoolean:
- case AnimatedColor:
- case AnimatedInteger:
- case AnimatedLength:
- case AnimatedLengthList:
- case AnimatedNumber:
- case AnimatedNumberList:
- case AnimatedNumberOptionalNumber:
- case AnimatedPath:
- case AnimatedPoints:
- case AnimatedPreserveAspectRatio:
- case AnimatedRect:
- case AnimatedString:
- valueToApply = m_animatedType->valueAsString();
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- setTargetAttributeAnimatedValue(valueToApply);
+ ASSERT(m_animatedAttributeType != AnimatedEnumeration);
+ ASSERT(m_animatedAttributeType != AnimatedTransformList);
+ ASSERT(m_animatedAttributeType != AnimatedUnknown);
+ ASSERT(m_animatedType);
+
+ setTargetAttributeAnimatedValue(m_animatedType->valueAsString());
}
float SVGAnimateElement::calculateDistance(const String& fromString, const String& toString)
@@ -357,27 +235,8 @@
if (!targetElement)
return -1;
m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
- switch (m_animatedAttributeType) {
- case AnimatedAngle:
- case AnimatedBoolean:
- case AnimatedColor:
- case AnimatedInteger:
- case AnimatedLength:
- case AnimatedLengthList:
- case AnimatedNumber:
- case AnimatedNumberList:
- case AnimatedNumberOptionalNumber:
- case AnimatedPath:
- case AnimatedPoints:
- case AnimatedPreserveAspectRatio:
- case AnimatedRect:
- case AnimatedString:
- return ensureAnimator()->calculateDistance(fromString, toString);
- default:
- break;
- }
- ASSERT_NOT_REACHED();
- return -1;
+
+ return ensureAnimator()->calculateDistance(fromString, toString);
}
SVGAnimatedTypeAnimator* SVGAnimateElement::ensureAnimator()
Modified: trunk/Source/WebCore/svg/SVGAnimatedPath.cpp (90581 => 90582)
--- trunk/Source/WebCore/svg/SVGAnimatedPath.cpp 2011-07-07 18:38:18 UTC (rev 90581)
+++ trunk/Source/WebCore/svg/SVGAnimatedPath.cpp 2011-07-07 18:43:44 UTC (rev 90582)
@@ -69,9 +69,10 @@
from = SVGAnimatedType::createPath(SVGPathByteStream::create());
}
-void SVGAnimatedPathAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>&, OwnPtr<SVGAnimatedType>&, const String&, const String&)
+void SVGAnimatedPathAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& by, const String& fromString, const String& byString)
{
- ASSERT_NOT_REACHED();
+ // Fallback to from-to animation, since from-by animation does not make sense.
+ calculateFromAndToValues(from, by, fromString, byString);
}
void SVGAnimatedPathAnimator::calculateAnimatedValue(float percentage, unsigned, OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, OwnPtr<SVGAnimatedType>& animated)