diff options
Diffstat (limited to 'Source/WebCore/svg/animation/SMILTimeContainer.cpp')
-rw-r--r-- | Source/WebCore/svg/animation/SMILTimeContainer.cpp | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/Source/WebCore/svg/animation/SMILTimeContainer.cpp b/Source/WebCore/svg/animation/SMILTimeContainer.cpp index 25529d692..333f7a17d 100644 --- a/Source/WebCore/svg/animation/SMILTimeContainer.cpp +++ b/Source/WebCore/svg/animation/SMILTimeContainer.cpp @@ -26,18 +26,14 @@ #include "config.h" #include "SMILTimeContainer.h" -#if ENABLE(SVG) #include "Document.h" #include "ElementIterator.h" -#include "SVGNames.h" #include "SVGSMILElement.h" #include "SVGSVGElement.h" #include <wtf/CurrentTime.h> namespace WebCore { -static const double animationFrameDelay = 0.025; - SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner) : m_beginTime(0) , m_pauseTime(0) @@ -45,7 +41,7 @@ SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner) , m_resumeTime(0) , m_presetStartTime(0) , m_documentOrderIndexesDirty(false) - , m_timer(this, &SMILTimeContainer::timerFired) + , m_timer(*this, &SMILTimeContainer::timerFired) , m_ownerSVGElement(owner) #ifndef NDEBUG , m_preventScheduledAnimationsChanges(false) @@ -93,16 +89,15 @@ void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target ElementAttributePair key(target, attributeName); AnimationsVector* scheduled = m_scheduledAnimations.get(key); ASSERT(scheduled); - size_t idx = scheduled->find(animation); - ASSERT(idx != notFound); - scheduled->remove(idx); + bool removed = scheduled->removeFirst(animation); + ASSERT_UNUSED(removed, removed); } void SMILTimeContainer::notifyIntervalsChanged() { // Schedule updateAnimations() to be called asynchronously so multiple intervals // can change with updateAnimations() only called once at the end. - startTimer(0); + startTimer(elapsed(), 0); } SMILTime SMILTimeContainer::elapsed() const @@ -163,7 +158,7 @@ void SMILTimeContainer::resume() m_resumeTime = monotonicallyIncreasingTime(); m_pauseTime = 0; - startTimer(0); + startTimer(elapsed(), 0); } void SMILTimeContainer::setElapsed(SMILTime time) @@ -189,12 +184,9 @@ void SMILTimeContainer::setElapsed(SMILTime time) #ifndef NDEBUG m_preventScheduledAnimationsChanges = true; #endif - GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); - for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it != end; ++it) { - AnimationsVector* scheduled = it->value.get(); - unsigned size = scheduled->size(); - for (unsigned n = 0; n < size; n++) - scheduled->at(n)->reset(); + for (auto& animation : m_scheduledAnimations.values()) { + for (auto& element : *animation) + element->reset(); } #ifndef NDEBUG m_preventScheduledAnimationsChanges = false; @@ -203,7 +195,7 @@ void SMILTimeContainer::setElapsed(SMILTime time) updateAnimations(time, true); } -void SMILTimeContainer::startTimer(SMILTime fireTime, SMILTime minimumDelay) +void SMILTimeContainer::startTimer(SMILTime elapsed, SMILTime fireTime, SMILTime minimumDelay) { if (!m_beginTime || isPaused()) return; @@ -211,11 +203,11 @@ void SMILTimeContainer::startTimer(SMILTime fireTime, SMILTime minimumDelay) if (!fireTime.isFinite()) return; - SMILTime delay = std::max(fireTime - elapsed(), minimumDelay); + SMILTime delay = std::max(fireTime - elapsed, minimumDelay); m_timer.startOneShot(delay.value()); } -void SMILTimeContainer::timerFired(Timer<SMILTimeContainer>*) +void SMILTimeContainer::timerFired() { ASSERT(m_beginTime); ASSERT(!m_pauseTime); @@ -267,9 +259,16 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) #endif AnimationsVector animationsToApply; - GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); - for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it != end; ++it) { - AnimationsVector* scheduled = it->value.get(); + for (auto& it : m_scheduledAnimations) { + AnimationsVector* scheduled = it.value.get(); + for (auto* animation : *scheduled) { + if (!animation->hasConditionsConnected()) + animation->connectConditions(); + } + } + + for (auto& it : m_scheduledAnimations) { + AnimationsVector* scheduled = it.value.get(); // Sort according to priority. Elements with later begin time have higher priority. // In case of a tie, document order decides. @@ -277,10 +276,8 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) // have higher priority. sortByPriority(*scheduled, elapsed); - SVGSMILElement* resultElement = 0; - unsigned size = scheduled->size(); - for (unsigned n = 0; n < size; n++) { - SVGSMILElement* animation = scheduled->at(n); + SVGSMILElement* resultElement = nullptr; + for (auto& animation : *scheduled) { ASSERT(animation->timeContainer() == this); ASSERT(animation->targetElement()); ASSERT(animation->hasValidAttributeName()); @@ -294,7 +291,7 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) // This will calculate the contribution from the animation and add it to the resultsElement. if (!animation->progress(elapsed, resultElement, seekToTime) && resultElement == animation) - resultElement = 0; + resultElement = nullptr; SMILTime nextFireTime = animation->nextProgressTime(); if (nextFireTime.isFinite()) @@ -305,26 +302,23 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) animationsToApply.append(resultElement); } - unsigned animationsToApplySize = animationsToApply.size(); - if (!animationsToApplySize) { + if (animationsToApply.isEmpty()) { #ifndef NDEBUG m_preventScheduledAnimationsChanges = false; #endif - startTimer(earliestFireTime, animationFrameDelay); + startTimer(elapsed, earliestFireTime, SMILAnimationFrameDelay); return; } // Apply results to target elements. - for (unsigned i = 0; i < animationsToApplySize; ++i) - animationsToApply[i]->applyResultsToTarget(); + for (auto& animation : animationsToApply) + animation->applyResultsToTarget(); #ifndef NDEBUG m_preventScheduledAnimationsChanges = false; #endif - startTimer(earliestFireTime, animationFrameDelay); + startTimer(elapsed, earliestFireTime, SMILAnimationFrameDelay); } } - -#endif // ENABLE(SVG) |