Commit 73639dc8 authored by fs@opera.com's avatar fs@opera.com

Fix computation of animated transform w/ different from/to transform types

Calculating the animated value between two transforms of differing types
would give random results (and ASSERT in debug.)
Fix by requiring the effective 'from' value to have the same type as the
'to' value. If the types are not the same, then use a "zero transform" as
the 'from' value.

Also adjust the behavior of animateTransform additive to-animations in
this case by clearing the list in these cases too (matching Presto and
Gecko in this particular case.)

BUG=231409

Review URL: https://codereview.chromium.org/330813002

git-svn-id: svn://svn.chromium.org/blink/trunk@176193 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b2ebc978
<!DOCTYPE html>
<svg width="200" height="200">
<rect width="100" height="100" transform="scale(2)" fill="green"/>
</svg>
<!DOCTYPE html>
<svg width="200" height="200">
<rect width="100" height="100" transform="translate(100,0)" fill="green">
<animateTransform attributeName="transform" additive="sum" type="scale" to="2" dur="2" fill="freeze"></animateTransform>
</rect>
</svg>
<script>
window.onload = function() {
var root = document.querySelector('svg');
root.pauseAnimations();
root.setCurrentTime(2);
};
</script>
...@@ -319,10 +319,15 @@ void SVGTransformList::calculateAnimatedValue(SVGAnimationElement* animationElem ...@@ -319,10 +319,15 @@ void SVGTransformList::calculateAnimatedValue(SVGAnimationElement* animationElem
// Get a reference to the from value before potentially cleaning it out (in the case of a To animation.) // Get a reference to the from value before potentially cleaning it out (in the case of a To animation.)
RefPtr<SVGTransform> toTransform = toList->at(0); RefPtr<SVGTransform> toTransform = toList->at(0);
RefPtr<SVGTransform> effectiveFrom = fromList->length() ? fromList->at(0) : SVGTransform::create(toTransform->transformType(), SVGTransform::ConstructZeroTransform); RefPtr<SVGTransform> effectiveFrom;
// If there's an existing 'from'/underlying value of the same type use that, else use a "zero transform".
if (fromList->length() && fromList->at(0)->transformType() == toTransform->transformType())
effectiveFrom = fromList->at(0);
else
effectiveFrom = SVGTransform::create(toTransform->transformType(), SVGTransform::ConstructZeroTransform);
// Never resize the animatedTransformList to the toList size, instead either clear the list or append to it. // Never resize the animatedTransformList to the toList size, instead either clear the list or append to it.
if (!isEmpty() && !animationElement->isAdditive()) if (!isEmpty() && (!animationElement->isAdditive() || isToAnimation))
clear(); clear();
RefPtr<SVGTransform> currentTransform = SVGTransformDistance(effectiveFrom, toTransform).scaledDistance(percentage).addToSVGTransform(effectiveFrom); RefPtr<SVGTransform> currentTransform = SVGTransformDistance(effectiveFrom, toTransform).scaledDistance(percentage).addToSVGTransform(effectiveFrom);
......
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