Index: Source/core/animation/AnimationPlayer.cpp |
diff --git a/Source/core/animation/AnimationPlayer.cpp b/Source/core/animation/AnimationPlayer.cpp |
index 4fa0bf6b782bfe7614c698f3c4b6aa57f9e88a5d..5522a49f9d49973cb28052982413361372966430 100644 |
--- a/Source/core/animation/AnimationPlayer.cpp |
+++ b/Source/core/animation/AnimationPlayer.cpp |
@@ -50,11 +50,14 @@ static unsigned nextSequenceNumber() |
PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(AnimationTimeline& timeline, AnimationSource* content) |
{ |
- return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(timeline, content)); |
+ RefPtrWillBeRawPtr<AnimationPlayer> player = adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(timeline, content)); |
+ player->suspendIfNeeded(); |
+ return player.release(); |
} |
AnimationPlayer::AnimationPlayer(AnimationTimeline& timeline, AnimationSource* content) |
- : m_playbackRate(1) |
+ : ActiveDOMObject(timeline.document()->contextDocument().get()) |
haraken
2014/05/23 07:15:05
Nit: This is a bit redundant way to get an Executi
dstockwell
2014/05/26 00:47:50
Done.
|
+ , m_playbackRate(1) |
, m_startTime(nullValue()) |
, m_holdTime(nullValue()) |
, m_storedTimeLag(0) |
@@ -285,11 +288,19 @@ 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)); |
+} |
+ |
+bool AnimationPlayer::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
+{ |
+ if (m_pendingFinishedEvent == event) |
+ m_pendingFinishedEvent = nullptr; |
+ return EventTargetWithInlineData::dispatchEvent(event); |
} |
void AnimationPlayer::setPlaybackRate(double playbackRate) |
@@ -367,10 +378,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; |
} |