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" |
11 #include "third_party/WebKit/public/web/WebInputEvent.h" | 11 #include "third_party/WebKit/public/web/WebInputEvent.h" |
12 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | 12 #include "ui/events/gesture_detection/filtered_gesture_provider.h" |
13 #include "ui/gfx/size_f.h" | 13 #include "ui/gfx/size_f.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 // Emulates touch input with mouse and keyboard. | 17 // Emulates touch input with mouse and keyboard. |
18 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient { | 18 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient { |
19 public: | 19 public: |
20 explicit TouchEmulator(TouchEmulatorClient* client); | 20 explicit TouchEmulator(TouchEmulatorClient* client); |
21 virtual ~TouchEmulator(); | 21 ~TouchEmulator() override; |
22 | 22 |
23 void Enable(); | 23 void Enable(); |
24 void Disable(); | 24 void Disable(); |
25 | 25 |
26 // Note that TouchEmulator should always listen to touch events and their acks | 26 // Note that TouchEmulator should always listen to touch events and their acks |
27 // (even in disabled state) to track native stream presence. | 27 // (even in disabled state) to track native stream presence. |
28 bool enabled() const { return enabled_; } | 28 bool enabled() const { return enabled_; } |
29 | 29 |
30 // Returns |true| if the event was consumed. Consumed event should not | 30 // Returns |true| if the event was consumed. Consumed event should not |
31 // propagate any further. | 31 // propagate any further. |
32 // TODO(dgozman): maybe pass latency info together with events. | 32 // TODO(dgozman): maybe pass latency info together with events. |
33 bool HandleMouseEvent(const blink::WebMouseEvent& event); | 33 bool HandleMouseEvent(const blink::WebMouseEvent& event); |
34 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); | 34 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); |
35 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event); | 35 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event); |
36 bool HandleTouchEvent(const blink::WebTouchEvent& event); | 36 bool HandleTouchEvent(const blink::WebTouchEvent& event); |
37 | 37 |
38 // Returns |true| if the event ack was consumed. Consumed ack should not | 38 // Returns |true| if the event ack was consumed. Consumed ack should not |
39 // propagate any further. | 39 // propagate any further. |
40 bool HandleTouchEventAck(const blink::WebTouchEvent& event, | 40 bool HandleTouchEventAck(const blink::WebTouchEvent& event, |
41 InputEventAckState ack_result); | 41 InputEventAckState ack_result); |
42 | 42 |
43 // Cancel any touches, for example, when focus is lost. | 43 // Cancel any touches, for example, when focus is lost. |
44 void CancelTouch(); | 44 void CancelTouch(); |
45 | 45 |
46 private: | 46 private: |
47 // ui::GestureProviderClient implementation. | 47 // ui::GestureProviderClient implementation. |
48 virtual void OnGestureEvent(const ui::GestureEventData& gesture) override; | 48 void OnGestureEvent(const ui::GestureEventData& gesture) override; |
49 | 49 |
50 // Returns cursor size in DIP. | 50 // Returns cursor size in DIP. |
51 gfx::SizeF InitCursorFromResource( | 51 gfx::SizeF InitCursorFromResource( |
52 WebCursor* cursor, float scale, int resource_id); | 52 WebCursor* cursor, float scale, int resource_id); |
53 void ResetState(); | 53 void ResetState(); |
54 void UpdateCursor(); | 54 void UpdateCursor(); |
55 bool UpdateShiftPressed(bool shift_pressed); | 55 bool UpdateShiftPressed(bool shift_pressed); |
56 | 56 |
57 // Whether we should convert scrolls into pinches. | 57 // Whether we should convert scrolls into pinches. |
58 bool InPinchGestureMode() const; | 58 bool InPinchGestureMode() const; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // The cumulative scale change from the start of pinch gesture. | 104 // The cumulative scale change from the start of pinch gesture. |
105 float pinch_scale_; | 105 float pinch_scale_; |
106 bool pinch_gesture_active_; | 106 bool pinch_gesture_active_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); | 108 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace content | 111 } // namespace content |
112 | 112 |
113 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | 113 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ |
OLD | NEW |