Chromium Code Reviews| Index: ui/events/gestures/blink/web_gesture_curve_impl.cc |
| diff --git a/ui/events/gestures/blink/web_gesture_curve_impl.cc b/ui/events/gestures/blink/web_gesture_curve_impl.cc |
| index 96cebee462f2c012b0d88505628f3b2c6e575e5b..9eda4ff69f1ea6dfd7c26acd515b6a19343bd16d 100644 |
| --- a/ui/events/gestures/blink/web_gesture_curve_impl.cc |
| +++ b/ui/events/gestures/blink/web_gesture_curve_impl.cc |
| @@ -42,6 +42,26 @@ scoped_ptr<GestureCurve> CreateDefaultPlatformCurve( |
| #endif |
| } |
| +scoped_ptr<GestureCurve> CreateSmoothScrollingCurve(float start_x, |
| + float start_y, |
| + float dx, |
| + float dy, |
| + base::TimeDelta duration) { |
| + DCHECK(duration > base::TimeDelta()); |
| +#if defined(OS_ANDROID) |
| + auto scroller = make_scoped_ptr(new Scroller(Scroller::Config())); |
| + base::TimeTicks start_time = base::TimeTicks(); |
| + |
| + scroller->StartScroll(start_x, start_y, dx, dy, start_time, duration); |
| + return scroller.Pass(); |
| +#else |
| + float vx = dx / duration.InSecondsF(); |
|
jdduke (slow)
2015/07/23 15:32:50
I'd almost rather we NOTREACHED() here and return
|
| + float vy = dy / duration.InSecondsF(); |
| + return make_scoped_ptr( |
| + new FlingCurve(gfx::Vector2dF(vx, vy), base::TimeTicks())); |
| +#endif |
| +} |
| + |
| } // namespace |
| // static |
| @@ -55,6 +75,20 @@ scoped_ptr<WebGestureCurve> WebGestureCurveImpl::CreateFromDefaultPlatformCurve( |
| } |
| // static |
| +scoped_ptr<WebGestureCurve> WebGestureCurveImpl::CreateFromSmoothScrollingCurve( |
| + float start_x, |
| + float start_y, |
| + float dx, |
| + float dy, |
| + base::TimeDelta duration, |
| + bool on_main_thread) { |
| + const gfx::Vector2dF initial_offset(start_x, start_y); |
| + return scoped_ptr<WebGestureCurve>(new WebGestureCurveImpl( |
| + CreateSmoothScrollingCurve(start_x, start_y, dx, dy, duration), |
| + initial_offset, on_main_thread ? ThreadType::MAIN : ThreadType::IMPL)); |
| +} |
| + |
| +// static |
| scoped_ptr<WebGestureCurve> WebGestureCurveImpl::CreateFromUICurveForTesting( |
| scoped_ptr<GestureCurve> curve, |
| const gfx::Vector2dF& initial_offset) { |