| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/gestures/gesture_recognizer_impl.h" | 5 #include "ui/base/gestures/gesture_recognizer_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "ui/base/events/event.h" | 10 #include "ui/base/events/event.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( | 125 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( |
| 126 const gfx::Point& location) { | 126 const gfx::Point& location) { |
| 127 const GesturePoint* closest_point = NULL; | 127 const GesturePoint* closest_point = NULL; |
| 128 int closest_distance_squared = 0; | 128 int closest_distance_squared = 0; |
| 129 std::map<GestureConsumer*, GestureSequence*>::iterator i; | 129 std::map<GestureConsumer*, GestureSequence*>::iterator i; |
| 130 for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) { | 130 for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) { |
| 131 const GesturePoint* points = i->second->points(); | 131 const GesturePoint* points = i->second->points(); |
| 132 for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) { | 132 for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) { |
| 133 if (!points[j].in_use()) | 133 if (!points[j].in_use()) |
| 134 continue; | 134 continue; |
| 135 gfx::Point delta = | 135 gfx::Point delta = points[j].last_touch_position().Subtract( |
| 136 points[j].last_touch_position().Subtract(location); | 136 location.DistanceFromOrigin()); |
| 137 int distance = delta.x() * delta.x() + delta.y() * delta.y(); | 137 int distance = delta.x() * delta.x() + delta.y() * delta.y(); |
| 138 if (!closest_point || distance < closest_distance_squared) { | 138 if (!closest_point || distance < closest_distance_squared) { |
| 139 closest_point = &points[j]; | 139 closest_point = &points[j]; |
| 140 closest_distance_squared = distance; | 140 closest_distance_squared = distance; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 const int max_distance = | 145 const int max_distance = |
| 146 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(); | 146 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 RemoveConsumerFromMap(consumer, &touch_id_target_); | 238 RemoveConsumerFromMap(consumer, &touch_id_target_); |
| 239 RemoveConsumerFromMap(consumer, &touch_id_target_for_gestures_); | 239 RemoveConsumerFromMap(consumer, &touch_id_target_for_gestures_); |
| 240 } | 240 } |
| 241 | 241 |
| 242 // GestureRecognizer, static | 242 // GestureRecognizer, static |
| 243 GestureRecognizer* GestureRecognizer::Create(GestureEventHelper* helper) { | 243 GestureRecognizer* GestureRecognizer::Create(GestureEventHelper* helper) { |
| 244 return new GestureRecognizerImpl(helper); | 244 return new GestureRecognizerImpl(helper); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace ui | 247 } // namespace ui |
| OLD | NEW |