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

Unified Diff: ui/base/events/event_dispatcher.h

Issue 10916210: events: Inlcude the event-phase and event-result in Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/events/event_dispatcher.h
diff --git a/ui/base/events/event_dispatcher.h b/ui/base/events/event_dispatcher.h
index 48aa5d4691b287b721dc1821ed9f5c80ec870ea2..13181245741cbf40d5ae739e572652f87f50d8be 100644
--- a/ui/base/events/event_dispatcher.h
+++ b/ui/base/events/event_dispatcher.h
@@ -39,9 +39,12 @@ class UI_EXPORT EventDispatcher {
EventHandlerList list;
target->GetPreTargetHandlers(&list);
ProcessPreTargetList(&list);
+ dispatcher.set_phase(EP_PRETARGET);
int result = DispatchEventToEventHandlers(list, event);
- if (result & ER_CONSUMED)
+ if (result & ER_CONSUMED) {
+ dispatcher.set_phase(EP_COMPLETE);
Ben Goodger (Google) 2012/09/10 18:07:14 it would be nice to find a way to do this with a s
sadrul 2012/09/10 18:35:24 Done.
return result;
+ }
// If the event hasn't been consumed, trigger the default handler. Note that
// even if the event has already been handled (i.e. return result has
@@ -49,18 +52,26 @@ class UI_EXPORT EventDispatcher {
// this layer, however it should not be processed in the next layer of
// abstraction.
if (CanDispatchToTarget(target)) {
+ dispatcher.set_phase(EP_TARGET);
result |= DispatchEventToSingleHandler(target, event);
- if (result & ER_CONSUMED)
+ dispatcher.set_result(event->result() | result);
+ if (result & ER_CONSUMED) {
+ dispatcher.set_phase(EP_COMPLETE);
return result;
+ }
}
- if (!CanDispatchToTarget(target))
+ if (!CanDispatchToTarget(target)) {
+ dispatcher.set_phase(EP_COMPLETE);
return result;
+ }
list.clear();
target->GetPostTargetHandlers(&list);
ProcessPostTargetList(&list);
+ dispatcher.set_phase(EP_POSTTARGET);
result |= DispatchEventToEventHandlers(list, event);
+ dispatcher.set_phase(EP_COMPLETE);
return result;
}
@@ -68,9 +79,11 @@ class UI_EXPORT EventDispatcher {
template<class T>
int DispatchEventToEventHandlers(EventHandlerList& list, T* event) {
int result = ER_UNHANDLED;
+ Event::DispatcherApi dispatcher(event);
for (EventHandlerList::const_iterator it = list.begin(),
end = list.end(); it != end; ++it) {
result |= DispatchEventToSingleHandler((*it), event);
+ dispatcher.set_result(event->result() | result);
if (result & ER_CONSUMED)
return result;
}

Powered by Google App Engine
This is Rietveld 408576698