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

Side by Side Diff: components/mus/event_dispatcher.cc

Issue 1362793002: Construct and check for mojo::Event's LocationData as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also audit wheel_data and brush_data. Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/mus/event_dispatcher.h" 5 #include "components/mus/event_dispatcher.h"
6 6
7 #include "components/mus/server_view.h" 7 #include "components/mus/server_view.h"
8 #include "components/mus/view_coordinate_conversions.h" 8 #include "components/mus/view_coordinate_conversions.h"
9 #include "components/mus/view_locator.h" 9 #include "components/mus/view_locator.h"
10 #include "components/mus/view_tree_host_impl.h" 10 #include "components/mus/view_tree_host_impl.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 pair.second.flags == event.flags) { 64 pair.second.flags == event.flags) {
65 *accelerator_id = pair.first; 65 *accelerator_id = pair.first;
66 return true; 66 return true;
67 } 67 }
68 } 68 }
69 return false; 69 return false;
70 } 70 }
71 71
72 ServerView* EventDispatcher::FindEventTarget(mojo::Event* event) { 72 ServerView* EventDispatcher::FindEventTarget(mojo::Event* event) {
73 ServerView* focused_view = view_tree_host_->GetFocusedView(); 73 ServerView* focused_view = view_tree_host_->GetFocusedView();
74 if (event->pointer_data) { 74 if (event->pointer_data && event->pointer_data->location) {
75 ServerView* root = view_tree_host_->root_view(); 75 ServerView* root = view_tree_host_->root_view();
76 const gfx::Point root_point( 76 const gfx::Point root_point(
77 static_cast<int>(event->pointer_data->location->x), 77 static_cast<int>(event->pointer_data->location->x),
78 static_cast<int>(event->pointer_data->location->y)); 78 static_cast<int>(event->pointer_data->location->y));
79 ServerView* target = focused_view; 79 ServerView* target = focused_view;
80 if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target || 80 if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target ||
81 !root->Contains(target)) { 81 !root->Contains(target)) {
82 target = FindDeepestVisibleView(root, root_point); 82 target = FindDeepestVisibleView(root, root_point);
83 CHECK(target); 83 CHECK(target);
84 } 84 }
85 const gfx::PointF local_point(ConvertPointFBetweenViews( 85 const gfx::PointF local_point(ConvertPointFBetweenViews(
86 root, target, gfx::PointF(event->pointer_data->location->x, 86 root, target, gfx::PointF(event->pointer_data->location->x,
87 event->pointer_data->location->y))); 87 event->pointer_data->location->y)));
88 event->pointer_data->location->x = local_point.x(); 88 event->pointer_data->location->x = local_point.x();
89 event->pointer_data->location->y = local_point.y(); 89 event->pointer_data->location->y = local_point.y();
90 return target; 90 return target;
91 } 91 }
92 92
93 return focused_view; 93 return focused_view;
94 } 94 }
95 95
96 } // namespace mus 96 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698