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

Unified Diff: ui/events/gesture_detection/gesture_provider.cc

Issue 468043003: Ignore min/max gesture bounds for mouse or stylus-derived gestures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GestureTextSelectorTest Created 6 years, 4 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: ui/events/gesture_detection/gesture_provider.cc
diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc
index 9b4b597edd6d1fccd61818f48d957aeb32106835..e38957ab31c4fcefccf0417e5ffe2c042a760b37 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -50,6 +50,7 @@ gfx::RectF GetBoundingBox(const MotionEvent& event) {
GestureEventData CreateGesture(const GestureEventDetails& details,
int motion_event_id,
+ MotionEvent::ToolType primary_tool_type,
base::TimeTicks time,
float x,
float y,
@@ -59,6 +60,7 @@ GestureEventData CreateGesture(const GestureEventDetails& details,
const gfx::RectF& bounding_box) {
return GestureEventData(details,
motion_event_id,
+ primary_tool_type,
time,
x,
y,
@@ -70,6 +72,7 @@ GestureEventData CreateGesture(const GestureEventDetails& details,
GestureEventData CreateGesture(EventType type,
int motion_event_id,
+ MotionEvent::ToolType primary_tool_type,
base::TimeTicks time,
float x,
float y,
@@ -79,6 +82,7 @@ GestureEventData CreateGesture(EventType type,
const gfx::RectF& bounding_box) {
return GestureEventData(GestureEventDetails(type, 0, 0),
motion_event_id,
+ primary_tool_type,
time,
x,
y,
@@ -92,6 +96,7 @@ GestureEventData CreateGesture(const GestureEventDetails& details,
const MotionEvent& event) {
return GestureEventData(details,
event.GetId(),
+ event.GetToolType(),
event.GetEventTime(),
event.GetX(),
event.GetY(),
@@ -194,6 +199,7 @@ class GestureProvider::ScaleGestureListenerImpl
pinch_event_sent_ = true;
provider_->Send(CreateGesture(ET_GESTURE_PINCH_BEGIN,
e.GetId(),
+ e.GetToolType(),
detector.GetEventTime(),
detector.GetFocusX(),
detector.GetFocusY(),
@@ -227,6 +233,7 @@ class GestureProvider::ScaleGestureListenerImpl
GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0);
provider_->Send(CreateGesture(pinch_details,
e.GetId(),
+ e.GetToolType(),
detector.GetEventTime(),
detector.GetFocusX(),
detector.GetFocusY(),
@@ -368,6 +375,7 @@ class GestureProvider::GestureListenerImpl
// used to determine which layer the scroll should affect.
provider_->Send(CreateGesture(scroll_details,
e2.GetId(),
+ e2.GetToolType(),
e2.GetEventTime(),
e1.GetX(),
e1.GetY(),
@@ -386,6 +394,7 @@ class GestureProvider::GestureListenerImpl
ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y);
provider_->Send(CreateGesture(scroll_details,
e2.GetId(),
+ e2.GetToolType(),
e2.GetEventTime(),
center.x(),
center.y(),
@@ -432,6 +441,7 @@ class GestureProvider::GestureListenerImpl
e1.GetTouchMajor());
provider_->Send(CreateGesture(two_finger_tap_details,
e2.GetId(),
+ e2.GetToolType(),
e2.GetEventTime(),
e1.GetX(),
e1.GetY(),
@@ -685,12 +695,13 @@ void GestureProvider::Send(GestureEventData gesture) {
gesture.type() == ET_GESTURE_SHOW_PRESS ||
gesture.type() == ET_GESTURE_END);
- // TODO(jdduke): Provide a way of skipping this clamping for stylus and/or
- // mouse-based input, perhaps by exposing the source type on MotionEvent.
- gesture.details.set_bounding_box(
- ClampBoundingBox(gesture.details.bounding_box_f(),
- min_gesture_bounds_length_,
- max_gesture_bounds_length_));
+ if (gesture.primary_tool_type == MotionEvent::TOOL_TYPE_UNKNOWN ||
+ gesture.primary_tool_type == MotionEvent::TOOL_TYPE_FINGER) {
+ gesture.details.set_bounding_box(
+ ClampBoundingBox(gesture.details.bounding_box_f(),
+ min_gesture_bounds_length_,
+ max_gesture_bounds_length_));
+ }
switch (gesture.type()) {
case ET_GESTURE_LONG_PRESS:
@@ -768,6 +779,7 @@ void GestureProvider::OnTouchEventHandlingBegin(const MotionEvent& event) {
const int action_index = event.GetActionIndex();
Send(CreateGesture(ET_GESTURE_BEGIN,
event.GetId(),
+ event.GetToolType(),
event.GetEventTime(),
event.GetX(action_index),
event.GetY(action_index),
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.h ('k') | ui/events/gesture_detection/gesture_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698