Chromium Code Reviews| 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; |
| } |