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

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

Issue 284323004: Web Animations: Make AnimationPlayer an ActiveDOMObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 years, 7 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/AnimationPlayer.idl » ('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 c738272efe92005e767d130bafcc3fa63e5b9cc7..99e1ec0c103297112771994177de51d78e9d27d4 100644
--- a/Source/core/animation/AnimationPlayer.cpp
+++ b/Source/core/animation/AnimationPlayer.cpp
@@ -48,13 +48,16 @@ static unsigned nextSequenceNumber()
}
-PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(AnimationTimeline& timeline, AnimationNode* content)
+PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(ExecutionContext* executionContext, AnimationTimeline& timeline, AnimationNode* content)
{
- return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(timeline, content));
+ RefPtrWillBeRawPtr<AnimationPlayer> player = adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(executionContext, timeline, content));
+ player->suspendIfNeeded();
+ return player.release();
}
-AnimationPlayer::AnimationPlayer(AnimationTimeline& timeline, AnimationNode* content)
- : m_playbackRate(1)
+AnimationPlayer::AnimationPlayer(ExecutionContext* executionContext, AnimationTimeline& timeline, AnimationNode* content)
+ : ActiveDOMObject(executionContext)
+ , m_playbackRate(1)
, m_startTime(nullValue())
, m_holdTime(nullValue())
, m_storedTimeLag(0)
@@ -285,11 +288,24 @@ const AtomicString& AnimationPlayer::interfaceName() const
ExecutionContext* AnimationPlayer::executionContext() const
{
- if (m_timeline) {
- if (Document* document = m_timeline->document())
- return document->contextDocument().get();
- }
- return 0;
+ return ActiveDOMObject::executionContext();
+}
+
+bool AnimationPlayer::hasPendingActivity() const
+{
+ return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventTypeNames::finish));
+}
+
+void AnimationPlayer::stop()
+{
+ m_pendingFinishedEvent = nullptr;
+}
+
+bool AnimationPlayer::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
+{
+ if (m_pendingFinishedEvent == event)
+ m_pendingFinishedEvent = nullptr;
+ return EventTargetWithInlineData::dispatchEvent(event);
}
void AnimationPlayer::setPlaybackRate(double playbackRate)
@@ -367,10 +383,10 @@ bool AnimationPlayer::update(TimingUpdateReason reason)
if (reason == TimingUpdateForAnimationFrame && hasStartTime()) {
const AtomicString& eventType = EventTypeNames::finish;
if (executionContext() && hasEventListeners(eventType)) {
- RefPtrWillBeRawPtr<AnimationPlayerEvent> event = AnimationPlayerEvent::create(eventType, currentTime(), timeline()->currentTime());
- event->setTarget(this);
- event->setCurrentTarget(this);
- m_timeline->document()->enqueueAnimationFrameEvent(event.release());
+ m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, currentTime(), timeline()->currentTime());
+ m_pendingFinishedEvent->setTarget(this);
+ m_pendingFinishedEvent->setCurrentTarget(this);
+ m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFinishedEvent);
}
m_finished = true;
}
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/AnimationPlayer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698