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

Unified 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: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/touch_emulator.h
diff --git a/content/browser/renderer_host/input/touch_emulator.h b/content/browser/renderer_host/input/touch_emulator.h
new file mode 100644
index 0000000000000000000000000000000000000000..2f19db7027af6b1261e5c610d7b774e0417d5971
--- /dev/null
+++ b/content/browser/renderer_host/input/touch_emulator.h
@@ -0,0 +1,86 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_
+
+#include "content/common/content_export.h"
+#include "content/common/cursors/webcursor.h"
+#include "content/port/common/input_event_ack_state.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "ui/events/gesture_detection/filtered_gesture_provider.h"
+
+namespace content {
+struct NativeWebKeyboardEvent;
+class RenderWidgetHostImpl;
+
+// Emulates touch input with mouse and keyboard.
+class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient {
+ public:
+ explicit TouchEmulator(RenderWidgetHostImpl* host);
jdduke (slow) 2014/04/04 16:21:11 Other than the cursor creation and the RenderWidge
dgozman 2014/04/07 16:54:55 Done.
+ virtual ~TouchEmulator();
+
+ // Returns |true| if the event was consumed.
+ // TODO(dgozman): maybe pass latency info together with events.
jdduke (slow) 2014/04/04 16:11:28 A new LatencyInfo will be generated for the touch,
+ bool HandleMouseEvent(const blink::WebMouseEvent& event);
+ bool HandleMouseWheelEvent(const blink::WebMouseWheelEvent& event);
+ bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+
+ // Returns |true| if the event ack was consumed.
jdduke (slow) 2014/04/04 16:11:28 Also note here that the consumed ack should not pr
dgozman 2014/04/07 16:54:55 Done.
+ bool HandleTouchEventAck(InputEventAckState ack_result);
+
+ // Cancel any touches, for example, when focus is lost.
+ void CancelTouch();
+
+ private:
+ // ui::GestureProviderClient implementation.
+ virtual void OnGestureEvent(const ui::GestureEventData& gesture) OVERRIDE;
+
+ void InitCursorFromResource(WebCursor* cursor, int resource_id);
+ void UpdateCursor();
+ bool UpdateShiftPressed(bool shift_pressed);
+
+ // Whether we should convert scroll into pinches.
jdduke (slow) 2014/04/04 16:11:28 scroll -> scrolls
dgozman 2014/04/07 16:54:55 Done.
+ bool InPinchGestureMode() const;
+
+ bool FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event);
+ void FillPinchEvent(const blink::WebInputEvent& event);
+
+ // The following methods generate and pass gesture events to the renderer.
+ void PinchBegin(const blink::WebGestureEvent& event);
+ void PinchUpdate(const blink::WebGestureEvent& event);
+ void PinchEnd(const blink::WebGestureEvent& event);
+ void ScrollEnd(const blink::WebGestureEvent& event);
+
+ RenderWidgetHostImpl* const host_;
+ ui::FilteredGestureProvider gesture_provider_;
+
+ // While emulation is on, default cursor is touch. Pressing shift changes
+ // cursor to the pinch one.
+ WebCursor touch_cursor_;
+ WebCursor pinch_cursor_;
+
+ bool mouse_pressed_;
+ bool shift_pressed_;
+
+ blink::WebTouchEvent touch_event_;
+ bool touch_active_;
+
+ // Whether scroll gesture has started but not yet finished. We should
+ // manually finish scroll when emulation is turned off.
+ bool scroll_gesture_active_;
+
+ blink::WebGestureEvent pinch_event_;
+ // Point which does not move while pinch-zooming.
+ gfx::Point pinch_anchor_;
+ // The cumulative scale change from the start of pinch gesture.
+ float pinch_scale_;
+ bool pinch_gesture_active_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchEmulator);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_

Powered by Google App Engine
This is Rietveld 408576698