OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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. | |
4 | |
5 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h" | |
6 | |
7 namespace content { | |
8 | |
9 SyntheticSmoothDragGesture::SyntheticSmoothDragGesture( | |
10 const SyntheticSmoothDragGestureParams& params) | |
11 : params_(params) { | |
12 } | |
13 | |
14 SyntheticSmoothDragGesture::~SyntheticSmoothDragGesture() { | |
15 } | |
16 | |
17 SyntheticGesture::Result SyntheticSmoothDragGesture::ForwardInputEvents( | |
18 const base::TimeTicks& timestamp, | |
19 SyntheticGestureTarget* target) { | |
20 if (move_gesture_ == nullptr) { | |
Sami
2015/02/23 18:03:28
nit: !move_gesture_ would be more idiomatic.
ssid
2015/02/23 19:10:36
Done.
| |
21 if (!InitializeMoveGesture(params_.gesture_source_type, target)) | |
22 return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED; | |
23 } | |
24 return move_gesture_->ForwardInputEvents(timestamp, target); | |
25 } | |
26 | |
27 SyntheticSmoothMoveGestureParams::InputType | |
28 SyntheticSmoothDragGesture::GetInputSourceType( | |
29 SyntheticGestureParams::GestureSourceType gesture_source_type) { | |
30 if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT) | |
31 return SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT; | |
32 else | |
33 return SyntheticSmoothMoveGestureParams::TOUCH_INPUT; | |
34 } | |
35 | |
36 bool SyntheticSmoothDragGesture::InitializeMoveGesture( | |
37 SyntheticGestureParams::GestureSourceType gesture_type, | |
38 SyntheticGestureTarget* target) { | |
39 if (gesture_type == SyntheticGestureParams::DEFAULT_INPUT) | |
40 gesture_type = target->GetDefaultSyntheticGestureSourceType(); | |
41 | |
42 if (gesture_type == SyntheticGestureParams::TOUCH_INPUT || | |
43 gesture_type == SyntheticGestureParams::MOUSE_INPUT) { | |
44 SyntheticSmoothMoveGestureParams move_params(params_); | |
45 move_params.input_type = GetInputSourceType(gesture_type); | |
46 move_params.prevent_slop = true; | |
47 move_gesture_.reset(new SyntheticSmoothMoveGesture(move_params)); | |
48 return true; | |
49 } | |
50 return false; | |
51 } | |
52 | |
53 } // namespace content | |
OLD | NEW |