Index: ui/base/gestures/gesture_recognizer_impl.cc |
diff --git a/ui/base/gestures/gesture_recognizer_impl.cc b/ui/base/gestures/gesture_recognizer_impl.cc |
index 78adfab9c0e6a1b0649a75ecd68f7320a29f96a1..a18f6ce5b2da2b282f3cabedb2901cd90ced1237 100644 |
--- a/ui/base/gestures/gesture_recognizer_impl.cc |
+++ b/ui/base/gestures/gesture_recognizer_impl.cc |
@@ -125,19 +125,20 @@ GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent( |
GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( |
const gfx::Point& location) { |
const GesturePoint* closest_point = NULL; |
- int closest_distance_squared = 0; |
+ int64 closest_distance_squared = 0; |
std::map<GestureConsumer*, GestureSequence*>::iterator i; |
for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) { |
const GesturePoint* points = i->second->points(); |
for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) { |
if (!points[j].in_use()) |
continue; |
- gfx::Point delta = |
- points[j].last_touch_position().Subtract(location); |
- int distance = delta.x() * delta.x() + delta.y() * delta.y(); |
- if (!closest_point || distance < closest_distance_squared) { |
+ gfx::Vector2d delta = points[j].last_touch_position() - location; |
+ // Relative distance is all we need here, so LengthSquared() is |
+ // appropriate, and cheaper than Length(). |
+ int64 distance_squared = delta.LengthSquared(); |
+ if (!closest_point || distance_squared < closest_distance_squared) { |
closest_point = &points[j]; |
- closest_distance_squared = distance; |
+ closest_distance_squared = distance_squared; |
} |
} |
} |