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

Unified Diff: content/browser/renderer_host/input/touch_emulator.cc

Issue 679633005: Expose native, desktop and mobile gesture detection defaults (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize Created 6 years, 2 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.cc
diff --git a/content/browser/renderer_host/input/touch_emulator.cc b/content/browser/renderer_host/input/touch_emulator.cc
index 61ae63ef1fffa283ce8a9e543cefadf9ebc8002b..2d0112a8482860d64f560ef90b739965c2c7319f 100644
--- a/content/browser/renderer_host/input/touch_emulator.cc
+++ b/content/browser/renderer_host/input/touch_emulator.cc
@@ -29,8 +29,9 @@ namespace {
ui::GestureProvider::Config GetGestureProviderConfig() {
// TODO(dgozman): Use different configs to emulate mobile/desktop as
- // requested by renderer.
- ui::GestureProvider::Config config = ui::DefaultGestureProviderConfig();
+ // requested by renderer, crbug/425586.
+ ui::GestureProvider::Config config = ui::GetGestureProviderConfig(
+ ui::GestureProviderConfigType::GENERIC_MOBILE);
dgozman 2014/10/28 11:25:21 Great!
tdresser 2014/10/28 13:41:41 Can't you also emulate a touch screen laptop? Als
jdduke (slow) 2014/10/30 22:06:54 I guess I would consider desktop as PC/laptop, and
tdresser 2014/10/31 12:34:11 Oh nevermind, I was confused.
config.gesture_begin_end_types_enabled = false;
config.gesture_detector_config.swipe_enabled = false;
config.gesture_detector_config.two_finger_tap_enabled = false;
@@ -157,8 +158,14 @@ bool TouchEmulator::HandleMouseEvent(const WebMouseEvent& mouse_event) {
UpdateShiftPressed((mouse_event.modifiers & WebInputEvent::ShiftKey) != 0);
- if (FillTouchEventAndPoint(mouse_event) &&
- gesture_provider_.OnTouchEvent(MotionEventWeb(touch_event_))) {
+ if (mouse_event.type != WebInputEvent::MouseDown &&
+ mouse_event.type != WebInputEvent::MouseMove &&
+ mouse_event.type != WebInputEvent::MouseUp) {
+ return true;
+ }
+
+ if (gesture_provider_.OnTouchEvent(MotionEventWeb(touch_event_))) {
+ FillTouchEventAndPoint(mouse_event);
ForwardTouchEventToClient();
}
@@ -394,12 +401,6 @@ void TouchEmulator::ScrollEnd(const WebGestureEvent& event) {
}
bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
- if (mouse_event.type != WebInputEvent::MouseDown &&
- mouse_event.type != WebInputEvent::MouseMove &&
- mouse_event.type != WebInputEvent::MouseUp) {
- return false;
- }
-
WebInputEvent::Type eventType;
switch (mouse_event.type) {
case WebInputEvent::MouseDown:
@@ -413,12 +414,14 @@ bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
break;
default:
eventType = WebInputEvent::Undefined;
- NOTREACHED();
+ NOTREACHED() << "Invalid event for touch emulation: " << mouse_event.type;
}
touch_event_.touchesLength = 1;
touch_event_.modifiers = mouse_event.modifiers;
WebTouchEventTraits::ResetTypeAndTouchStates(
eventType, mouse_event.timeStampSeconds, &touch_event_);
+ touch_event_.defaultActionMayCauseScrolling =
dgozman 2014/10/28 11:25:22 So, this function should be called exactly after |
jdduke (slow) 2014/10/30 22:06:54 Yeah, this was pretty unclear. I reworked the logi
+ gesture_provider_.LastTouchEventDidGenerateScroll();
WebTouchPoint& point = touch_event_.touches[0];
point.id = 0;

Powered by Google App Engine
This is Rietveld 408576698