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

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

Issue 464013002: Fix bounding box calculation for touches with radius of 0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jdduke's comments. 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 | ui/events/gesture_detection/gesture_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 603108a5ba13ff2fd2eb85030194b3d85c87d0ca..9b4b597edd6d1fccd61818f48d957aeb32106835 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -31,15 +31,21 @@ const char* GetMotionEventActionName(MotionEvent::Action action) {
}
gfx::RectF GetBoundingBox(const MotionEvent& event) {
- gfx::RectF bounds;
+ // Can't use gfx::RectF::Union, as it ignores touches with a radius of 0.
+ float left = std::numeric_limits<float>::max();
+ float top = std::numeric_limits<float>::max();
+ float right = -std::numeric_limits<float>::max();
+ float bottom = -std::numeric_limits<float>::max();
for (size_t i = 0; i < event.GetPointerCount(); ++i) {
float diameter = event.GetTouchMajor(i);
- bounds.Union(gfx::RectF(event.GetX(i) - diameter / 2,
- event.GetY(i) - diameter / 2,
- diameter,
- diameter));
- }
- return bounds;
+ float x = event.GetX(i) - diameter / 2;
+ float y = event.GetY(i) - diameter / 2;
+ left = std::min(left, x);
+ right = std::max(right, x + diameter);
+ top = std::min(top, y);
+ bottom = std::max(bottom, y + diameter);
+ }
+ return gfx::RectF(left, top, right - left, bottom - top);
}
GestureEventData CreateGesture(const GestureEventDetails& details,
« no previous file with comments | « no previous file | ui/events/gesture_detection/gesture_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698