OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2012. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2012. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 RefPtr<SVGTransformList> fromList = isToAnimation ? this : toSVGTransformLis t(fromValue); | 312 RefPtr<SVGTransformList> fromList = isToAnimation ? this : toSVGTransformLis t(fromValue); |
313 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue); | 313 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue); |
314 RefPtr<SVGTransformList> toAtEndOfDurationList = toSVGTransformList(toAtEndO fDurationValue); | 314 RefPtr<SVGTransformList> toAtEndOfDurationList = toSVGTransformList(toAtEndO fDurationValue); |
315 | 315 |
316 size_t toListSize = toList->length(); | 316 size_t toListSize = toList->length(); |
317 if (!toListSize) | 317 if (!toListSize) |
318 return; | 318 return; |
319 | 319 |
320 // Get a reference to the from value before potentially cleaning it out (in the case of a To animation.) | 320 // Get a reference to the from value before potentially cleaning it out (in the case of a To animation.) |
321 RefPtr<SVGTransform> toTransform = toList->at(0); | 321 RefPtr<SVGTransform> toTransform = toList->at(0); |
322 RefPtr<SVGTransform> effectiveFrom = fromList->length() ? fromList->at(0) : SVGTransform::create(toTransform->transformType(), SVGTransform::ConstructZeroTr ansform); | 322 RefPtr<SVGTransform> effectiveFrom; |
323 // If there's an existing 'from'/underlying value of the same type use that, else use a "zero transform". | |
324 if (fromList->length() && fromList->at(0)->transformType() == toTransform->t ransformType()) | |
325 effectiveFrom = fromList->at(0); | |
326 else | |
327 effectiveFrom = SVGTransform::create(toTransform->transformType(), SVGTr ansform::ConstructZeroTransform); | |
323 | 328 |
324 // Never resize the animatedTransformList to the toList size, instead either clear the list or append to it. | 329 // Never resize the animatedTransformList to the toList size, instead either clear the list or append to it. |
325 if (!isEmpty() && !animationElement->isAdditive()) | 330 if (!isEmpty() && (!animationElement->isAdditive() || isToAnimation)) |
326 clear(); | 331 clear(); |
327 | 332 |
328 RefPtr<SVGTransform> currentTransform = SVGTransformDistance(effectiveFrom, toTransform).scaledDistance(percentage).addToSVGTransform(effectiveFrom); | 333 RefPtr<SVGTransform> currentTransform = SVGTransformDistance(effectiveFrom, toTransform).scaledDistance(percentage).addToSVGTransform(effectiveFrom); |
329 if (animationElement->isAccumulated() && repeatCount) { | 334 if (animationElement->isAccumulated() && repeatCount) { |
330 RefPtr<SVGTransform> effectiveToAtEnd = !toAtEndOfDurationList->isEmpty( ) ? toAtEndOfDurationList->at(0) : SVGTransform::create(toTransform->transformTy pe(), SVGTransform::ConstructZeroTransform); | 335 RefPtr<SVGTransform> effectiveToAtEnd = !toAtEndOfDurationList->isEmpty( ) ? toAtEndOfDurationList->at(0) : SVGTransform::create(toTransform->transformTy pe(), SVGTransform::ConstructZeroTransform); |
pdr.
2014/06/13 17:29:41
Can you assert here that the transform types are t
fs
2014/06/16 08:13:49
SVGTransformDistance::addSVGTransforms() asserts t
| |
331 append(SVGTransformDistance::addSVGTransforms(currentTransform, effectiv eToAtEnd, repeatCount)); | 336 append(SVGTransformDistance::addSVGTransforms(currentTransform, effectiv eToAtEnd, repeatCount)); |
332 } else { | 337 } else { |
333 append(currentTransform); | 338 append(currentTransform); |
334 } | 339 } |
335 } | 340 } |
336 | 341 |
337 float SVGTransformList::calculateDistance(PassRefPtr<SVGPropertyBase> toValue, S VGElement*) | 342 float SVGTransformList::calculateDistance(PassRefPtr<SVGPropertyBase> toValue, S VGElement*) |
338 { | 343 { |
339 // FIXME: This is not correct in all cases. The spec demands that each compo nent (translate x and y for example) | 344 // FIXME: This is not correct in all cases. The spec demands that each compo nent (translate x and y for example) |
340 // is paced separately. To implement this we need to treat each component as individual animation everywhere. | 345 // is paced separately. To implement this we need to treat each component as individual animation everywhere. |
341 | 346 |
342 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue); | 347 RefPtr<SVGTransformList> toList = toSVGTransformList(toValue); |
343 if (isEmpty() || length() != toList->length()) | 348 if (isEmpty() || length() != toList->length()) |
344 return -1; | 349 return -1; |
345 | 350 |
346 ASSERT(length() == 1); | 351 ASSERT(length() == 1); |
347 if (at(0)->transformType() == toList->at(0)->transformType()) | 352 if (at(0)->transformType() == toList->at(0)->transformType()) |
348 return -1; | 353 return -1; |
349 | 354 |
350 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances | 355 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances |
351 // Paced animations assume a notion of distance between the various animatio n values defined by the ‘to’, ‘from’, ‘by’ and ‘values’ attributes. | 356 // Paced animations assume a notion of distance between the various animatio n values defined by the ‘to’, ‘from’, ‘by’ and ‘values’ attributes. |
352 // Distance is defined only for scalar types (such as <length>), colors and the subset of transformation types that are supported by ‘animateTransform’. | 357 // Distance is defined only for scalar types (such as <length>), colors and the subset of transformation types that are supported by ‘animateTransform’. |
353 return SVGTransformDistance(at(0), toList->at(0)).distance(); | 358 return SVGTransformDistance(at(0), toList->at(0)).distance(); |
354 } | 359 } |
355 | 360 |
356 } | 361 } |
OLD | NEW |