Title: [89367] trunk
Revision
89367
Author
k...@webkit.org
Date
2011-06-21 11:14:12 -0700 (Tue, 21 Jun 2011)

Log Message

2011-06-21  Dirk Schulze  <k...@webkit.org>

        Reviewed by Rob Buis.

        SVG no fallback to discrete animation on attribute 'values' for SVGString
        https://bugs.webkit.org/show_bug.cgi?id=57085

        Check for AnimatedString, AnimatedBoolean and AnimatedEnumeration on 'values' calculation.
        If the property type matches one of the above values, fallback to discrete animation.

        The patch also changes behavior for String animation. The animation code doesn't handle inheritance
        for strings anymore. This is done by the CSS parser itself now, we just need to handle inheritance
        on animations that interpolate between two values like for calcMode="linear".

        Test: svg/animations/svgstring-animation-fallback-to-discrete.html

        * svg/SVGAnimateElement.cpp:
        (WebCore::SVGAnimateElement::calculateAnimatedValue):
        * svg/SVGAnimateElement.h:
        * svg/SVGAnimationElement.cpp:
        (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
2011-06-21  Dirk Schulze  <k...@webkit.org>

        Reviewed by Rob Buis.

        SVG no fallback to discrete animation on attribute 'values' for SVGString
        https://bugs.webkit.org/show_bug.cgi?id=57085
        
        Added new test to check fallback to discrete animations on string values. One
        test needed rebaseline. Even if we do not pass the test it is still a progression. 

        * platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.txt:
        * svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
        * svg/animations/svgstring-animation-fallback-to-discrete-expected.txt: Added.
        * svg/animations/svgstring-animation-fallback-to-discrete.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (89366 => 89367)


--- trunk/LayoutTests/ChangeLog	2011-06-21 18:05:09 UTC (rev 89366)
+++ trunk/LayoutTests/ChangeLog	2011-06-21 18:14:12 UTC (rev 89367)
@@ -1,3 +1,23 @@
+2011-06-21  Dirk Schulze  <k...@webkit.org>
+
+        Reviewed by Rob Buis.
+
+        SVG no fallback to discrete animation on attribute 'values' for SVGString
+        https://bugs.webkit.org/show_bug.cgi?id=57085
+        
+        Added new test to check fallback to discrete animations on string values. One
+        test needed rebaseline. Even if we do not pass the test it is still a progression. 
+
+        * platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.png:
+        * platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.txt:
+        * svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js: Added.
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+        * svg/animations/svgstring-animation-fallback-to-discrete-expected.txt: Added.
+        * svg/animations/svgstring-animation-fallback-to-discrete.html: Added.
+
 2011-06-21  Matthew Delaney  <mdela...@apple.com>
 
         Reviewed by Simon Fraser.

Modified: trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.txt (89366 => 89367)


--- trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.txt	2011-06-21 18:05:09 UTC (rev 89366)
+++ trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-31-t-expected.txt	2011-06-21 18:14:12 UTC (rev 89367)
@@ -19,7 +19,8 @@
         RenderSVGHiddenContainer {g} at (0,0) size 0x0
           RenderSVGPath {circle} at (235,10) size 70x70 [stroke={[type=SOLID] [color=#000000] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=180.00] [cy=30.00] [r=20.00]
       RenderSVGPath {circle} at (235,115) size 70x70 [stroke={[type=SOLID] [color=#000000] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=180.00] [cy=100.00] [r=20.00]
-      RenderSVGContainer {g} at (0,0) size 0x0
+      RenderSVGContainer {g} at (310,10) size 70x70
+        RenderSVGPath {circle} at (310,10) size 70x70 [stroke={[type=SOLID] [color=#000000] [stroke width=5.00]}] [fill={[type=SOLID] [color=#00FFFF]}] [cx=230.00] [cy=30.00] [r=20.00]
       RenderSVGContainer {g} at (310,115) size 70x70
         RenderSVGPath {circle} at (310,115) size 70x70 [stroke={[type=SOLID] [color=#000000] [stroke width=5.00]}] [fill={[type=SOLID] [color=#00FFFF]}] [cx=230.00] [cy=100.00] [r=20.00]
     RenderSVGText {text} at (385,26) size 45x18 contains 1 chunk(s)

Added: trunk/LayoutTests/svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js (0 => 89367)


--- trunk/LayoutTests/svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/svgstring-animation-fallback-to-discrete.js	2011-06-21 18:14:12 UTC (rev 89367)
@@ -0,0 +1,52 @@
+description("Tests fallback to calcMode='discrete' on animation of SVGString with 'values'.");
+createSVGTestCase();
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("width", "100");
+rect.setAttribute("height", "100");
+rect.setAttribute("fill", "green");
+rect.setAttribute("onclick", "executeTest()");
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "visibility");
+animate.setAttribute("begin", "click");
+animate.setAttribute("dur", "6s");
+animate.setAttribute("calcMode", "linear");
+animate.setAttribute("values", "visible ; hidden ; visible");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+var computedStyle = rect.ownerDocument.defaultView.getComputedStyle(rect);
+
+// Setup animation test
+function sample1() {
+    // Check initial/end conditions
+    shouldBe("rect.style.visibility", "'visible'");
+}
+
+function sample2() {
+    shouldBe("rect.style.visibility", "'hidden'");
+}
+
+function sample3() {
+    shouldBe("rect.style.visibility", "'visible'");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animation", 1.9999, "rect", sample1],
+        ["animation", 2,      "rect", sample2],
+        ["animation", 3.9999, "rect", sample3],
+        ["animation", 4,      "rect", sample1]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 30)", 0);
+var successfullyParsed = true;

Added: trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete-expected.txt (0 => 89367)


--- trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete-expected.txt	2011-06-21 18:14:12 UTC (rev 89367)
@@ -0,0 +1,15 @@
+SVG 1.1 dynamic animation tests
+
+Tests fallback to calcMode='discrete' on animation of SVGString with 'values'.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rect.style.visibility is 'visible'
+PASS rect.style.visibility is 'hidden'
+FAIL rect.style.visibility should be visible. Was hidden.
+PASS rect.style.visibility is 'visible'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete.html (0 => 89367)


--- trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/svgstring-animation-fallback-to-discrete.html	2011-06-21 18:14:12 UTC (rev 89367)
@@ -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 (89366 => 89367)


--- trunk/Source/WebCore/ChangeLog	2011-06-21 18:05:09 UTC (rev 89366)
+++ trunk/Source/WebCore/ChangeLog	2011-06-21 18:14:12 UTC (rev 89367)
@@ -1,3 +1,25 @@
+2011-06-21  Dirk Schulze  <k...@webkit.org>
+
+        Reviewed by Rob Buis.
+
+        SVG no fallback to discrete animation on attribute 'values' for SVGString
+        https://bugs.webkit.org/show_bug.cgi?id=57085
+
+        Check for AnimatedString, AnimatedBoolean and AnimatedEnumeration on 'values' calculation.
+        If the property type matches one of the above values, fallback to discrete animation.
+
+        The patch also changes behavior for String animation. The animation code doesn't handle inheritance
+        for strings anymore. This is done by the CSS parser itself now, we just need to handle inheritance
+        on animations that interpolate between two values like for calcMode="linear".
+
+        Test: svg/animations/svgstring-animation-fallback-to-discrete.html
+
+        * svg/SVGAnimateElement.cpp:
+        (WebCore::SVGAnimateElement::calculateAnimatedValue):
+        * svg/SVGAnimateElement.h:
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
+
 2011-06-21  Cary Clark  <carycl...@google.com>
 
         Reviewed by Eric Seidel.

Modified: trunk/Source/WebCore/svg/SVGAnimateElement.cpp (89366 => 89367)


--- trunk/Source/WebCore/svg/SVGAnimateElement.cpp	2011-06-21 18:05:09 UTC (rev 89366)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.cpp	2011-06-21 18:14:12 UTC (rev 89367)
@@ -262,12 +262,6 @@
         break;
     }
     ASSERT(animationMode == FromToAnimation || animationMode == ToAnimation || animationMode == ValuesAnimation);
-    // Replace 'currentColor' / 'inherit' by their computed property values.
-    if (m_fromPropertyValueType == InheritValue)
-        adjustForInheritance(targetElement, attributeName(), m_fromString);
-    if (m_toPropertyValueType == InheritValue)
-        adjustForInheritance(targetElement, attributeName(), m_toString);
-
     if ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1)
         results->m_animatedString = m_toString;
     else

Modified: trunk/Source/WebCore/svg/SVGAnimateElement.h (89366 => 89367)


--- trunk/Source/WebCore/svg/SVGAnimateElement.h	2011-06-21 18:05:09 UTC (rev 89366)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.h	2011-06-21 18:14:12 UTC (rev 89367)
@@ -44,6 +44,8 @@
     
     static void adjustForCurrentColor(SVGElement* targetElement, Color&);
     void adjustForInheritance(SVGElement* targetElement, const QualifiedName&, String& value);
+    
+    AnimatedAttributeType determineAnimatedAttributeType(SVGElement*) const;
 
 protected:
     SVGAnimateElement(const QualifiedName&, Document*);
@@ -57,7 +59,7 @@
 
 private:
     SVGAnimatedTypeAnimator* ensureAnimator();
-    
+
     // If we have 'currentColor' or 'inherit' as animation value, we need to grab the value during the animation
     // since the value can be animated itself.
     enum AnimatedPropertyValueType {
@@ -67,7 +69,6 @@
     };
     
     virtual bool hasValidAttributeType() const;
-    AnimatedAttributeType determineAnimatedAttributeType(SVGElement*) const;
     AnimatedAttributeType m_animatedAttributeType;
 
     AnimatedPropertyValueType m_fromPropertyValueType;

Modified: trunk/Source/WebCore/svg/SVGAnimationElement.cpp (89366 => 89367)


--- trunk/Source/WebCore/svg/SVGAnimationElement.cpp	2011-06-21 18:05:09 UTC (rev 89366)
+++ trunk/Source/WebCore/svg/SVGAnimationElement.cpp	2011-06-21 18:14:12 UTC (rev 89367)
@@ -481,6 +481,16 @@
     ASSERT(valuesCount > 1);
     
     CalcMode calcMode = this->calcMode();
+    if (hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::animateColorTag)) {
+        const SVGAnimateElement* animateElement = static_cast<const SVGAnimateElement*>(this);
+        AnimatedAttributeType attributeType = animateElement->determineAnimatedAttributeType(targetElement());
+        // Fall back to discrete animations for Strings.
+        if (attributeType == AnimatedBoolean
+            || attributeType == AnimatedEnumeration
+            || attributeType == AnimatedPreserveAspectRatio
+            || attributeType == AnimatedString)
+            calcMode = CalcModeDiscrete;
+    }
     if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced)
         return currentValuesFromKeyPoints(percent, effectivePercent, from, to);
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to