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

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

Issue 538653002: Changing the bounding box for show press and tap gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete some unused lines Created 6 years, 3 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 c76460e53c63da200bda0dcf3cec80946e79fd0a..4c8fe915a94d6a285382c015d6cca0305faaf900 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -54,6 +54,13 @@ gfx::RectF GetBoundingBox(const MotionEvent& event) {
return gfx::RectF(left, top, right - left, bottom - top);
}
+gfx::RectF GetBoundingBox(float x, float y, float max_diameter) {
+ // Can't use gfx::RectF::Union, as it ignores touches with a radius of 0.
+ float left = x - max_diameter / 2;
+ float top = y - max_diameter / 2;
+ return gfx::RectF(left, top, max_diameter, max_diameter);
+}
+
GestureEventData CreateGesture(const GestureEventDetails& details,
int motion_event_id,
MotionEvent::ToolType primary_tool_type,
@@ -116,6 +123,48 @@ GestureEventData CreateGesture(EventType type, const MotionEvent& event) {
return CreateGesture(GestureEventDetails(type, 0, 0), event);
}
+GestureEventData CreateGesture(const GestureEventDetails& details,
tdresser 2014/09/04 13:54:00 Hmmm, I don't really like adding even more |Create
+ const MotionEvent& event,
+ float max_diameter) {
+ return GestureEventData(
+ details,
+ event.GetId(),
+ event.GetToolType(),
+ event.GetEventTime(),
+ event.GetX(),
+ event.GetY(),
+ event.GetRawX(),
+ event.GetRawY(),
+ event.GetPointerCount(),
+ GetBoundingBox(event.GetX(), event.GetY(), max_diameter));
+}
+
+GestureEventData CreateGesture(const GestureEventDetails& details,
+ const MotionEvent& event,
+ float x,
+ float y,
+ float max_diameter) {
+ return GestureEventData(details,
+ event.GetId(),
+ event.GetToolType(),
+ event.GetEventTime(),
+ event.GetX(),
+ event.GetY(),
+ event.GetRawX(),
+ event.GetRawY(),
+ event.GetPointerCount(),
+ GetBoundingBox(x, y, max_diameter));
+}
+
+GestureEventData CreateTapGesture(EventType type,
+ const MotionEvent& event,
+ float x,
+ float y,
+ float max_diameter) {
+ return CreateGesture(
+ GestureEventDetails(type, 1, 0), event, x, y, max_diameter);
+}
+
GestureEventData CreateTapGesture(EventType type, const MotionEvent& event) {
// Set the tap count to 1 even for ET_GESTURE_DOUBLE_TAP, in order to be
// consistent with double tap behavior on a mobile viewport. See
@@ -472,12 +521,15 @@ class GestureProvider::GestureListenerImpl
return true;
}
- virtual void OnShowPress(const MotionEvent& e) OVERRIDE {
+ virtual void OnShowPress(const MotionEvent& e, float max_diameter) OVERRIDE {
GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0);
- Send(CreateGesture(show_press_details, e));
+ Send(CreateGesture(show_press_details, e, max_diameter));
}
- virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE {
+ virtual bool OnSingleTapUp(const MotionEvent& e,
+ float x,
+ float y,
+ float max_diameter) OVERRIDE {
// This is a hack to address the issue where user hovers
// over a link for longer than double_tap_timeout_, then
// OnSingleTapConfirmed() is not triggered. But we still
@@ -487,15 +539,16 @@ class GestureProvider::GestureListenerImpl
if (!ignore_single_tap_) {
if (e.GetEventTime() - current_down_time_ >
config_.gesture_detector_config.double_tap_timeout) {
- return OnSingleTapConfirmed(e);
+ return OnSingleTapConfirmed(e, x, y, max_diameter);
} else if (!IsDoubleTapEnabled() || config_.disable_click_delay) {
// If double-tap has been disabled, there is no need to wait
// for the double-tap timeout.
- return OnSingleTapConfirmed(e);
+ return OnSingleTapConfirmed(e, x, y, max_diameter);
} else {
// Notify Blink about this tapUp event anyway, when none of the above
// conditions applied.
- Send(CreateTapGesture(ET_GESTURE_TAP_UNCONFIRMED, e));
+ Send(CreateTapGesture(
+ ET_GESTURE_TAP_UNCONFIRMED, e, x, y, max_diameter));
tdresser 2014/09/04 13:54:01 Add a space to line up with "Create"
}
}
@@ -511,7 +564,10 @@ class GestureProvider::GestureListenerImpl
}
// GestureDetector::DoubleTapListener implementation.
- virtual bool OnSingleTapConfirmed(const MotionEvent& e) OVERRIDE {
+ virtual bool OnSingleTapConfirmed(const MotionEvent& e,
+ float x,
+ float y,
+ float max_diameter) OVERRIDE {
// Long taps in the edges of the screen have their events delayed by
// ContentViewHolder for tab swipe operations. As a consequence of the delay
// this method might be called after receiving the up event.
@@ -521,7 +577,7 @@ class GestureProvider::GestureListenerImpl
ignore_single_tap_ = true;
- Send(CreateTapGesture(ET_GESTURE_TAP, e));
+ Send(CreateTapGesture(ET_GESTURE_TAP, e, x, y, max_diameter));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698