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

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

Issue 821223002: Pass gesture detector config type when enabling touch emulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@touch-emulator-enabled
Patch Set: Created 5 years, 12 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
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 #include "content/browser/renderer_host/input/touch_emulator.h" 5 #include "content/browser/renderer_host/input/touch_emulator.h"
6 6
7 #include "content/browser/renderer_host/input/motion_event_web.h" 7 #include "content/browser/renderer_host/input/motion_event_web.h"
8 #include "content/browser/renderer_host/input/web_input_event_util.h" 8 #include "content/browser/renderer_host/input/web_input_event_util.h"
9 #include "content/common/input/web_touch_event_traits.h" 9 #include "content/common/input/web_touch_event_traits.h"
10 #include "content/grit/content_resources.h" 10 #include "content/grit/content_resources.h"
11 #include "content/public/common/content_client.h" 11 #include "content/public/common/content_client.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 13 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
14 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" 14 #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
15 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
17 17
18 using blink::WebGestureEvent; 18 using blink::WebGestureEvent;
19 using blink::WebInputEvent; 19 using blink::WebInputEvent;
20 using blink::WebKeyboardEvent; 20 using blink::WebKeyboardEvent;
21 using blink::WebMouseEvent; 21 using blink::WebMouseEvent;
22 using blink::WebMouseWheelEvent; 22 using blink::WebMouseWheelEvent;
23 using blink::WebTouchEvent; 23 using blink::WebTouchEvent;
24 using blink::WebTouchPoint; 24 using blink::WebTouchPoint;
25 25
26 namespace content { 26 namespace content {
27 27
28 namespace { 28 namespace {
29 29
30 ui::GestureProvider::Config GetGestureProviderConfig() { 30 ui::GestureProvider::Config GetEmulatorGestureProviderConfig(
31 // TODO(dgozman): Use different configs to emulate mobile/desktop as 31 ui::GestureProviderConfigType config_type) {
32 // requested by renderer, crbug/425586. 32 ui::GestureProvider::Config config =
33 ui::GestureProvider::Config config = ui::GetGestureProviderConfig( 33 ui::GetGestureProviderConfig(config_type);
34 ui::GestureProviderConfigType::GENERIC_MOBILE);
35 config.gesture_begin_end_types_enabled = false; 34 config.gesture_begin_end_types_enabled = false;
36 config.gesture_detector_config.swipe_enabled = false; 35 config.gesture_detector_config.swipe_enabled = false;
37 config.gesture_detector_config.two_finger_tap_enabled = false; 36 config.gesture_detector_config.two_finger_tap_enabled = false;
38 return config; 37 return config;
39 } 38 }
40 39
41 // Time between two consecutive mouse moves, during which second mouse move 40 // Time between two consecutive mouse moves, during which second mouse move
42 // is not converted to touch. 41 // is not converted to touch.
43 const double kMouseMoveDropIntervalSeconds = 5.f / 1000; 42 const double kMouseMoveDropIntervalSeconds = 5.f / 1000;
44 43
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void TouchEmulator::ResetState() { 76 void TouchEmulator::ResetState() {
78 last_mouse_event_was_move_ = false; 77 last_mouse_event_was_move_ = false;
79 last_mouse_move_timestamp_ = 0; 78 last_mouse_move_timestamp_ = 0;
80 mouse_pressed_ = false; 79 mouse_pressed_ = false;
81 shift_pressed_ = false; 80 shift_pressed_ = false;
82 suppress_next_fling_cancel_ = false; 81 suppress_next_fling_cancel_ = false;
83 pinch_scale_ = 1.f; 82 pinch_scale_ = 1.f;
84 pinch_gesture_active_ = false; 83 pinch_gesture_active_ = false;
85 } 84 }
86 85
87 void TouchEmulator::Enable() { 86 void TouchEmulator::Enable(ui::GestureProviderConfigType config_type) {
88 if (!gesture_provider_) { 87 gesture_provider_.reset(new ui::FilteredGestureProvider(
jdduke (slow) 2014/12/30 18:13:00 I'm a little concerned about repeated enables (wit
dgozman 2015/01/14 14:00:23 Yeah, but what else can we do? With this code, ren
89 gesture_provider_.reset(new ui::FilteredGestureProvider( 88 GetEmulatorGestureProviderConfig(config_type), this));
90 GetGestureProviderConfig(), this)); 89 // TODO(dgozman): Use synthetic secondary touch to support multi-touch.
91 // TODO(dgozman): Use synthetic secondary touch to support multi-touch. 90 gesture_provider_->SetMultiTouchZoomSupportEnabled(false);
92 gesture_provider_->SetMultiTouchZoomSupportEnabled(false); 91 // TODO(dgozman): Enable double tap if requested by the renderer.
93 // TODO(dgozman): Enable double tap if requested by the renderer. 92 // TODO(dgozman): Don't break double-tap-based pinch with shift handling.
94 // TODO(dgozman): Don't break double-tap-based pinch with shift handling. 93 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
95 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
96
97 ResetState();
98 }
99 UpdateCursor(); 94 UpdateCursor();
100 } 95 }
101 96
102 void TouchEmulator::Disable() { 97 void TouchEmulator::Disable() {
103 if (!gesture_provider_) 98 if (!gesture_provider_)
104 return; 99 return;
105 100
106 UpdateCursor(); 101 UpdateCursor();
107 CancelTouch(); 102 CancelTouch();
108 gesture_provider_.reset(); 103 gesture_provider_.reset();
104 ResetState();
109 } 105 }
110 106
111 gfx::SizeF TouchEmulator::InitCursorFromResource( 107 gfx::SizeF TouchEmulator::InitCursorFromResource(
112 WebCursor* cursor, float scale, int resource_id) { 108 WebCursor* cursor, float scale, int resource_id) {
113 gfx::Image& cursor_image = 109 gfx::Image& cursor_image =
114 content::GetContentClient()->GetNativeImageNamed(resource_id); 110 content::GetContentClient()->GetNativeImageNamed(resource_id);
115 WebCursor::CursorInfo cursor_info; 111 WebCursor::CursorInfo cursor_info;
116 cursor_info.type = blink::WebCursorInfo::TypeCustom; 112 cursor_info.type = blink::WebCursorInfo::TypeCustom;
117 cursor_info.image_scale_factor = scale; 113 cursor_info.image_scale_factor = scale;
118 cursor_info.custom_image = cursor_image.AsBitmap(); 114 cursor_info.custom_image = cursor_image.AsBitmap();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 point.screenPosition.x = mouse_event.globalX; 431 point.screenPosition.x = mouse_event.globalX;
436 point.position.y = mouse_event.y; 432 point.position.y = mouse_event.y;
437 point.screenPosition.y = mouse_event.globalY; 433 point.screenPosition.y = mouse_event.globalY;
438 } 434 }
439 435
440 bool TouchEmulator::InPinchGestureMode() const { 436 bool TouchEmulator::InPinchGestureMode() const {
441 return shift_pressed_; 437 return shift_pressed_;
442 } 438 }
443 439
444 } // namespace content 440 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698