Commit 3ca490b2 authored by krit@webkit.org's avatar krit@webkit.org
Browse files

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

        Reviewed by Nikolas Zimmermann.

        SVG is missing to-animation support for Path
        https://bugs.webkit.org/show_bug.cgi?id=52982

        Added an animation test to check 'to' animations in combination with SVG paths.

        * svg/animations/animate-path-to-animation-expected.txt: Added.
        * svg/animations/animate-path-to-animation.html: Added.
        * svg/animations/script-tests/animate-path-to-animation.js: Added.
        (sample1):
        (sample2):
        (sample3):
        (executeTest):
2011-01-25  Dirk Schulze  <krit@webkit.org>

        Reviewed by Nikolas Zimmermann.

        SVG is missing to-animation support for Path
        https://bugs.webkit.org/show_bug.cgi?id=52982

        SVG was missing 'to' animation support for SVG paths. Even the fallback to discrete
        animation did not work and an assert was thrown, because of the missing m_fromPath.
        This also influences a test of the W3C test suite. Subtest 2 of animate-elem-83-t.svg passes now.

        Test: svg/animations/animate-path-to-animation.html

        * svg/SVGAnimateElement.cpp:
        (WebCore::SVGAnimateElement::calculateAnimatedValue): Take the value of the last SVGAnimateElement for
        m_fromPath, since 'to' animations are accumulative.
        (WebCore::SVGAnimateElement::calculateFromAndToValues): Added support for 'to' animations.
        (WebCore::SVGAnimateElement::resetToBaseValue): Set m_animatedPath on the first animation element to baseVal.
        * svg/SVGPathByteStream.h:
        (WebCore::SVGPathByteStream::copySVGPathByteStream): Return copy of current byte stream.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6f294555
2011-01-25 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
SVG is missing to-animation support for Path
https://bugs.webkit.org/show_bug.cgi?id=52982
Added an animation test to check 'to' animations in combination with SVG paths.
* svg/animations/animate-path-to-animation-expected.txt: Added.
* svg/animations/animate-path-to-animation.html: Added.
* svg/animations/script-tests/animate-path-to-animation.js: Added.
(sample1):
(sample2):
(sample3):
(executeTest):
2011-01-25 Nikolas Zimmermann <nzimmermann@rim.com>
 
Introduce FontMetrics abstraction
......
SVG 1.1 dynamic animation tests
Test calcMode spline with to animation. 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 almost 20, after first half
PASS path.pathSegList.getItem(0).y is almost 20, after first half
PASS path.pathSegList.getItem(0).x is almost 0, after first half
PASS path.pathSegList.getItem(0).y is almost 0, after first half
PASS path.pathSegList.getItem(0).x is 40
PASS path.pathSegList.getItem(0).y is 40
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-path-to-animation.js"></script>
</body>
</html>
description("Test calcMode spline with to animation. 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("to", "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() {
var ok = isCloseEnough(path.pathSegList.getItem(0).x, 20, 0.01);
if (ok)
testPassed("path.pathSegList.getItem(0).x is almost 20, after first half");
else
testFailed("path.pathSegList.getItem(0).x was NOT almost 20, as expected");
ok = isCloseEnough(path.pathSegList.getItem(0).y, 20, 0.01);
if (ok)
testPassed("path.pathSegList.getItem(0).y is almost 20, after first half");
else
testFailed("path.pathSegList.getItem(0).y was NOT almost 20, as expected");
}
function sample3() {
var ok = isCloseEnough(path.pathSegList.getItem(0).x, 0, 0.01);
if (ok)
testPassed("path.pathSegList.getItem(0).x is almost 0, after first half");
else
testFailed("path.pathSegList.getItem(0).x was NOT almost 0, as expected");
ok = isCloseEnough(path.pathSegList.getItem(0).y, 0, 0.01);
if (ok)
testPassed("path.pathSegList.getItem(0).y is almost 0, after first half");
else
testFailed("path.pathSegList.getItem(0).y was NOT almost 0, as expected");
}
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;
2011-01-25 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
SVG is missing to-animation support for Path
https://bugs.webkit.org/show_bug.cgi?id=52982
SVG was missing 'to' animation support for SVG paths. Even the fallback to discrete
animation did not work and an assert was thrown, because of the missing m_fromPath.
This also influences a test of the W3C test suite. Subtest 2 of animate-elem-83-t.svg passes now.
Test: svg/animations/animate-path-to-animation.html
* svg/SVGAnimateElement.cpp:
(WebCore::SVGAnimateElement::calculateAnimatedValue): Take the value of the last SVGAnimateElement for
m_fromPath, since 'to' animations are accumulative.
(WebCore::SVGAnimateElement::calculateFromAndToValues): Added support for 'to' animations.
(WebCore::SVGAnimateElement::resetToBaseValue): Set m_animatedPath on the first animation element to baseVal.
* svg/SVGPathByteStream.h:
(WebCore::SVGPathByteStream::copySVGPathByteStream): Return copy of current byte stream.
2011-01-25 Pavel Feldman <pfeldman@chromium.org>
 
Reviewed by Yury Semikhatsky.
......@@ -138,6 +138,10 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat
}
AnimationMode animationMode = this->animationMode();
if (m_propertyType == PathProperty) {
if (animationMode == ToAnimation) {
ASSERT(results->m_animatedPathPointer);
m_fromPath = results->m_animatedPathPointer->copy();
}
if (!percentage) {
ASSERT(m_fromPath);
ASSERT(percentage >= 0);
......@@ -210,8 +214,9 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const
}
} else if (m_propertyType == PathProperty) {
SVGPathParserFactory* factory = SVGPathParserFactory::self();
if (factory->buildSVGPathByteStreamFromString(fromString, m_fromPath, UnalteredParsing)) {
if (factory->buildSVGPathByteStreamFromString(toString, m_toPath, UnalteredParsing))
if (factory->buildSVGPathByteStreamFromString(toString, m_toPath, UnalteredParsing)) {
// For to-animations the from number is calculated later
if (animationMode() == ToAnimation || factory->buildSVGPathByteStreamFromString(fromString, m_fromPath, UnalteredParsing))
return true;
}
m_fromPath.clear();
......@@ -272,7 +277,9 @@ void SVGAnimateElement::resetToBaseValue(const String& baseString)
return;
} else if (m_propertyType == PathProperty) {
m_animatedPath.clear();
m_animatedPathPointer = 0;
SVGPathParserFactory* factory = SVGPathParserFactory::self();
factory->buildSVGPathByteStreamFromString(baseString, m_animatedPath, UnalteredParsing);
m_animatedPathPointer = m_animatedPath.get();
return;
} else if (m_propertyType == PointsProperty) {
m_animatedPoints.clear();
......
......@@ -51,6 +51,11 @@ public:
return adoptPtr(new SVGPathByteStream);
}
PassOwnPtr<SVGPathByteStream> copy()
{
return adoptPtr(new SVGPathByteStream(m_data));
}
typedef Vector<unsigned char> Data;
typedef Data::const_iterator DataIterator;
......@@ -62,6 +67,11 @@ public:
private:
SVGPathByteStream() { }
SVGPathByteStream(Data& data)
: m_data(data)
{
}
Data m_data;
};
......
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