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

Side by Side Diff: ui/android/view_android.cc

Issue 2770613002: Forward GenericMotionEvent to EventForwarder (Closed)
Patch Set: comments Created 3 years, 8 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 | « ui/android/view_android.h ('k') | ui/android/view_android_unittests.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/android/view_android.h" 5 #include "ui/android/view_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool ViewAndroid::SendTouchEventToClient(bool for_touch_handle, 293 bool ViewAndroid::SendTouchEventToClient(bool for_touch_handle,
294 ViewClient* client, 294 ViewClient* client,
295 const MotionEventAndroid& event) { 295 const MotionEventAndroid& event) {
296 return client->OnTouchEvent(event, for_touch_handle); 296 return client->OnTouchEvent(event, for_touch_handle);
297 } 297 }
298 298
299 bool ViewAndroid::OnMouseEvent(const MotionEventAndroid& event) { 299 bool ViewAndroid::OnMouseEvent(const MotionEventAndroid& event) {
300 return HitTest(base::Bind(&ViewAndroid::SendMouseEventToClient), event); 300 return HitTest(base::Bind(&ViewAndroid::SendMouseEventToClient), event);
301 } 301 }
302 302
303 // static
303 bool ViewAndroid::SendMouseEventToClient(ViewClient* client, 304 bool ViewAndroid::SendMouseEventToClient(ViewClient* client,
304 const MotionEventAndroid& event) { 305 const MotionEventAndroid& event) {
305 return client->OnMouseEvent(event); 306 return client->OnMouseEvent(event);
306 } 307 }
307 308
309 // static
310 bool ViewAndroid::OnMouseWheelEvent(const MotionEventAndroid& event) {
311 return HitTest(base::Bind(&ViewAndroid::SendMouseWheelEventToClient), event);
312 }
313
314 // static
315 bool ViewAndroid::SendMouseWheelEventToClient(ViewClient* client,
316 const MotionEventAndroid& event) {
317 return client->OnMouseWheelEvent(event);
318 }
319
308 bool ViewAndroid::HitTest(ViewClientCallback send_to_client, 320 bool ViewAndroid::HitTest(ViewClientCallback send_to_client,
309 const MotionEventAndroid& event) { 321 const MotionEventAndroid& event) {
310 if (client_ && send_to_client.Run(client_, event)) 322 if (client_ && send_to_client.Run(client_, event))
311 return true; 323 return true;
312 324
313 if (!children_.empty()) { 325 if (!children_.empty()) {
314 std::unique_ptr<MotionEventAndroid> e( 326 std::unique_ptr<MotionEventAndroid> e(
315 event.Offset(-layout_params_.x, -layout_params_.y)); 327 event.Offset(-layout_params_.x, -layout_params_.y));
316 328
317 // Match from back to front for hit testing. 329 // Match from back to front for hit testing.
318 for (auto* child : base::Reversed(children_)) { 330 for (auto* child : base::Reversed(children_)) {
319 bool matched = child->layout_params_.match_parent; 331 bool matched = child->layout_params_.match_parent;
320 if (!matched) { 332 if (!matched) {
321 gfx::Rect bound(child->layout_params_.x, child->layout_params_.y, 333 gfx::Rect bound(child->layout_params_.x, child->layout_params_.y,
322 child->layout_params_.width, 334 child->layout_params_.width,
323 child->layout_params_.height); 335 child->layout_params_.height);
324 matched = bound.Contains(e->GetX(0), e->GetY(0)); 336 matched = bound.Contains(e->GetX(0), e->GetY(0));
325 } 337 }
326 if (matched && child->HitTest(send_to_client, *e)) 338 if (matched && child->HitTest(send_to_client, *e))
327 return true; 339 return true;
328 } 340 }
329 } 341 }
330 return false; 342 return false;
331 } 343 }
332 344
333 } // namespace ui 345 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/view_android.h ('k') | ui/android/view_android_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698