Index: Source/core/animation/AnimationPlayer.cpp |
diff --git a/Source/core/animation/AnimationPlayer.cpp b/Source/core/animation/AnimationPlayer.cpp |
index 4fa0bf6b782bfe7614c698f3c4b6aa57f9e88a5d..74b0e31a19e7f716de71b5ae9149aa7aa47116a6 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, AnimationSource* content) |
+PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(ExecutionContext& executionContext, AnimationTimeline& timeline, AnimationSource* 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, AnimationSource* content) |
- : m_playbackRate(1) |
+AnimationPlayer::AnimationPlayer(ExecutionContext& executionContext, AnimationTimeline& timeline, AnimationSource* 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; |
haraken
2014/05/26 01:16:09
Just to confirm: You don't need to change m_finish
dstockwell
2014/05/26 01:32:40
Correct, this is not needed here.
dstockwell
2014/05/30 09:28:21
I was wrong. I thought m_finished only needed to b
|
+} |
+ |
+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; |
} |