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

Unified Diff: Source/core/animation/AnimationPlayer.cpp

Issue 555063002: Web Animations: Add tests for player state transitions and fix discovered issues (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Address comments. Created 6 years, 3 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
Index: Source/core/animation/AnimationPlayer.cpp
diff --git a/Source/core/animation/AnimationPlayer.cpp b/Source/core/animation/AnimationPlayer.cpp
index 97f5b92eef45111fc7deb227386a16dc822ae98c..91b3fed69fbafa96e46816fcd6e41f5aa99d1b7a 100644
--- a/Source/core/animation/AnimationPlayer.cpp
+++ b/Source/core/animation/AnimationPlayer.cpp
@@ -307,19 +307,13 @@ void AnimationPlayer::setCurrentTime(double newCurrentTime)
return;
setCompositorPending();
-
- // Setting current time while pending forces a start time.
- if (m_currentTimePending) {
- m_startTime = 0;
- m_currentTimePending = false;
- }
-
+ m_currentTimePending = false;
setCurrentTimeInternal(newCurrentTime / 1000, TimingUpdateOnDemand);
}
void AnimationPlayer::setStartTime(double startTime)
{
- if (m_paused) // FIXME: Should this throw an exception?
+ if (m_paused || m_idle)
return;
if (!std::isfinite(startTime))
return;
@@ -472,23 +466,13 @@ void AnimationPlayer::reverse()
}
uncancel();
-
- if (m_content) {
- if (m_playbackRate > 0 && currentTimeInternal() > sourceEnd()) {
- setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
- ASSERT(finished());
- } else if (m_playbackRate < 0 && currentTimeInternal() < 0) {
- setCurrentTimeInternal(0, TimingUpdateOnDemand);
- ASSERT(finished());
- }
- }
setPlaybackRate(-m_playbackRate);
- unpauseInternal();
+ play();
}
void AnimationPlayer::finish(ExceptionState& exceptionState)
{
- if (!m_playbackRate) {
+ if (!m_playbackRate || m_idle) {
return;
}
if (m_playbackRate > 0 && sourceEnd() == std::numeric_limits<double>::infinity()) {
@@ -500,13 +484,14 @@ void AnimationPlayer::finish(ExceptionState& exceptionState)
}
uncancel();
- m_startTime = 0;
- if (m_playbackRate < 0) {
- setCurrentTimeInternal(0, TimingUpdateOnDemand);
- } else {
- setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
+ double newCurrentTime = m_playbackRate < 0 ? 0 : sourceEnd();
+ setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand);
+ if (!paused()) {
+ m_startTime = calculateStartTime(newCurrentTime);
}
+
+ m_currentTimePending = false;
ASSERT(finished());
}
@@ -546,7 +531,7 @@ void AnimationPlayer::setPlaybackRate(double playbackRate)
return;
setCompositorPending();
- if (!finished() && !paused())
+ if (!finished() && !paused() && hasStartTime())
m_currentTimePending = true;
double storedCurrentTime = currentTimeInternal();
@@ -663,6 +648,7 @@ void AnimationPlayer::cancel()
m_held = true;
m_idle = true;
m_startTime = nullValue();
+ m_currentTimePending = false;
setCompositorPending();
}
« no previous file with comments | « LayoutTests/web-animations-api/player-state-changes.html ('k') | Source/core/animation/AnimationPlayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698