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

Side by Side Diff: ui/events/event_processor.cc

Issue 542323002: Convert ui::GestureEvent coordinates during targeting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/events/event_processor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/event_processor.h" 5 #include "ui/events/event_processor.h"
6 6
7 #include "ui/events/event_target.h" 7 #include "ui/events/event_target.h"
8 #include "ui/events/event_targeter.h" 8 #include "ui/events/event_targeter.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) { 12 EventDispatchDetails EventProcessor::OnEventFromSource(Event* event) {
13 EventTarget* root = GetRootTarget(); 13 EventTarget* root = GetRootTarget();
14 CHECK(root); 14 CHECK(root);
15 EventTargeter* targeter = root->GetEventTargeter(); 15 EventTargeter* targeter = root->GetEventTargeter();
16 CHECK(targeter); 16 CHECK(targeter);
17 PrepareEventForDispatch(event);
17 18
18 PrepareEventForDispatch(event); 19 // If |event| is in the process of being dispatched or has already been
19 EventTarget* target = targeter->FindTargetForEvent(root, event); 20 // dispatched, then dispatch a copy of the event instead.
21 bool dispatch_original_event = event->phase() == EP_PREDISPATCH;
22 Event* event_to_dispatch = event;
23 scoped_ptr<Event> event_copy;
24 if (!dispatch_original_event) {
25 event_copy = Event::Clone(*event);
26 event_to_dispatch = event_copy.get();
27 }
20 28
21 // If the event is in the process of being dispatched or has already been 29 EventTarget* target = targeter->FindTargetForEvent(root, event_to_dispatch);
22 // dispatched, then dispatch a copy of the event instead. 30 while (target) {
23 scoped_ptr<Event> event_copy; 31 EventDispatchDetails details = DispatchEvent(target, event_to_dispatch);
24 if (event->phase() != EP_PREDISPATCH)
25 event_copy = Event::Clone(*event);
26 32
27 while (target) { 33 if (!dispatch_original_event) {
28 EventDispatchDetails details; 34 if (event_to_dispatch->stopped_propagation())
29 if (event_copy) {
30 details = DispatchEvent(target, event_copy.get());
31
32 if (event_copy->stopped_propagation())
33 event->StopPropagation(); 35 event->StopPropagation();
34 else if (event_copy->handled()) 36 else if (event_to_dispatch->handled())
35 event->SetHandled(); 37 event->SetHandled();
36 } else {
37 details = DispatchEvent(target, event);
38 } 38 }
39 39
40 if (details.dispatcher_destroyed || 40 if (details.dispatcher_destroyed ||
41 details.target_destroyed || 41 details.target_destroyed ||
42 event->handled()) { 42 event->handled()) {
43 return details; 43 return details;
44 } 44 }
45 45
46 target = targeter->FindNextBestTarget(target, event); 46 target = targeter->FindNextBestTarget(target, event_to_dispatch);
47 } 47 }
48 48
49 return EventDispatchDetails(); 49 return EventDispatchDetails();
50 } 50 }
51 51
52 void EventProcessor::PrepareEventForDispatch(Event* event) { 52 void EventProcessor::PrepareEventForDispatch(Event* event) {
53 } 53 }
54 54
55 } // namespace ui 55 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/events/event_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698