Title: [106878] trunk
Revision
106878
Author
[email protected]
Date
2012-02-06 16:55:15 -0800 (Mon, 06 Feb 2012)

Log Message

Fix color animations by value
https://bugs.webkit.org/show_bug.cgi?id=77812

Patch by Philip Rogers <[email protected]> on 2012-02-06
Reviewed by Darin Adler.

Source/WebCore:

Test: svg/animations/animate-color-fill-from-by.html

* svg/SVGAnimatedColor.cpp:
(WebCore::SVGAnimatedColorAnimator::calculateFromAndByValues):

LayoutTests:

* svg/animations/animate-color-fill-from-by-expected.txt: Added.
* svg/animations/animate-color-fill-from-by.html: Added.
* svg/animations/script-tests/animate-color-fill-from-by.js: Added.
(checkFillColor):
(sample1):
(sample2):
(sample3):
(executeTest):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106877 => 106878)


--- trunk/LayoutTests/ChangeLog	2012-02-07 00:53:23 UTC (rev 106877)
+++ trunk/LayoutTests/ChangeLog	2012-02-07 00:55:15 UTC (rev 106878)
@@ -1,3 +1,19 @@
+2012-02-06  Philip Rogers  <[email protected]>
+
+        Fix color animations by value
+        https://bugs.webkit.org/show_bug.cgi?id=77812
+
+        Reviewed by Darin Adler.
+
+        * svg/animations/animate-color-fill-from-by-expected.txt: Added.
+        * svg/animations/animate-color-fill-from-by.html: Added.
+        * svg/animations/script-tests/animate-color-fill-from-by.js: Added.
+        (checkFillColor):
+        (sample1):
+        (sample2):
+        (sample3):
+        (executeTest):
+
 2012-02-03  Jer Noble  <[email protected]>
 
         REGRESSION (r104303): Clicking inline video controls gives the video a focus ring

Added: trunk/LayoutTests/svg/animations/animate-color-fill-from-by-expected.txt (0 => 106878)


