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

Side by Side Diff: ui/events/event_processor.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/events/event_processor.h ('k') | ui/events/event_processor_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 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 EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) { 12 EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) {
13 EventTarget* root = GetRootTarget();
14 CHECK(root);
15 EventTargeter* targeter = root->GetEventTargeter();
16 CHECK(targeter);
17
13 // If |event| is in the process of being dispatched or has already been 18 // If |event| is in the process of being dispatched or has already been
14 // dispatched, then dispatch a copy of the event instead. 19 // dispatched, then dispatch a copy of the event instead.
15 bool dispatch_original_event = event->phase() == EP_PREDISPATCH; 20 bool dispatch_original_event = event->phase() == EP_PREDISPATCH;
16 Event* event_to_dispatch = event; 21 Event* event_to_dispatch = event;
17 std::unique_ptr<Event> event_copy; 22 std::unique_ptr<Event> event_copy;
18 if (!dispatch_original_event) { 23 if (!dispatch_original_event) {
19 event_copy = Event::Clone(*event); 24 event_copy = Event::Clone(*event);
20 event_to_dispatch = event_copy.get(); 25 event_to_dispatch = event_copy.get();
21 } 26 }
22 27
23 OnEventProcessingStarted(event_to_dispatch); 28 OnEventProcessingStarted(event_to_dispatch);
24 EventTarget* target = nullptr; 29 EventTarget* target = NULL;
25 EventTargeter* targeter = nullptr; 30 if (!event_to_dispatch->handled())
26 if (!event_to_dispatch->handled()) { 31 target = targeter->FindTargetForEvent(root, event_to_dispatch);
27 target = event->target();
28 EventTarget* root = GetRootForEvent(event_to_dispatch);
29 DCHECK(root);
30 targeter = root->GetEventTargeter();
31 if (!targeter) {
32 targeter = GetDefaultEventTargeter();
33 if (!target)
34 target = targeter->FindTargetForEvent(root, event_to_dispatch);
35 } else {
36 target = targeter->FindTargetForEvent(root, event_to_dispatch);
37 }
38 DCHECK(targeter);
39 }
40 32
41 EventDispatchDetails details; 33 EventDispatchDetails details;
42 while (target) { 34 while (target) {
43 details = DispatchEvent(target, event_to_dispatch); 35 details = DispatchEvent(target, event_to_dispatch);
44 36
45 if (!dispatch_original_event) { 37 if (!dispatch_original_event) {
46 if (event_to_dispatch->stopped_propagation()) 38 if (event_to_dispatch->stopped_propagation())
47 event->StopPropagation(); 39 event->StopPropagation();
48 else if (event_to_dispatch->handled()) 40 else if (event_to_dispatch->handled())
49 event->SetHandled(); 41 event->SetHandled();
(...skipping 12 matching lines...) Expand all
62 return details; 54 return details;
63 } 55 }
64 56
65 void EventProcessor::OnEventProcessingStarted(Event* event) { 57 void EventProcessor::OnEventProcessingStarted(Event* event) {
66 } 58 }
67 59
68 void EventProcessor::OnEventProcessingFinished(Event* event) { 60 void EventProcessor::OnEventProcessingFinished(Event* event) {
69 } 61 }
70 62
71 } // namespace ui 63 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_processor.h ('k') | ui/events/event_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698