1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WEBKIT_GLUE_TOUCH_FLING_PLATFORM_GESTURE_CURVE_H_
6 #define WEBKIT_GLUE_TOUCH_FLING_PLATFORM_GESTURE_CURVE_H_
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGestureCurve.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
11 #include "webkit/glue/webkit_glue_export.h"
14 class WebGestureCurveTarget
;
17 namespace webkit_glue
{
19 // Implementation of WebGestureCurve suitable for touch pad/screen-based
20 // fling scroll. Starts with a flat velocity profile based on 'velocity', which
21 // tails off to zero. Time is scaled to that duration of the fling is
22 // proportional to the initial velocity.
23 class TouchFlingGestureCurve
: public WebKit::WebGestureCurve
{
25 static WebGestureCurve
* CreateForTouchPad(
26 const WebKit::WebFloatPoint
& velocity
,
27 const WebKit::WebSize
& cumulativeScroll
);
28 static WebGestureCurve
* CreateForTouchScreen(
29 const WebKit::WebFloatPoint
& velocity
,
30 const WebKit::WebSize
& cumulativeScroll
);
31 WEBKIT_GLUE_EXPORT
static WebGestureCurve
* Create(
32 const WebKit::WebFloatPoint
& initial_velocity
,
33 float p0
, float p1
, float p2
,
35 const WebKit::WebSize
& cumulativeScroll
);
37 virtual bool apply(double monotonicTime
,
38 WebKit::WebGestureCurveTarget
*) OVERRIDE
;
41 TouchFlingGestureCurve(const WebKit::WebFloatPoint
& initial_velocity
,
46 const WebKit::WebSize
& cumulativeScroll
);
47 virtual ~TouchFlingGestureCurve();
49 WebKit::WebFloatPoint displacement_ratio_
;
50 WebKit::WebSize cumulative_scroll_
;
51 float coefficients_
[3];
53 float curve_duration_
;
54 float position_offset_
;
56 DISALLOW_COPY_AND_ASSIGN(TouchFlingGestureCurve
);
59 } // namespace webkit_glue
61 #endif // WEBKIT_GLUE_TOUCH_FLING_PLATFORM_GESTURE_CURVE_H_