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

Unified Diff: ui/events/event_processor.cc

Issue 2681613002: Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: comments Created 3 years, 10 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
Index: ui/events/event_processor.cc
diff --git a/ui/events/event_processor.cc b/ui/events/event_processor.cc
index 61d2e72138a8dc51beb04f960b19197d715c750d..ef7a0f70d93f1ccfb1e8dc01a693884887892387 100644
--- a/ui/events/event_processor.cc
+++ b/ui/events/event_processor.cc
@@ -10,11 +10,6 @@
namespace ui {
EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) {
- EventTarget* root = GetRootTarget();
- CHECK(root);
- EventTargeter* targeter = root->GetEventTargeter();
- CHECK(targeter);
-
// If |event| is in the process of being dispatched or has already been
// dispatched, then dispatch a copy of the event instead.
bool dispatch_original_event = event->phase() == EP_PREDISPATCH;
@@ -26,9 +21,21 @@ EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) {
}
OnEventProcessingStarted(event_to_dispatch);
- EventTarget* target = NULL;
- if (!event_to_dispatch->handled())
- target = targeter->FindTargetForEvent(root, event_to_dispatch);
+ EventTarget* target = event->target();
+ EventTargeter* targeter = nullptr;
+ if (!event_to_dispatch->handled()) {
+ EventTarget* root = GetRootForEvent(event_to_dispatch);
+ DCHECK(root);
+ targeter = root->GetEventTargeter();
+ if (!targeter) {
+ targeter = GetDefaultEventTargeter();
+ if (!target)
+ target = targeter->FindTargetForEvent(root, event_to_dispatch);
+ } else {
+ target = targeter->FindTargetForEvent(root, event_to_dispatch);
sky 2017/02/15 20:47:17 This duplicates line 33. I think it would be easie
riajiang 2017/02/16 00:34:08 I'm not sure if I understood this. There's a case
sky 2017/02/16 01:03:02 Ah, I see it now. Thanks.
+ }
+ DCHECK(targeter);
+ }
EventDispatchDetails details;
while (target) {

Powered by Google App Engine
This is Rietveld 408576698