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 : drag_state_(SETUP), params_(params) { |
| 12 } |
| 13 |
| 14 SyntheticSmoothDragGesture::~SyntheticSmoothDragGesture() { |
| 15 } |
| 16 |
| 17 SyntheticGesture::Result SyntheticSmoothDragGesture::ForwardInputEvents( |
| 18 const base::TimeTicks& timestamp, |
| 19 SyntheticGestureTarget* target) { |
| 20 if (drag_state_ == SETUP) { |
| 21 SyntheticGestureParams::GestureSourceType gesture_type = |
| 22 params_.gesture_source_type; |
| 23 if (gesture_type == SyntheticGestureParams::DEFAULT_INPUT) |
| 24 gesture_type = target->GetDefaultSyntheticGestureSourceType(); |
| 25 |
| 26 if (gesture_type == SyntheticGestureParams::TOUCH_INPUT || |
| 27 gesture_type == SyntheticGestureParams::MOUSE_INPUT) |
| 28 move_gesture_ = new SyntheticSmoothMoveGesture( |
| 29 GetInputSourceType(gesture_type), params_.start_point, |
| 30 params_.distances, params_.speed_in_pixels_s, true); |
| 31 else |
| 32 return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED; |
| 33 |
| 34 drag_state_ = FORWARD; |
| 35 } |
| 36 return move_gesture_->ForwardInputEvents(timestamp, target); |
| 37 } |
| 38 |
| 39 SyntheticSmoothMoveGesture::InputType |
| 40 SyntheticSmoothDragGesture::GetInputSourceType( |
| 41 SyntheticGestureParams::GestureSourceType gesture_source_type) { |
| 42 if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT) |
| 43 return SyntheticSmoothMoveGesture::MOUSE_CLICK; |
| 44 else |
| 45 return SyntheticSmoothMoveGesture::TOUCH_INPUT; |
| 46 } |
| 47 |
| 48 } // namespace content |
OLD | NEW |