OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | |
7 | |
8 #include "content/common/content_export.h" | |
9 #include "content/common/cursors/webcursor.h" | |
10 #include "content/port/common/input_event_ack_state.h" | |
11 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
12 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | |
13 | |
14 namespace content { | |
15 struct NativeWebKeyboardEvent; | |
16 class RenderWidgetHostImpl; | |
17 | |
18 // Emulates touch input with mouse and keyboard. | |
19 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient { | |
20 public: | |
21 explicit TouchEmulator(RenderWidgetHostImpl* host); | |
jdduke (slow)
2014/04/04 16:21:11
Other than the cursor creation and the RenderWidge
dgozman
2014/04/07 16:54:55
Done.
| |
22 virtual ~TouchEmulator(); | |
23 | |
24 // Returns |true| if the event was consumed. | |
25 // TODO(dgozman): maybe pass latency info together with events. | |
jdduke (slow)
2014/04/04 16:11:28
A new LatencyInfo will be generated for the touch,
| |
26 bool HandleMouseEvent(const blink::WebMouseEvent& event); | |
27 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); | |
28 bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | |
29 | |
30 // Returns |true| if the event ack was consumed. | |
jdduke (slow)
2014/04/04 16:11:28
Also note here that the consumed ack should not pr
dgozman
2014/04/07 16:54:55
Done.
| |
31 bool HandleTouchEventAck(InputEventAckState ack_result); | |
32 | |
33 // Cancel any touches, for example, when focus is lost. | |
34 void CancelTouch(); | |
35 | |
36 private: | |
37 // ui::GestureProviderClient implementation. | |
38 virtual void OnGestureEvent(const ui::GestureEventData& gesture) OVERRIDE; | |
39 | |
40 void InitCursorFromResource(WebCursor* cursor, int resource_id); | |
41 void UpdateCursor(); | |
42 bool UpdateShiftPressed(bool shift_pressed); | |
43 | |
44 // Whether we should convert scroll into pinches. | |
jdduke (slow)
2014/04/04 16:11:28
scroll -> scrolls
dgozman
2014/04/07 16:54:55
Done.
| |
45 bool InPinchGestureMode() const; | |
46 | |
47 bool FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event); | |
48 void FillPinchEvent(const blink::WebInputEvent& event); | |
49 | |
50 // The following methods generate and pass gesture events to the renderer. | |
51 void PinchBegin(const blink::WebGestureEvent& event); | |
52 void PinchUpdate(const blink::WebGestureEvent& event); | |
53 void PinchEnd(const blink::WebGestureEvent& event); | |
54 void ScrollEnd(const blink::WebGestureEvent& event); | |
55 | |
56 RenderWidgetHostImpl* const host_; | |
57 ui::FilteredGestureProvider gesture_provider_; | |
58 | |
59 // While emulation is on, default cursor is touch. Pressing shift changes | |
60 // cursor to the pinch one. | |
61 WebCursor touch_cursor_; | |
62 WebCursor pinch_cursor_; | |
63 | |
64 bool mouse_pressed_; | |
65 bool shift_pressed_; | |
66 | |
67 blink::WebTouchEvent touch_event_; | |
68 bool touch_active_; | |
69 | |
70 // Whether scroll gesture has started but not yet finished. We should | |
71 // manually finish scroll when emulation is turned off. | |
72 bool scroll_gesture_active_; | |
73 | |
74 blink::WebGestureEvent pinch_event_; | |
75 // Point which does not move while pinch-zooming. | |
76 gfx::Point pinch_anchor_; | |
77 // The cumulative scale change from the start of pinch gesture. | |
78 float pinch_scale_; | |
79 bool pinch_gesture_active_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); | |
82 }; | |
83 | |
84 } // namespace content | |
85 | |
86 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | |
OLD | NEW |