| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 Animation* Animation::create(AnimationEffectReadOnly* effect, | 62 Animation* Animation::create(AnimationEffectReadOnly* effect, |
| 63 AnimationTimeline* timeline) { | 63 AnimationTimeline* timeline) { |
| 64 if (!timeline) { | 64 if (!timeline) { |
| 65 // FIXME: Support creating animations without a timeline. | 65 // FIXME: Support creating animations without a timeline. |
| 66 return nullptr; | 66 return nullptr; |
| 67 } | 67 } |
| 68 | 68 |
| 69 Animation* animation = | 69 Animation* animation = |
| 70 new Animation(timeline->document()->contextDocument(), *timeline, effect); | 70 new Animation(timeline->document()->contextDocument(), *timeline, effect); |
| 71 animation->suspendIfNeeded(); | |
| 72 | 71 |
| 73 if (timeline) { | 72 if (timeline) { |
| 74 timeline->animationAttached(*animation); | 73 timeline->animationAttached(*animation); |
| 75 animation->attachCompositorTimeline(); | 74 animation->attachCompositorTimeline(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 return animation; | 77 return animation; |
| 79 } | 78 } |
| 80 | 79 |
| 81 Animation::Animation(ExecutionContext* executionContext, | 80 Animation::Animation(ExecutionContext* executionContext, |
| 82 AnimationTimeline& timeline, | 81 AnimationTimeline& timeline, |
| 83 AnimationEffectReadOnly* content) | 82 AnimationEffectReadOnly* content) |
| 84 : SuspendableObject(executionContext), | 83 : ContextLifecycleObserver(executionContext), |
| 85 m_playState(Idle), | 84 m_playState(Idle), |
| 86 m_playbackRate(1), | 85 m_playbackRate(1), |
| 87 m_startTime(nullValue()), | 86 m_startTime(nullValue()), |
| 88 m_holdTime(0), | 87 m_holdTime(0), |
| 89 m_sequenceNumber(nextSequenceNumber()), | 88 m_sequenceNumber(nextSequenceNumber()), |
| 90 m_content(content), | 89 m_content(content), |
| 91 m_timeline(&timeline), | 90 m_timeline(&timeline), |
| 92 m_paused(false), | 91 m_paused(false), |
| 93 m_held(false), | 92 m_held(false), |
| 94 m_isPausedForTesting(false), | 93 m_isPausedForTesting(false), |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 m_readyPromise->resolve(this); | 638 m_readyPromise->resolve(this); |
| 640 } | 639 } |
| 641 return m_readyPromise->promise(scriptState->world()); | 640 return m_readyPromise->promise(scriptState->world()); |
| 642 } | 641 } |
| 643 | 642 |
| 644 const AtomicString& Animation::interfaceName() const { | 643 const AtomicString& Animation::interfaceName() const { |
| 645 return EventTargetNames::AnimationPlayer; | 644 return EventTargetNames::AnimationPlayer; |
| 646 } | 645 } |
| 647 | 646 |
| 648 ExecutionContext* Animation::getExecutionContext() const { | 647 ExecutionContext* Animation::getExecutionContext() const { |
| 649 return SuspendableObject::getExecutionContext(); | 648 return ContextLifecycleObserver::getExecutionContext(); |
| 650 } | 649 } |
| 651 | 650 |
| 652 bool Animation::hasPendingActivity() const { | 651 bool Animation::hasPendingActivity() const { |
| 653 bool hasPendingPromise = | 652 bool hasPendingPromise = |
| 654 !m_finished && m_finishedPromise && | 653 !m_finished && m_finishedPromise && |
| 655 m_finishedPromise->getState() == ScriptPromisePropertyBase::Pending; | 654 m_finishedPromise->getState() == ScriptPromisePropertyBase::Pending; |
| 656 | 655 |
| 657 return m_pendingFinishedEvent || hasPendingPromise || | 656 return m_pendingFinishedEvent || hasPendingPromise || |
| 658 (!m_finished && hasEventListeners(EventTypeNames::finish)); | 657 (!m_finished && hasEventListeners(EventTypeNames::finish)); |
| 659 } | 658 } |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 | 1111 |
| 1113 DEFINE_TRACE(Animation) { | 1112 DEFINE_TRACE(Animation) { |
| 1114 visitor->trace(m_content); | 1113 visitor->trace(m_content); |
| 1115 visitor->trace(m_timeline); | 1114 visitor->trace(m_timeline); |
| 1116 visitor->trace(m_pendingFinishedEvent); | 1115 visitor->trace(m_pendingFinishedEvent); |
| 1117 visitor->trace(m_pendingCancelledEvent); | 1116 visitor->trace(m_pendingCancelledEvent); |
| 1118 visitor->trace(m_finishedPromise); | 1117 visitor->trace(m_finishedPromise); |
| 1119 visitor->trace(m_readyPromise); | 1118 visitor->trace(m_readyPromise); |
| 1120 visitor->trace(m_compositorPlayer); | 1119 visitor->trace(m_compositorPlayer); |
| 1121 EventTargetWithInlineData::trace(visitor); | 1120 EventTargetWithInlineData::trace(visitor); |
| 1122 SuspendableObject::trace(visitor); | 1121 ContextLifecycleObserver::trace(visitor); |
| 1123 } | 1122 } |
| 1124 | 1123 |
| 1125 Animation::CompositorAnimationPlayerHolder* | 1124 Animation::CompositorAnimationPlayerHolder* |
| 1126 Animation::CompositorAnimationPlayerHolder::create(Animation* animation) { | 1125 Animation::CompositorAnimationPlayerHolder::create(Animation* animation) { |
| 1127 return new CompositorAnimationPlayerHolder(animation); | 1126 return new CompositorAnimationPlayerHolder(animation); |
| 1128 } | 1127 } |
| 1129 | 1128 |
| 1130 Animation::CompositorAnimationPlayerHolder::CompositorAnimationPlayerHolder( | 1129 Animation::CompositorAnimationPlayerHolder::CompositorAnimationPlayerHolder( |
| 1131 Animation* animation) | 1130 Animation* animation) |
| 1132 : m_animation(animation) { | 1131 : m_animation(animation) { |
| 1133 m_compositorPlayer = CompositorAnimationPlayer::create(); | 1132 m_compositorPlayer = CompositorAnimationPlayer::create(); |
| 1134 m_compositorPlayer->setAnimationDelegate(m_animation); | 1133 m_compositorPlayer->setAnimationDelegate(m_animation); |
| 1135 } | 1134 } |
| 1136 | 1135 |
| 1137 void Animation::CompositorAnimationPlayerHolder::dispose() { | 1136 void Animation::CompositorAnimationPlayerHolder::dispose() { |
| 1138 if (!m_animation) | 1137 if (!m_animation) |
| 1139 return; | 1138 return; |
| 1140 m_animation->dispose(); | 1139 m_animation->dispose(); |
| 1141 DCHECK(!m_animation); | 1140 DCHECK(!m_animation); |
| 1142 DCHECK(!m_compositorPlayer); | 1141 DCHECK(!m_compositorPlayer); |
| 1143 } | 1142 } |
| 1144 | 1143 |
| 1145 void Animation::CompositorAnimationPlayerHolder::detach() { | 1144 void Animation::CompositorAnimationPlayerHolder::detach() { |
| 1146 DCHECK(m_compositorPlayer); | 1145 DCHECK(m_compositorPlayer); |
| 1147 m_compositorPlayer->setAnimationDelegate(nullptr); | 1146 m_compositorPlayer->setAnimationDelegate(nullptr); |
| 1148 m_animation = nullptr; | 1147 m_animation = nullptr; |
| 1149 m_compositorPlayer.reset(); | 1148 m_compositorPlayer.reset(); |
| 1150 } | 1149 } |
| 1151 } // namespace blink | 1150 } // namespace blink |
| OLD | NEW |