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

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

Issue 462163002: Use a minimum touch size for selection handle hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_handle_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/touch_handle.cc
diff --git a/content/browser/renderer_host/input/touch_handle.cc b/content/browser/renderer_host/input/touch_handle.cc
index 2636179e68e666aef09b2912370e95670f6483c9..d5bda485dca02ced7e60a57ecea442f74a031c5d 100644
--- a/content/browser/renderer_host/input/touch_handle.cc
+++ b/content/browser/renderer_host/input/touch_handle.cc
@@ -17,11 +17,15 @@ const double kFadeDurationMs = 200;
// when the handle is moving rapidly while the fade is active.
const double kFadeDistanceSquared = 20.f * 20.f;
+// Avoid using an empty touch rect, as it may fail the intersection test event
+// if it lies within the other rect's bounds.
+const float kMinTouchMajorForHitTesting = 1.f;
+
// The maximum touch size to use when computing whether a touch point is
// targetting a touch handle. This is necessary for devices that misreport
// touch radii, preventing inappropriately largely touch sizes from completely
// breaking handle dragging behavior.
-const float kMaxTouchMajorForHitTesting = 48.f;
+const float kMaxTouchMajorForHitTesting = 36.f;
} // namespace
@@ -120,8 +124,9 @@ bool TouchHandle::WillHandleTouchEvent(const ui::MotionEvent& event) {
case ui::MotionEvent::ACTION_DOWN: {
if (!is_visible_)
return false;
- const float touch_size =
- std::min(event.GetTouchMajor(), kMaxTouchMajorForHitTesting);
+ const float touch_size = std::max(
+ kMinTouchMajorForHitTesting,
+ std::min(kMaxTouchMajorForHitTesting, event.GetTouchMajor()));
const gfx::RectF touch_rect(event.GetX() - touch_size * .5f,
event.GetY() - touch_size * .5f,
touch_size,
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698