https://bugs.webkit.org/show_bug.cgi?id=64859
Patch by Young Han Lee <joybro@company100.net> on 2011-09-24
Reviewed by Dirk Schulze.
If from-to animation have discrete calc-mode and have a 'keyTimes' list, values of
the keyTimes indicate the begin and the end of the animation respectively.[1][2]
When keyTimes is given, calculate the progress percentage of the animation with it
even for from-to animation.
[1] http://www.w3.org/TR/SVG/animate.html#ValueAttributes
[2] http://www.w3.org/TR/2001/REC-smil-animation-
20010904/#AnimFuncValues
Source/WebCore:
Test: svg/animations/animate-from-to-keyTimes.html
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::calculatePercentForFromTo):
(WebCore::SVGAnimationElement::updateAnimation):
* svg/SVGAnimationElement.h:
LayoutTests:
* svg/animations/animate-from-to-keyTimes-expected.txt: Added.
* svg/animations/animate-from-to-keyTimes.html: Added.
* svg/animations/script-tests/animate-from-to-keyTimes.js: Added.
(sample1):
(sample2):
(executeTest):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95907
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-24 Young Han Lee <joybro@company100.net>
+
+ SVGAnimation does not support 'values' for from-to animations
+ https://bugs.webkit.org/show_bug.cgi?id=64859
+
+ Reviewed by Dirk Schulze.
+
+ If from-to animation have discrete calc-mode and have a 'keyTimes' list, values of
+ the keyTimes indicate the begin and the end of the animation respectively.[1][2]
+
+ When keyTimes is given, calculate the progress percentage of the animation with it
+ even for from-to animation.
+
+ [1] http://www.w3.org/TR/SVG/animate.html#ValueAttributes
+ [2] http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
+
+ * svg/animations/animate-from-to-keyTimes-expected.txt: Added.
+ * svg/animations/animate-from-to-keyTimes.html: Added.
+ * svg/animations/script-tests/animate-from-to-keyTimes.js: Added.
+ (sample1):
+ (sample2):
+ (executeTest):
+
2011-09-23 Chris Fleizach <cfleizach@apple.com>
WebKit does not expose AXPlaceholder value on password fields
--- /dev/null
+SVG 1.1 dynamic animation tests
+
+PASS rect.x.baseVal.value is 100
+PASS rect.x.baseVal.value is 200
+PASS rect.x.baseVal.value is 200
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!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-from-to-keyTimes.js"></script>
+</body>
+</html>
--- /dev/null
+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("to", "200");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("keyTimes", "0;0.25");
+animate.setAttribute("calcMode", "discrete");
+animate.setAttribute("fill", "freeze");
+rect.appendChild(animate);
+rootSVGElement.appendChild(rect);
+
+// Setup animation test
+function sample1() {
+ shouldBe("rect.x.baseVal.value", "100");
+}
+
+function sample2() {
+ shouldBe("rect.x.baseVal.value", "200");
+}
+
+function executeTest() {
+ const expectedValues = [
+ // [animationId, time, elementId, sampleCallback]
+ ["animation", 0.5, "rect", sample1],
+ ["animation", 1.5, "rect", sample2],
+ ["animation", 2.5, "rect", sample2]
+ ];
+
+ runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(150, 30)", 0);
+var successfullyParsed = true;
+2011-09-24 Young Han Lee <joybro@company100.net>
+
+ SVGAnimation does not support 'values' for from-to animations
+ https://bugs.webkit.org/show_bug.cgi?id=64859
+
+ Reviewed by Dirk Schulze.
+
+ If from-to animation have discrete calc-mode and have a 'keyTimes' list, values of
+ the keyTimes indicate the begin and the end of the animation respectively.[1][2]
+
+ When keyTimes is given, calculate the progress percentage of the animation with it
+ even for from-to animation.
+
+ [1] http://www.w3.org/TR/SVG/animate.html#ValueAttributes
+ [2] http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
+
+ Test: svg/animations/animate-from-to-keyTimes.html
+
+ * svg/SVGAnimationElement.cpp:
+ (WebCore::SVGAnimationElement::calculatePercentForFromTo):
+ (WebCore::SVGAnimationElement::updateAnimation):
+ * svg/SVGAnimationElement.h:
+
2011-09-23 Chris Fleizach <cfleizach@apple.com>
WebKit does not expose AXPlaceholder value on password fields
}
return (toKeyPoint - fromKeyPoint) * keyPointPercent + fromKeyPoint;
}
+
+float SVGAnimationElement::calculatePercentForFromTo(float percent) const
+{
+ if (calcMode() == CalcModeDiscrete && m_keyTimes.size() == 2)
+ return percent > m_keyTimes[1] ? 1 : 0;
+
+ return percent;
+}
void SVGAnimationElement::currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const
{
effectivePercent = calculatePercentFromKeyPoints(percent);
else if (m_keyPoints.isEmpty() && mode == CalcModeSpline && m_keyTimes.size() > 1)
effectivePercent = calculatePercentForSpline(percent, calculateKeyTimesIndex(percent));
+ else if (animationMode() == FromToAnimation || animationMode() == ToAnimation)
+ effectivePercent = calculatePercentForFromTo(percent);
else
effectivePercent = percent;
float calculatePercentFromKeyPoints(float percent) const;
void currentValuesFromKeyPoints(float percent, float& effectivePercent, String& from, String& to) const;
float calculatePercentForSpline(float percent, unsigned splineIndex) const;
+ float calculatePercentForFromTo(float percent) const;
unsigned calculateKeyTimesIndex(float percent) const;
BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGAnimationElement)