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

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: comments addressed, tests changed 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
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
29 EventTarget* target = targeter->FindTargetForEvent(root, event_to_dispatch); 28 OnEventProcessingStarted(event_to_dispatch);
29 EventTarget* target = NULL;
30 if (!event_to_dispatch->handled())
31 target = targeter->FindTargetForEvent(root, event_to_dispatch);
tdanderson 2014/09/23 21:30:27 Another option would be to have EventTargeter::Fin
sadrul 2014/09/25 16:12:00 I think we should do this here, and not require al
tdanderson 2014/09/25 17:11:58 Sounds good, left as-is then.
32
30 EventDispatchDetails details; 33 EventDispatchDetails details;
31 while (target) { 34 while (target) {
32 details = DispatchEvent(target, event_to_dispatch); 35 details = DispatchEvent(target, event_to_dispatch);
33 36
34 if (!dispatch_original_event) { 37 if (!dispatch_original_event) {
35 if (event_to_dispatch->stopped_propagation()) 38 if (event_to_dispatch->stopped_propagation())
36 event->StopPropagation(); 39 event->StopPropagation();
37 else if (event_to_dispatch->handled()) 40 else if (event_to_dispatch->handled())
38 event->SetHandled(); 41 event->SetHandled();
39 } 42 }
40 43
41 if (details.dispatcher_destroyed) 44 if (details.dispatcher_destroyed)
42 return details; 45 return details;
43 46
44 if (details.target_destroyed || event->handled()) 47 if (details.target_destroyed || event->handled())
45 break; 48 break;
46 49
47 target = targeter->FindNextBestTarget(target, event_to_dispatch); 50 target = targeter->FindNextBestTarget(target, event_to_dispatch);
48 } 51 }
49 52
50 OnEventProcessingFinished(event); 53 OnEventProcessingFinished(event);
51 return details; 54 return details;
52 } 55 }
53 56
54 void EventProcessor::PrepareEventForDispatch(Event* event) { 57 void EventProcessor::OnEventProcessingStarted(Event* event) {
55 } 58 }
56 59
57 void EventProcessor::OnEventProcessingFinished(Event* event) { 60 void EventProcessor::OnEventProcessingFinished(Event* event) {
58 } 61 }
59 62
60 } // namespace ui 63 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698