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

Unified Diff: ui/events/gestures/gesture_recognizer_impl.cc

Issue 469523003: Add the actual location coordinates to the touch cancel event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the unit tests 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
Index: ui/events/gestures/gesture_recognizer_impl.cc
diff --git a/ui/events/gestures/gesture_recognizer_impl.cc b/ui/events/gestures/gesture_recognizer_impl.cc
index 099d29f0112973af828b491cf255fe71110afd45..2c5ec7e77c1f6a2bbc98008f94fb999ea126c6a8 100644
--- a/ui/events/gestures/gesture_recognizer_impl.cc
+++ b/ui/events/gestures/gesture_recognizer_impl.cc
@@ -266,10 +266,16 @@ void GestureRecognizerImpl::SetupTargets(const TouchEvent& event,
void GestureRecognizerImpl::CancelTouches(
std::vector<std::pair<int, GestureConsumer*> >* touches) {
tdresser 2014/08/13 19:57:58 Can't we just look up the GestureProvider here, an
lanwei 2014/08/14 00:38:46 Yes, we can, but I feel if we do this for each tou
tdresser 2014/08/14 12:16:39 An n^2 algorithm when n nearly always 1 or 2 isn't
+ std::map<int, gfx::PointF> map =
+ GroupGestureConsumerWithTouchPoints(touches);
while (!touches->empty()) {
int touch_id = touches->begin()->first;
GestureConsumer* target = touches->begin()->second;
- TouchEvent touch_event(ui::ET_TOUCH_CANCELLED, gfx::PointF(0, 0),
+ gfx::PointF point(0, 0);
+ if(map.count(touch_id) > 0) {
+ point = map[touch_id];
+ }
+ TouchEvent touch_event(ui::ET_TOUCH_CANCELLED, point,
ui::EF_IS_SYNTHESIZED, touch_id,
ui::EventTimeForNow(), 0.0f, 0.0f, 0.0f, 0.0f);
GestureEventHelper* helper = FindDispatchHelperForConsumer(target);
@@ -279,6 +285,38 @@ void GestureRecognizerImpl::CancelTouches(
}
}
+std::map<int, gfx::PointF>
+GestureRecognizerImpl::GroupGestureConsumerWithTouchPoints(
+ std::vector<std::pair<int, GestureConsumer*> >* touches) {
+ std::map<int, gfx::PointF> map;
+ std::set<GestureConsumer*> consumerSet;
+ for (std::vector<std::pair<int, GestureConsumer*> >::iterator
+ it = touches->begin(); it != touches->end(); ++it) {
+ consumerSet.insert(it->second);
+ }
+ for (std::set<GestureConsumer*>::iterator iter = consumerSet.begin();
+ iter != consumerSet.end(); ++iter) {
+ std::map<int, gfx::PointF> subMap = MapTouchIDWithPointLocation(*iter);
+ map.insert(subMap.begin(), subMap.end());
+ }
+ return map;
+}
+
+std::map<int, gfx::PointF> GestureRecognizerImpl::MapTouchIDWithPointLocation(
+ GestureConsumer* consumer) {
+ std::map<int, gfx::PointF> map;
+ if (use_unified_gesture_detector_) {
+ GestureProviderAura* gesture_provider =
+ consumer_gesture_provider_[consumer];
+ const MotionEventAura& pointer_state = gesture_provider->pointer_state();
+ for (size_t i = 0; i < pointer_state.GetPointerCount(); ++i) {
+ gfx::PointF point(pointer_state.GetX(i), pointer_state.GetY(i));
+ map[pointer_state.GetPointerId(i)] = point;
+ }
+ }
+ return map;
+}
+
void GestureRecognizerImpl::DispatchGestureEvent(GestureEvent* event) {
GestureConsumer* consumer = GetTargetForGestureEvent(*event);
if (consumer) {
« ui/events/gestures/gesture_recognizer_impl.h ('K') | « ui/events/gestures/gesture_recognizer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698