| Index: cc/animation/scroll_offset_animation_curve.cc
|
| diff --git a/cc/animation/scroll_offset_animation_curve.cc b/cc/animation/scroll_offset_animation_curve.cc
|
| index b207994c092a327a70c753d99b7c93f4446bf4c2..d5dd4d5959c7d27a6b4b742a3e9690b46e498886 100644
|
| --- a/cc/animation/scroll_offset_animation_curve.cc
|
| +++ b/cc/animation/scroll_offset_animation_curve.cc
|
| @@ -41,7 +41,8 @@ static float MaximumDimension(const gfx::Vector2dF& delta) {
|
| }
|
|
|
| static base::TimeDelta SegmentDuration(const gfx::Vector2dF& delta,
|
| - DurationBehavior behavior) {
|
| + DurationBehavior behavior,
|
| + base::TimeDelta delayed_by) {
|
| double duration = kConstantDuration;
|
| switch (behavior) {
|
| case DurationBehavior::CONSTANT:
|
| @@ -60,8 +61,14 @@ static base::TimeDelta SegmentDuration(const gfx::Vector2dF& delta,
|
| default:
|
| NOTREACHED();
|
| }
|
| - return base::TimeDelta::FromMicroseconds(duration / kDurationDivisor *
|
| - base::Time::kMicrosecondsPerSecond);
|
| +
|
| + base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds(
|
| + duration / kDurationDivisor * base::Time::kMicrosecondsPerSecond);
|
| +
|
| + time_delta -= delayed_by;
|
| + if (time_delta >= base::TimeDelta())
|
| + return time_delta;
|
| + return base::TimeDelta();
|
| }
|
|
|
| static std::unique_ptr<TimingFunction> EaseOutWithInitialVelocity(
|
| @@ -98,11 +105,12 @@ ScrollOffsetAnimationCurve::ScrollOffsetAnimationCurve(
|
| ScrollOffsetAnimationCurve::~ScrollOffsetAnimationCurve() {}
|
|
|
| void ScrollOffsetAnimationCurve::SetInitialValue(
|
| - const gfx::ScrollOffset& initial_value) {
|
| + const gfx::ScrollOffset& initial_value,
|
| + base::TimeDelta delayed_by) {
|
| initial_value_ = initial_value;
|
| has_set_initial_value_ = true;
|
| total_animation_duration_ = SegmentDuration(
|
| - target_value_.DeltaFrom(initial_value_), duration_behavior_);
|
| + target_value_.DeltaFrom(initial_value_), duration_behavior_, delayed_by);
|
| }
|
|
|
| bool ScrollOffsetAnimationCurve::HasSetInitialValue() const {
|
| @@ -120,6 +128,9 @@ gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue(
|
| base::TimeDelta duration = total_animation_duration_ - last_retarget_;
|
| t -= last_retarget_;
|
|
|
| + if (duration.is_zero())
|
| + return target_value_;
|
| +
|
| if (t <= base::TimeDelta())
|
| return initial_value_;
|
|
|
| @@ -190,10 +201,13 @@ void ScrollOffsetAnimationCurve::UpdateTarget(
|
| double t,
|
| const gfx::ScrollOffset& new_target) {
|
| if (std::abs(MaximumDimension(target_value_.DeltaFrom(new_target))) <
|
| - kEpsilon) {
|
| + kEpsilon ||
|
| + total_animation_duration_.is_zero()) {
|
| target_value_ = new_target;
|
| return;
|
| }
|
| +
|
| + t = std::max(t, last_retarget_.InSecondsF());
|
| gfx::ScrollOffset current_position =
|
| GetValue(base::TimeDelta::FromSecondsD(t));
|
| gfx::Vector2dF old_delta = target_value_.DeltaFrom(initial_value_);
|
| @@ -208,7 +222,8 @@ void ScrollOffsetAnimationCurve::UpdateTarget(
|
| // segment duration. This minimizes the "rubber-band" bouncing effect when
|
| // old_normalized_velocity is large and new_delta is small.
|
| double new_duration =
|
| - std::min(SegmentDuration(new_delta, duration_behavior_).InSecondsF(),
|
| + std::min(SegmentDuration(new_delta, duration_behavior_, base::TimeDelta())
|
| + .InSecondsF(),
|
| VelocityBasedDurationBound(old_delta, old_normalized_velocity,
|
| old_duration, new_delta));
|
|
|
|
|