--- trunk/LayoutTests/svg/animations/animate-color-fill-from-by-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/animate-color-fill-from-by-expected.txt	2012-02-07 00:55:15 UTC (rev 106878)
@@ -0,0 +1,44 @@
+SVG 1.1 dynamic animation tests
+
+Tests animation on 'currentColor'.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Initial condition:
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('fill') is "#d00000"
+PASS (fillPaint = document.defaultView.getComputedStyle(rect).getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
+PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR
+PASS fillPaint.uri is ""
+PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_CURRENTCOLOR
+PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
+PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 208
+PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
+PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
+
+Half-time condition:
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('fill') is "#d00068"
+PASS (fillPaint = document.defaultView.getComputedStyle(rect).getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
+PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR
+PASS fillPaint.uri is ""
+PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_CURRENTCOLOR
+PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
+PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 208
+PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
+PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 104
+
+End condition:
+PASS document.defaultView.getComputedStyle(rect).getPropertyValue('fill') is "#d000d0"
+PASS (fillPaint = document.defaultView.getComputedStyle(rect).getPropertyCSSValue('fill')).toString() is "[object SVGPaint]"
+PASS fillPaint.paintType is SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR
+PASS fillPaint.uri is ""
+PASS fillPaint.colorType is SVGColor.SVG_COLORTYPE_CURRENTCOLOR
+PASS (fillColor = fillPaint.rgbColor).toString() is "[object RGBColor]"
+PASS fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 208
+PASS fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0
+PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 208
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/animations/animate-color-fill-from-by.html (0 => 106878)


--- trunk/LayoutTests/svg/animations/animate-color-fill-from-by.html	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/animate-color-fill-from-by.html	2012-02-07 00:55:15 UTC (rev 106878)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<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>

Added: trunk/LayoutTests/svg/animations/script-tests/animate-color-fill-from-by.js (0 => 106878)


--- trunk/LayoutTests/svg/animations/script-tests/animate-color-fill-from-by.js	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/animate-color-fill-from-by.js	2012-02-07 00:55:15 UTC (rev 106878)
@@ -0,0 +1,74 @@
+description("Tests animation on 'currentColor'.");
+createSVGTestCase();
+
+// Setup test document
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("width", "100px");
+rect.setAttribute("height", "100px");
+rect.setAttribute("fill", "currentColor");
+rect.setAttribute("color", "d00000");
+
+var animateColor = createSVGElement("animateColor");
+animateColor.setAttribute("id", "animateColor");
+animateColor.setAttribute("attributeName", "color");
+animateColor.setAttribute("from", "#d00000");
+animateColor.setAttribute("by", "#0000d0");
+animateColor.setAttribute("dur", "3s");
+animateColor.setAttribute("begin", "click");
+animateColor.setAttribute("fill", "freeze");
+rect.appendChild(animateColor);
+rootSVGElement.appendChild(rect);
+
+function checkFillColor(red, green, blue, hex) {
+    shouldBeEqualToString("document.defaultView.getComputedStyle(rect).getPropertyValue('fill')", hex);
+
+    try {
+        shouldBeEqualToString("(fillPaint = document.defaultView.getComputedStyle(rect).getPropertyCSSValue('fill')).toString()", "[object SVGPaint]");
+        shouldBe("fillPaint.paintType", "SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR");
+        shouldBeEqualToString("fillPaint.uri", "");
+        shouldBe("fillPaint.colorType", "SVGColor.SVG_COLORTYPE_CURRENTCOLOR");
+        shouldBeEqualToString("(fillColor = fillPaint.rgbColor).toString()", "[object RGBColor]");
+        shouldBe("fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "" + red);
+        shouldBe("fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "" + green);
+        shouldBe("fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "" + blue);
+    } catch(e) {
+        // Opera doesn't support getPropertyCSSValue - no way to compare to their SVGPaint/SVGColor objects :(
+    }
+}
+
+// Setup animation test
+function sample1() {
+    debug("");
+    debug("Initial condition:");
+    checkFillColor(208, 0, 0, "#d00000");
+}
+
+function sample2() {
+    debug("");
+    debug("Half-time condition:");
+    checkFillColor(208, 0, 104, "#d00068");
+}
+
+function sample3() {
+    debug("");
+    debug("End condition:");
+    checkFillColor(208, 0, 208, "#d000d0");
+}
+
+function executeTest() {
+    const expectedValues = [
+        // [animationId, time, elementId, sampleCallback]
+        ["animateColor", 0.0,    "rect", sample1],
+        ["animateColor", 1.5,    "rect", sample2],
+        ["animateColor", 3.0,    "rect", sample3]
+    ];
+
+    runAnimationTest(expectedValues);
+}
+
+// Begin test async
+rect.setAttribute("onclick", "executeTest()");
+window.setTimeout("triggerUpdate(50, 50)", 0);
+
+var successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (106877 => 106878)


--- trunk/Source/WebCore/ChangeLog	2012-02-07 00:53:23 UTC (rev 106877)
+++ trunk/Source/WebCore/ChangeLog	2012-02-07 00:55:15 UTC (rev 106878)
@@ -1,3 +1,15 @@
+2012-02-06  Philip Rogers  <[email protected]>
+
+        Fix color animations by value
+        https://bugs.webkit.org/show_bug.cgi?id=77812
+
+        Reviewed by Darin Adler.
+
+        Test: svg/animations/animate-color-fill-from-by.html
+
+        * svg/SVGAnimatedColor.cpp:
+        (WebCore::SVGAnimatedColorAnimator::calculateFromAndByValues):
+
 2012-02-03  Jer Noble  <[email protected]>
 
         REGRESSION (r104303): Clicking inline video controls gives the video a focus ring

Modified: trunk/Source/WebCore/svg/SVGAnimatedColor.cpp (106877 => 106878)


--- trunk/Source/WebCore/svg/SVGAnimatedColor.cpp	2012-02-07 00:53:23 UTC (rev 106877)
+++ trunk/Source/WebCore/svg/SVGAnimatedColor.cpp	2012-02-07 00:55:15 UTC (rev 106878)
@@ -60,6 +60,8 @@
 
     from = constructFromString(fromString);
     to = constructFromString(byString);
+
+    to->color() = ColorDistance::addColorsAndClamp(from->color(), to->color());
 }
 
 void SVGAnimatedColorAnimator::calculateAnimatedValue(float percentage, unsigned,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to