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_pointer_gesture.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
9 #include "ui/events/latency_info.h" | |
10 | |
11 namespace content { | |
12 | |
13 SyntheticPointerGesture::SyntheticPointerGesture( | |
14 SyntheticGestureParams::GestureSourceType gesture_source_type, | |
15 PointerActionType pointer_action_type, | |
16 SyntheticPointer* synthetic_pointer, | |
17 gfx::PointF position, | |
18 int index) | |
19 : gesture_source_type_(gesture_source_type), | |
20 pointer_action_type_(pointer_action_type), | |
21 position_(position), | |
22 index_(index), | |
23 synthetic_pointer_(synthetic_pointer) {} | |
24 | |
25 SyntheticPointerGesture::~SyntheticPointerGesture() {} | |
26 | |
27 SyntheticGesture::Result SyntheticPointerGesture::ForwardInputEvents( | |
28 const base::TimeTicks& timestamp, | |
29 SyntheticGestureTarget* target) { | |
30 if (gesture_source_type_ == SyntheticGestureParams::DEFAULT_INPUT) | |
31 gesture_source_type_ = target->GetDefaultSyntheticGestureSourceType(); | |
32 | |
33 DCHECK_NE(gesture_source_type_, SyntheticGestureParams::DEFAULT_INPUT); | |
34 | |
35 ForwardTouchOrMouseInputEvents(timestamp, target); | |
36 return SyntheticGesture::GESTURE_FINISHED; | |
37 } | |
38 | |
39 void SyntheticPointerGesture::ForwardTouchOrMouseInputEvents( | |
40 const base::TimeTicks& timestamp, | |
41 SyntheticGestureTarget* target) { | |
42 switch (pointer_action_type_) { | |
43 case SyntheticGesture::PRESS: | |
44 synthetic_pointer_->Press(position_.x(), position_.y(), target, | |
45 timestamp); | |
46 break; | |
47 case SyntheticGesture::MOVE: | |
48 synthetic_pointer_->Move(index_, position_.x(), position_.y(), target, | |
49 timestamp); | |
50 break; | |
51 case SyntheticGesture::RELEASE: | |
52 synthetic_pointer_->Release(index_, target, timestamp); | |
53 break; | |
54 } | |
55 synthetic_pointer_->DispatchEvent(target, timestamp); | |
56 } | |
57 | |
58 } // namespace content | |
OLD | NEW |