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

Side by Side Diff: ui/events/event_processor.cc

Issue 2681613002: Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/events/event_processor.h" 5 #include "ui/events/event_processor.h"
6 6
7 #include "ui/events/event_target.h" 7 #include "ui/events/event_target.h"
8 #include "ui/events/event_targeter.h" 8 #include "ui/events/event_targeter.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 EventProcessor::~EventProcessor() {
13 delete event_target_;
sadrul 2017/02/07 04:04:54 This shouldn't be taking ownership of the event-ta
riajiang 2017/02/07 17:42:40 Right! And no longer need this event_target_ anymo
14 }
15
12 EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) { 16 EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) {
13 EventTarget* root = GetRootTarget(); 17 EventTarget* root = GetRootTarget();
14 CHECK(root); 18 CHECK(root);
15 EventTargeter* targeter = root->GetEventTargeter(); 19 EventTargeter* targeter = root->GetEventTargeter();
16 CHECK(targeter); 20 CHECK(targeter);
17 21
18 // If |event| is in the process of being dispatched or has already been 22 // If |event| is in the process of being dispatched or has already been
19 // dispatched, then dispatch a copy of the event instead. 23 // dispatched, then dispatch a copy of the event instead.
20 bool dispatch_original_event = event->phase() == EP_PREDISPATCH; 24 bool dispatch_original_event = event->phase() == EP_PREDISPATCH;
21 Event* event_to_dispatch = event; 25 Event* event_to_dispatch = event;
22 std::unique_ptr<Event> event_copy; 26 std::unique_ptr<Event> event_copy;
23 if (!dispatch_original_event) { 27 if (!dispatch_original_event) {
24 event_copy = Event::Clone(*event); 28 event_copy = Event::Clone(*event);
25 event_to_dispatch = event_copy.get(); 29 event_to_dispatch = event_copy.get();
26 } 30 }
27 31
28 OnEventProcessingStarted(event_to_dispatch); 32 OnEventProcessingStarted(event_to_dispatch);
29 EventTarget* target = NULL; 33 EventTarget* target = nullptr;
30 if (!event_to_dispatch->handled()) 34 if (event_target_) {
35 target = event_target_;
36 event_target_ = nullptr;
37 } else if (!event_to_dispatch->handled()) {
31 target = targeter->FindTargetForEvent(root, event_to_dispatch); 38 target = targeter->FindTargetForEvent(root, event_to_dispatch);
39 }
32 40
33 EventDispatchDetails details; 41 EventDispatchDetails details;
34 while (target) { 42 while (target) {
35 details = DispatchEvent(target, event_to_dispatch); 43 details = DispatchEvent(target, event_to_dispatch);
36 44
37 if (!dispatch_original_event) { 45 if (!dispatch_original_event) {
38 if (event_to_dispatch->stopped_propagation()) 46 if (event_to_dispatch->stopped_propagation())
39 event->StopPropagation(); 47 event->StopPropagation();
40 else if (event_to_dispatch->handled()) 48 else if (event_to_dispatch->handled())
41 event->SetHandled(); 49 event->SetHandled();
(...skipping 12 matching lines...) Expand all
54 return details; 62 return details;
55 } 63 }
56 64
57 void EventProcessor::OnEventProcessingStarted(Event* event) { 65 void EventProcessor::OnEventProcessingStarted(Event* event) {
58 } 66 }
59 67
60 void EventProcessor::OnEventProcessingFinished(Event* event) { 68 void EventProcessor::OnEventProcessingFinished(Event* event) {
61 } 69 }
62 70
63 } // namespace ui 71 } // namespace ui
OLDNEW
« ui/aura/mus/window_tree_client.cc ('K') | « ui/events/event_processor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698