| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 SVGAnimationElement* animationElement, | 348 SVGAnimationElement* animationElement, |
| 349 float percentage, | 349 float percentage, |
| 350 unsigned repeatCount, | 350 unsigned repeatCount, |
| 351 SVGPropertyBase* fromValue, | 351 SVGPropertyBase* fromValue, |
| 352 SVGPropertyBase* toValue, | 352 SVGPropertyBase* toValue, |
| 353 SVGPropertyBase* toAtEndOfDurationValue, | 353 SVGPropertyBase* toAtEndOfDurationValue, |
| 354 SVGElement* contextElement) { | 354 SVGElement* contextElement) { |
| 355 ASSERT(animationElement); | 355 ASSERT(animationElement); |
| 356 bool isToAnimation = animationElement->getAnimationMode() == ToAnimation; | 356 bool isToAnimation = animationElement->getAnimationMode() == ToAnimation; |
| 357 | 357 |
| 358 // Spec: To animations provide specific functionality to get a smooth change f
rom the underlying value to the | 358 // Spec: To animations provide specific functionality to get a smooth change |
| 359 // 'to' attribute value, which conflicts mathematically with the requirement f
or additive transform animations | 359 // from the underlying value to the 'to' attribute value, which conflicts |
| 360 // to be post-multiplied. As a consequence, in SVG 1.1 the behavior of to anim
ations for 'animateTransform' is undefined | 360 // mathematically with the requirement for additive transform animations to be |
| 361 // post-multiplied. As a consequence, in SVG 1.1 the behavior of to animations |
| 362 // for 'animateTransform' is undefined. |
| 361 // FIXME: This is not taken into account yet. | 363 // FIXME: This is not taken into account yet. |
| 362 SVGTransformList* fromList = | 364 SVGTransformList* fromList = |
| 363 isToAnimation ? this : toSVGTransformList(fromValue); | 365 isToAnimation ? this : toSVGTransformList(fromValue); |
| 364 SVGTransformList* toList = toSVGTransformList(toValue); | 366 SVGTransformList* toList = toSVGTransformList(toValue); |
| 365 SVGTransformList* toAtEndOfDurationList = | 367 SVGTransformList* toAtEndOfDurationList = |
| 366 toSVGTransformList(toAtEndOfDurationValue); | 368 toSVGTransformList(toAtEndOfDurationValue); |
| 367 | 369 |
| 368 size_t toListSize = toList->length(); | 370 size_t toListSize = toList->length(); |
| 369 if (!toListSize) | 371 if (!toListSize) |
| 370 return; | 372 return; |
| 371 | 373 |
| 372 // Get a reference to the from value before potentially cleaning it out (in th
e case of a To animation.) | 374 // Get a reference to the from value before potentially cleaning it out (in |
| 375 // the case of a To animation.) |
| 373 SVGTransform* toTransform = toList->at(0); | 376 SVGTransform* toTransform = toList->at(0); |
| 374 SVGTransform* effectiveFrom = nullptr; | 377 SVGTransform* effectiveFrom = nullptr; |
| 375 // If there's an existing 'from'/underlying value of the same type use that, e
lse use a "zero transform". | 378 // If there's an existing 'from'/underlying value of the same type use that, |
| 379 // else use a "zero transform". |
| 376 if (fromList->length() && | 380 if (fromList->length() && |
| 377 fromList->at(0)->transformType() == toTransform->transformType()) | 381 fromList->at(0)->transformType() == toTransform->transformType()) |
| 378 effectiveFrom = fromList->at(0); | 382 effectiveFrom = fromList->at(0); |
| 379 else | 383 else |
| 380 effectiveFrom = SVGTransform::create(toTransform->transformType(), | 384 effectiveFrom = SVGTransform::create(toTransform->transformType(), |
| 381 SVGTransform::ConstructZeroTransform); | 385 SVGTransform::ConstructZeroTransform); |
| 382 | 386 |
| 383 // Never resize the animatedTransformList to the toList size, instead either c
lear the list or append to it. | 387 // Never resize the animatedTransformList to the toList size, instead either |
| 388 // clear the list or append to it. |
| 384 if (!isEmpty() && (!animationElement->isAdditive() || isToAnimation)) | 389 if (!isEmpty() && (!animationElement->isAdditive() || isToAnimation)) |
| 385 clear(); | 390 clear(); |
| 386 | 391 |
| 387 SVGTransform* currentTransform = | 392 SVGTransform* currentTransform = |
| 388 SVGTransformDistance(effectiveFrom, toTransform) | 393 SVGTransformDistance(effectiveFrom, toTransform) |
| 389 .scaledDistance(percentage) | 394 .scaledDistance(percentage) |
| 390 .addToSVGTransform(effectiveFrom); | 395 .addToSVGTransform(effectiveFrom); |
| 391 if (animationElement->isAccumulated() && repeatCount) { | 396 if (animationElement->isAccumulated() && repeatCount) { |
| 392 SVGTransform* effectiveToAtEnd = | 397 SVGTransform* effectiveToAtEnd = |
| 393 !toAtEndOfDurationList->isEmpty() | 398 !toAtEndOfDurationList->isEmpty() |
| 394 ? toAtEndOfDurationList->at(0) | 399 ? toAtEndOfDurationList->at(0) |
| 395 : SVGTransform::create(toTransform->transformType(), | 400 : SVGTransform::create(toTransform->transformType(), |
| 396 SVGTransform::ConstructZeroTransform); | 401 SVGTransform::ConstructZeroTransform); |
| 397 append(SVGTransformDistance::addSVGTransforms( | 402 append(SVGTransformDistance::addSVGTransforms( |
| 398 currentTransform, effectiveToAtEnd, repeatCount)); | 403 currentTransform, effectiveToAtEnd, repeatCount)); |
| 399 } else { | 404 } else { |
| 400 append(currentTransform); | 405 append(currentTransform); |
| 401 } | 406 } |
| 402 } | 407 } |
| 403 | 408 |
| 404 float SVGTransformList::calculateDistance(SVGPropertyBase* toValue, | 409 float SVGTransformList::calculateDistance(SVGPropertyBase* toValue, |
| 405 SVGElement*) { | 410 SVGElement*) { |
| 406 // FIXME: This is not correct in all cases. The spec demands that each compone
nt (translate x and y for example) | 411 // FIXME: This is not correct in all cases. The spec demands that each |
| 407 // is paced separately. To implement this we need to treat each component as i
ndividual animation everywhere. | 412 // component (translate x and y for example) is paced separately. To implement |
| 413 // this we need to treat each component as individual animation everywhere. |
| 408 | 414 |
| 409 SVGTransformList* toList = toSVGTransformList(toValue); | 415 SVGTransformList* toList = toSVGTransformList(toValue); |
| 410 if (isEmpty() || length() != toList->length()) | 416 if (isEmpty() || length() != toList->length()) |
| 411 return -1; | 417 return -1; |
| 412 | 418 |
| 413 ASSERT(length() == 1); | 419 ASSERT(length() == 1); |
| 414 if (at(0)->transformType() == toList->at(0)->transformType()) | 420 if (at(0)->transformType() == toList->at(0)->transformType()) |
| 415 return -1; | 421 return -1; |
| 416 | 422 |
| 417 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances | 423 // Spec: http://www.w3.org/TR/SVG/animate.html#complexDistances |
| 418 // Paced animations assume a notion of distance between the various animation
values defined by the 'to', 'from', 'by' and 'values' attributes. | 424 // Paced animations assume a notion of distance between the various animation |
| 419 // Distance is defined only for scalar types (such as <length>), colors and th
e subset of transformation types that are supported by 'animateTransform'. | 425 // values defined by the 'to', 'from', 'by' and 'values' attributes. Distance |
| 426 // is defined only for scalar types (such as <length>), colors and the subset |
| 427 // of transformation types that are supported by 'animateTransform'. |
| 420 return SVGTransformDistance(at(0), toList->at(0)).distance(); | 428 return SVGTransformDistance(at(0), toList->at(0)).distance(); |
| 421 } | 429 } |
| 422 | 430 |
| 423 } // namespace blink | 431 } // namespace blink |
| OLD | NEW |