Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3651)

Unified Diff: cc/animation/scroll_offset_animation_curve.cc

Issue 2332923002: Fix scroll animation UpdateTarget for zero-duration segments (Closed)
Patch Set: update tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/animation/scroll_offset_animation_curve_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a3831432897b6f8b3b71295254768597d06f2e8e..c1bfe63e0344479ab90bd3af89ddde08844bd556 100644
--- a/cc/animation/scroll_offset_animation_curve.cc
+++ b/cc/animation/scroll_offset_animation_curve.cc
@@ -207,18 +207,6 @@ void ScrollOffsetAnimationCurve::UpdateTarget(
return;
}
- // The total_animation_duration_ is zero because of the delay that we
- // accounted for when the animation was created. The new duration should
- // also take the delay into account.
- if (total_animation_duration_.is_zero()) {
- DCHECK_LE(t, 0);
- total_animation_duration_ =
- SegmentDuration(new_target.DeltaFrom(initial_value_),
- duration_behavior_, base::TimeDelta::FromSecondsD(-t));
- target_value_ = new_target;
- return;
- }
-
base::TimeDelta delayed_by = base::TimeDelta::FromSecondsD(
std::max(0.0, last_retarget_.InSecondsF() - t));
t = std::max(t, last_retarget_.InSecondsF());
@@ -228,6 +216,15 @@ void ScrollOffsetAnimationCurve::UpdateTarget(
gfx::Vector2dF old_delta = target_value_.DeltaFrom(initial_value_);
gfx::Vector2dF new_delta = new_target.DeltaFrom(current_position);
+ // The last segement was of zero duration.
+ if ((total_animation_duration_ - last_retarget_).is_zero()) {
+ DCHECK_EQ(t, last_retarget_.InSecondsF());
+ total_animation_duration_ =
+ SegmentDuration(new_delta, duration_behavior_, delayed_by);
+ target_value_ = new_target;
+ return;
+ }
+
double old_duration =
(total_animation_duration_ - last_retarget_).InSecondsF();
double old_normalized_velocity = timing_function_->Velocity(
« no previous file with comments | « no previous file | cc/animation/scroll_offset_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698