| Index: Source/core/animation/AnimationPlayer.cpp
|
| diff --git a/Source/core/animation/AnimationPlayer.cpp b/Source/core/animation/AnimationPlayer.cpp
|
| index f662c6713f443e4be79a1e63962ddfdf2b9f73ee..568c362fc5bd9066ea2be91e82dacd0ebc3f7177 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;
|
| }
|
| @@ -358,8 +362,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();
|
| }
|
| @@ -387,10 +393,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())
|
| @@ -433,6 +439,7 @@ void AnimationPlayer::play()
|
| m_startTime = nullValue();
|
|
|
| setCompositorPending();
|
| + uncancel();
|
| unpauseInternal();
|
| if (!m_content)
|
| return;
|
| @@ -449,6 +456,9 @@ void AnimationPlayer::reverse()
|
| if (!m_playbackRate) {
|
| return;
|
| }
|
| +
|
| + uncancel();
|
| +
|
| if (m_content) {
|
| if (m_playbackRate > 0 && currentTimeInternal() > sourceEnd()) {
|
| setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
|
| @@ -474,6 +484,10 @@ void AnimationPlayer::finish(ExceptionState& exceptionState)
|
| if (playing()) {
|
| setCompositorPending();
|
| }
|
| +
|
| + uncancel();
|
| + m_startTime = 0;
|
| +
|
| if (m_playbackRate < 0) {
|
| setCurrentTimeInternal(0, TimingUpdateOnDemand);
|
| } else {
|
| @@ -595,13 +609,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());
|
| @@ -613,7 +627,7 @@ bool AnimationPlayer::update(TimingUpdateReason reason)
|
| }
|
| }
|
| ASSERT(!m_outdated);
|
| - return !m_finished || !finished();
|
| + return !m_finished;
|
| }
|
|
|
| double AnimationPlayer::timeToEffectChange()
|
| @@ -630,7 +644,9 @@ double AnimationPlayer::timeToEffectChange()
|
|
|
| void AnimationPlayer::cancel()
|
| {
|
| - setSource(0);
|
| + m_idle = true;
|
| + m_startTime = nullValue();
|
| + setCompositorPending();
|
| }
|
|
|
| #if !ENABLE(OILPAN)
|
|
|