Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 bool ViewAndroid::SendMouseEventToClient(ViewClient* client, | 303 bool ViewAndroid::SendMouseEventToClient(ViewClient* client, |
| 304 const MotionEventAndroid& event) { | 304 const MotionEventAndroid& event) { |
| 305 return client->OnMouseEvent(event); | 305 return client->OnMouseEvent(event); |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool ViewAndroid::OnMouseWheelEvent(const MotionEventAndroid& event) { | |
| 309 return HitTest(base::Bind(&ViewAndroid::SendMouseWheelEventToClient), event); | |
| 310 } | |
| 311 | |
| 312 bool ViewAndroid::SendMouseWheelEventToClient(ViewClient* client, | |
|
boliu
2017/03/28 16:28:42
add "// static" to all static methods
Jinsuk Kim
2017/03/28 23:17:45
Done.
| |
| 313 const MotionEventAndroid& event) { | |
| 314 return client->OnMouseWheelEvent(event); | |
| 315 } | |
| 316 | |
| 308 bool ViewAndroid::HitTest(ViewClientCallback send_to_client, | 317 bool ViewAndroid::HitTest(ViewClientCallback send_to_client, |
| 309 const MotionEventAndroid& event) { | 318 const MotionEventAndroid& event) { |
| 310 if (client_ && send_to_client.Run(client_, event)) | 319 if (client_ && send_to_client.Run(client_, event)) |
| 311 return true; | 320 return true; |
| 312 | 321 |
| 313 if (!children_.empty()) { | 322 if (!children_.empty()) { |
| 314 std::unique_ptr<MotionEventAndroid> e( | 323 std::unique_ptr<MotionEventAndroid> e( |
| 315 event.Offset(-layout_params_.x, -layout_params_.y)); | 324 event.Offset(-layout_params_.x, -layout_params_.y)); |
| 316 | 325 |
| 317 // Match from back to front for hit testing. | 326 // Match from back to front for hit testing. |
| 318 for (auto* child : base::Reversed(children_)) { | 327 for (auto* child : base::Reversed(children_)) { |
| 319 bool matched = child->layout_params_.match_parent; | 328 bool matched = child->layout_params_.match_parent; |
| 320 if (!matched) { | 329 if (!matched) { |
| 321 gfx::Rect bound(child->layout_params_.x, child->layout_params_.y, | 330 gfx::Rect bound(child->layout_params_.x, child->layout_params_.y, |
| 322 child->layout_params_.width, | 331 child->layout_params_.width, |
| 323 child->layout_params_.height); | 332 child->layout_params_.height); |
| 324 matched = bound.Contains(e->GetX(0), e->GetY(0)); | 333 matched = bound.Contains(e->GetX(0), e->GetY(0)); |
| 325 } | 334 } |
| 326 if (matched && child->HitTest(send_to_client, *e)) | 335 if (matched && child->HitTest(send_to_client, *e)) |
| 327 return true; | 336 return true; |
| 328 } | 337 } |
| 329 } | 338 } |
| 330 return false; | 339 return false; |
| 331 } | 340 } |
| 332 | 341 |
| 333 } // namespace ui | 342 } // namespace ui |
| OLD | NEW |