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, |