OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ |
7 | 7 |
8 #include "content/browser/renderer_host/input/touch_emulator_client.h" | 8 #include "content/browser/renderer_host/input/touch_emulator_client.h" |
9 #include "content/common/cursors/webcursor.h" | 9 #include "content/common/cursors/webcursor.h" |
10 #include "content/common/input/input_event_ack_state.h" | 10 #include "content/common/input/input_event_ack_state.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 virtual ~TouchEmulator(); | 21 virtual ~TouchEmulator(); |
22 | 22 |
23 void Enable(bool allow_pinch); | 23 void Enable(bool allow_pinch); |
24 void Disable(); | 24 void Disable(); |
25 | 25 |
26 // Returns |true| if the event was consumed. | 26 // Returns |true| if the event was consumed. |
27 // TODO(dgozman): maybe pass latency info together with events. | 27 // TODO(dgozman): maybe pass latency info together with events. |
28 bool HandleMouseEvent(const blink::WebMouseEvent& event); | 28 bool HandleMouseEvent(const blink::WebMouseEvent& event); |
29 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); | 29 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); |
30 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event); | 30 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event); |
| 31 bool HandleTouchEvent(const blink::WebTouchEvent& event); |
31 | 32 |
32 // Returns |true| if the event ack was consumed. Consumed ack should not | 33 // Returns |true| if the event ack was consumed. Consumed ack should not |
33 // propagate any further. | 34 // propagate any further. |
34 bool HandleTouchEventAck(InputEventAckState ack_result); | 35 bool HandleTouchEventAck(const blink::WebTouchEvent& event, |
| 36 InputEventAckState ack_result); |
35 | 37 |
36 // Cancel any touches, for example, when focus is lost. | 38 // Cancel any touches, for example, when focus is lost. |
37 void CancelTouch(); | 39 void CancelTouch(); |
38 | 40 |
39 private: | 41 private: |
40 // ui::GestureProviderClient implementation. | 42 // ui::GestureProviderClient implementation. |
41 virtual void OnGestureEvent(const ui::GestureEventData& gesture) OVERRIDE; | 43 virtual void OnGestureEvent(const ui::GestureEventData& gesture) OVERRIDE; |
42 | 44 |
43 // Returns cursor size in DIP. | 45 // Returns cursor size in DIP. |
44 gfx::SizeF InitCursorFromResource( | 46 gfx::SizeF InitCursorFromResource( |
45 WebCursor* cursor, float scale, int resource_id); | 47 WebCursor* cursor, float scale, int resource_id); |
46 void ResetState(); | 48 void ResetState(); |
47 void UpdateCursor(); | 49 void UpdateCursor(); |
48 bool UpdateShiftPressed(bool shift_pressed); | 50 bool UpdateShiftPressed(bool shift_pressed); |
49 | 51 |
50 // Whether we should convert scrolls into pinches. | 52 // Whether we should convert scrolls into pinches. |
51 bool InPinchGestureMode() const; | 53 bool InPinchGestureMode() const; |
52 | 54 |
53 bool FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event); | 55 bool FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event); |
54 void FillPinchEvent(const blink::WebInputEvent& event); | 56 void FillPinchEvent(const blink::WebInputEvent& event); |
55 | 57 |
56 // The following methods generate and pass gesture events to the renderer. | 58 // The following methods generate and pass gesture events to the renderer. |
57 void PinchBegin(const blink::WebGestureEvent& event); | 59 void PinchBegin(const blink::WebGestureEvent& event); |
58 void PinchUpdate(const blink::WebGestureEvent& event); | 60 void PinchUpdate(const blink::WebGestureEvent& event); |
59 void PinchEnd(const blink::WebGestureEvent& event); | 61 void PinchEnd(const blink::WebGestureEvent& event); |
60 void ScrollEnd(const blink::WebGestureEvent& event); | 62 void ScrollEnd(const blink::WebGestureEvent& event); |
61 | 63 |
| 64 void ForwardTouchEventToClient(); |
| 65 |
62 TouchEmulatorClient* const client_; | 66 TouchEmulatorClient* const client_; |
63 ui::FilteredGestureProvider gesture_provider_; | 67 ui::FilteredGestureProvider gesture_provider_; |
64 | 68 |
65 // Disabled emulator does only process touch acks left from previous | 69 // Disabled emulator does only process touch acks left from previous |
66 // emulation. It does not intercept any events. | 70 // emulation. It does not intercept any events. |
67 bool enabled_; | 71 bool enabled_; |
68 bool allow_pinch_; | 72 bool allow_pinch_; |
69 | 73 |
70 // While emulation is on, default cursor is touch. Pressing shift changes | 74 // While emulation is on, default cursor is touch. Pressing shift changes |
71 // cursor to the pinch one. | 75 // cursor to the pinch one. |
72 WebCursor pointer_cursor_; | 76 WebCursor pointer_cursor_; |
73 WebCursor touch_cursor_; | 77 WebCursor touch_cursor_; |
74 WebCursor pinch_cursor_; | 78 WebCursor pinch_cursor_; |
75 gfx::SizeF cursor_size_; | 79 gfx::SizeF cursor_size_; |
76 | 80 |
77 // These are used to drop extra mouse move events coming too quickly, so | 81 // These are used to drop extra mouse move events coming too quickly, so |
78 // we don't handle too much touches in gesture provider. | 82 // we don't handle too much touches in gesture provider. |
79 bool last_mouse_event_was_move_; | 83 bool last_mouse_event_was_move_; |
80 double last_mouse_move_timestamp_; | 84 double last_mouse_move_timestamp_; |
81 | 85 |
82 bool mouse_pressed_; | 86 bool mouse_pressed_; |
83 bool shift_pressed_; | 87 bool shift_pressed_; |
84 | 88 |
85 blink::WebTouchEvent touch_event_; | 89 blink::WebTouchEvent touch_event_; |
86 bool touch_active_; | 90 int emulated_stream_active_sequence_count_; |
| 91 int native_stream_active_sequence_count_; |
87 | 92 |
88 // Whether we should suppress next fling cancel. This may happen when we | 93 // Whether we should suppress next fling cancel. This may happen when we |
89 // did not send fling start in pinch mode. | 94 // did not send fling start in pinch mode. |
90 bool suppress_next_fling_cancel_; | 95 bool suppress_next_fling_cancel_; |
91 | 96 |
92 blink::WebGestureEvent pinch_event_; | 97 blink::WebGestureEvent pinch_event_; |
93 // Point which does not move while pinch-zooming. | 98 // Point which does not move while pinch-zooming. |
94 gfx::Point pinch_anchor_; | 99 gfx::Point pinch_anchor_; |
95 // The cumulative scale change from the start of pinch gesture. | 100 // The cumulative scale change from the start of pinch gesture. |
96 float pinch_scale_; | 101 float pinch_scale_; |
97 bool pinch_gesture_active_; | 102 bool pinch_gesture_active_; |
98 | 103 |
99 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); | 104 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); |
100 }; | 105 }; |
101 | 106 |
102 } // namespace content | 107 } // namespace content |
103 | 108 |
104 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | 109 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ |
OLD | NEW |