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

Side by Side Diff: ui/gfx/android/scroller.cc

Issue 136173004: Early terminate flings when scrolling impossible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/test/web_gesture_curve_mock.cc ('k') | ui/gfx/android/scroller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/android/scroller.h" 5 #include "ui/gfx/android/scroller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 10
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 final_y_ = start_y + total_distance * coeff_y; 269 final_y_ = start_y + total_distance * coeff_y;
270 final_y_ = Clamped(final_y_, min_y_, max_y_); 270 final_y_ = Clamped(final_y_, min_y_, max_y_);
271 271
272 RecomputeDeltas(); 272 RecomputeDeltas();
273 } 273 }
274 274
275 bool Scroller::ComputeScrollOffset(base::TimeTicks time) { 275 bool Scroller::ComputeScrollOffset(base::TimeTicks time) {
276 if (finished_) 276 if (finished_)
277 return false; 277 return false;
278 278
279 if (time == curr_time_)
280 return true;
281
279 base::TimeDelta time_passed = time - start_time_; 282 base::TimeDelta time_passed = time - start_time_;
280 283
281 if (time_passed < base::TimeDelta()) { 284 if (time_passed < base::TimeDelta()) {
282 time_passed = base::TimeDelta(); 285 time_passed = base::TimeDelta();
283 } 286 }
284 287
285 if (time_passed >= duration_) { 288 if (time_passed >= duration_) {
286 curr_x_ = final_x_; 289 curr_x_ = final_x_;
287 curr_y_ = final_y_; 290 curr_y_ = final_y_;
288 curr_time_ = start_time_ + duration_; 291 curr_time_ = start_time_ + duration_;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 430 }
428 431
429 double Scroller::GetSplineFlingDistance(float velocity) const { 432 double Scroller::GetSplineFlingDistance(float velocity) const {
430 const double l = GetSplineDeceleration(velocity); 433 const double l = GetSplineDeceleration(velocity);
431 const double decel_minus_one = kDecelerationRate - 1.0; 434 const double decel_minus_one = kDecelerationRate - 1.0;
432 return fling_friction_ * tuning_coeff_ * 435 return fling_friction_ * tuning_coeff_ *
433 std::exp(kDecelerationRate / decel_minus_one * l); 436 std::exp(kDecelerationRate / decel_minus_one * l);
434 } 437 }
435 438
436 } // namespace gfx 439 } // namespace gfx
OLDNEW
« no previous file with comments | « content/test/web_gesture_curve_mock.cc ('k') | ui/gfx/android/scroller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698