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

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

Issue 2715743005: Revert of Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "ui/aura/client/capture_client.h" 14 #include "ui/aura/client/capture_client.h"
15 #include "ui/aura/client/cursor_client.h" 15 #include "ui/aura/client/cursor_client.h"
16 #include "ui/aura/client/event_client.h" 16 #include "ui/aura/client/event_client.h"
17 #include "ui/aura/client/focus_client.h" 17 #include "ui/aura/client/focus_client.h"
18 #include "ui/aura/client/screen_position_client.h" 18 #include "ui/aura/client/screen_position_client.h"
19 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
20 #include "ui/aura/env_input_state_controller.h" 20 #include "ui/aura/env_input_state_controller.h"
21 #include "ui/aura/mus/mus_mouse_location_updater.h" 21 #include "ui/aura/mus/mus_mouse_location_updater.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/aura/window_delegate.h" 23 #include "ui/aura/window_delegate.h"
24 #include "ui/aura/window_targeter.h" 24 #include "ui/aura/window_targeter.h"
25 #include "ui/aura/window_tracker.h" 25 #include "ui/aura/window_tracker.h"
26 #include "ui/aura/window_tree_host.h" 26 #include "ui/aura/window_tree_host.h"
27 #include "ui/base/hit_test.h" 27 #include "ui/base/hit_test.h"
28 #include "ui/compositor/dip_util.h" 28 #include "ui/compositor/dip_util.h"
29 #include "ui/events/event.h" 29 #include "ui/events/event.h"
30 #include "ui/events/event_targeter.h"
31 #include "ui/events/event_utils.h" 30 #include "ui/events/event_utils.h"
32 #include "ui/events/gestures/gesture_recognizer.h" 31 #include "ui/events/gestures/gesture_recognizer.h"
33 #include "ui/events/gestures/gesture_types.h" 32 #include "ui/events/gestures/gesture_types.h"
34 33
35 typedef ui::EventDispatchDetails DispatchDetails; 34 typedef ui::EventDispatchDetails DispatchDetails;
36 35
37 namespace aura { 36 namespace aura {
38 37
39 namespace { 38 namespace {
40 39
(...skipping 29 matching lines...) Expand all
70 : host_(host), 69 : host_(host),
71 mouse_pressed_handler_(NULL), 70 mouse_pressed_handler_(NULL),
72 mouse_moved_handler_(NULL), 71 mouse_moved_handler_(NULL),
73 event_dispatch_target_(NULL), 72 event_dispatch_target_(NULL),
74 old_dispatch_target_(NULL), 73 old_dispatch_target_(NULL),
75 synthesize_mouse_move_(false), 74 synthesize_mouse_move_(false),
76 move_hold_count_(0), 75 move_hold_count_(0),
77 dispatching_held_event_(nullptr), 76 dispatching_held_event_(nullptr),
78 observer_manager_(this), 77 observer_manager_(this),
79 env_controller_(new EnvInputStateController), 78 env_controller_(new EnvInputStateController),
80 event_targeter_(new WindowTargeter),
81 repost_event_factory_(this), 79 repost_event_factory_(this),
82 held_event_factory_(this) { 80 held_event_factory_(this) {
83 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); 81 ui::GestureRecognizer::Get()->AddGestureEventHelper(this);
84 Env::GetInstance()->AddObserver(this); 82 Env::GetInstance()->AddObserver(this);
85 if (Env::GetInstance()->mode() == Env::Mode::MUS) 83 if (Env::GetInstance()->mode() == Env::Mode::MUS)
86 mus_mouse_location_updater_ = base::MakeUnique<MusMouseLocationUpdater>(); 84 mus_mouse_location_updater_ = base::MakeUnique<MusMouseLocationUpdater>();
87 } 85 }
88 86
89 WindowEventDispatcher::~WindowEventDispatcher() { 87 WindowEventDispatcher::~WindowEventDispatcher() {
90 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); 88 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor");
91 Env::GetInstance()->RemoveObserver(this); 89 Env::GetInstance()->RemoveObserver(this);
92 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this); 90 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this);
93 } 91 }
94 92
95 ui::EventTargeter* WindowEventDispatcher::GetDefaultEventTargeter() {
96 return event_targeter_.get();
97 }
98
99 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) { 93 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) {
100 DCHECK(event->type() == ui::ET_MOUSE_PRESSED || 94 DCHECK(event->type() == ui::ET_MOUSE_PRESSED ||
101 event->type() == ui::ET_GESTURE_TAP_DOWN || 95 event->type() == ui::ET_GESTURE_TAP_DOWN ||
102 event->type() == ui::ET_TOUCH_PRESSED); 96 event->type() == ui::ET_TOUCH_PRESSED);
103 // We allow for only one outstanding repostable event. This is used 97 // We allow for only one outstanding repostable event. This is used
104 // in exiting context menus. A dropped repost request is allowed. 98 // in exiting context menus. A dropped repost request is allowed.
105 if (event->type() == ui::ET_MOUSE_PRESSED) { 99 if (event->type() == ui::ET_MOUSE_PRESSED) {
106 held_repostable_event_.reset(new ui::MouseEvent( 100 held_repostable_event_.reset(new ui::MouseEvent(
107 *event->AsMouseEvent(), static_cast<aura::Window*>(event->target()), 101 *event->AsMouseEvent(), static_cast<aura::Window*>(event->target()),
108 window())); 102 window()));
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 void WindowEventDispatcher::SetNativeCapture() { 409 void WindowEventDispatcher::SetNativeCapture() {
416 host_->SetCapture(); 410 host_->SetCapture();
417 } 411 }
418 412
419 void WindowEventDispatcher::ReleaseNativeCapture() { 413 void WindowEventDispatcher::ReleaseNativeCapture() {
420 host_->ReleaseCapture(); 414 host_->ReleaseCapture();
421 } 415 }
422 416
423 //////////////////////////////////////////////////////////////////////////////// 417 ////////////////////////////////////////////////////////////////////////////////
424 // WindowEventDispatcher, ui::EventProcessor implementation: 418 // WindowEventDispatcher, ui::EventProcessor implementation:
425 ui::EventTarget* WindowEventDispatcher::GetRootForEvent(ui::Event* event) { 419 ui::EventTarget* WindowEventDispatcher::GetRootTarget() {
426 if (Env::GetInstance()->mode() == Env::Mode::LOCAL) 420 return window();
427 return window();
428
429 if (!event->target())
430 return window();
431
432 ui::EventTarget* target = event->target();
433 ui::EventTarget* ancestor_with_targeter = target;
434 for (ui::EventTarget* ancestor = target->GetParentTarget(); ancestor;
435 ancestor = ancestor->GetParentTarget()) {
436 if (ancestor->GetEventTargeter())
437 ancestor_with_targeter = ancestor;
438 if (ancestor == window())
439 break;
440 }
441
442 if (ancestor_with_targeter != target && event->IsLocatedEvent()) {
443 gfx::Point location = event->AsLocatedEvent()->location();
444 gfx::Point root_location = event->AsLocatedEvent()->root_location();
445 Window::ConvertPointToTarget(static_cast<Window*>(target),
446 static_cast<Window*>(ancestor_with_targeter),
447 &location);
448 Window::ConvertPointToTarget(static_cast<Window*>(target),
449 static_cast<Window*>(ancestor_with_targeter),
450 &root_location);
451 event->AsLocatedEvent()->set_location(location);
452 event->AsLocatedEvent()->set_root_location(root_location);
453 }
454 return ancestor_with_targeter;
455 } 421 }
456 422
457 void WindowEventDispatcher::OnEventProcessingStarted(ui::Event* event) { 423 void WindowEventDispatcher::OnEventProcessingStarted(ui::Event* event) {
458 // The held events are already in |window()|'s coordinate system. So it is 424 // The held events are already in |window()|'s coordinate system. So it is
459 // not necessary to apply the transform to convert from the host's 425 // not necessary to apply the transform to convert from the host's
460 // coordinate system to |window()|'s coordinate system. 426 // coordinate system to |window()|'s coordinate system.
461 if (event->IsLocatedEvent() && !is_dispatched_held_event(*event)) 427 if (event->IsLocatedEvent() && !is_dispatched_held_event(*event))
462 TransformEventForDeviceScaleFactor(static_cast<ui::LocatedEvent*>(event)); 428 TransformEventForDeviceScaleFactor(static_cast<ui::LocatedEvent*>(event));
463 429
464 if (mus_mouse_location_updater_) 430 if (mus_mouse_location_updater_)
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 870 }
905 871
906 // This flag is set depending on the gestures recognized in the call above, 872 // This flag is set depending on the gestures recognized in the call above,
907 // and needs to propagate with the forwarded event. 873 // and needs to propagate with the forwarded event.
908 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); 874 event->set_may_cause_scrolling(orig_event.may_cause_scrolling());
909 875
910 return PreDispatchLocatedEvent(target, event); 876 return PreDispatchLocatedEvent(target, event);
911 } 877 }
912 878
913 } // namespace aura 879 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698