Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp |
| diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp |
| index b717e08a653fad1d135766e18a01070cddfca373..0c377567ec80ab609c62216752cd280e18e78744 100644 |
| --- a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp |
| +++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp |
| @@ -10,6 +10,7 @@ |
| #include "platform/geometry/IntSize.h" |
| #include "platform/graphics/GraphicsLayer.h" |
| #include "platform/scroll/ScrollableArea.h" |
| +#include "platform/scroll/SmoothScrollSequencer.h" |
| #include "platform/wtf/PtrUtil.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebCompositorSupport.h" |
| @@ -30,7 +31,10 @@ void ProgrammaticScrollAnimator::ResetAnimationState() { |
| void ProgrammaticScrollAnimator::NotifyOffsetChanged( |
| const ScrollOffset& offset) { |
| - ScrollOffsetChanged(offset, kProgrammaticScroll); |
| + if (sequenced_for_smooth_scroll_) |
|
bokan
2017/06/07 17:56:00
nit: scroll_type = sequenced_for_smooth_scroll ? k
sunyunjia
2017/06/07 18:34:10
Done.
|
| + ScrollOffsetChanged(offset, kSequencedSmoothScroll); |
| + else |
| + ScrollOffsetChanged(offset, kProgrammaticScroll); |
| } |
| void ProgrammaticScrollAnimator::ScrollToOffsetWithoutAnimation( |
| @@ -39,12 +43,15 @@ void ProgrammaticScrollAnimator::ScrollToOffsetWithoutAnimation( |
| NotifyOffsetChanged(offset); |
| } |
| -void ProgrammaticScrollAnimator::AnimateToOffset(const ScrollOffset& offset) { |
| +void ProgrammaticScrollAnimator::AnimateToOffset( |
| + const ScrollOffset& offset, |
| + bool sequenced_for_smooth_scroll) { |
| if (run_state_ == RunState::kPostAnimationCleanup) |
| ResetAnimationState(); |
| start_time_ = 0.0; |
| target_offset_ = offset; |
| + sequenced_for_smooth_scroll_ = sequenced_for_smooth_scroll; |
| animation_curve_ = CompositorScrollOffsetAnimationCurve::Create( |
| CompositorOffsetFromBlinkOffset(target_offset_), |
| CompositorScrollOffsetAnimationCurve::kScrollDurationDeltaBased); |
| @@ -76,6 +83,7 @@ void ProgrammaticScrollAnimator::TickAnimation(double monotonic_time) { |
| if (is_finished) { |
| run_state_ = RunState::kPostAnimationCleanup; |
| + AnimationFinished(); |
| } else if (!scrollable_area_->ScheduleAnimation()) { |
| NotifyOffsetChanged(offset); |
| ResetAnimationState(); |
| @@ -116,7 +124,11 @@ void ProgrammaticScrollAnimator::UpdateCompositorAnimations() { |
| bool sent_to_compositor = false; |
| - if (!scrollable_area_->ShouldScrollOnMainThread()) { |
| + // TODO(sunyunjia): Sequenced Smooth Scroll should also be able to |
| + // scroll on the compositor thread. We should send the ScrollType |
| + // information to the compositor thread. |
|
bokan
2017/06/07 17:56:53
Oh, and please file a bug to make this work with c
sunyunjia
2017/06/07 18:34:10
Done.
|
| + if (!scrollable_area_->ShouldScrollOnMainThread() && |
| + !sequenced_for_smooth_scroll_) { |
| std::unique_ptr<CompositorAnimation> animation = |
| CompositorAnimation::Create( |
| *animation_curve_, CompositorTargetProperty::SCROLL_OFFSET, 0, 0); |
| @@ -169,6 +181,16 @@ void ProgrammaticScrollAnimator::NotifyCompositorAnimationFinished( |
| int group_id) { |
| DCHECK_NE(run_state_, RunState::kRunningOnCompositorButNeedsUpdate); |
| ScrollAnimatorCompositorCoordinator::CompositorAnimationFinished(group_id); |
| + AnimationFinished(); |
| +} |
| + |
| +void ProgrammaticScrollAnimator::AnimationFinished() { |
| + if (sequenced_for_smooth_scroll_) { |
| + sequenced_for_smooth_scroll_ = false; |
| + if (SmoothScrollSequencer* sequencer = |
| + GetScrollableArea()->GetSmoothScrollSequencer()) |
| + sequencer->RunQueuedAnimations(); |
| + } |
| } |
| DEFINE_TRACE(ProgrammaticScrollAnimator) { |