Chromium Code Reviews| Index: ui/events/event_processor.cc |
| diff --git a/ui/events/event_processor.cc b/ui/events/event_processor.cc |
| index 3077cc85b168aea483a9e506021af80b5e64375e..437a08e8223ce247b87e5b72a919f283fa67885e 100644 |
| --- a/ui/events/event_processor.cc |
| +++ b/ui/events/event_processor.cc |
| @@ -18,8 +18,31 @@ EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) { |
| PrepareEventForDispatch(event); |
| EventTarget* target = targeter->FindTargetForEvent(root, event); |
| + // Create a copy of |event| if it is currently being processed by another |
| + // EventProcessor. |
|
sadrul
2014/09/04 15:45:06
If the event is in the process of being dispatched
tdanderson
2014/09/04 17:19:03
Done.
|
| + scoped_ptr<Event> event_copy; |
| + if (event->phase() != EP_PREDISPATCH) |
| + event_copy = Event::Clone(*event); |
| + |
| while (target) { |
| - EventDispatchDetails details = DispatchEvent(target, event); |
| + EventDispatchDetails details; |
| + if (event_copy) { |
| + // The state of |event| (such as its target and phase) should remain |
| + // unchanged once we have finished our nested processing, with the |
| + // exception of whether or not the event was handled. Thus dispatch |
| + // |event_copy| instead of |event|. |
|
sadrul
2014/09/04 15:45:06
You don't need this comment. The comment above in
tdanderson
2014/09/04 17:19:03
Done.
|
| + details = DispatchEvent(target, event_copy.get()); |
| + |
| + if (event_copy->stopped_propagation()) |
| + event->StopPropagation(); |
| + else if (event_copy->handled()) |
| + event->SetHandled(); |
| + } else { |
| + // |this| is the only EventProcessor currently processing |event|, so |
| + // copying the event prior to dispatch is unnecessary. |
| + details = DispatchEvent(target, event); |
| + } |
| + |
| if (details.dispatcher_destroyed || |
| details.target_destroyed || |
| event->handled()) { |