Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( | 153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( |
| 154 const gfx::Point& point) { | 154 const gfx::Point& point) { |
| 155 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, | 155 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, |
| 156 ui::EF_NONE); | 156 ui::EF_NONE); |
| 157 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); | 157 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, | 160 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, |
| 161 Window* window, | 161 Window* window, |
| 162 ui::EventResult result) { | 162 ui::EventResult result) { |
| 163 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 163 ui::TouchEvent orig_event(*static_cast<const ui::TouchEvent*>(event), |
| 164 gestures.reset(ui::GestureRecognizer::Get()-> | 164 static_cast<Window*>(window), |
|
sadrul
2014/08/06 00:46:08
Don't need the casts here.
tdresser
2014/08/06 12:47:04
Done.
| |
| 165 ProcessTouchEventForGesture(*event, result, window)); | 165 this->window()); |
| 166 // Once we've fully migrated to the eager gesture detector, we won't need to | |
| 167 // pass an event here. | |
| 168 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( | |
| 169 ui::GestureRecognizer::Get()->ProcessTouchEventOnAsyncAck( | |
| 170 orig_event, result, window)); | |
| 166 DispatchDetails details = ProcessGestures(gestures.get()); | 171 DispatchDetails details = ProcessGestures(gestures.get()); |
| 167 if (details.dispatcher_destroyed) | 172 if (details.dispatcher_destroyed) |
| 168 return; | 173 return; |
| 169 } | 174 } |
| 170 | 175 |
| 171 void WindowEventDispatcher::HoldPointerMoves() { | 176 void WindowEventDispatcher::HoldPointerMoves() { |
| 172 if (!move_hold_count_) | 177 if (!move_hold_count_) |
| 173 held_event_factory_.InvalidateWeakPtrs(); | 178 held_event_factory_.InvalidateWeakPtrs(); |
| 174 ++move_hold_count_; | 179 ++move_hold_count_; |
| 175 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", | 180 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 old_dispatch_target_ = NULL; | 483 old_dispatch_target_ = NULL; |
| 479 #ifndef NDEBUG | 484 #ifndef NDEBUG |
| 480 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); | 485 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); |
| 481 #endif | 486 #endif |
| 482 | 487 |
| 483 if (event.IsTouchEvent() && !details.target_destroyed) { | 488 if (event.IsTouchEvent() && !details.target_destroyed) { |
| 484 // Do not let 'held' touch events contribute to any gestures unless it is | 489 // Do not let 'held' touch events contribute to any gestures unless it is |
| 485 // being dispatched. | 490 // being dispatched. |
| 486 if (dispatching_held_event_ || !held_move_event_ || | 491 if (dispatching_held_event_ || !held_move_event_ || |
| 487 !held_move_event_->IsTouchEvent()) { | 492 !held_move_event_->IsTouchEvent()) { |
| 493 // If the event is being handled asynchronously, ignore it. | |
| 494 if(event.result() & ui::ER_CONSUMED) | |
| 495 return details; | |
| 496 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | |
| 497 | |
| 498 // Once we've fully migrated to the eager gesture detector, we won't | |
| 499 // need to pass an event here. | |
| 488 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), | 500 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
| 489 static_cast<Window*>(event.target()), window()); | 501 static_cast<Window*>(event.target()), |
| 490 // Get the list of GestureEvents from GestureRecognizer. | 502 window()); |
| 491 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 503 gestures.reset( |
| 492 gestures.reset(ui::GestureRecognizer::Get()-> | 504 ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch( |
| 493 ProcessTouchEventForGesture(orig_event, event.result(), | 505 orig_event, event.result(), static_cast<Window*>(target))); |
| 494 static_cast<Window*>(target))); | 506 |
| 495 return ProcessGestures(gestures.get()); | 507 return ProcessGestures(gestures.get()); |
| 496 } | 508 } |
| 497 } | 509 } |
| 498 | 510 |
| 499 return details; | 511 return details; |
| 500 } | 512 } |
| 501 | 513 |
| 502 //////////////////////////////////////////////////////////////////////////////// | 514 //////////////////////////////////////////////////////////////////////////////// |
| 503 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 515 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
| 504 | 516 |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); | 871 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); |
| 860 event->SetHandled(); | 872 event->SetHandled(); |
| 861 return; | 873 return; |
| 862 } | 874 } |
| 863 break; | 875 break; |
| 864 | 876 |
| 865 default: | 877 default: |
| 866 NOTREACHED(); | 878 NOTREACHED(); |
| 867 break; | 879 break; |
| 868 } | 880 } |
| 881 | |
| 882 if (dispatching_held_event_ || !held_move_event_ || | |
| 883 !held_move_event_->IsTouchEvent()) { | |
| 884 ui::TouchEvent orig_event( | |
| 885 static_cast<const ui::TouchEvent&>(*event), target, window()); | |
|
sadrul
2014/08/06 00:46:08
Don't need the cast
tdresser
2014/08/06 12:47:04
Done.
| |
| 886 | |
| 887 // If the touch event is invalid in some way, the gesture recognizer will | |
| 888 // reject it. In this case, stop the touch from reaching the next event | |
| 889 // phase. | |
| 890 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, | |
| 891 target)) { | |
| 892 event->SetHandled(); | |
| 893 } | |
| 894 } | |
| 895 | |
| 869 PreDispatchLocatedEvent(target, event); | 896 PreDispatchLocatedEvent(target, event); |
| 870 } | 897 } |
| 871 | 898 |
| 872 } // namespace aura | 899 } // namespace aura |
| OLD | NEW |