| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/animation/Animation.h" | 31 #include "core/animation/Animation.h" |
| 32 | 32 |
| 33 #include "core/animation/AnimationTimeline.h" | |
| 34 #include "core/animation/CompositorPendingAnimations.h" | 33 #include "core/animation/CompositorPendingAnimations.h" |
| 35 #include "core/animation/DocumentTimeline.h" | 34 #include "core/animation/DocumentTimeline.h" |
| 36 #include "core/animation/KeyframeEffectReadOnly.h" | 35 #include "core/animation/KeyframeEffectReadOnly.h" |
| 37 #include "core/animation/SuperAnimationTimeline.h" | 36 #include "core/animation/SuperAnimationTimeline.h" |
| 38 #include "core/animation/css/CSSAnimations.h" | 37 #include "core/animation/css/CSSAnimations.h" |
| 39 #include "core/dom/DOMNodeIds.h" | 38 #include "core/dom/DOMNodeIds.h" |
| 40 #include "core/dom/Document.h" | 39 #include "core/dom/Document.h" |
| 41 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
| 42 #include "core/dom/ExecutionContext.h" | 41 #include "core/dom/ExecutionContext.h" |
| 43 #include "core/dom/StyleChangeReason.h" | 42 #include "core/dom/StyleChangeReason.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 63 namespace { | 62 namespace { |
| 64 | 63 |
| 65 static unsigned NextSequenceNumber() { | 64 static unsigned NextSequenceNumber() { |
| 66 static unsigned next = 0; | 65 static unsigned next = 0; |
| 67 return ++next; | 66 return ++next; |
| 68 } | 67 } |
| 69 } | 68 } |
| 70 | 69 |
| 71 Animation* Animation::Create(AnimationEffectReadOnly* effect, | 70 Animation* Animation::Create(AnimationEffectReadOnly* effect, |
| 72 SuperAnimationTimeline* timeline) { | 71 SuperAnimationTimeline* timeline) { |
| 73 if (!timeline || !timeline->IsAnimationTimeline()) { | 72 if (!timeline || !timeline->IsDocumentTimeline()) { |
| 74 // FIXME: Support creating animations without a timeline. | 73 // FIXME: Support creating animations without a timeline. |
| 75 NOTREACHED(); | 74 NOTREACHED(); |
| 76 return nullptr; | 75 return nullptr; |
| 77 } | 76 } |
| 78 | 77 |
| 79 AnimationTimeline* subtimeline = ToAnimationTimeline(timeline); | 78 DocumentTimeline* subtimeline = ToDocumentTimeline(timeline); |
| 80 | 79 |
| 81 Animation* animation = new Animation( | 80 Animation* animation = new Animation( |
| 82 subtimeline->GetDocument()->ContextDocument(), *subtimeline, effect); | 81 subtimeline->GetDocument()->ContextDocument(), *subtimeline, effect); |
| 83 | 82 |
| 84 if (subtimeline) { | 83 if (subtimeline) { |
| 85 subtimeline->AnimationAttached(*animation); | 84 subtimeline->AnimationAttached(*animation); |
| 86 animation->AttachCompositorTimeline(); | 85 animation->AttachCompositorTimeline(); |
| 87 } | 86 } |
| 88 | 87 |
| 89 return animation; | 88 return animation; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 105 DCHECK(RuntimeEnabledFeatures::WebAnimationsAPIEnabled()); | 104 DCHECK(RuntimeEnabledFeatures::WebAnimationsAPIEnabled()); |
| 106 | 105 |
| 107 if (!timeline) { | 106 if (!timeline) { |
| 108 return Create(execution_context, effect, exception_state); | 107 return Create(execution_context, effect, exception_state); |
| 109 } | 108 } |
| 110 | 109 |
| 111 return Create(effect, timeline); | 110 return Create(effect, timeline); |
| 112 } | 111 } |
| 113 | 112 |
| 114 Animation::Animation(ExecutionContext* execution_context, | 113 Animation::Animation(ExecutionContext* execution_context, |
| 115 AnimationTimeline& timeline, | 114 DocumentTimeline& timeline, |
| 116 AnimationEffectReadOnly* content) | 115 AnimationEffectReadOnly* content) |
| 117 : ContextLifecycleObserver(execution_context), | 116 : ContextLifecycleObserver(execution_context), |
| 118 play_state_(kIdle), | 117 play_state_(kIdle), |
| 119 playback_rate_(1), | 118 playback_rate_(1), |
| 120 start_time_(NullValue()), | 119 start_time_(NullValue()), |
| 121 hold_time_(0), | 120 hold_time_(0), |
| 122 sequence_number_(NextSequenceNumber()), | 121 sequence_number_(NextSequenceNumber()), |
| 123 content_(content), | 122 content_(content), |
| 124 timeline_(&timeline), | 123 timeline_(&timeline), |
| 125 paused_(false), | 124 paused_(false), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 probe::didCreateAnimation(timeline_->GetDocument(), sequence_number_); | 143 probe::didCreateAnimation(timeline_->GetDocument(), sequence_number_); |
| 145 } | 144 } |
| 146 | 145 |
| 147 Animation::~Animation() { | 146 Animation::~Animation() { |
| 148 // Verify that m_compositorPlayer has been disposed of. | 147 // Verify that m_compositorPlayer has been disposed of. |
| 149 DCHECK(!compositor_player_); | 148 DCHECK(!compositor_player_); |
| 150 } | 149 } |
| 151 | 150 |
| 152 void Animation::Dispose() { | 151 void Animation::Dispose() { |
| 153 DestroyCompositorPlayer(); | 152 DestroyCompositorPlayer(); |
| 154 // If the AnimationTimeline and its Animation objects are | 153 // If the DocumentTimeline and its Animation objects are |
| 155 // finalized by the same GC, we have to eagerly clear out | 154 // finalized by the same GC, we have to eagerly clear out |
| 156 // this Animation object's compositor player registration. | 155 // this Animation object's compositor player registration. |
| 157 DCHECK(!compositor_player_); | 156 DCHECK(!compositor_player_); |
| 158 } | 157 } |
| 159 | 158 |
| 160 double Animation::EffectEnd() const { | 159 double Animation::EffectEnd() const { |
| 161 return content_ ? content_->EndTimeInternal() : 0; | 160 return content_ ? content_->EndTimeInternal() : 0; |
| 162 } | 161 } |
| 163 | 162 |
| 164 bool Animation::Limited(double current_time) const { | 163 bool Animation::Limited(double current_time) const { |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 DCHECK(!compositor_player_); | 1280 DCHECK(!compositor_player_); |
| 1282 } | 1281 } |
| 1283 | 1282 |
| 1284 void Animation::CompositorAnimationPlayerHolder::Detach() { | 1283 void Animation::CompositorAnimationPlayerHolder::Detach() { |
| 1285 DCHECK(compositor_player_); | 1284 DCHECK(compositor_player_); |
| 1286 compositor_player_->SetAnimationDelegate(nullptr); | 1285 compositor_player_->SetAnimationDelegate(nullptr); |
| 1287 animation_ = nullptr; | 1286 animation_ = nullptr; |
| 1288 compositor_player_.reset(); | 1287 compositor_player_.reset(); |
| 1289 } | 1288 } |
| 1290 } // namespace blink | 1289 } // namespace blink |
| OLD | NEW |