Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 62 static unsigned NextSequenceNumber() { | 63 static unsigned NextSequenceNumber() { |
| 63 static unsigned next = 0; | 64 static unsigned next = 0; |
| 64 return ++next; | 65 return ++next; |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 | 68 |
| 68 Animation* Animation::Create(AnimationEffectReadOnly* effect, | 69 Animation* Animation::Create(AnimationEffectReadOnly* effect, |
| 69 AnimationTimeline* timeline) { | 70 AnimationTimeline* timeline) { |
| 70 if (!timeline) { | 71 if (!timeline) { |
| 71 // FIXME: Support creating animations without a timeline. | 72 // FIXME: Support creating animations without a timeline. |
| 73 NOTREACHED(); | |
| 72 return nullptr; | 74 return nullptr; |
| 73 } | 75 } |
| 74 | 76 |
| 75 Animation* animation = new Animation( | 77 Animation* animation = new Animation( |
| 76 timeline->GetDocument()->ContextDocument(), *timeline, effect); | 78 timeline->GetDocument()->ContextDocument(), *timeline, effect); |
| 77 | 79 |
| 78 if (timeline) { | 80 if (timeline) { |
| 79 timeline->AnimationAttached(*animation); | 81 timeline->AnimationAttached(*animation); |
| 80 animation->AttachCompositorTimeline(); | 82 animation->AttachCompositorTimeline(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 return animation; | 85 return animation; |
| 84 } | 86 } |
| 85 | 87 |
| 88 Animation* Animation::Create(ExecutionContext* execution_context, | |
| 89 AnimationEffectReadOnly* effect, | |
| 90 ExceptionState& exception_state) { | |
| 91 if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled()) { | |
| 92 exception_state.ThrowTypeError("Illegal constructor"); | |
| 93 return nullptr; | |
| 94 } | |
| 95 | |
| 96 if (!execution_context || !execution_context->IsDocument()) { | |
| 97 NOTREACHED(); | |
|
alancutter (OOO until 2018)
2017/04/26 04:34:48
This is redundant with the ToDocument() call below
suzyh_UTC10 (ex-contributor)
2017/06/06 06:21:48
Removed.
| |
| 98 return nullptr; | |
| 99 } | |
| 100 | |
| 101 Document* document = ToDocument(execution_context); | |
| 102 return Create(effect, &document->Timeline()); | |
| 103 } | |
| 104 | |
| 105 Animation* Animation::Create(ExecutionContext* execution_context, | |
| 106 AnimationEffectReadOnly* effect, | |
| 107 AnimationTimeline* timeline, | |
| 108 ExceptionState& exception_state) { | |
| 109 if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled()) { | |
| 110 exception_state.ThrowTypeError("Illegal constructor"); | |
| 111 return nullptr; | |
| 112 } | |
| 113 | |
| 114 if (!timeline) { | |
| 115 return Create(execution_context, effect, exception_state); | |
| 116 } | |
| 117 | |
| 118 return Create(effect, timeline); | |
| 119 } | |
| 120 | |
| 86 Animation::Animation(ExecutionContext* execution_context, | 121 Animation::Animation(ExecutionContext* execution_context, |
| 87 AnimationTimeline& timeline, | 122 AnimationTimeline& timeline, |
| 88 AnimationEffectReadOnly* content) | 123 AnimationEffectReadOnly* content) |
| 89 : ContextLifecycleObserver(execution_context), | 124 : ContextLifecycleObserver(execution_context), |
| 90 play_state_(kIdle), | 125 play_state_(kIdle), |
| 91 playback_rate_(1), | 126 playback_rate_(1), |
| 92 start_time_(NullValue()), | 127 start_time_(NullValue()), |
| 93 hold_time_(0), | 128 hold_time_(0), |
| 94 sequence_number_(NextSequenceNumber()), | 129 sequence_number_(NextSequenceNumber()), |
| 95 content_(content), | 130 content_(content), |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 DCHECK(!compositor_player_); | 1217 DCHECK(!compositor_player_); |
| 1183 } | 1218 } |
| 1184 | 1219 |
| 1185 void Animation::CompositorAnimationPlayerHolder::Detach() { | 1220 void Animation::CompositorAnimationPlayerHolder::Detach() { |
| 1186 DCHECK(compositor_player_); | 1221 DCHECK(compositor_player_); |
| 1187 compositor_player_->SetAnimationDelegate(nullptr); | 1222 compositor_player_->SetAnimationDelegate(nullptr); |
| 1188 animation_ = nullptr; | 1223 animation_ = nullptr; |
| 1189 compositor_player_.reset(); | 1224 compositor_player_.reset(); |
| 1190 } | 1225 } |
| 1191 } // namespace blink | 1226 } // namespace blink |
| OLD | NEW |