b/3133123 Pass touch point ids to WebKit.
This is the CL in framework side and it needs the WebKit part CL:
https://android-git.corp.google.com/g/#change,89627
Change-Id: I11d4ffa29fa106d918332e6983090b06726ebd36
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index e81aa98..db2cd50 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1550,6 +1550,7 @@
@Override
public String toString() {
return "MotionEvent{" + Integer.toHexString(System.identityHashCode(this))
+ + " pointerId=" + getPointerId(0)
+ " action=" + actionToString(mAction)
+ " x=" + getX()
+ " y=" + getY()
@@ -1567,6 +1568,8 @@
+ " edgeFlags=0x" + Integer.toHexString(mEdgeFlags)
+ " device=" + mDeviceId
+ " source=0x" + Integer.toHexString(mSource)
+ + (getPointerCount() > 1 ?
+ " pointerId2=" + getPointerId(1) + " x2=" + getX(2) + " y2=" + getY(2) : "")
+ "}";
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 4addb08..8beca07 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -5455,6 +5455,8 @@
if (shouldForwardTouchEvent()) {
TouchEventData ted = new TouchEventData();
ted.mAction = action;
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
ted.mMetaState = ev.getMetaState();
@@ -5497,6 +5499,8 @@
|| eventTime - mLastSentTouchTime > mCurrentTouchInterval)) {
TouchEventData ted = new TouchEventData();
ted.mAction = action;
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
ted.mMetaState = ev.getMetaState();
@@ -5666,6 +5670,8 @@
// pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent()) {
TouchEventData ted = new TouchEventData();
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
ted.mAction = action;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
@@ -5683,6 +5689,8 @@
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
if (inFullScreenMode() || mDeferTouchProcess) {
TouchEventData ted = new TouchEventData();
+ ted.mIds = new int[1];
+ ted.mIds[0] = ev.getPointerId(0);
ted.mAction = WebViewCore.ACTION_DOUBLETAP;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY);
@@ -5816,8 +5824,10 @@
TouchEventData ted = new TouchEventData();
ted.mAction = ev.getAction() & MotionEvent.ACTION_MASK;
final int count = ev.getPointerCount();
+ ted.mIds = new int[count];
ted.mPoints = new Point[count];
for (int c = 0; c < count; c++) {
+ ted.mIds[c] = ev.getPointerId(c);
int x = viewToContentX((int) ev.getX(c) + mScrollX);
int y = viewToContentY((int) ev.getY(c) + mScrollY);
ted.mPoints[c] = new Point(x, y);
@@ -5911,6 +5921,8 @@
mWebViewCore.removeMessages(EventHub.TOUCH_EVENT);
}
TouchEventData ted = new TouchEventData();
+ ted.mIds = new int[1];
+ ted.mIds[0] = 0;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(x, y);
ted.mAction = MotionEvent.ACTION_CANCEL;
@@ -7038,6 +7050,8 @@
if (inFullScreenMode() || mDeferTouchProcess) {
TouchEventData ted = new TouchEventData();
ted.mAction = WebViewCore.ACTION_LONGPRESS;
+ ted.mIds = new int[1];
+ ted.mIds[0] = 0;
ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(viewToContentX((int) mLastTouchX + mScrollX),
viewToContentY((int) mLastTouchY + mScrollY));
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index c874160..0abf7d4 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -562,8 +562,8 @@
private native void nativeTouchUp(int touchGeneration,
int framePtr, int nodePtr, int x, int y);
- private native boolean nativeHandleTouchEvent(int action, int[] x, int[] y,
- int count, int metaState);
+ private native boolean nativeHandleTouchEvent(int action, int[] idArray,
+ int[] xArray, int[] yArray, int count, int metaState);
private native void nativeUpdateFrameCache();
@@ -828,6 +828,7 @@
static class TouchEventData {
int mAction;
+ int[] mIds; // Ids of the touch points
Point[] mPoints;
int mMetaState;
boolean mReprocess;
@@ -1331,8 +1332,8 @@
mWebView.mPrivateHandler,
WebView.PREVENT_TOUCH_ID,
ted.mAction,
- nativeHandleTouchEvent(ted.mAction, xArray,
- yArray, count, ted.mMetaState) ? 1 : 0,
+ nativeHandleTouchEvent(ted.mAction, ted.mIds,
+ xArray, yArray, count, ted.mMetaState) ? 1 : 0,
ted.mReprocess ? ted : null).sendToTarget();
break;
}