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

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

Issue 552503003: Introduce EventProcessor::OnEventProcessingStarted() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: two comments from sadrul Created 6 years, 3 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(); 13 EventTarget* root = GetRootTarget();
14 CHECK(root); 14 CHECK(root);
15 EventTargeter* targeter = root->GetEventTargeter(); 15 EventTargeter* targeter = root->GetEventTargeter();
16 CHECK(targeter); 16 CHECK(targeter);
17 PrepareEventForDispatch(event);
18 17
19 // 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
20 // dispatched, then dispatch a copy of the event instead. 19 // dispatched, then dispatch a copy of the event instead.
21 bool dispatch_original_event = event->phase() == EP_PREDISPATCH; 20 bool dispatch_original_event = event->phase() == EP_PREDISPATCH;
22 Event* event_to_dispatch = event; 21 Event* event_to_dispatch = event;
23 scoped_ptr<Event> event_copy; 22 scoped_ptr<Event> event_copy;
24 if (!dispatch_original_event) { 23 if (!dispatch_original_event) {
25 event_copy = Event::Clone(*event); 24 event_copy = Event::Clone(*event);
26 event_to_dispatch = event_copy.get(); 25 event_to_dispatch = event_copy.get();
27 } 26 }
28 27
28 EventDispatchDetails details;
29 OnEventProcessingStarted(event_to_dispatch);
29 EventTarget* target = targeter->FindTargetForEvent(root, event_to_dispatch); 30 EventTarget* target = targeter->FindTargetForEvent(root, event_to_dispatch);
sadrul 2014/09/16 17:16:53 You don't need to find the target if you aren't go
tdanderson 2014/09/23 21:30:27 Yes, good point... also, FindTargetForEvent() may
30 EventDispatchDetails details; 31 while (target && !event_to_dispatch->handled()) {
31 while (target) {
32 details = DispatchEvent(target, event_to_dispatch); 32 details = DispatchEvent(target, event_to_dispatch);
33 33
34 if (!dispatch_original_event) { 34 if (!dispatch_original_event) {
35 if (event_to_dispatch->stopped_propagation()) 35 if (event_to_dispatch->stopped_propagation())
36 event->StopPropagation(); 36 event->StopPropagation();
37 else if (event_to_dispatch->handled()) 37 else if (event_to_dispatch->handled())
38 event->SetHandled(); 38 event->SetHandled();
39 } 39 }
40 40
41 if (details.dispatcher_destroyed) 41 if (details.dispatcher_destroyed)
42 return details; 42 return details;
43 43
44 if (details.target_destroyed || event->handled()) 44 if (details.target_destroyed || event->handled())
45 break; 45 break;
46 46
47 target = targeter->FindNextBestTarget(target, event_to_dispatch); 47 target = targeter->FindNextBestTarget(target, event_to_dispatch);
48 } 48 }
49 49
50 OnEventProcessingFinished(event); 50 OnEventProcessingFinished(event);
51 return details; 51 return details;
52 } 52 }
53 53
54 void EventProcessor::PrepareEventForDispatch(Event* event) { 54 void EventProcessor::OnEventProcessingStarted(Event* event) {
55 } 55 }
56 56
57 void EventProcessor::OnEventProcessingFinished(Event* event) { 57 void EventProcessor::OnEventProcessingFinished(Event* event) {
58 } 58 }
59 59
60 } // namespace ui 60 } // 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