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

Side by Side Diff: ui/aura/window_event_dispatcher.cc

Issue 680413006: Re-enable Eager Gesture Recognition on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address sadrul's comments. Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( 152 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint(
153 const gfx::Point& point) { 153 const gfx::Point& point) {
154 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, 154 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE,
155 ui::EF_NONE); 155 ui::EF_NONE);
156 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); 156 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
157 } 157 }
158 158
159 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, 159 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event,
160 Window* window, 160 Window* window,
161 ui::EventResult result) { 161 ui::EventResult result) {
162 // TODO(tdresser): Move this to PreDispatchTouchEvent, to enable eager
163 // gesture detection. See crbug.com/410280.
164 if (!ui::GestureRecognizer::Get()
165 ->ProcessTouchEventPreDispatch(*event, window)) {
166 return;
167 }
168
169 // Once we've fully migrated to the eager gesture detector, we won't need to 162 // Once we've fully migrated to the eager gesture detector, we won't need to
170 // pass an event here. 163 // pass an event here.
171 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( 164 scoped_ptr<ui::GestureRecognizer::Gestures> gestures(
172 ui::GestureRecognizer::Get()->ProcessTouchEventOnAsyncAck( 165 ui::GestureRecognizer::Get()->AckAsyncTouchEvent(
173 *event, result, window)); 166 *event, result, window));
174 DispatchDetails details = ProcessGestures(gestures.get()); 167 DispatchDetails details = ProcessGestures(gestures.get());
175 if (details.dispatcher_destroyed) 168 if (details.dispatcher_destroyed)
176 return; 169 return;
177 } 170 }
178 171
179 void WindowEventDispatcher::HoldPointerMoves() { 172 void WindowEventDispatcher::HoldPointerMoves() {
180 if (!move_hold_count_) 173 if (!move_hold_count_)
181 held_event_factory_.InvalidateWeakPtrs(); 174 held_event_factory_.InvalidateWeakPtrs();
182 ++move_hold_count_; 175 ++move_hold_count_;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 old_dispatch_target_ = NULL; 484 old_dispatch_target_ = NULL;
492 #ifndef NDEBUG 485 #ifndef NDEBUG
493 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); 486 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_));
494 #endif 487 #endif
495 488
496 if (event.IsTouchEvent() && !details.target_destroyed) { 489 if (event.IsTouchEvent() && !details.target_destroyed) {
497 // Do not let 'held' touch events contribute to any gestures unless it is 490 // Do not let 'held' touch events contribute to any gestures unless it is
498 // being dispatched. 491 // being dispatched.
499 if (dispatching_held_event_ || !held_move_event_ || 492 if (dispatching_held_event_ || !held_move_event_ ||
500 !held_move_event_->IsTouchEvent()) { 493 !held_move_event_->IsTouchEvent()) {
494 const ui::TouchEvent& touchevent =
495 static_cast<const ui::TouchEvent&>(event);
501 496
502 // Once we've fully migrated to the eager gesture detector, we won't 497 if (!touchevent.synchronous_handling_disabled()) {
503 // need to pass an event here. 498 scoped_ptr<ui::GestureRecognizer::Gestures> gestures;
504 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event),
505 static_cast<Window*>(event.target()),
506 window());
507 499
508 if (event.result() & ui::ER_CONSUMED) 500 // Once we've fully migrated to the eager gesture detector, we won't
509 orig_event.StopPropagation(); 501 // need to pass an event here.
502 gestures.reset(ui::GestureRecognizer::Get()->AckSyncTouchEvent(
503 touchevent.unique_event_id(), event.result(),
504 static_cast<Window*>(target)));
510 505
511 // TODO(tdresser): Move this to PreDispatchTouchEvent, to enable eager 506 return ProcessGestures(gestures.get());
512 // gesture detection. See crbug.com/410280.
513 if (!ui::GestureRecognizer::Get()
514 ->ProcessTouchEventPreDispatch(orig_event,
515 static_cast<Window*>(target))) {
516 return details;
517 } 507 }
518
519 scoped_ptr<ui::GestureRecognizer::Gestures> gestures;
520
521 gestures.reset(
522 ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch(
523 orig_event, event.result(), static_cast<Window*>(target)));
524
525 return ProcessGestures(gestures.get());
526 } 508 }
527 } 509 }
528 510
529 return details; 511 return details;
530 } 512 }
531 513
532 //////////////////////////////////////////////////////////////////////////////// 514 ////////////////////////////////////////////////////////////////////////////////
533 // WindowEventDispatcher, ui::GestureEventHelper implementation: 515 // WindowEventDispatcher, ui::GestureEventHelper implementation:
534 516
535 bool WindowEventDispatcher::CanDispatchToConsumer( 517 bool WindowEventDispatcher::CanDispatchToConsumer(
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 event->SetHandled(); 876 event->SetHandled();
895 return; 877 return;
896 } 878 }
897 break; 879 break;
898 880
899 default: 881 default:
900 NOTREACHED(); 882 NOTREACHED();
901 break; 883 break;
902 } 884 }
903 885
886 ui::TouchEvent orig_event(*event, target, window());
887 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event,
888 target)) {
889 // The event is invalid - ignore it.
890 event->StopPropagation();
891 event->DisableSynchronousHandling();
892 return;
893 }
894
904 PreDispatchLocatedEvent(target, event); 895 PreDispatchLocatedEvent(target, event);
905 } 896 }
906 897
907 } // namespace aura 898 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698