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

Issue 534193002: Web-Animations: Implement idle state for AnimationPlayers. (Closed)

Created:
6 years, 3 months ago by shans
Modified:
6 years, 3 months ago
Reviewers:
dstockwell
CC:
dstockwell, darktears, blink-reviews, blink-reviews-animation_chromium.org, Eric Willigers, Mike Lawther (Google), rjwright, Steve Block, Timothy Loh
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Web-Animations: Implement idle state for AnimationPlayers. Refactor AnimationPlayer::cancel() to enter idle state rather than nullifying m_source. BUG=396366

Patch Set 1 #

Total comments: 1

Patch Set 2 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+139 lines, -15 lines) Patch
M Source/core/animation/AnimationPlayer.h View 2 chunks +13 lines, -2 lines 0 comments Download
M Source/core/animation/AnimationPlayer.cpp View 1 11 chunks +27 lines, -11 lines 0 comments Download
M Source/core/animation/AnimationPlayerTest.cpp View 1 3 chunks +99 lines, -2 lines 0 comments Download

Messages

Total messages: 9 (3 generated)
shans
6 years, 3 months ago (2014-09-03 11:20:29 UTC) #2
dstockwell
https://codereview.chromium.org/534193002/diff/1/Source/core/animation/AnimationPlayerTest.cpp File Source/core/animation/AnimationPlayerTest.cpp (right): https://codereview.chromium.org/534193002/diff/1/Source/core/animation/AnimationPlayerTest.cpp#newcode825 Source/core/animation/AnimationPlayerTest.cpp:825: EXPECT_EQ(0, player->currentTime()); What should happen when the playback rate ...
6 years, 3 months ago (2014-09-04 00:34:06 UTC) #3
shans
On 2014/09/04 00:34:06, dstockwell wrote: > https://codereview.chromium.org/534193002/diff/1/Source/core/animation/AnimationPlayerTest.cpp > File Source/core/animation/AnimationPlayerTest.cpp (right): > > https://codereview.chromium.org/534193002/diff/1/Source/core/animation/AnimationPlayerTest.cpp#newcode825 > ...
6 years, 3 months ago (2014-09-04 03:50:35 UTC) #4
dstockwell
lgtm
6 years, 3 months ago (2014-09-08 00:57:24 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/shans@chromium.org/534193002/20001
6 years, 3 months ago (2014-09-08 00:58:13 UTC) #7
commit-bot: I haz the power
6 years, 3 months ago (2014-09-08 00:58:20 UTC) #9
Failed to apply patch for Source/core/animation/AnimationPlayer.cpp:
While running patch -p1 --forward --force --no-backup-if-mismatch;
  patching file Source/core/animation/AnimationPlayer.cpp
  Hunk #2 FAILED at 70.
  Hunk #3 succeeded at 151 (offset -1 lines).
  Hunk #4 succeeded at 359 (offset -1 lines).
  Hunk #5 succeeded at 390 (offset -1 lines).
  Hunk #6 succeeded at 436 (offset -1 lines).
  Hunk #7 succeeded at 453 (offset -1 lines).
  Hunk #8 succeeded at 481 (offset -1 lines).
  Hunk #9 succeeded at 606 (offset -1 lines).
  Hunk #10 succeeded at 624 (offset -1 lines).
  Hunk #11 succeeded at 641 (offset -1 lines).
  1 out of 11 hunks FAILED -- saving rejects to file
Source/core/animation/AnimationPlayer.cpp.rej

Patch:       Source/core/animation/AnimationPlayer.cpp
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)

Powered by Google App Engine
This is Rietveld 408576698