Index: cc/animation/scroll_offset_animations_impl.cc |
diff --git a/cc/animation/scroll_offset_animations_impl.cc b/cc/animation/scroll_offset_animations_impl.cc |
index ffebdbcd5e76bdae3f1666dfd8f9384d4235b25d..1f6759221a730d29ceb0c8bc8d0a01e9118476cc 100644 |
--- a/cc/animation/scroll_offset_animations_impl.cc |
+++ b/cc/animation/scroll_offset_animations_impl.cc |
@@ -90,6 +90,43 @@ bool ScrollOffsetAnimationsImpl::ScrollAnimationUpdateTarget( |
return true; |
} |
+void ScrollOffsetAnimationsImpl::ScrollAnimationApplyAdjustment( |
+ ElementId element_id, |
+ const gfx::Vector2dF& adjustment, |
+ base::TimeTicks frame_monotonic_time) { |
+ DCHECK(scroll_offset_animation_player_); |
+ if (element_id != scroll_offset_animation_player_->element_id()) |
+ return; |
+ |
+ if (!scroll_offset_animation_player_->element_animations()) |
+ return; |
+ |
+ Animation* animation = |
+ scroll_offset_animation_player_->element_animations()->GetAnimation( |
+ TargetProperty::SCROLL_OFFSET); |
+ if (!animation) |
+ return; |
+ |
+ // Abort the old animation. |
+ ScrollAnimationAbort(/* needs_completion */ false); |
+ |
+ // Start a new one with the adjusment. |
+ std::unique_ptr<ScrollOffsetAnimationCurve> new_curve = |
+ animation->curve() |
+ ->ToScrollOffsetAnimationCurve() |
+ ->CloneToScrollOffsetAnimationCurve(); |
+ new_curve->ApplyAdjustment( |
+ animation->TrimTimeToCurrentIteration(frame_monotonic_time), adjustment); |
+ |
+ std::unique_ptr<Animation> new_animation = Animation::Create( |
+ std::move(new_curve), AnimationIdProvider::NextAnimationId(), |
+ AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET); |
+ new_animation->set_is_impl_only(true); |
+ new_animation->set_affects_active_elements(false); |
+ |
+ scroll_offset_animation_player_->AddAnimation(std::move(new_animation)); |
+} |
+ |
void ScrollOffsetAnimationsImpl::ScrollAnimationAbort(bool needs_completion) { |
DCHECK(scroll_offset_animation_player_); |
scroll_offset_animation_player_->AbortAnimations( |