| 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 PassRefPtr<AnimationPlayer> AnimationPlayer::create(DocumentTimeline& timeline,
TimedItem* content) | 51 PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(DocumentTimeline
& timeline, TimedItem* content) |
| 52 { | 52 { |
| 53 return adoptRef(new AnimationPlayer(timeline, content)); | 53 return adoptRefWillBeRefCountedGarbageCollected(new AnimationPlayer(timeline
, content)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 AnimationPlayer::AnimationPlayer(DocumentTimeline& timeline, TimedItem* content) | 56 AnimationPlayer::AnimationPlayer(DocumentTimeline& timeline, TimedItem* content) |
| 57 : m_playbackRate(1) | 57 : m_playbackRate(1) |
| 58 , m_startTime(nullValue()) | 58 , m_startTime(nullValue()) |
| 59 , m_holdTime(nullValue()) | 59 , m_holdTime(nullValue()) |
| 60 , m_storedTimeLag(0) | 60 , m_storedTimeLag(0) |
| 61 , m_sortInfo(nextSequenceNumber(), timeline.effectiveTime()) | 61 , m_sortInfo(nextSequenceNumber(), timeline.effectiveTime()) |
| 62 , m_content(content) | 62 , m_content(content) |
| 63 , m_timeline(&timeline) | 63 , m_timeline(&timeline) |
| 64 , m_paused(false) | 64 , m_paused(false) |
| 65 , m_held(false) | 65 , m_held(false) |
| 66 , m_isPausedForTesting(false) | 66 , m_isPausedForTesting(false) |
| 67 , m_outdated(false) | 67 , m_outdated(false) |
| 68 , m_finished(false) | 68 , m_finished(false) |
| 69 { | 69 { |
| 70 if (m_content) { | 70 if (m_content) { |
| 71 if (m_content->player()) | 71 if (m_content->player()) |
| 72 m_content->player()->cancel(); | 72 m_content->player()->cancel(); |
| 73 m_content->attach(this); | 73 m_content->attach(this); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 AnimationPlayer::~AnimationPlayer() | 77 AnimationPlayer::~AnimationPlayer() |
| 78 { | 78 { |
| 79 #if !ENABLE(OILPAN) |
| 79 if (m_content) | 80 if (m_content) |
| 80 m_content->detach(); | 81 m_content->detach(); |
| 81 if (m_timeline) | 82 if (m_timeline) |
| 82 m_timeline->playerDestroyed(this); | 83 m_timeline->playerDestroyed(this); |
| 84 #endif |
| 83 } | 85 } |
| 84 | 86 |
| 85 double AnimationPlayer::sourceEnd() const | 87 double AnimationPlayer::sourceEnd() const |
| 86 { | 88 { |
| 87 return m_content ? m_content->endTimeInternal() : 0; | 89 return m_content ? m_content->endTimeInternal() : 0; |
| 88 } | 90 } |
| 89 | 91 |
| 90 bool AnimationPlayer::limited(double currentTime) const | 92 bool AnimationPlayer::limited(double currentTime) const |
| 91 { | 93 { |
| 92 return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && cu
rrentTime >= sourceEnd()); | 94 return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && cu
rrentTime >= sourceEnd()); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 bool AnimationPlayer::SortInfo::operator<(const SortInfo& other) const | 393 bool AnimationPlayer::SortInfo::operator<(const SortInfo& other) const |
| 392 { | 394 { |
| 393 ASSERT(!std::isnan(m_startTime) && !std::isnan(other.m_startTime)); | 395 ASSERT(!std::isnan(m_startTime) && !std::isnan(other.m_startTime)); |
| 394 if (m_startTime < other.m_startTime) | 396 if (m_startTime < other.m_startTime) |
| 395 return true; | 397 return true; |
| 396 if (m_startTime > other.m_startTime) | 398 if (m_startTime > other.m_startTime) |
| 397 return false; | 399 return false; |
| 398 return m_sequenceNumber < other.m_sequenceNumber; | 400 return m_sequenceNumber < other.m_sequenceNumber; |
| 399 } | 401 } |
| 400 | 402 |
| 403 #if !ENABLE(OILPAN) |
| 401 bool AnimationPlayer::canFree() const | 404 bool AnimationPlayer::canFree() const |
| 402 { | 405 { |
| 403 ASSERT(m_content); | 406 ASSERT(m_content); |
| 404 return hasOneRef() && m_content->isAnimation() && m_content->hasOneRef(); | 407 return hasOneRef() && m_content->isAnimation() && m_content->hasOneRef(); |
| 405 } | 408 } |
| 409 #endif |
| 406 | 410 |
| 407 bool AnimationPlayer::addEventListener(const AtomicString& eventType, PassRefPtr
<EventListener> listener, bool useCapture) | 411 bool AnimationPlayer::addEventListener(const AtomicString& eventType, PassRefPtr
<EventListener> listener, bool useCapture) |
| 408 { | 412 { |
| 409 if (eventType == EventTypeNames::finish) | 413 if (eventType == EventTypeNames::finish) |
| 410 UseCounter::count(executionContext(), UseCounter::AnimationPlayerFinishE
vent); | 414 UseCounter::count(executionContext(), UseCounter::AnimationPlayerFinishE
vent); |
| 411 return EventTargetWithInlineData::addEventListener(eventType, listener, useC
apture); | 415 return EventTargetWithInlineData::addEventListener(eventType, listener, useC
apture); |
| 412 } | 416 } |
| 413 | 417 |
| 414 void AnimationPlayer::pauseForTesting(double pauseTime) | 418 void AnimationPlayer::pauseForTesting(double pauseTime) |
| 415 { | 419 { |
| 416 RELEASE_ASSERT(!paused()); | 420 RELEASE_ASSERT(!paused()); |
| 417 updateTimingState(pauseTime); | 421 updateTimingState(pauseTime); |
| 418 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) | 422 if (!m_isPausedForTesting && hasActiveAnimationsOnCompositor()) |
| 419 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre
ntTimeInternal()); | 423 toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(curre
ntTimeInternal()); |
| 420 m_isPausedForTesting = true; | 424 m_isPausedForTesting = true; |
| 421 pause(); | 425 pause(); |
| 422 } | 426 } |
| 423 | 427 |
| 428 void AnimationPlayer::trace(Visitor* visitor) |
| 429 { |
| 430 visitor->trace(m_content); |
| 431 visitor->trace(m_timeline); |
| 432 } |
| 433 |
| 424 } // namespace | 434 } // namespace |
| OLD | NEW |