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

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

Issue 534193002: Web-Animations: Implement idle state for AnimationPlayers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/AnimationPlayerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/AnimationPlayer.cpp
diff --git a/Source/core/animation/AnimationPlayer.cpp b/Source/core/animation/AnimationPlayer.cpp
index 0e3f917380346ec77bd233305db755d29cf46bce..3c84a397aa0dbb5ebf9dd0da207776c7b0d4ce91 100644
--- a/Source/core/animation/AnimationPlayer.cpp
+++ b/Source/core/animation/AnimationPlayer.cpp
@@ -52,6 +52,7 @@ static unsigned nextSequenceNumber()
PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(ExecutionContext* executionContext, AnimationTimeline& timeline, AnimationNode* content)
{
RefPtrWillBeRawPtr<AnimationPlayer> player = adoptRefWillBeNoop(new AnimationPlayer(executionContext, timeline, content));
+ player->uncancel();
timeline.document()->compositorPendingAnimations().add(player.get());
player->suspendIfNeeded();
return player.release();
@@ -69,15 +70,18 @@ AnimationPlayer::AnimationPlayer(ExecutionContext* executionContext, AnimationTi
, m_held(true)
, m_isPausedForTesting(false)
, m_outdated(true)
- , m_finished(false)
+ , m_finished(true)
, m_compositorState(nullptr)
, m_compositorPending(true)
, m_currentTimePending(false)
+ , m_idle(true)
{
ScriptWrappable::init(this);
if (m_content) {
- if (m_content->player())
+ if (m_content->player()) {
m_content->player()->cancel();
+ m_content->player()->setSource(0);
+ }
m_content->attach(this);
}
}
@@ -151,7 +155,7 @@ double AnimationPlayer::startTime() const
double AnimationPlayer::currentTime()
{
- if (m_currentTimePending)
+ if (m_currentTimePending || m_idle)
return std::numeric_limits<double>::quiet_NaN();
return currentTimeInternal() * 1000;
}
@@ -359,8 +363,10 @@ void AnimationPlayer::setSource(AnimationNode* newSource)
m_content = newSource;
if (newSource) {
// FIXME: This logic needs to be updated once groups are implemented
- if (newSource->player())
+ if (newSource->player()) {
newSource->player()->cancel();
+ newSource->player()->setSource(0);
+ }
newSource->attach(this);
setOutdated();
}
@@ -388,10 +394,10 @@ String AnimationPlayer::playState()
AnimationPlayer::AnimationPlayState AnimationPlayer::playStateInternal()
{
- // FIXME(shanestephens): Add clause for in-idle-state here.
+ if (m_idle)
+ return Idle;
if (m_currentTimePending || (isNull(m_startTime) && !m_paused && m_playbackRate != 0))
return Pending;
- // FIXME(shanestephens): Add idle handling here.
if (m_paused)
return Paused;
if (finished())
@@ -434,6 +440,7 @@ void AnimationPlayer::play()
m_startTime = nullValue();
setCompositorPending();
+ uncancel();
unpauseInternal();
if (!m_content)
return;
@@ -450,6 +457,9 @@ void AnimationPlayer::reverse()
if (!m_playbackRate) {
return;
}
+
+ uncancel();
+
if (m_content) {
if (m_playbackRate > 0 && currentTimeInternal() > sourceEnd()) {
setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
@@ -475,6 +485,10 @@ void AnimationPlayer::finish(ExceptionState& exceptionState)
if (playing()) {
setCompositorPending();
}
+
+ uncancel();
+ m_startTime = 0;
+
if (m_playbackRate < 0) {
setCurrentTimeInternal(0, TimingUpdateOnDemand);
} else {
@@ -596,13 +610,13 @@ bool AnimationPlayer::update(TimingUpdateReason reason)
updateCurrentTimingState(reason);
m_outdated = false;
- if (m_content) {
+ if (m_content && !m_idle) {
double inheritedTime = isNull(m_timeline->currentTimeInternal()) ? nullValue() : currentTimeInternal();
m_content->updateInheritedTime(inheritedTime, reason);
}
- if (finished() && !m_finished) {
- if (reason == TimingUpdateForAnimationFrame && hasStartTime()) {
+ if ((m_idle || finished()) && !m_finished) {
+ if (reason == TimingUpdateForAnimationFrame && (m_idle || hasStartTime())) {
const AtomicString& eventType = EventTypeNames::finish;
if (executionContext() && hasEventListeners(eventType)) {
m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, currentTime(), timeline()->currentTime());
@@ -614,7 +628,7 @@ bool AnimationPlayer::update(TimingUpdateReason reason)
}
}
ASSERT(!m_outdated);
- return !m_finished || !finished();
+ return !m_finished;
}
double AnimationPlayer::timeToEffectChange()
@@ -631,7 +645,9 @@ double AnimationPlayer::timeToEffectChange()
void AnimationPlayer::cancel()
{
- setSource(0);
+ m_idle = true;
+ m_startTime = nullValue();
+ setCompositorPending();
}
#if !ENABLE(OILPAN)
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/AnimationPlayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698