Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Side by Side Diff: content/browser/renderer_host/input/touch_emulator.h

Issue 474213002: DevTools: control touch emulation from the browser side only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment addressed. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 virtual ~TouchEmulator();
22 22
23 void Enable(bool allow_pinch); 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);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void ScrollEnd(const blink::WebGestureEvent& event); 67 void ScrollEnd(const blink::WebGestureEvent& event);
68 68
69 void ForwardTouchEventToClient(); 69 void ForwardTouchEventToClient();
70 70
71 TouchEmulatorClient* const client_; 71 TouchEmulatorClient* const client_;
72 ui::FilteredGestureProvider gesture_provider_; 72 ui::FilteredGestureProvider gesture_provider_;
73 73
74 // Disabled emulator does only process touch acks left from previous 74 // Disabled emulator does only process touch acks left from previous
75 // emulation. It does not intercept any events. 75 // emulation. It does not intercept any events.
76 bool enabled_; 76 bool enabled_;
77 bool allow_pinch_;
78 77
79 // While emulation is on, default cursor is touch. Pressing shift changes 78 // While emulation is on, default cursor is touch. Pressing shift changes
80 // cursor to the pinch one. 79 // cursor to the pinch one.
81 WebCursor pointer_cursor_; 80 WebCursor pointer_cursor_;
82 WebCursor touch_cursor_; 81 WebCursor touch_cursor_;
83 WebCursor pinch_cursor_; 82 WebCursor pinch_cursor_;
84 gfx::SizeF cursor_size_; 83 gfx::SizeF cursor_size_;
85 84
86 // These are used to drop extra mouse move events coming too quickly, so 85 // These are used to drop extra mouse move events coming too quickly, so
87 // we don't handle too much touches in gesture provider. 86 // we don't handle too much touches in gesture provider.
(...skipping 17 matching lines...) Expand all
105 // The cumulative scale change from the start of pinch gesture. 104 // The cumulative scale change from the start of pinch gesture.
106 float pinch_scale_; 105 float pinch_scale_;
107 bool pinch_gesture_active_; 106 bool pinch_gesture_active_;
108 107
109 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); 108 DISALLOW_COPY_AND_ASSIGN(TouchEmulator);
110 }; 109 };
111 110
112 } // namespace content 111 } // namespace content
113 112
114 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ 113 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_
OLDNEW
« no previous file with comments | « content/browser/devtools/renderer_overrides_handler.cc ('k') | content/browser/renderer_host/input/touch_emulator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698