| 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 14 matching lines...) Expand all Loading... |
| 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" | 33 #include "core/animation/AnimationTimeline.h" |
| 34 #include "core/animation/CompositorPendingAnimations.h" | 34 #include "core/animation/CompositorPendingAnimations.h" |
| 35 #include "core/animation/DocumentTimeline.h" |
| 35 #include "core/animation/KeyframeEffectReadOnly.h" | 36 #include "core/animation/KeyframeEffectReadOnly.h" |
| 36 #include "core/animation/css/CSSAnimations.h" | 37 #include "core/animation/css/CSSAnimations.h" |
| 37 #include "core/dom/DOMNodeIds.h" | 38 #include "core/dom/DOMNodeIds.h" |
| 38 #include "core/dom/Document.h" | 39 #include "core/dom/Document.h" |
| 39 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
| 40 #include "core/dom/ExecutionContext.h" | 41 #include "core/dom/ExecutionContext.h" |
| 41 #include "core/dom/StyleChangeReason.h" | 42 #include "core/dom/StyleChangeReason.h" |
| 42 #include "core/dom/TaskRunnerHelper.h" | 43 #include "core/dom/TaskRunnerHelper.h" |
| 43 #include "core/events/AnimationPlaybackEvent.h" | 44 #include "core/events/AnimationPlaybackEvent.h" |
| 44 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 63 static unsigned NextSequenceNumber() { | 64 static unsigned NextSequenceNumber() { |
| 64 static unsigned next = 0; | 65 static unsigned next = 0; |
| 65 return ++next; | 66 return ++next; |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 Animation* Animation::Create(AnimationEffectReadOnly* effect, | 70 Animation* Animation::Create(AnimationEffectReadOnly* effect, |
| 70 AnimationTimeline* timeline) { | 71 AnimationTimeline* timeline) { |
| 71 if (!timeline) { | 72 if (!timeline) { |
| 72 // FIXME: Support creating animations without a timeline. | 73 // FIXME: Support creating animations without a timeline. |
| 74 NOTREACHED(); |
| 73 return nullptr; | 75 return nullptr; |
| 74 } | 76 } |
| 75 | 77 |
| 76 Animation* animation = new Animation( | 78 Animation* animation = new Animation( |
| 77 timeline->GetDocument()->ContextDocument(), *timeline, effect); | 79 timeline->GetDocument()->ContextDocument(), *timeline, effect); |
| 78 | 80 |
| 79 if (timeline) { | 81 if (timeline) { |
| 80 timeline->AnimationAttached(*animation); | 82 timeline->AnimationAttached(*animation); |
| 81 animation->AttachCompositorTimeline(); | 83 animation->AttachCompositorTimeline(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 return animation; | 86 return animation; |
| 85 } | 87 } |
| 86 | 88 |
| 89 Animation* Animation::Create(ExecutionContext* execution_context, |
| 90 AnimationEffectReadOnly* effect, |
| 91 ExceptionState& exception_state) { |
| 92 DCHECK(RuntimeEnabledFeatures::WebAnimationsAPIEnabled()); |
| 93 |
| 94 Document* document = ToDocument(execution_context); |
| 95 return Create(effect, &document->Timeline()); |
| 96 } |
| 97 |
| 98 Animation* Animation::Create(ExecutionContext* execution_context, |
| 99 AnimationEffectReadOnly* effect, |
| 100 AnimationTimeline* timeline, |
| 101 ExceptionState& exception_state) { |
| 102 DCHECK(RuntimeEnabledFeatures::WebAnimationsAPIEnabled()); |
| 103 |
| 104 if (!timeline) { |
| 105 return Create(execution_context, effect, exception_state); |
| 106 } |
| 107 |
| 108 return Create(effect, timeline); |
| 109 } |
| 110 |
| 87 Animation::Animation(ExecutionContext* execution_context, | 111 Animation::Animation(ExecutionContext* execution_context, |
| 88 AnimationTimeline& timeline, | 112 AnimationTimeline& timeline, |
| 89 AnimationEffectReadOnly* content) | 113 AnimationEffectReadOnly* content) |
| 90 : ContextLifecycleObserver(execution_context), | 114 : ContextLifecycleObserver(execution_context), |
| 91 play_state_(kIdle), | 115 play_state_(kIdle), |
| 92 playback_rate_(1), | 116 playback_rate_(1), |
| 93 start_time_(NullValue()), | 117 start_time_(NullValue()), |
| 94 hold_time_(0), | 118 hold_time_(0), |
| 95 sequence_number_(NextSequenceNumber()), | 119 sequence_number_(NextSequenceNumber()), |
| 96 content_(content), | 120 content_(content), |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 DCHECK(!compositor_player_); | 1233 DCHECK(!compositor_player_); |
| 1210 } | 1234 } |
| 1211 | 1235 |
| 1212 void Animation::CompositorAnimationPlayerHolder::Detach() { | 1236 void Animation::CompositorAnimationPlayerHolder::Detach() { |
| 1213 DCHECK(compositor_player_); | 1237 DCHECK(compositor_player_); |
| 1214 compositor_player_->SetAnimationDelegate(nullptr); | 1238 compositor_player_->SetAnimationDelegate(nullptr); |
| 1215 animation_ = nullptr; | 1239 animation_ = nullptr; |
| 1216 compositor_player_.reset(); | 1240 compositor_player_.reset(); |
| 1217 } | 1241 } |
| 1218 } // namespace blink | 1242 } // namespace blink |
| OLD | NEW |