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

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

Issue 2789203006: Routes touch ACK events to the correct GestureProvider (Closed)
Patch Set: Added Bug specific unit test Created 3 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 bool GestureRecognizerImpl::ProcessTouchEventPreDispatch( 266 bool GestureRecognizerImpl::ProcessTouchEventPreDispatch(
267 TouchEvent* event, 267 TouchEvent* event,
268 GestureConsumer* consumer) { 268 GestureConsumer* consumer) {
269 SetupTargets(*event, consumer); 269 SetupTargets(*event, consumer);
270 270
271 if (event->result() & ER_CONSUMED) 271 if (event->result() & ER_CONSUMED)
272 return false; 272 return false;
273 273
274 GestureProviderAura* gesture_provider = 274 GestureProviderAura* gesture_provider =
275 GetGestureProviderForConsumer(consumer); 275 GetGestureProviderForConsumer(consumer);
276 event_to_gesture_provider_[event->unique_event_id()] = gesture_provider;
tdresser 2017/04/06 20:59:52 Can we put this in SetupTargets?
malaykeshav 2017/04/07 01:07:59 Done
276 return gesture_provider->OnTouchEvent(event); 277 return gesture_provider->OnTouchEvent(event);
277 } 278 }
278 279
279 GestureRecognizer::Gestures GestureRecognizerImpl::AckTouchEvent( 280 GestureRecognizer::Gestures GestureRecognizerImpl::AckTouchEvent(
280 uint32_t unique_event_id, 281 uint32_t unique_event_id,
281 ui::EventResult result, 282 ui::EventResult result,
282 GestureConsumer* consumer) { 283 GestureConsumer* consumer) {
283 GestureProviderAura* gesture_provider = 284 GestureProviderAura* gesture_provider = nullptr;
284 GetGestureProviderForConsumer(consumer); 285
286 // Check if we have already processed this event before dispatch and have a
287 // consumer associated with it.
288 if (event_to_gesture_provider_.count(unique_event_id)) {
289 gesture_provider = event_to_gesture_provider_[unique_event_id];
290 event_to_gesture_provider_.erase(unique_event_id);
tdresser 2017/04/06 20:59:52 This is performing three lookups into this map. H
malaykeshav 2017/04/07 01:07:59 Done
291 } else {
292 gesture_provider = GetGestureProviderForConsumer(consumer);
293 }
285 gesture_provider->OnTouchEventAck(unique_event_id, result != ER_UNHANDLED); 294 gesture_provider->OnTouchEventAck(unique_event_id, result != ER_UNHANDLED);
286 return gesture_provider->GetAndResetPendingGestures(); 295 return gesture_provider->GetAndResetPendingGestures();
287 } 296 }
288 297
289 bool GestureRecognizerImpl::CleanupStateForConsumer( 298 bool GestureRecognizerImpl::CleanupStateForConsumer(
290 GestureConsumer* consumer) { 299 GestureConsumer* consumer) {
291 bool state_cleaned_up = false; 300 bool state_cleaned_up = false;
292 301
293 if (consumer_gesture_provider_.count(consumer)) { 302 if (consumer_gesture_provider_.count(consumer)) {
294 state_cleaned_up = true; 303 state_cleaned_up = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 std::vector<GestureEventHelper*>::iterator it; 362 std::vector<GestureEventHelper*>::iterator it;
354 for (it = helpers.begin(); it != helpers.end(); ++it) 363 for (it = helpers.begin(); it != helpers.end(); ++it)
355 gesture_recognizer->AddGestureEventHelper(*it); 364 gesture_recognizer->AddGestureEventHelper(*it);
356 365
357 helpers.clear(); 366 helpers.clear();
358 g_gesture_recognizer_instance = 367 g_gesture_recognizer_instance =
359 static_cast<GestureRecognizerImpl*>(gesture_recognizer); 368 static_cast<GestureRecognizerImpl*>(gesture_recognizer);
360 } 369 }
361 370
362 } // namespace ui 371 } // namespace ui
OLDNEW
« 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