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 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. |
|
sadrul
2014/10/23 15:56:34
Is this comment still correct?
tdresser
2014/10/27 15:52:31
Yes, this is still correct.
This patch only migrat
| |
| 171 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( | 164 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( |
| 172 ui::GestureRecognizer::Get()->ProcessTouchEventOnAsyncAck( | 165 ui::GestureRecognizer::Get() |
| 173 *event, result, window)); | 166 ->ProcessTouchEventAck(*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_; |
| 183 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", | 176 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 old_dispatch_target_ = NULL; | 483 old_dispatch_target_ = NULL; |
| 491 #ifndef NDEBUG | 484 #ifndef NDEBUG |
| 492 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); | 485 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); |
| 493 #endif | 486 #endif |
| 494 | 487 |
| 495 if (event.IsTouchEvent() && !details.target_destroyed) { | 488 if (event.IsTouchEvent() && !details.target_destroyed) { |
| 496 // 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 |
| 497 // being dispatched. | 490 // being dispatched. |
| 498 if (dispatching_held_event_ || !held_move_event_ || | 491 if (dispatching_held_event_ || !held_move_event_ || |
| 499 !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) | |
|
sadrul
2014/10/23 15:56:34
space after 'if'.
I remember we discussed using s
tdresser
2014/10/27 15:52:32
(Added space after 'if')
We concluded that it was
| |
| 495 return details; | |
| 496 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | |
| 500 | 497 |
| 501 // Once we've fully migrated to the eager gesture detector, we won't | 498 // Once we've fully migrated to the eager gesture detector, we won't |
| 502 // need to pass an event here. | 499 // need to pass an event here. |
| 503 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), | 500 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
| 504 static_cast<Window*>(event.target()), | 501 static_cast<Window*>(event.target()), |
| 505 window()); | 502 window()); |
| 506 | 503 |
| 507 if (event.result() & ui::ER_CONSUMED) | 504 if (ui::GestureRecognizer::Get()->ProcessTouchEvent( |
| 508 orig_event.StopPropagation(); | 505 orig_event, static_cast<Window*>(target))) { |
|
sadrul
2014/10/23 15:56:34
As the TODO you are removing mentions, shouldn't t
tdresser
2014/10/27 15:52:31
I previously thought that was the correct path for
sadrul
2014/10/29 19:35:00
I thought one of the major points of eager GR was
| |
| 509 | 506 gestures.reset(ui::GestureRecognizer::Get()->ProcessTouchEventAck( |
| 510 // TODO(tdresser): Move this to PreDispatchTouchEvent, to enable eager | 507 orig_event, event.result(), static_cast<Window*>(target))); |
| 511 // gesture detection. See crbug.com/410280. | 508 return ProcessGestures(gestures.get()); |
| 512 if (!ui::GestureRecognizer::Get() | |
| 513 ->ProcessTouchEventPreDispatch(orig_event, | |
| 514 static_cast<Window*>(target))) { | |
| 515 return details; | |
| 516 } | 509 } |
| 517 | |
| 518 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | |
| 519 | |
| 520 gestures.reset( | |
| 521 ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch( | |
| 522 orig_event, event.result(), static_cast<Window*>(target))); | |
| 523 | |
| 524 return ProcessGestures(gestures.get()); | |
| 525 } | 510 } |
| 526 } | 511 } |
| 527 | 512 |
| 528 return details; | 513 return details; |
| 529 } | 514 } |
| 530 | 515 |
| 516 bool WindowEventDispatcher::OnForwardingAsyncTouchEvent(ui::TouchEvent* event) { | |
| 517 ui::TouchEvent orig_event( | |
| 518 *event, static_cast<aura::Window*>(event->target()), window()); | |
| 519 | |
| 520 bool should_forward = ui::GestureRecognizer::Get()->ProcessTouchEvent( | |
| 521 orig_event, static_cast<aura::Window*>(event->target())); | |
| 522 | |
| 523 // Make sure that |PostDispatch| doesn't give |event| to the GestureRecognizer | |
| 524 // again. | |
| 525 event->StopPropagation(); | |
| 526 return should_forward; | |
| 527 } | |
| 528 | |
| 531 //////////////////////////////////////////////////////////////////////////////// | 529 //////////////////////////////////////////////////////////////////////////////// |
| 532 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 530 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
| 533 | 531 |
| 534 bool WindowEventDispatcher::CanDispatchToConsumer( | 532 bool WindowEventDispatcher::CanDispatchToConsumer( |
| 535 ui::GestureConsumer* consumer) { | 533 ui::GestureConsumer* consumer) { |
| 536 Window* consumer_window = ConsumerToWindow(consumer); | 534 Window* consumer_window = ConsumerToWindow(consumer); |
| 537 return (consumer_window && consumer_window->GetRootWindow() == window()); | 535 return (consumer_window && consumer_window->GetRootWindow() == window()); |
| 538 } | 536 } |
| 539 | 537 |
| 540 void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { | 538 void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 | 895 |
| 898 default: | 896 default: |
| 899 NOTREACHED(); | 897 NOTREACHED(); |
| 900 break; | 898 break; |
| 901 } | 899 } |
| 902 | 900 |
| 903 PreDispatchLocatedEvent(target, event); | 901 PreDispatchLocatedEvent(target, event); |
| 904 } | 902 } |
| 905 | 903 |
| 906 } // namespace aura | 904 } // namespace aura |
| OLD | NEW |