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

Side by Side Diff: ui/events/gestures/gesture_recognizer_impl.cc

Issue 630003003: Change GestureConfiguration types to be consistent with each other and with the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really fix compile Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/events/gestures/gesture_recognizer_impl.h" 5 #include "ui/events/gestures/gesture_recognizer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent( 84 GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent(
85 const GestureEvent& event) { 85 const GestureEvent& event) {
86 GestureConsumer* target = NULL; 86 GestureConsumer* target = NULL;
87 int touch_id = event.details().oldest_touch_id(); 87 int touch_id = event.details().oldest_touch_id();
88 target = touch_id_target_for_gestures_[touch_id]; 88 target = touch_id_target_for_gestures_[touch_id];
89 return target; 89 return target;
90 } 90 }
91 91
92 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( 92 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation(
93 const gfx::PointF& location, int source_device_id) { 93 const gfx::PointF& location, int source_device_id) {
94 const int max_distance = 94 const float max_distance =
95 GestureConfiguration::max_separation_for_gesture_touches_in_pixels(); 95 GestureConfiguration::max_separation_for_gesture_touches_in_pixels();
96 96
97 gfx::PointF closest_point; 97 gfx::PointF closest_point;
98 int closest_touch_id = 0; 98 int closest_touch_id = 0;
99 float closest_distance_squared = std::numeric_limits<float>::infinity(); 99 double closest_distance_squared = std::numeric_limits<double>::infinity();
100 100
101 std::map<GestureConsumer*, GestureProviderAura*>::iterator i; 101 std::map<GestureConsumer*, GestureProviderAura*>::iterator i;
102 for (i = consumer_gesture_provider_.begin(); 102 for (i = consumer_gesture_provider_.begin();
103 i != consumer_gesture_provider_.end(); 103 i != consumer_gesture_provider_.end();
104 ++i) { 104 ++i) {
105 const MotionEventAura& pointer_state = i->second->pointer_state(); 105 const MotionEventAura& pointer_state = i->second->pointer_state();
106 for (size_t j = 0; j < pointer_state.GetPointerCount(); ++j) { 106 for (size_t j = 0; j < pointer_state.GetPointerCount(); ++j) {
107 if (source_device_id != pointer_state.GetSourceDeviceId(j)) 107 if (source_device_id != pointer_state.GetSourceDeviceId(j))
108 continue; 108 continue;
109 gfx::PointF point(pointer_state.GetX(j), pointer_state.GetY(j)); 109 gfx::PointF point(pointer_state.GetX(j), pointer_state.GetY(j));
110 // Relative distance is all we need here, so LengthSquared() is 110 // Relative distance is all we need here, so LengthSquared() is
111 // appropriate, and cheaper than Length(). 111 // appropriate, and cheaper than Length().
112 float distance_squared = (point - location).LengthSquared(); 112 double distance_squared = (point - location).LengthSquared();
113 if (distance_squared < closest_distance_squared) { 113 if (distance_squared < closest_distance_squared) {
114 closest_point = point; 114 closest_point = point;
115 closest_touch_id = pointer_state.GetPointerId(j); 115 closest_touch_id = pointer_state.GetPointerId(j);
116 closest_distance_squared = distance_squared; 116 closest_distance_squared = distance_squared;
117 } 117 }
118 } 118 }
119 } 119 }
120 120
121 if (closest_distance_squared < max_distance * max_distance) 121 if (closest_distance_squared < max_distance * max_distance)
122 return touch_id_target_[closest_touch_id]; 122 return touch_id_target_[closest_touch_id];
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 std::vector<GestureEventHelper*>::iterator it; 339 std::vector<GestureEventHelper*>::iterator it;
340 for (it = helpers.begin(); it != helpers.end(); ++it) 340 for (it = helpers.begin(); it != helpers.end(); ++it)
341 gesture_recognizer->AddGestureEventHelper(*it); 341 gesture_recognizer->AddGestureEventHelper(*it);
342 342
343 helpers.clear(); 343 helpers.clear();
344 g_gesture_recognizer_instance = 344 g_gesture_recognizer_instance =
345 static_cast<GestureRecognizerImpl*>(gesture_recognizer); 345 static_cast<GestureRecognizerImpl*>(gesture_recognizer);
346 } 346 }
347 347
348 } // namespace ui 348 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698