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

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

Issue 393953012: Eager Gesture Recognition on Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 4 months 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 | Annotate | Revision Log
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(*event, window, this->window());
164 gestures.reset(ui::GestureRecognizer::Get()-> 164 // Once we've fully migrated to the eager gesture detector, we won't need to
165 ProcessTouchEventForGesture(*event, result, window)); 165 // pass an event here.
166 scoped_ptr<ui::GestureRecognizer::Gestures> gestures(
167 ui::GestureRecognizer::Get()->ProcessTouchEventOnAsyncAck(
168 orig_event, result, window));
166 DispatchDetails details = ProcessGestures(gestures.get()); 169 DispatchDetails details = ProcessGestures(gestures.get());
167 if (details.dispatcher_destroyed) 170 if (details.dispatcher_destroyed)
168 return; 171 return;
169 } 172 }
170 173
171 void WindowEventDispatcher::HoldPointerMoves() { 174 void WindowEventDispatcher::HoldPointerMoves() {
172 if (!move_hold_count_) 175 if (!move_hold_count_)
173 held_event_factory_.InvalidateWeakPtrs(); 176 held_event_factory_.InvalidateWeakPtrs();
174 ++move_hold_count_; 177 ++move_hold_count_;
175 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", 178 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves",
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 old_dispatch_target_ = NULL; 485 old_dispatch_target_ = NULL;
483 #ifndef NDEBUG 486 #ifndef NDEBUG
484 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); 487 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_));
485 #endif 488 #endif
486 489
487 if (event.IsTouchEvent() && !details.target_destroyed) { 490 if (event.IsTouchEvent() && !details.target_destroyed) {
488 // Do not let 'held' touch events contribute to any gestures unless it is 491 // Do not let 'held' touch events contribute to any gestures unless it is
489 // being dispatched. 492 // being dispatched.
490 if (dispatching_held_event_ || !held_move_event_ || 493 if (dispatching_held_event_ || !held_move_event_ ||
491 !held_move_event_->IsTouchEvent()) { 494 !held_move_event_->IsTouchEvent()) {
495 // If the event is being handled asynchronously, ignore it.
496 if(event.result() & ui::ER_CONSUMED)
497 return details;
498 scoped_ptr<ui::GestureRecognizer::Gestures> gestures;
499
500 // Once we've fully migrated to the eager gesture detector, we won't
501 // need to pass an event here.
492 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), 502 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event),
493 static_cast<Window*>(event.target()), window()); 503 static_cast<Window*>(event.target()),
494 // Get the list of GestureEvents from GestureRecognizer. 504 window());
495 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; 505 gestures.reset(
496 gestures.reset(ui::GestureRecognizer::Get()-> 506 ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch(
497 ProcessTouchEventForGesture(orig_event, event.result(), 507 orig_event, event.result(), static_cast<Window*>(target)));
498 static_cast<Window*>(target))); 508
499 return ProcessGestures(gestures.get()); 509 return ProcessGestures(gestures.get());
500 } 510 }
501 } 511 }
502 512
503 return details; 513 return details;
504 } 514 }
505 515
506 //////////////////////////////////////////////////////////////////////////////// 516 ////////////////////////////////////////////////////////////////////////////////
507 // WindowEventDispatcher, ui::GestureEventHelper implementation: 517 // WindowEventDispatcher, ui::GestureEventHelper implementation:
508 518
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); 873 held_move_event_.reset(new ui::TouchEvent(*event, target, window()));
864 event->SetHandled(); 874 event->SetHandled();
865 return; 875 return;
866 } 876 }
867 break; 877 break;
868 878
869 default: 879 default:
870 NOTREACHED(); 880 NOTREACHED();
871 break; 881 break;
872 } 882 }
883
884 if (dispatching_held_event_ || !held_move_event_ ||
885 !held_move_event_->IsTouchEvent()) {
886 ui::TouchEvent orig_event(*event, target, window());
887
888 // If the touch event is invalid in some way, the gesture recognizer will
889 // reject it. In this case, stop the touch from reaching the next event
890 // phase.
891 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event,
892 target)) {
893 event->SetHandled();
894 }
895 }
896
873 PreDispatchLocatedEvent(target, event); 897 PreDispatchLocatedEvent(target, event);
874 } 898 }
875 899
876 } // namespace aura 900 } // 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