diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 0d248895274a288c6f8a7b44d10b2d40b31af55b..c31ec1fc84bd3546b9563968ad5b63006c119a4d 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,26 @@ +2011-09-24 Young Han Lee + + 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 WebKit does not expose AXPlaceholder value on password fields diff --git a/LayoutTests/svg/animations/animate-from-to-keyTimes-expected.txt b/LayoutTests/svg/animations/animate-from-to-keyTimes-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d0bb399e9260b592095f8738a899fa0af51efb8c --- /dev/null +++ b/LayoutTests/svg/animations/animate-from-to-keyTimes-expected.txt @@ -0,0 +1,9 @@ +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 + diff --git a/LayoutTests/svg/animations/animate-from-to-keyTimes.html b/LayoutTests/svg/animations/animate-from-to-keyTimes.html new file mode 100644 index 0000000000000000000000000000000000000000..ac7f5524605049a1525902af34713cd0790d513f --- /dev/null +++ b/LayoutTests/svg/animations/animate-from-to-keyTimes.html @@ -0,0 +1,15 @@ + + + + + + + + + +

SVG 1.1 dynamic animation tests

+

+
+ + + diff --git a/LayoutTests/svg/animations/script-tests/animate-from-to-keyTimes.js b/LayoutTests/svg/animations/script-tests/animate-from-to-keyTimes.js new file mode 100644 index 0000000000000000000000000000000000000000..5883314423abbcc9062e72def3cf49219965f0ef --- /dev/null +++ b/LayoutTests/svg/animations/script-tests/animate-from-to-keyTimes.js @@ -0,0 +1,45 @@ +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; diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index f5aa8ea703919fd37ff11af53755b456d84be80c..b0dd04b345249321a5e129859fca18adab280241 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,26 @@ +2011-09-24 Young Han Lee + + 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 WebKit does not expose AXPlaceholder value on password fields diff --git a/Source/WebCore/svg/SVGAnimationElement.cpp b/Source/WebCore/svg/SVGAnimationElement.cpp index 50590af6516730ebfa6c8b52f077f941504ca303..39808b4d810395b1a1256789c37e1e9651efe09b 100644 --- a/Source/WebCore/svg/SVGAnimationElement.cpp +++ b/Source/WebCore/svg/SVGAnimationElement.cpp @@ -461,6 +461,14 @@ float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const } 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 { @@ -608,6 +616,8 @@ void SVGAnimationElement::updateAnimation(float percent, unsigned repeat, SVGSMI 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; diff --git a/Source/WebCore/svg/SVGAnimationElement.h b/Source/WebCore/svg/SVGAnimationElement.h index 87af9d0540248c0f62cc19d24f2f239d2907e932..2e109f02794dbab1ac87e53b3ceb8ee15c250b34 100644 --- a/Source/WebCore/svg/SVGAnimationElement.h +++ b/Source/WebCore/svg/SVGAnimationElement.h @@ -120,6 +120,7 @@ private: 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)