OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" | 5 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/web/WebInputEvent.h" |
9 #include "ui/events/latency_info.h" | 9 #include "ui/events/latency_info.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 SyntheticPointerAction::SyntheticPointerAction( | 13 SyntheticPointerAction::SyntheticPointerAction( |
14 SyntheticGestureParams::GestureSourceType gesture_source_type, | 14 const SyntheticPointerActionParams& params) |
15 PointerActionType pointer_action_type, | 15 : params_(params) {} |
16 SyntheticPointer* synthetic_pointer, | 16 |
17 gfx::PointF position, | 17 SyntheticPointerAction::SyntheticPointerAction( |
18 int index) | 18 const SyntheticPointerActionParams& params, |
19 : gesture_source_type_(gesture_source_type), | 19 SyntheticPointer* synthetic_pointer) |
20 pointer_action_type_(pointer_action_type), | 20 : params_(params), synthetic_pointer_(synthetic_pointer) {} |
21 position_(position), | |
22 index_(index), | |
23 synthetic_pointer_(synthetic_pointer) {} | |
24 | 21 |
25 SyntheticPointerAction::~SyntheticPointerAction() {} | 22 SyntheticPointerAction::~SyntheticPointerAction() {} |
26 | 23 |
27 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( | 24 SyntheticGesture::Result SyntheticPointerAction::ForwardInputEvents( |
28 const base::TimeTicks& timestamp, | 25 const base::TimeTicks& timestamp, |
29 SyntheticGestureTarget* target) { | 26 SyntheticGestureTarget* target) { |
30 if (gesture_source_type_ == SyntheticGestureParams::DEFAULT_INPUT) | 27 if (params_.gesture_source_type == SyntheticGestureParams::DEFAULT_INPUT) |
31 gesture_source_type_ = target->GetDefaultSyntheticGestureSourceType(); | 28 params_.gesture_source_type = |
| 29 target->GetDefaultSyntheticGestureSourceType(); |
32 | 30 |
33 DCHECK_NE(gesture_source_type_, SyntheticGestureParams::DEFAULT_INPUT); | 31 DCHECK_NE(params_.gesture_source_type, SyntheticGestureParams::DEFAULT_INPUT); |
34 | 32 |
35 ForwardTouchOrMouseInputEvents(timestamp, target); | 33 ForwardTouchOrMouseInputEvents(timestamp, target); |
36 return SyntheticGesture::GESTURE_FINISHED; | 34 return SyntheticGesture::GESTURE_FINISHED; |
37 } | 35 } |
38 | 36 |
39 void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( | 37 void SyntheticPointerAction::ForwardTouchOrMouseInputEvents( |
40 const base::TimeTicks& timestamp, | 38 const base::TimeTicks& timestamp, |
41 SyntheticGestureTarget* target) { | 39 SyntheticGestureTarget* target) { |
42 switch (pointer_action_type_) { | 40 switch (params_.pointer_action_type()) { |
43 case SyntheticGesture::PRESS: | 41 case SyntheticPointerActionParams::PointerActionType::PRESS: |
44 synthetic_pointer_->Press(position_.x(), position_.y(), target, | 42 synthetic_pointer_->Press(params_.position().x(), params_.position().y(), |
45 timestamp); | 43 target, timestamp); |
46 break; | 44 break; |
47 case SyntheticGesture::MOVE: | 45 case SyntheticPointerActionParams::PointerActionType::MOVE: |
48 synthetic_pointer_->Move(index_, position_.x(), position_.y(), target, | 46 synthetic_pointer_->Move(params_.index(), params_.position().x(), |
49 timestamp); | 47 params_.position().y(), target, timestamp); |
50 break; | 48 break; |
51 case SyntheticGesture::RELEASE: | 49 case SyntheticPointerActionParams::PointerActionType::RELEASE: |
52 synthetic_pointer_->Release(index_, target, timestamp); | 50 synthetic_pointer_->Release(params_.index(), target, timestamp); |
| 51 break; |
| 52 default: |
| 53 NOTREACHED(); |
53 break; | 54 break; |
54 } | 55 } |
55 synthetic_pointer_->DispatchEvent(target, timestamp); | 56 synthetic_pointer_->DispatchEvent(target, timestamp); |
56 } | 57 } |
57 | 58 |
58 } // namespace content | 59 } // namespace content |
OLD | NEW |