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

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

Issue 2551573002: [Touch emulator] Update cursor when device scale factor changes. (Closed)
Patch Set: other platforms Created 4 years 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_emulator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/browser/renderer_host/input/touch_emulator_client.h" 11 #include "content/browser/renderer_host/input/touch_emulator_client.h"
12 #include "content/common/cursors/webcursor.h" 12 #include "content/common/cursors/webcursor.h"
13 #include "content/common/input/input_event_ack_state.h" 13 #include "content/common/input/input_event_ack_state.h"
14 #include "third_party/WebKit/public/platform/WebInputEvent.h" 14 #include "third_party/WebKit/public/platform/WebInputEvent.h"
15 #include "ui/events/gesture_detection/filtered_gesture_provider.h" 15 #include "ui/events/gesture_detection/filtered_gesture_provider.h"
16 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" 16 #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
17 #include "ui/gfx/geometry/size_f.h" 17 #include "ui/gfx/geometry/size_f.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 // Emulates touch input with mouse and keyboard. 21 // Emulates touch input with mouse and keyboard.
22 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient { 22 class CONTENT_EXPORT TouchEmulator : public ui::GestureProviderClient {
23 public: 23 public:
24 TouchEmulator(TouchEmulatorClient* client, float device_scale_factor); 24 TouchEmulator(TouchEmulatorClient* client, float device_scale_factor);
25 ~TouchEmulator() override; 25 ~TouchEmulator() override;
26 26
27 void Enable(ui::GestureProviderConfigType config_type); 27 void Enable(ui::GestureProviderConfigType config_type);
28 void Disable(); 28 void Disable();
29 29
30 // Call when device scale factor changes.
31 void SetDeviceScaleFactor(float device_scale_factor);
32
30 // See GestureProvider::SetDoubleTapSupportForPageEnabled. 33 // See GestureProvider::SetDoubleTapSupportForPageEnabled.
31 void SetDoubleTapSupportForPageEnabled(bool enabled); 34 void SetDoubleTapSupportForPageEnabled(bool enabled);
32 35
33 // Note that TouchEmulator should always listen to touch events and their acks 36 // Note that TouchEmulator should always listen to touch events and their acks
34 // (even in disabled state) to track native stream presence. 37 // (even in disabled state) to track native stream presence.
35 bool enabled() const { return !!gesture_provider_; } 38 bool enabled() const { return !!gesture_provider_; }
36 39
37 // Returns |true| if the event was consumed. Consumed event should not 40 // Returns |true| if the event was consumed. Consumed event should not
38 // propagate any further. 41 // propagate any further.
39 // TODO(dgozman): maybe pass latency info together with events. 42 // TODO(dgozman): maybe pass latency info together with events.
(...skipping 10 matching lines...) Expand all
50 // Cancel any touches, for example, when focus is lost. 53 // Cancel any touches, for example, when focus is lost.
51 void CancelTouch(); 54 void CancelTouch();
52 55
53 private: 56 private:
54 // ui::GestureProviderClient implementation. 57 // ui::GestureProviderClient implementation.
55 void OnGestureEvent(const ui::GestureEventData& gesture) override; 58 void OnGestureEvent(const ui::GestureEventData& gesture) override;
56 59
57 // Returns cursor size in DIP. 60 // Returns cursor size in DIP.
58 gfx::SizeF InitCursorFromResource( 61 gfx::SizeF InitCursorFromResource(
59 WebCursor* cursor, float scale, int resource_id); 62 WebCursor* cursor, float scale, int resource_id);
63 bool InitCursors(float device_scale_factor, bool force);
60 void ResetState(); 64 void ResetState();
61 void UpdateCursor(); 65 void UpdateCursor();
62 bool UpdateShiftPressed(bool shift_pressed); 66 bool UpdateShiftPressed(bool shift_pressed);
63 67
64 // Whether we should convert scrolls into pinches. 68 // Whether we should convert scrolls into pinches.
65 bool InPinchGestureMode() const; 69 bool InPinchGestureMode() const;
66 70
67 void FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event); 71 void FillTouchEventAndPoint(const blink::WebMouseEvent& mouse_event);
68 void FillPinchEvent(const blink::WebInputEvent& event); 72 void FillPinchEvent(const blink::WebInputEvent& event);
69 73
(...skipping 11 matching lines...) Expand all
81 85
82 // Emulator is enabled iff gesture provider is created. 86 // Emulator is enabled iff gesture provider is created.
83 // Disabled emulator does only process touch acks left from previous 87 // Disabled emulator does only process touch acks left from previous
84 // emulation. It does not intercept any events. 88 // emulation. It does not intercept any events.
85 std::unique_ptr<ui::FilteredGestureProvider> gesture_provider_; 89 std::unique_ptr<ui::FilteredGestureProvider> gesture_provider_;
86 ui::GestureProviderConfigType gesture_provider_config_type_; 90 ui::GestureProviderConfigType gesture_provider_config_type_;
87 bool double_tap_enabled_; 91 bool double_tap_enabled_;
88 92
89 // While emulation is on, default cursor is touch. Pressing shift changes 93 // While emulation is on, default cursor is touch. Pressing shift changes
90 // cursor to the pinch one. 94 // cursor to the pinch one.
95 bool use_2x_cursors_;
tdresser 2016/12/05 16:55:01 Move up above comment?
dgozman 2016/12/05 18:56:32 Done.
91 WebCursor pointer_cursor_; 96 WebCursor pointer_cursor_;
92 WebCursor touch_cursor_; 97 WebCursor touch_cursor_;
93 WebCursor pinch_cursor_; 98 WebCursor pinch_cursor_;
94 gfx::SizeF cursor_size_; 99 gfx::SizeF cursor_size_;
95 100
96 // These are used to drop extra mouse move events coming too quickly, so 101 // These are used to drop extra mouse move events coming too quickly, so
97 // we don't handle too much touches in gesture provider. 102 // we don't handle too much touches in gesture provider.
98 bool last_mouse_event_was_move_; 103 bool last_mouse_event_was_move_;
99 double last_mouse_move_timestamp_; 104 double last_mouse_move_timestamp_;
100 105
(...skipping 14 matching lines...) Expand all
115 // The cumulative scale change from the start of pinch gesture. 120 // The cumulative scale change from the start of pinch gesture.
116 float pinch_scale_; 121 float pinch_scale_;
117 bool pinch_gesture_active_; 122 bool pinch_gesture_active_;
118 123
119 DISALLOW_COPY_AND_ASSIGN(TouchEmulator); 124 DISALLOW_COPY_AND_ASSIGN(TouchEmulator);
120 }; 125 };
121 126
122 } // namespace content 127 } // namespace content
123 128
124 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_ 129 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_EMULATOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_emulator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698