Commit 46b465c4 authored by krit@webkit.org's avatar krit@webkit.org

2011-01-27 Dirk Schulze <krit@webkit.org>

        Reviewed by Nikolas Zimmermann.

        SVG animation doesn't support calcMode discrete for number and color values.
        https://bugs.webkit.org/show_bug.cgi?id=53189

        Add support for calcMode discrete on number and color animation.

        Tests: svg/animations/animate-color-calcMode-discrete.html
               svg/animations/animate-number-calcMode-discrete.html

        * svg/SVGAnimateElement.cpp:
        (WebCore::SVGAnimateElement::calculateAnimatedValue):
2011-01-27  Dirk Schulze  <krit@webkit.org>

        Reviewed by Nikolas Zimmermann.

        SVG animation doesn't support calcMode discrete for number and color values.
        https://bugs.webkit.org/show_bug.cgi?id=53189

        Test for correct behavior on animating numbers and colors with calcMode discrete.

        * svg/animations/animate-color-calcMode-discrete-expected.txt: Added.
        * svg/animations/animate-color-calcMode-discrete.html: Added.
        * svg/animations/animate-number-calcMode-discrete-expected.txt: Added.
        * svg/animations/animate-number-calcMode-discrete.html: Added.
        * svg/animations/script-tests/animate-color-calcMode-discrete.js: Added.
        (sample1):
        (sample2):
        (executeTest):
        * svg/animations/script-tests/animate-number-calcMode-discrete.js: Added.
        (sample1):
        (sample2):
        (executeTest):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76819 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a058ea75
