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

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

Issue 138163016: [DevTools] Touch emulation in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Most review comments addressed Created 6 years, 8 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
OLDNEW
(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/browser/renderer_host/input/touch_emulator_client.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
16 // Emulates touch input with mouse and keyboard.
17 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient {
18 public:
19 explicit TouchEmulator(TouchEmulatorClient* client);
20 TouchEmulator(TouchEmulatorClient* client,
21 ui::GestureProvider::Config gesture_config);
22 virtual ~TouchEmulator();
23
24 // Returns |true| if the event was consumed.
25 // TODO(dgozman): maybe pass latency info together with events.
26 bool HandleMouseEvent(const blink::WebMouseEvent& event);
27 bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event);
28 bool HandleKeyboardEvent(const blink::WebKeyboardEvent& event);
29
30 // Returns |true| if the event ack was consumed. Consumed ack should not
31 // propagate any further.
32 bool HandleTouchEventAck(InputEventAckState ack_result);
33
34 // Cancel any touches, for example, when focus is lost.
35 void CancelTouch();
36
37 private:
38 // ui::GestureProviderClient implementation.
39 virtual void OnGestureEvent(const ui::GestureEventData& gesture) OVERRIDE;
40
41 void Init();
42 void InitCursorFromResource(WebCursor* cursor, int resource_id);
43 void UpdateCursor();
44 bool UpdateShiftPressed(bool shift_pressed);
45
46 // Whether we should convert scrolls into pinches.
47 bool InPinchGestureMode() const;
48
49 bool FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event);
50 void FillPinchEvent(const blink::WebInputEvent& event);
51
52 // The following methods generate and pass gesture events to the renderer.
53 void PinchBegin(const blink::WebGestureEvent& event);
54 void PinchUpdate(const blink::WebGestureEvent& event);
55 void PinchEnd(const blink::WebGestureEvent& event);
56 void ScrollEnd(const blink::WebGestureEvent& event);
57
58 TouchEmulatorClient* const client_;
59 ui::FilteredGestureProvider gesture_provider_;
60
61 // While emulation is on, default cursor is touch. Pressing shift changes
62 // cursor to the pinch one.
63 WebCursor touch_cursor_;
64 WebCursor pinch_cursor_;
65
66 bool mouse_pressed_;
67 bool shift_pressed_;
68
69 blink::WebTouchEvent touch_event_;
70 bool touch_active_;
71
72 // Whether scroll gesture has started but not yet finished. We should
73 // manually finish scroll when emulation is turned off.
74 bool scroll_gesture_active_;
75
76 // Whether fling start was suppressed while in a pinch mode.
77 bool fling_start_suppressed_;
78
79 blink::WebGestureEvent pinch_event_;
80 // Point which does not move while pinch-zooming.
81 gfx::Point pinch_anchor_;
82 // The cumulative scale change from the start of pinch gesture.
83 float pinch_scale_;
84 bool pinch_gesture_active_;
85
86 DISALLOW_COPY_AND_ASSIGN(TouchEmulator);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698