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

Unified Diff: ui/events/android/motion_event_android.cc

Issue 2896993002: Route OnDragEvent through ViewAndroid tree (Closed)
Patch Set: +ui/base Created 3 years, 7 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
« no previous file with comments | « ui/events/android/motion_event_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/android/motion_event_android.cc
diff --git a/ui/events/android/motion_event_android.cc b/ui/events/android/motion_event_android.cc
index 3768d8c609e0435966467a7ef58fd432645b423d..4d4584201968b47f5aab37dd825d0dcf0b51d13a 100644
--- a/ui/events/android/motion_event_android.cc
+++ b/ui/events/android/motion_event_android.cc
@@ -261,12 +261,16 @@ MotionEventAndroid::MotionEventAndroid(const MotionEventAndroid& e)
cached_pointers_[1] = e.cached_pointers_[1];
}
-std::unique_ptr<MotionEventAndroid> MotionEventAndroid::Offset(float x,
- float y) const {
+std::unique_ptr<MotionEventAndroid> MotionEventAndroid::CreateFor(
+ const gfx::PointF& point) const {
std::unique_ptr<MotionEventAndroid> event(new MotionEventAndroid(*this));
- event->cached_pointers_[0] = OffsetCachedPointer(cached_pointers_[0], x, y);
- if (cached_pointer_count_ > 1)
- event->cached_pointers_[1] = OffsetCachedPointer(cached_pointers_[1], x, y);
+ if (cached_pointer_count_ > 1) {
+ gfx::Vector2dF diff = event->cached_pointers_[1].position -
+ event->cached_pointers_[0].position;
+ event->cached_pointers_[1] =
+ CreateCachedPointer(cached_pointers_[1], point + diff);
+ }
+ event->cached_pointers_[0] = CreateCachedPointer(cached_pointers_[0], point);
return event;
}
@@ -475,14 +479,12 @@ MotionEventAndroid::CachedPointer MotionEventAndroid::FromAndroidPointer(
return result;
}
-MotionEventAndroid::CachedPointer MotionEventAndroid::OffsetCachedPointer(
+MotionEventAndroid::CachedPointer MotionEventAndroid::CreateCachedPointer(
const CachedPointer& pointer,
- float x,
- float y) const {
+ const gfx::PointF& point) const {
CachedPointer result;
result.id = pointer.id;
- result.position = gfx::PointF(pointer.position.x() + ToDips(x),
- pointer.position.y() + ToDips(y));
+ result.position = point;
result.touch_major = pointer.touch_major;
result.touch_minor = pointer.touch_minor;
result.orientation = pointer.orientation;
« no previous file with comments | « ui/events/android/motion_event_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698