2011-01-27 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
SVG animation doesn't support calcMode discrete for number and color values.
https://bugs.webkit.org/show_bug.cgi?id=53189
Test for correct behavior on animating numbers and colors with calcMode discrete.
* svg/animations/animate-color-calcMode-discrete-expected.txt: Added.
* svg/animations/animate-color-calcMode-discrete.html: Added.
* svg/animations/animate-number-calcMode-discrete-expected.txt: Added.
* svg/animations/animate-number-calcMode-discrete.html: Added.
* svg/animations/script-tests/animate-color-calcMode-discrete.js: Added.
(sample1):
(sample2):
(executeTest):
* svg/animations/script-tests/animate-number-calcMode-discrete.js: Added.
(sample1):
(sample2):
(executeTest):
2011-01-27 Ryosuke Niwa <rniwa@webkit.org>
Unreviewed Chromium test expectation update for video tests.
SVG 1.1 dynamic animation tests
Test calcMode discrete with from-to animation on colors. You should see a green 100x100 rect and only PASS messages
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(255, 0, 0)"
PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(255, 0, 0)"
PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
PASS document.defaultView.getComputedStyle(rect).getPropertyValue('color') is "rgb(0, 255, 255)"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
<script src="resources/SVGAnimationTestCase.js"></script>
</head>
<body>
<h1>SVG 1.1 dynamic animation tests</h1>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/animate-color-calcMode-discrete.js"></script>
</body>
</html>
SVG 1.1 dynamic animation tests
Test calcMode discrete with from-to animation on numbers. You should see a green 100x100 rect and only PASS messages
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS rect.x.baseVal.value is 100
PASS rect.x.baseVal.value is 100
PASS rect.x.baseVal.value is 0
PASS rect.x.baseVal.value is 0
PASS rect.x.baseVal.value is 100
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
<script src="resources/SVGAnimationTestCase.js"></script>
</head>
<body>
<h1>SVG 1.1 dynamic animation tests</h1>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/animate-number-calcMode-discrete.js"></script>
</body>
</html>
description("Test calcMode discrete with from-to animation on colors. You should see a green 100x100 rect and only PASS messages");
createSVGTestCase();
// Setup test document
var rect = createSVGElement("rect");
rect.setAttribute("id", "rect");
rect.setAttribute("width", "100");
rect.setAttribute("height", "100");
rect.setAttribute("color", "rgb(0,255,255)");
rect.setAttribute("fill", "currentColor");
rect.setAttribute("onclick", "executeTest()");
var animate = createSVGElement("animate");
animate.setAttribute("id", "animation");
animate.setAttribute("attributeName", "color");
animate.setAttribute("from", "rgb(255,0,0)");
animate.setAttribute("to", "rgb(0,255,255)");
animate.setAttribute("begin", "click");
animate.setAttribute("dur", "4s");
animate.setAttribute("calcMode", "discrete");
rect.appendChild(animate);
rootSVGElement.appendChild(rect);
// Setup animation test
function sample1() {
// Check initial/end conditions
shouldBeEqualToString("document.defaultView.getComputedStyle(rect).getPropertyValue('color')", "rgb(255, 0, 0)");
}
function sample2() {
shouldBeEqualToString("document.defaultView.getComputedStyle(rect).getPropertyValue('color')", "rgb(0, 255, 255)");
}
function executeTest() {
const expectedValues = [
// [animationId, time, elementId, sampleCallback]
["animation", 0.0, "rect", sample2],
["animation", 0.001, "rect", sample1],
["animation", 1.0, "rect", sample1],
["animation", 3.0, "rect", sample2],
["animation", 3.9999, "rect", sample2],
["animation", 4.0 , "rect", sample2]
];
runAnimationTest(expectedValues);
}
// Begin test async
window.setTimeout("triggerUpdate(50, 50)", 0);
var successfullyParsed = true;
description("Test calcMode discrete with from-to animation on numbers. You should see a green 100x100 rect and only PASS messages");
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 animate = createSVGElement("animate");
animate.setAttribute("id", "animation");
animate.setAttribute("attributeName", "x");
animate.setAttribute("from", "100");
animate.setAttribute("to", "0");
animate.setAttribute("begin", "click");
animate.setAttribute("dur", "4s");
animate.setAttribute("calcMode", "discrete");
rect.appendChild(animate);
rootSVGElement.appendChild(rect);
// Setup animation test
function sample1() {
// FIXME: Add animVal support. Animates baseVal at the moment.
// Check initial/end conditions
shouldBe("rect.x.baseVal.value", "100");
}
function sample2() {
shouldBe("rect.x.baseVal.value", "0");
}
function executeTest() {
const expectedValues = [
// [animationId, time, elementId, sampleCallback]
["animation", 0.0, "rect", sample1],
["animation", 1.0, "rect", sample1],
["animation", 3.0, "rect", sample2],
["animation", 3.9999, "rect", sample2],
["animation", 4.0 , "rect", sample1]
];
runAnimationTest(expectedValues);
}
// Begin test async
window.setTimeout("triggerUpdate(150, 30)", 0);
var successfullyParsed = true;
2011-01-27 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
SVG animation doesn't support calcMode discrete for number and color values.
https://bugs.webkit.org/show_bug.cgi?id=53189
Add support for calcMode discrete on number and color animation.
Tests: svg/animations/animate-color-calcMode-discrete.html
svg/animations/animate-number-calcMode-discrete.html
* svg/SVGAnimateElement.cpp:
(WebCore::SVGAnimateElement::calculateAnimatedValue):
2011-01-26 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
......@@ -100,6 +100,9 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
{
ASSERT(percentage >= 0.f && percentage <= 1.f);
ASSERT(resultElement);
bool isInFirstHalfOfAnimation = percentage < 0.5;
AnimationMode animationMode = this->animationMode();
if (hasTagName(SVGNames::setTag))
percentage = 1.f;
if (!resultElement->hasTagName(SVGNames::animateTag) && !resultElement->hasTagName(SVGNames::animateColorTag)
......@@ -111,32 +114,40 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
return;
if (m_propertyType == NumberProperty) {
// To animation uses contributions from the lower priority animations as the base value.
if (animationMode() == ToAnimation)
if (animationMode == ToAnimation)
m_fromNumber = results->m_animatedNumber;
double number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;
double number;
if (calcMode() == CalcModeDiscrete)
number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber;
else
number = (m_toNumber - m_fromNumber) * percentage + m_fromNumber;
// FIXME: This is not correct for values animation.
if (isAccumulated() && repeat)
number += m_toNumber * repeat;
if (isAdditive() && animationMode() != ToAnimation)
if (isAdditive() && animationMode != ToAnimation)
results->m_animatedNumber += number;
else
results->m_animatedNumber = number;
return;
}
if (m_propertyType == ColorProperty) {
if (animationMode() == ToAnimation)
if (animationMode == ToAnimation)
m_fromColor = results->m_animatedColor;
Color color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor);
Color color;
if (calcMode() == CalcModeDiscrete)
color = isInFirstHalfOfAnimation ? m_fromColor : m_toColor;
else
color = ColorDistance(m_fromColor, m_toColor).scaledDistance(percentage).addToColorAndClamp(m_fromColor);
// FIXME: Accumulate colors.
if (isAdditive() && animationMode() != ToAnimation)
if (isAdditive() && animationMode != ToAnimation)
results->m_animatedColor = ColorDistance::addColorsAndClamp(results->m_animatedColor, color);
else
results->m_animatedColor = color;
return;
}
AnimationMode animationMode = this->animationMode();
if (m_propertyType == PathProperty) {
if (animationMode == ToAnimation) {
ASSERT(results->m_animatedPathPointer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment