Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/Animation.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp |
| index 355364e365b0103bb0452ffbc7abb170dfe8cb96..6fff06190a87bad0336044ac6c36076b20930293 100644 |
| --- a/third_party/WebKit/Source/core/animation/Animation.cpp |
| +++ b/third_party/WebKit/Source/core/animation/Animation.cpp |
| @@ -34,6 +34,7 @@ |
| #include "core/animation/CompositorPendingAnimations.h" |
| #include "core/animation/DocumentTimeline.h" |
| #include "core/animation/KeyframeEffectReadOnly.h" |
| +#include "core/animation/SuperAnimationTimeline.h" |
| #include "core/animation/css/CSSAnimations.h" |
| #include "core/dom/DOMNodeIds.h" |
| #include "core/dom/Document.h" |
| @@ -68,18 +69,20 @@ static unsigned NextSequenceNumber() { |
| } |
| Animation* Animation::Create(AnimationEffectReadOnly* effect, |
| - AnimationTimeline* timeline) { |
| - if (!timeline) { |
| + SuperAnimationTimeline* timeline) { |
| + if (!timeline || !timeline->IsAnimationTimeline()) { |
| // FIXME: Support creating animations without a timeline. |
| NOTREACHED(); |
| return nullptr; |
| } |
| + AnimationTimeline* subtimeline = ToAnimationTimeline(timeline); |
|
alancutter (OOO until 2018)
2017/06/21 05:36:17
Add TODO to remove the dependency on (future) Docu
|
| + |
| Animation* animation = new Animation( |
| - timeline->GetDocument()->ContextDocument(), *timeline, effect); |
| + subtimeline->GetDocument()->ContextDocument(), *subtimeline, effect); |
| - if (timeline) { |
| - timeline->AnimationAttached(*animation); |
| + if (subtimeline) { |
| + subtimeline->AnimationAttached(*animation); |
| animation->AttachCompositorTimeline(); |
| } |
| @@ -97,7 +100,7 @@ Animation* Animation::Create(ExecutionContext* execution_context, |
| Animation* Animation::Create(ExecutionContext* execution_context, |
| AnimationEffectReadOnly* effect, |
| - AnimationTimeline* timeline, |
| + SuperAnimationTimeline* timeline, |
| ExceptionState& exception_state) { |
| DCHECK(RuntimeEnabledFeatures::WebAnimationsAPIEnabled()); |
| @@ -769,7 +772,7 @@ bool Animation::CanStartAnimationOnCompositorInternal( |
| // FIXME: Timeline playback rates should be compositable |
| if (playback_rate_ == 0 || (std::isinf(EffectEnd()) && playback_rate_ < 0) || |
| - (timeline() && timeline()->PlaybackRate() != 1)) |
| + (TimelineInternal() && TimelineInternal()->PlaybackRate() != 1)) |
| return false; |
| if (!timeline_ || !content_ || !content_->IsKeyframeEffectReadOnly()) |
| @@ -811,7 +814,7 @@ void Animation::StartAnimationOnCompositor( |
| bool reversed = playback_rate_ < 0; |
| - double start_time = timeline()->ZeroTime() + StartTimeInternal(); |
| + double start_time = TimelineInternal()->ZeroTime() + StartTimeInternal(); |
| if (reversed) { |
| start_time -= EffectEnd() / fabs(playback_rate_); |
| } |
| @@ -844,7 +847,8 @@ void Animation::SetCompositorPending(bool effect_changed) { |
| compositor_state_->playback_rate != playback_rate_ || |
| compositor_state_->start_time != start_time_) { |
| compositor_pending_ = true; |
| - timeline()->GetDocument()->GetCompositorPendingAnimations().Add(this); |
| + TimelineInternal()->GetDocument()->GetCompositorPendingAnimations().Add( |
| + this); |
| } |
| } |
| @@ -900,8 +904,9 @@ bool Animation::Update(TimingUpdateReason reason) { |
| const AtomicString& event_type = EventTypeNames::cancel; |
| if (GetExecutionContext() && HasEventListeners(event_type)) { |
| double event_current_time = NullValue(); |
| - pending_cancelled_event_ = AnimationPlaybackEvent::Create( |
| - event_type, event_current_time, timeline()->currentTime()); |
| + pending_cancelled_event_ = |
| + AnimationPlaybackEvent::Create(event_type, event_current_time, |
| + TimelineInternal()->currentTime()); |
| pending_cancelled_event_->SetTarget(this); |
| pending_cancelled_event_->SetCurrentTarget(this); |
| timeline_->GetDocument()->EnqueueAnimationFrameEvent( |
| @@ -911,8 +916,9 @@ bool Animation::Update(TimingUpdateReason reason) { |
| const AtomicString& event_type = EventTypeNames::finish; |
| if (GetExecutionContext() && HasEventListeners(event_type)) { |
| double event_current_time = CurrentTimeInternal() * 1000; |
| - pending_finished_event_ = AnimationPlaybackEvent::Create( |
| - event_type, event_current_time, timeline()->currentTime()); |
| + pending_finished_event_ = |
| + AnimationPlaybackEvent::Create(event_type, event_current_time, |
| + TimelineInternal()->currentTime()); |
| pending_finished_event_->SetTarget(this); |
| pending_finished_event_->SetCurrentTarget(this); |
| timeline_->GetDocument()->EnqueueAnimationFrameEvent( |
| @@ -1024,7 +1030,7 @@ void Animation::DetachCompositedLayers() { |
| } |
| void Animation::NotifyAnimationStarted(double monotonic_time, int group) { |
| - timeline() |
| + TimelineInternal() |
| ->GetDocument() |
| ->GetCompositorPendingAnimations() |
| .NotifyCompositorAnimationStarted(monotonic_time, group); |
| @@ -1128,9 +1134,9 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() { |
| animation_->EndUpdatingState(); |
| if (old_play_state != new_play_state) { |
| - probe::animationPlayStateChanged(animation_->timeline()->GetDocument(), |
| - animation_, old_play_state, |
| - new_play_state); |
| + probe::animationPlayStateChanged( |
| + animation_->TimelineInternal()->GetDocument(), animation_, |
| + old_play_state, new_play_state); |
| } |
| } |