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

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: tests added, CL for review 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);
30 EventDispatchDetails details; 28 EventDispatchDetails details;
31 while (target) { 29 if (OnEventProcessingStarted(event)) {
32 details = DispatchEvent(target, event_to_dispatch); 30 EventTarget* target = targeter->FindTargetForEvent(root, event_to_dispatch);
31 while (target) {
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 }
40
41 if (details.dispatcher_destroyed)
42 return details;
43
44 if (details.target_destroyed || event->handled())
45 break;
46
47 target = targeter->FindNextBestTarget(target, event_to_dispatch);
39 } 48 }
40
41 if (details.dispatcher_destroyed)
42 return details;
43
44 if (details.target_destroyed || event->handled())
45 break;
46
47 target = targeter->FindNextBestTarget(target, event_to_dispatch);
48 } 49 }
49 50
50 OnEventProcessingFinished(event); 51 OnEventProcessingFinished(event);
51 return details; 52 return details;
52 } 53 }
53 54
54 void EventProcessor::PrepareEventForDispatch(Event* event) { 55 bool EventProcessor::OnEventProcessingStarted(Event* event) {
56 return true;
55 } 57 }
56 58
57 void EventProcessor::OnEventProcessingFinished(Event* event) { 59 void EventProcessor::OnEventProcessingFinished(Event* event) {
58 } 60 }
59 61
60 } // namespace ui 62 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698