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..589973dc560f89acc099b72a74e5b14d22988ea8 100644 |
| --- a/ui/events/event_processor.cc |
| +++ b/ui/events/event_processor.cc |
| @@ -17,9 +17,28 @@ EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) { |
| PrepareEventForDispatch(event); |
| EventTarget* target = targeter->FindTargetForEvent(root, event); |
| + scoped_ptr<Event> event_copy(Event::Clone(*event)); |
|
sadrul
2014/09/03 16:23:53
I was thinking of something more like this:
scop
tdanderson
2014/09/03 20:20:02
Done.
|
| while (target) { |
| - EventDispatchDetails details = DispatchEvent(target, event); |
| + EventDispatchDetails details; |
| + if (event->phase() != EP_PREDISPATCH) { |
| + // |event| is currently being processed by another EventProcessor, which |
| + // expects the event's state (e.g., target, phase, etc.) to remain |
| + // unchanged once |this| has finished its nested processing (with the |
| + // exception of whether or not the event was handled). Thus dispatch |
| + // a copy of the event instead. |
| + 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); |
|
sadrul
2014/09/03 16:23:53
DispatchEvent() would set the event-phase to POSTD
tdanderson
2014/09/03 20:20:02
Thanks for catching this! In the next patch set I
|
| + } |
| + |
| if (details.dispatcher_destroyed || |
| details.target_destroyed || |
| event->handled()) { |