OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... | |
41 namespace { | 41 namespace { |
42 | 42 |
43 static unsigned nextSequenceNumber() | 43 static unsigned nextSequenceNumber() |
44 { | 44 { |
45 static unsigned next = 0; | 45 static unsigned next = 0; |
46 return ++next; | 46 return ++next; |
47 } | 47 } |
48 | 48 |
49 } | 49 } |
50 | 50 |
51 PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(AnimationTimelin e& timeline, AnimationSource* content) | 51 PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(ExecutionContext & executionContext, AnimationTimeline& timeline, AnimationSource* content) |
52 { | 52 { |
53 return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(timeline , content)); | 53 RefPtrWillBeRawPtr<AnimationPlayer> player = adoptRefWillBeRefCountedGarbage Collected(new AnimationPlayer(executionContext, timeline, content)); |
54 player->suspendIfNeeded(); | |
55 return player.release(); | |
54 } | 56 } |
55 | 57 |
56 AnimationPlayer::AnimationPlayer(AnimationTimeline& timeline, AnimationSource* c ontent) | 58 AnimationPlayer::AnimationPlayer(ExecutionContext& executionContext, AnimationTi meline& timeline, AnimationSource* content) |
57 : m_playbackRate(1) | 59 : ActiveDOMObject(&executionContext) |
60 , m_playbackRate(1) | |
58 , m_startTime(nullValue()) | 61 , m_startTime(nullValue()) |
59 , m_holdTime(nullValue()) | 62 , m_holdTime(nullValue()) |
60 , m_storedTimeLag(0) | 63 , m_storedTimeLag(0) |
61 , m_sortInfo(nextSequenceNumber(), timeline.effectiveTime()) | 64 , m_sortInfo(nextSequenceNumber(), timeline.effectiveTime()) |
62 , m_content(content) | 65 , m_content(content) |
63 , m_timeline(&timeline) | 66 , m_timeline(&timeline) |
64 , m_paused(false) | 67 , m_paused(false) |
65 , m_held(false) | 68 , m_held(false) |
66 , m_isPausedForTesting(false) | 69 , m_isPausedForTesting(false) |
67 , m_outdated(true) | 70 , m_outdated(true) |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 cancelAnimationOnCompositor(); | 281 cancelAnimationOnCompositor(); |
279 } | 282 } |
280 | 283 |
281 const AtomicString& AnimationPlayer::interfaceName() const | 284 const AtomicString& AnimationPlayer::interfaceName() const |
282 { | 285 { |
283 return EventTargetNames::AnimationPlayer; | 286 return EventTargetNames::AnimationPlayer; |
284 } | 287 } |
285 | 288 |
286 ExecutionContext* AnimationPlayer::executionContext() const | 289 ExecutionContext* AnimationPlayer::executionContext() const |
287 { | 290 { |
288 if (m_timeline) { | 291 return ActiveDOMObject::executionContext(); |
289 if (Document* document = m_timeline->document()) | 292 } |
290 return document->contextDocument().get(); | 293 |
291 } | 294 bool AnimationPlayer::hasPendingActivity() const |
292 return 0; | 295 { |
296 return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventType Names::finish)); | |
297 } | |
298 | |
299 void AnimationPlayer::stop() | |
300 { | |
301 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
| |
302 } | |
303 | |
304 bool AnimationPlayer::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) | |
305 { | |
306 if (m_pendingFinishedEvent == event) | |
307 m_pendingFinishedEvent = nullptr; | |
308 return EventTargetWithInlineData::dispatchEvent(event); | |
293 } | 309 } |
294 | 310 |
295 void AnimationPlayer::setPlaybackRate(double playbackRate) | 311 void AnimationPlayer::setPlaybackRate(double playbackRate) |
296 { | 312 { |
297 if (!std::isfinite(playbackRate)) | 313 if (!std::isfinite(playbackRate)) |
298 return; | 314 return; |
299 double storedCurrentTime = currentTimeInternal(); | 315 double storedCurrentTime = currentTimeInternal(); |
300 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play backRate <= 0)) | 316 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play backRate <= 0)) |
301 m_finished = false; | 317 m_finished = false; |
302 m_playbackRate = playbackRate; | 318 m_playbackRate = playbackRate; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 | 376 |
361 if (m_content) { | 377 if (m_content) { |
362 double inheritedTime = isNull(m_timeline->currentTimeInternal()) ? nullV alue() : currentTimeInternal(); | 378 double inheritedTime = isNull(m_timeline->currentTimeInternal()) ? nullV alue() : currentTimeInternal(); |
363 m_content->updateInheritedTime(inheritedTime, reason); | 379 m_content->updateInheritedTime(inheritedTime, reason); |
364 } | 380 } |
365 | 381 |
366 if (finished() && !m_finished) { | 382 if (finished() && !m_finished) { |
367 if (reason == TimingUpdateForAnimationFrame && hasStartTime()) { | 383 if (reason == TimingUpdateForAnimationFrame && hasStartTime()) { |
368 const AtomicString& eventType = EventTypeNames::finish; | 384 const AtomicString& eventType = EventTypeNames::finish; |
369 if (executionContext() && hasEventListeners(eventType)) { | 385 if (executionContext() && hasEventListeners(eventType)) { |
370 RefPtrWillBeRawPtr<AnimationPlayerEvent> event = AnimationPlayer Event::create(eventType, currentTime(), timeline()->currentTime()); | 386 m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, currentTime(), timeline()->currentTime()); |
371 event->setTarget(this); | 387 m_pendingFinishedEvent->setTarget(this); |
372 event->setCurrentTarget(this); | 388 m_pendingFinishedEvent->setCurrentTarget(this); |
373 m_timeline->document()->enqueueAnimationFrameEvent(event.release ()); | 389 m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFini shedEvent); |
374 } | 390 } |
375 m_finished = true; | 391 m_finished = true; |
376 } | 392 } |
377 } | 393 } |
378 ASSERT(!m_outdated); | 394 ASSERT(!m_outdated); |
379 return !m_finished || !finished(); | 395 return !m_finished || !finished(); |
380 } | 396 } |
381 | 397 |
382 double AnimationPlayer::timeToEffectChange() | 398 double AnimationPlayer::timeToEffectChange() |
383 { | 399 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 pause(); | 447 pause(); |
432 } | 448 } |
433 | 449 |
434 void AnimationPlayer::trace(Visitor* visitor) | 450 void AnimationPlayer::trace(Visitor* visitor) |
435 { | 451 { |
436 visitor->trace(m_content); | 452 visitor->trace(m_content); |
437 visitor->trace(m_timeline); | 453 visitor->trace(m_timeline); |
438 } | 454 } |
439 | 455 |
440 } // namespace | 456 } // namespace |
OLD | NEW |