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/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/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,