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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(AnimationTimelin e& timeline, AnimationSource* content)
52 { 52 {
53 return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(timeline , content)); 53 RefPtrWillBeRawPtr<AnimationPlayer> player = adoptRefWillBeRefCountedGarbage Collected(new AnimationPlayer(timeline, content));
54 player->suspendIfNeeded();
55 return player.release();
54 } 56 }
55 57
56 AnimationPlayer::AnimationPlayer(AnimationTimeline& timeline, AnimationSource* c ontent) 58 AnimationPlayer::AnimationPlayer(AnimationTimeline& timeline, AnimationSource* c ontent)
57 : m_playbackRate(1) 59 : 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.
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
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 bool AnimationPlayer::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
300 {
301 if (m_pendingFinishedEvent == event)
302 m_pendingFinishedEvent = nullptr;
303 return EventTargetWithInlineData::dispatchEvent(event);
293 } 304 }
294 305
295 void AnimationPlayer::setPlaybackRate(double playbackRate) 306 void AnimationPlayer::setPlaybackRate(double playbackRate)
296 { 307 {
297 if (!std::isfinite(playbackRate)) 308 if (!std::isfinite(playbackRate))
298 return; 309 return;
299 double storedCurrentTime = currentTimeInternal(); 310 double storedCurrentTime = currentTimeInternal();
300 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play backRate <= 0)) 311 if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && play backRate <= 0))
301 m_finished = false; 312 m_finished = false;
302 m_playbackRate = playbackRate; 313 m_playbackRate = playbackRate;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 371
361 if (m_content) { 372 if (m_content) {
362 double inheritedTime = isNull(m_timeline->currentTimeInternal()) ? nullV alue() : currentTimeInternal(); 373 double inheritedTime = isNull(m_timeline->currentTimeInternal()) ? nullV alue() : currentTimeInternal();
363 m_content->updateInheritedTime(inheritedTime, reason); 374 m_content->updateInheritedTime(inheritedTime, reason);
364 } 375 }
365 376
366 if (finished() && !m_finished) { 377 if (finished() && !m_finished) {
367 if (reason == TimingUpdateForAnimationFrame && hasStartTime()) { 378 if (reason == TimingUpdateForAnimationFrame && hasStartTime()) {
368 const AtomicString& eventType = EventTypeNames::finish; 379 const AtomicString& eventType = EventTypeNames::finish;
369 if (executionContext() && hasEventListeners(eventType)) { 380 if (executionContext() && hasEventListeners(eventType)) {
370 RefPtrWillBeRawPtr<AnimationPlayerEvent> event = AnimationPlayer Event::create(eventType, currentTime(), timeline()->currentTime()); 381 m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, currentTime(), timeline()->currentTime());
371 event->setTarget(this); 382 m_pendingFinishedEvent->setTarget(this);
372 event->setCurrentTarget(this); 383 m_pendingFinishedEvent->setCurrentTarget(this);
373 m_timeline->document()->enqueueAnimationFrameEvent(event.release ()); 384 m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFini shedEvent);
374 } 385 }
375 m_finished = true; 386 m_finished = true;
376 } 387 }
377 } 388 }
378 ASSERT(!m_outdated); 389 ASSERT(!m_outdated);
379 return !m_finished || !finished(); 390 return !m_finished || !finished();
380 } 391 }
381 392
382 double AnimationPlayer::timeToEffectChange() 393 double AnimationPlayer::timeToEffectChange()
383 { 394 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 pause(); 442 pause();
432 } 443 }
433 444
434 void AnimationPlayer::trace(Visitor* visitor) 445 void AnimationPlayer::trace(Visitor* visitor)
435 { 446 {
436 visitor->trace(m_content); 447 visitor->trace(m_content);
437 visitor->trace(m_timeline); 448 visitor->trace(m_timeline);
438 } 449 }
439 450
440 } // namespace 451 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698