OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 continue; | 453 continue; |
454 } | 454 } |
455 | 455 |
456 // Sort according to priority. Elements with later begin time have highe
r priority. | 456 // Sort according to priority. Elements with later begin time have highe
r priority. |
457 // In case of a tie, document order decides. | 457 // In case of a tie, document order decides. |
458 // FIXME: This should also consider timing relationships between the ele
ments. Dependents | 458 // FIXME: This should also consider timing relationships between the ele
ments. Dependents |
459 // have higher priority. | 459 // have higher priority. |
460 copyToVector(*entry.value, scheduledAnimationsInSameGroup); | 460 copyToVector(*entry.value, scheduledAnimationsInSameGroup); |
461 std::sort(scheduledAnimationsInSameGroup.begin(), scheduledAnimationsInS
ameGroup.end(), PriorityCompare(elapsed)); | 461 std::sort(scheduledAnimationsInSameGroup.begin(), scheduledAnimationsInS
ameGroup.end(), PriorityCompare(elapsed)); |
462 | 462 |
463 SVGSMILElement* resultElement = nullptr; | 463 AnimationsVector sandwich; |
464 for (const auto& itAnimation : scheduledAnimationsInSameGroup) { | 464 for (const auto& itAnimation : scheduledAnimationsInSameGroup) { |
465 SVGSMILElement* animation = itAnimation.get(); | 465 SVGSMILElement* animation = itAnimation.get(); |
466 ASSERT(animation->timeContainer() == this); | 466 ASSERT(animation->timeContainer() == this); |
467 ASSERT(animation->targetElement()); | 467 ASSERT(animation->targetElement()); |
468 ASSERT(animation->hasValidAttributeName()); | 468 ASSERT(animation->hasValidAttributeName()); |
469 ASSERT(animation->hasValidAttributeType()); | 469 ASSERT(animation->hasValidAttributeType()); |
470 | 470 |
471 // Results are accumulated to the first animation that animates and
contributes to a particular element/attribute pair. | 471 // This will calculate the contribution from the animation and updat
e timing. |
472 if (!resultElement) { | 472 if (animation->progress(elapsed, seekToTime)) { |
473 resultElement = animation; | 473 sandwich.append(animation); |
474 resultElement->lockAnimatedType(); | 474 } else { |
475 } | 475 animation->clearAnimatedType(); |
476 | |
477 // This will calculate the contribution from the animation and add i
t to the resultElement. | |
478 if (!animation->progress(elapsed, resultElement, seekToTime) && resu
ltElement == animation) { | |
479 resultElement->unlockAnimatedType(); | |
480 resultElement->clearAnimatedType(); | |
481 resultElement = nullptr; | |
482 } | 476 } |
483 | 477 |
484 SMILTime nextFireTime = animation->nextProgressTime(); | 478 SMILTime nextFireTime = animation->nextProgressTime(); |
485 if (nextFireTime.isFinite()) | 479 if (nextFireTime.isFinite()) |
486 earliestFireTime = std::min(nextFireTime, earliestFireTime); | 480 earliestFireTime = std::min(nextFireTime, earliestFireTime); |
487 } | 481 } |
488 | 482 |
489 if (resultElement) { | 483 if (!sandwich.isEmpty()) { |
| 484 // Results are accumulated to the first animation that animates and |
| 485 // contributes to a particular element/attribute pair. |
| 486 // Only reset the animated type to the base value once for |
| 487 // the lowest priority animation that animates and |
| 488 // contributes to a particular element/attribute pair. |
| 489 SVGSMILElement* resultElement = sandwich.first(); |
| 490 resultElement->resetAnimatedType(); |
| 491 |
| 492 // Go through the sandwich from lowest prio to highest and generate |
| 493 // the animated value (if any.) |
| 494 for (const auto& animation : sandwich) |
| 495 animation->updateAnimatedValue(resultElement); |
| 496 |
490 animationsToApply.append(resultElement); | 497 animationsToApply.append(resultElement); |
491 resultElement->unlockAnimatedType(); | |
492 } | 498 } |
493 } | 499 } |
494 m_scheduledAnimations.removeAll(invalidKeys); | 500 m_scheduledAnimations.removeAll(invalidKeys); |
495 | 501 |
496 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar
e(elapsed)); | 502 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar
e(elapsed)); |
497 | 503 |
498 unsigned animationsToApplySize = animationsToApply.size(); | 504 unsigned animationsToApplySize = animationsToApply.size(); |
499 if (!animationsToApplySize) { | 505 if (!animationsToApplySize) { |
500 #if ENABLE(ASSERT) | 506 #if ENABLE(ASSERT) |
501 m_preventScheduledAnimationsChanges = false; | 507 m_preventScheduledAnimationsChanges = false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 setElapsed(elapsed() + initialFrameDelay); | 542 setElapsed(elapsed() + initialFrameDelay); |
537 } | 543 } |
538 | 544 |
539 DEFINE_TRACE(SMILTimeContainer) | 545 DEFINE_TRACE(SMILTimeContainer) |
540 { | 546 { |
541 visitor->trace(m_scheduledAnimations); | 547 visitor->trace(m_scheduledAnimations); |
542 visitor->trace(m_ownerSVGElement); | 548 visitor->trace(m_ownerSVGElement); |
543 } | 549 } |
544 | 550 |
545 } // namespace blink | 551 } // namespace blink |
OLD | NEW |