Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1388)

Unified Diff: Source/core/svg/animation/SMILTimeContainer.cpp

Issue 143403005: Make the timer in SMILTimeContainer more of an implementation detail (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Not Soon anymore. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/animation/SMILTimeContainer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/animation/SMILTimeContainer.cpp
diff --git a/Source/core/svg/animation/SMILTimeContainer.cpp b/Source/core/svg/animation/SMILTimeContainer.cpp
index 744de372bd45303f6d52db9045fc120825359ca6..c12bfce5438f5aad7e6b4b36cd50b80eec5e043a 100644
--- a/Source/core/svg/animation/SMILTimeContainer.cpp
+++ b/Source/core/svg/animation/SMILTimeContainer.cpp
@@ -54,7 +54,7 @@ SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner)
SMILTimeContainer::~SMILTimeContainer()
{
- m_timer.stop();
+ cancelAnimationFrame();
ASSERT(!m_timer.isActive());
#ifndef NDEBUG
ASSERT(!m_preventScheduledAnimationsChanges);
@@ -103,7 +103,7 @@ void SMILTimeContainer::notifyIntervalsChanged()
{
// Schedule updateAnimations() to be called asynchronously so multiple intervals
// can change with updateAnimations() only called once at the end.
- startTimer(0);
+ scheduleAnimationFrame();
}
SMILTime SMILTimeContainer::elapsed() const
@@ -140,7 +140,7 @@ void SMILTimeContainer::begin()
if (m_pauseTime) {
m_pauseTime = now;
- m_timer.stop();
+ cancelAnimationFrame();
}
}
@@ -151,7 +151,7 @@ void SMILTimeContainer::pause()
if (m_beginTime) {
m_accumulatedActiveTime += m_pauseTime - lastResumeTime();
- m_timer.stop();
+ cancelAnimationFrame();
}
m_resumeTime = 0;
}
@@ -162,7 +162,7 @@ void SMILTimeContainer::resume()
m_resumeTime = currentTime();
m_pauseTime = 0;
- startTimer(0);
+ scheduleAnimationFrame();
}
void SMILTimeContainer::setElapsed(SMILTime time)
@@ -174,7 +174,7 @@ void SMILTimeContainer::setElapsed(SMILTime time)
}
if (m_beginTime)
- m_timer.stop();
+ cancelAnimationFrame();
double now = currentTime();
m_beginTime = now - time.value();
@@ -203,22 +203,39 @@ void SMILTimeContainer::setElapsed(SMILTime time)
updateAnimations(time, true);
}
-void SMILTimeContainer::startTimer(SMILTime fireTime, SMILTime minimumDelay)
+bool SMILTimeContainer::isTimelineRunning() const
+{
+ return m_beginTime && !isPaused();
+}
+
+void SMILTimeContainer::scheduleAnimationFrame(SMILTime fireTime)
{
- if (!m_beginTime || isPaused())
+ if (!isTimelineRunning())
return;
if (!fireTime.isFinite())
return;
- SMILTime delay = max(fireTime - elapsed(), minimumDelay);
+ SMILTime delay = max(fireTime - elapsed(), SMILTime(animationFrameDelay));
m_timer.startOneShot(delay.value());
}
+void SMILTimeContainer::scheduleAnimationFrame()
+{
+ if (!isTimelineRunning())
+ return;
+
+ m_timer.startOneShot(0);
+}
+
+void SMILTimeContainer::cancelAnimationFrame()
+{
+ m_timer.stop();
+}
+
void SMILTimeContainer::timerFired(Timer<SMILTimeContainer>*)
{
- ASSERT(m_beginTime);
- ASSERT(!m_pauseTime);
+ ASSERT(isTimelineRunning());
updateAnimations(elapsed());
}
@@ -309,7 +326,7 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
#ifndef NDEBUG
m_preventScheduledAnimationsChanges = false;
#endif
- startTimer(earliestFireTime, animationFrameDelay);
+ scheduleAnimationFrame(earliestFireTime);
return;
}
@@ -321,7 +338,7 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
m_preventScheduledAnimationsChanges = false;
#endif
- startTimer(earliestFireTime, animationFrameDelay);
+ scheduleAnimationFrame(earliestFireTime);
for (unsigned i = 0; i < animationsToApplySize; ++i) {
if (animationsToApply[i]->inDocument() && animationsToApply[i]->isSVGDiscardElement()) {
« no previous file with comments | « Source/core/svg/animation/SMILTimeContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698