| 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/events/gesture_detection/gesture_provider_config_helper.h" | 13 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 14 #include "ui/gfx/geometry/size_f.h" | 14 #include "ui/gfx/geometry/size_f.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // Emulates touch input with mouse and keyboard. | 18 // Emulates touch input with mouse and keyboard. |
| 19 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient { | 19 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient { |
| 20 public: | 20 public: |
| 21 explicit TouchEmulator(TouchEmulatorClient* client); | 21 explicit TouchEmulator(TouchEmulatorClient* client); |
| 22 ~TouchEmulator() override; | 22 ~TouchEmulator() override; |
| 23 | 23 |
| 24 void Enable(ui::GestureProviderConfigType config_type); | 24 void Enable(ui::GestureProviderConfigType config_type); |
| 25 void Disable(); | 25 void Disable(); |
| 26 | 26 |
| 27 // See GestureProvider::SetDoubleTapSupportForPageEnabled. |
| 28 void SetDoubleTapSupportForPageEnabled(bool enabled); |
| 29 |
| 27 // Note that TouchEmulator should always listen to touch events and their acks | 30 // Note that TouchEmulator should always listen to touch events and their acks |
| 28 // (even in disabled state) to track native stream presence. | 31 // (even in disabled state) to track native stream presence. |
| 29 bool enabled() const { return gesture_provider_; } | 32 bool enabled() const { return gesture_provider_; } |
| 30 | 33 |
| 31 // Returns |true| if the event was consumed. Consumed event should not | 34 // Returns |true| if the event was consumed. Consumed event should not |
| 32 // propagate any further. | 35 // propagate any further. |
| 33 // TODO(dgozman): maybe pass latency info together with events. | 36 // TODO(dgozman): maybe pass latency info together with events. |
| 34 bool HandleMouseEvent(const blink::WebMouseEvent& event); | 37 bool HandleMouseEvent(const blink::WebMouseEvent& event); |
| 35 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); | 38 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event); |
| 36 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event); | 39 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // it to the client if appropriate. | 74 // it to the client if appropriate. |
| 72 void HandleEmulatedTouchEvent(blink::WebTouchEvent event); | 75 void HandleEmulatedTouchEvent(blink::WebTouchEvent event); |
| 73 | 76 |
| 74 TouchEmulatorClient* const client_; | 77 TouchEmulatorClient* const client_; |
| 75 | 78 |
| 76 // Emulator is enabled iff gesture provider is created. | 79 // Emulator is enabled iff gesture provider is created. |
| 77 // Disabled emulator does only process touch acks left from previous | 80 // Disabled emulator does only process touch acks left from previous |
| 78 // emulation. It does not intercept any events. | 81 // emulation. It does not intercept any events. |
| 79 scoped_ptr<ui::FilteredGestureProvider> gesture_provider_; | 82 scoped_ptr<ui::FilteredGestureProvider> gesture_provider_; |
| 80 ui::GestureProviderConfigType gesture_provider_config_type_; | 83 ui::GestureProviderConfigType gesture_provider_config_type_; |
| 84 bool double_tap_enabled_; |
| 81 | 85 |
| 82 // While emulation is on, default cursor is touch. Pressing shift changes | 86 // While emulation is on, default cursor is touch. Pressing shift changes |
| 83 // cursor to the pinch one. | 87 // cursor to the pinch one. |
| 84 WebCursor pointer_cursor_; | 88 WebCursor pointer_cursor_; |
| 85 WebCursor touch_cursor_; | 89 WebCursor touch_cursor_; |
| 86 WebCursor pinch_cursor_; | 90 WebCursor pinch_cursor_; |
| 87 gfx::SizeF cursor_size_; | 91 gfx::SizeF cursor_size_; |
| 88 | 92 |
| 89 // These are used to drop extra mouse move events coming too quickly, so | 93 // These are used to drop extra mouse move events coming too quickly, so |
| 90 // we don't handle too much touches in gesture provider. | 94 // we don't handle too much touches in gesture provider. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 // The cumulative scale change from the start of pinch gesture. | 112 // The cumulative scale change from the start of pinch gesture. |
| 109 float pinch_scale_; | 113 float pinch_scale_; |
| 110 bool pinch_gesture_active_; | 114 bool pinch_gesture_active_; |
| 111 | 115 |
| 112 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); | 116 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); |
| 113 }; | 117 }; |
| 114 | 118 |
| 115 } // namespace content | 119 } // namespace content |
| 116 | 120 |
| 117 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ | 121 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ |
| OLD | NEW |