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

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: . 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
« no previous file with comments | « ui/base/events/event_constants.h ('k') | ui/base/events/event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..55cab111d8a80ab3ca11e34e015c8095b451c50f 100644
--- a/ui/base/events/event_dispatcher.h
+++ b/ui/base/events/event_dispatcher.h
@@ -33,12 +33,13 @@ class UI_EXPORT EventDispatcher {
if (!target || !target->CanAcceptEvents())
return ER_UNHANDLED;
- Event::DispatcherApi dispatcher(event);
- dispatcher.set_target(target);
+ ScopedDispatchHelper dispatch_helper(event);
+ dispatch_helper.set_target(target);
EventHandlerList list;
target->GetPreTargetHandlers(&list);
ProcessPreTargetList(&list);
+ dispatch_helper.set_phase(EP_PRETARGET);
int result = DispatchEventToEventHandlers(list, event);
if (result & ER_CONSUMED)
return result;
@@ -49,7 +50,9 @@ class UI_EXPORT EventDispatcher {
// this layer, however it should not be processed in the next layer of
// abstraction.
if (CanDispatchToTarget(target)) {
+ dispatch_helper.set_phase(EP_TARGET);
result |= DispatchEventToSingleHandler(target, event);
+ dispatch_helper.set_result(event->result() | result);
if (result & ER_CONSUMED)
return result;
}
@@ -60,17 +63,29 @@ class UI_EXPORT EventDispatcher {
list.clear();
target->GetPostTargetHandlers(&list);
ProcessPostTargetList(&list);
+ dispatch_helper.set_phase(EP_POSTTARGET);
result |= DispatchEventToEventHandlers(list, event);
return result;
}
private:
+ class UI_EXPORT ScopedDispatchHelper : public NON_EXPORTED_BASE(
+ Event::DispatcherApi) {
+ public:
+ explicit ScopedDispatchHelper(Event* event);
+ virtual ~ScopedDispatchHelper();
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedDispatchHelper);
+ };
+
template<class T>
int DispatchEventToEventHandlers(EventHandlerList& list, T* event) {
int result = ER_UNHANDLED;
+ Event::DispatcherApi dispatch_helper(event);
for (EventHandlerList::const_iterator it = list.begin(),
end = list.end(); it != end; ++it) {
result |= DispatchEventToSingleHandler((*it), event);
+ dispatch_helper.set_result(event->result() | result);
if (result & ER_CONSUMED)
return result;
}
« no previous file with comments | « ui/base/events/event_constants.h ('k') | ui/base/events/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698