Index: ui/events/event_processor.cc |
diff --git a/ui/events/event_processor.cc b/ui/events/event_processor.cc |
index 3077cc85b168aea483a9e506021af80b5e64375e..e07d3deeac3672bf70b3a27c22939c4d7a72fe12 100644 |
--- a/ui/events/event_processor.cc |
+++ b/ui/events/event_processor.cc |
@@ -19,7 +19,26 @@ EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) { |
EventTarget* target = targeter->FindTargetForEvent(root, event); |
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. |
+ scoped_ptr<Event> event_copy(event->Clone()); |
+ details = DispatchEvent(target, event_copy.get()); |
sadrul
2014/08/29 21:12:17
I think we want to clone the event before going in
tdanderson
2014/09/02 22:57:09
Done.
|
+ |
+ 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()) { |