Index: content/public/android/java/src/org/chromium/content/browser/TouchEventSynthesizer.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/TouchEventSynthesizer.java b/content/public/android/java/src/org/chromium/content/browser/TouchEventSynthesizer.java |
index 2dd88b9861e516c4a42e2d3a1c9fb1cbd2fdc264..710f1f15a4ebf6524cc0ff7259ad96b71d633d38 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/TouchEventSynthesizer.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/TouchEventSynthesizer.java |
@@ -27,7 +27,8 @@ public class TouchEventSynthesizer { |
private final ContentViewCore mContentViewCore; |
private final PointerProperties[] mPointerProperties; |
private final PointerCoords[] mPointerCoords; |
- private long mDownTime; |
+ private long mDownTimeInMs; |
+ private double mDownTimestampInS; |
jdduke (slow)
2014/01/03 18:24:30
We shouldn't need two times here. The provided ti
Dominik Grewe
2014/01/06 11:46:07
Done.
|
TouchEventSynthesizer(ContentViewCore contentViewCore) { |
mContentViewCore = contentViewCore; |
@@ -54,14 +55,22 @@ public class TouchEventSynthesizer { |
} |
@CalledByNative |
- void inject(int action, int pointerCount) { |
- long time = SystemClock.uptimeMillis(); |
+ void inject(int action, int pointerCount, double timestampInS) { |
+ long timeInMs; |
jdduke (slow)
2014/01/03 18:24:30
Instead of taking a double |timeStampInS|, just ha
Dominik Grewe
2014/01/06 11:46:07
Done.
|
+ if (action == ACTION_START) { |
+ timeInMs = SystemClock.uptimeMillis(); |
+ mDownTimeInMs = timeInMs; |
+ mDownTimestampInS = timestampInS; |
+ } else { |
+ // Compute time using the provided timestamp. |
+ double timestampDelta = timestampInS - mDownTimestampInS; |
+ timeInMs = mDownTimeInMs + (long)(timestampDelta * 1000.0); |
+ } |
switch (action) { |
case ACTION_START: { |
- mDownTime = time; |
MotionEvent event = MotionEvent.obtain( |
- mDownTime, time, MotionEvent.ACTION_DOWN, 1, |
+ mDownTimeInMs, timeInMs, MotionEvent.ACTION_DOWN, 1, |
mPointerProperties, mPointerCoords, |
0, 0, 1, 1, 0, 0, 0, 0); |
mContentViewCore.onTouchEvent(event); |
@@ -69,8 +78,9 @@ public class TouchEventSynthesizer { |
if (pointerCount > 1) { |
event = MotionEvent.obtain( |
- mDownTime, time, MotionEvent.ACTION_POINTER_DOWN, |
- pointerCount, mPointerProperties, mPointerCoords, |
+ mDownTimeInMs, timeInMs, |
+ MotionEvent.ACTION_POINTER_DOWN, pointerCount, |
+ mPointerProperties, mPointerCoords, |
0, 0, 1, 1, 0, 0, 0, 0); |
mContentViewCore.onTouchEvent(event); |
event.recycle(); |
@@ -78,7 +88,7 @@ public class TouchEventSynthesizer { |
break; |
} |
case ACTION_MOVE: { |
- MotionEvent event = MotionEvent.obtain(mDownTime, time, |
+ MotionEvent event = MotionEvent.obtain(mDownTimeInMs, timeInMs, |
MotionEvent.ACTION_MOVE, |
pointerCount, mPointerProperties, mPointerCoords, |
0, 0, 1, 1, 0, 0, 0, 0); |
@@ -88,7 +98,7 @@ public class TouchEventSynthesizer { |
} |
case ACTION_CANCEL: { |
MotionEvent event = MotionEvent.obtain( |
- mDownTime, time, MotionEvent.ACTION_CANCEL, 1, |
+ mDownTimeInMs, timeInMs, MotionEvent.ACTION_CANCEL, 1, |
mPointerProperties, mPointerCoords, |
0, 0, 1, 1, 0, 0, 0, 0); |
mContentViewCore.onTouchEvent(event); |
@@ -98,7 +108,7 @@ public class TouchEventSynthesizer { |
case ACTION_END: { |
if (pointerCount > 1) { |
MotionEvent event = MotionEvent.obtain( |
- mDownTime, time, MotionEvent.ACTION_POINTER_UP, |
+ mDownTimeInMs, timeInMs, MotionEvent.ACTION_POINTER_UP, |
pointerCount, mPointerProperties, mPointerCoords, |
0, 0, 1, 1, 0, 0, 0, 0); |
mContentViewCore.onTouchEvent(event); |
@@ -106,7 +116,7 @@ public class TouchEventSynthesizer { |
} |
MotionEvent event = MotionEvent.obtain( |
- mDownTime, time, MotionEvent.ACTION_UP, 1, |
+ mDownTimeInMs, timeInMs, MotionEvent.ACTION_UP, 1, |
mPointerProperties, mPointerCoords, |
0, 0, 1, 1, 0, 0, 0, 0); |
mContentViewCore.onTouchEvent(event); |