1 // Copyright 2013 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 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
9 SyntheticSmoothScrollGesture::SyntheticSmoothScrollGesture(
10 const SyntheticSmoothScrollGestureParams
& params
)
14 SyntheticSmoothScrollGesture::~SyntheticSmoothScrollGesture() {
17 SyntheticGesture::Result
SyntheticSmoothScrollGesture::ForwardInputEvents(
18 const base::TimeTicks
& timestamp
,
19 SyntheticGestureTarget
* target
) {
21 if (!InitializeMoveGesture(params_
.gesture_source_type
, target
))
22 return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED
;
24 return move_gesture_
->ForwardInputEvents(timestamp
, target
);
27 SyntheticSmoothMoveGestureParams::InputType
28 SyntheticSmoothScrollGesture::GetInputSourceType(
29 SyntheticGestureParams::GestureSourceType gesture_source_type
) {
30 if (gesture_source_type
== SyntheticGestureParams::MOUSE_INPUT
)
31 return SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT
;
33 return SyntheticSmoothMoveGestureParams::TOUCH_INPUT
;
36 bool SyntheticSmoothScrollGesture::InitializeMoveGesture(
37 SyntheticGestureParams::GestureSourceType gesture_type
,
38 SyntheticGestureTarget
* target
) {
39 if (gesture_type
== SyntheticGestureParams::DEFAULT_INPUT
)
40 gesture_type
= target
->GetDefaultSyntheticGestureSourceType();
42 if (gesture_type
== SyntheticGestureParams::TOUCH_INPUT
||
43 gesture_type
== SyntheticGestureParams::MOUSE_INPUT
) {
44 SyntheticSmoothMoveGestureParams move_params
;
45 move_params
.start_point
= params_
.anchor
;
46 move_params
.distances
= params_
.distances
;
47 move_params
.speed_in_pixels_s
= params_
.speed_in_pixels_s
;
48 move_params
.prevent_fling
= params_
.prevent_fling
;
49 move_params
.input_type
= GetInputSourceType(gesture_type
);
50 move_params
.add_slop
= true;
51 move_gesture_
.reset(new SyntheticSmoothMoveGesture(move_params
));
57 } // namespace content