Chromium Code Reviews| Index: ui/aura/window_event_dispatcher.cc |
| diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc |
| index 2e42a9559614609352bad7f2b3e80ff9ba60bdd0..8da9d27b14512ecfe847843d37ba8c13d315cf33 100644 |
| --- a/ui/aura/window_event_dispatcher.cc |
| +++ b/ui/aura/window_event_dispatcher.cc |
| @@ -24,6 +24,7 @@ |
| #include "ui/events/event.h" |
| #include "ui/events/gestures/gesture_recognizer.h" |
| #include "ui/events/gestures/gesture_types.h" |
| +#include "ui/events/gestures/unified_gesture_detector_enabled.h" |
| typedef ui::EventDispatchDetails DispatchDetails; |
| @@ -161,8 +162,19 @@ void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, |
| Window* window, |
| ui::EventResult result) { |
| scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
| - gestures.reset(ui::GestureRecognizer::Get()-> |
| - ProcessTouchEventForGesture(*event, result, window)); |
| + |
| + if (ui::IsUnifiedGestureDetectorEnabled()) { |
|
jdduke (slow)
2014/07/31 16:19:02
Would it be crazy to abstract all of these differe
tdresser
2014/08/01 13:35:32
Done.
|
| + gestures.reset( |
| + ui::GestureRecognizer::Get()->AckTouchEventForGesture(result, window)); |
| + } else { |
| + ui::TouchEvent orig_event(*static_cast<const ui::TouchEvent*>(event), |
| + static_cast<Window*>(window), |
| + this->window()); |
| + gestures.reset( |
| + ui::GestureRecognizer::Get()->ProcessTouchEventForGestureForOldAuraGR( |
| + orig_event, result, window)); |
| + } |
| + |
| DispatchDetails details = ProcessGestures(gestures.get()); |
| if (details.dispatcher_destroyed) |
| return; |
| @@ -485,13 +497,23 @@ ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent( |
| // being dispatched. |
| if (dispatching_held_event_ || !held_move_event_ || |
| !held_move_event_->IsTouchEvent()) { |
| - ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
| - static_cast<Window*>(event.target()), window()); |
| - // Get the list of GestureEvents from GestureRecognizer. |
| + // If the event isn't being handled asynchronously, handle it now. |
| scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
| - gestures.reset(ui::GestureRecognizer::Get()-> |
| - ProcessTouchEventForGesture(orig_event, event.result(), |
| - static_cast<Window*>(target))); |
| + |
| + if (ui::IsUnifiedGestureDetectorEnabled()) { |
| + if (event.result() & ui::ER_CONSUMED) |
| + return details; |
| + gestures.reset(ui::GestureRecognizer::Get()->AckTouchEventForGesture( |
| + event.result(), static_cast<Window*>(target))); |
| + } else { |
| + ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
| + static_cast<Window*>(event.target()), |
| + window()); |
| + gestures.reset( |
| + ui::GestureRecognizer::Get() |
| + ->ProcessTouchEventForGestureForOldAuraGR( |
| + orig_event, event.result(), static_cast<Window*>(target))); |
| + } |
| return ProcessGestures(gestures.get()); |
| } |
| } |
| @@ -866,6 +888,21 @@ void WindowEventDispatcher::PreDispatchTouchEvent(Window* target, |
| NOTREACHED(); |
| break; |
| } |
| + |
| + if (ui::IsUnifiedGestureDetectorEnabled() && |
| + (dispatching_held_event_ || !held_move_event_ || |
| + !held_move_event_->IsTouchEvent())) { |
| + ui::TouchEvent orig_event( |
| + static_cast<const ui::TouchEvent&>(*event), target, window()); |
| + if (!ui::GestureRecognizer::Get()->ProcessTouchEventForGesture(orig_event, |
| + target)) { |
| + // If the touch event is invalid in some way, the gesture recognizer will |
| + // reject it. In this case, stop the touch from reaching the next event |
| + // phase. |
| + event->SetHandled(); |
| + } |
| + } |
| + |
| PreDispatchLocatedEvent(target, event); |
| } |