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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()->ProcessTouchEventPostDispatch( |
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 |
| 172 void WindowEventDispatcher::IgnoreLastTouchEvent(Window* window) { |
| 173 ui::GestureRecognizer::Get()->IgnoreLastTouchEvent(window); |
| 174 } |
| 175 |
179 void WindowEventDispatcher::HoldPointerMoves() { | 176 void WindowEventDispatcher::HoldPointerMoves() { |
180 if (!move_hold_count_) | 177 if (!move_hold_count_) |
181 held_event_factory_.InvalidateWeakPtrs(); | 178 held_event_factory_.InvalidateWeakPtrs(); |
182 ++move_hold_count_; | 179 ++move_hold_count_; |
183 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", | 180 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", |
184 this); | 181 this); |
185 } | 182 } |
186 | 183 |
187 void WindowEventDispatcher::ReleasePointerMoves() { | 184 void WindowEventDispatcher::ReleasePointerMoves() { |
188 --move_hold_count_; | 185 --move_hold_count_; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 #ifndef NDEBUG | 489 #ifndef NDEBUG |
493 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); | 490 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); |
494 #endif | 491 #endif |
495 | 492 |
496 if (event.IsTouchEvent() && !details.target_destroyed) { | 493 if (event.IsTouchEvent() && !details.target_destroyed) { |
497 // Do not let 'held' touch events contribute to any gestures unless it is | 494 // Do not let 'held' touch events contribute to any gestures unless it is |
498 // being dispatched. | 495 // being dispatched. |
499 if (dispatching_held_event_ || !held_move_event_ || | 496 if (dispatching_held_event_ || !held_move_event_ || |
500 !held_move_event_->IsTouchEvent()) { | 497 !held_move_event_->IsTouchEvent()) { |
501 | 498 |
502 // Once we've fully migrated to the eager gesture detector, we won't | 499 if (!event.synchronous_handling_disabled()) { |
503 // need to pass an event here. | 500 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 | 501 |
508 if (event.result() & ui::ER_CONSUMED) | 502 // Once we've fully migrated to the eager gesture detector, we won't |
509 orig_event.StopPropagation(); | 503 // need to pass an event here. |
| 504 gestures.reset( |
| 505 ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch( |
| 506 static_cast<const ui::TouchEvent&>(event), event.result(), |
| 507 static_cast<Window*>(target))); |
510 | 508 |
511 // TODO(tdresser): Move this to PreDispatchTouchEvent, to enable eager | 509 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 } | 510 } |
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 } | 511 } |
527 } | 512 } |
528 | 513 |
529 return details; | 514 return details; |
530 } | 515 } |
531 | 516 |
532 //////////////////////////////////////////////////////////////////////////////// | 517 //////////////////////////////////////////////////////////////////////////////// |
533 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 518 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
534 | 519 |
535 bool WindowEventDispatcher::CanDispatchToConsumer( | 520 bool WindowEventDispatcher::CanDispatchToConsumer( |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 event->SetHandled(); | 879 event->SetHandled(); |
895 return; | 880 return; |
896 } | 881 } |
897 break; | 882 break; |
898 | 883 |
899 default: | 884 default: |
900 NOTREACHED(); | 885 NOTREACHED(); |
901 break; | 886 break; |
902 } | 887 } |
903 | 888 |
| 889 ui::TouchEvent orig_event(*event, target, window()); |
| 890 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, |
| 891 target)) { |
| 892 event->StopPropagation(); |
| 893 event->DisableSynchronousHandling(); |
| 894 return; |
| 895 } |
| 896 |
904 PreDispatchLocatedEvent(target, event); | 897 PreDispatchLocatedEvent(target, event); |
905 } | 898 } |
906 | 899 |
907 } // namespace aura | 900 } // namespace aura |
OLD | NEW |