Merge "b/3133123 Pass touch point ids to WebKit." into honeycomb

This commit is contained in:
Huahui Wu
2011-01-13 17:02:33 -08:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 4 deletions

View File

@@ -1550,6 +1550,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return "MotionEvent{" + Integer.toHexString(System.identityHashCode(this)) return "MotionEvent{" + Integer.toHexString(System.identityHashCode(this))
+ " pointerId=" + getPointerId(0)
+ " action=" + actionToString(mAction) + " action=" + actionToString(mAction)
+ " x=" + getX() + " x=" + getX()
+ " y=" + getY() + " y=" + getY()
@@ -1567,6 +1568,8 @@ public final class MotionEvent extends InputEvent implements Parcelable {
+ " edgeFlags=0x" + Integer.toHexString(mEdgeFlags) + " edgeFlags=0x" + Integer.toHexString(mEdgeFlags)
+ " device=" + mDeviceId + " device=" + mDeviceId
+ " source=0x" + Integer.toHexString(mSource) + " source=0x" + Integer.toHexString(mSource)
+ (getPointerCount() > 1 ?
" pointerId2=" + getPointerId(1) + " x2=" + getX(2) + " y2=" + getY(2) : "")
+ "}"; + "}";
} }

View File

@@ -5471,6 +5471,8 @@ public class WebView extends AbsoluteLayout
if (shouldForwardTouchEvent()) { if (shouldForwardTouchEvent()) {
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mAction = action; ted.mAction = action;
ted.mIds = new int[1];
ted.mIds[0] = ev.getPointerId(0);
ted.mPoints = new Point[1]; ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY); ted.mPoints[0] = new Point(contentX, contentY);
ted.mMetaState = ev.getMetaState(); ted.mMetaState = ev.getMetaState();
@@ -5513,6 +5515,8 @@ public class WebView extends AbsoluteLayout
|| eventTime - mLastSentTouchTime > mCurrentTouchInterval)) { || eventTime - mLastSentTouchTime > mCurrentTouchInterval)) {
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mAction = action; ted.mAction = action;
ted.mIds = new int[1];
ted.mIds[0] = ev.getPointerId(0);
ted.mPoints = new Point[1]; ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY); ted.mPoints[0] = new Point(contentX, contentY);
ted.mMetaState = ev.getMetaState(); ted.mMetaState = ev.getMetaState();
@@ -5682,6 +5686,8 @@ public class WebView extends AbsoluteLayout
// pass the touch events from UI thread to WebCore thread // pass the touch events from UI thread to WebCore thread
if (shouldForwardTouchEvent()) { if (shouldForwardTouchEvent()) {
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mIds = new int[1];
ted.mIds[0] = ev.getPointerId(0);
ted.mAction = action; ted.mAction = action;
ted.mPoints = new Point[1]; ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY); ted.mPoints[0] = new Point(contentX, contentY);
@@ -5699,6 +5705,8 @@ public class WebView extends AbsoluteLayout
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
if (inFullScreenMode() || mDeferTouchProcess) { if (inFullScreenMode() || mDeferTouchProcess) {
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mIds = new int[1];
ted.mIds[0] = ev.getPointerId(0);
ted.mAction = WebViewCore.ACTION_DOUBLETAP; ted.mAction = WebViewCore.ACTION_DOUBLETAP;
ted.mPoints = new Point[1]; ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(contentX, contentY); ted.mPoints[0] = new Point(contentX, contentY);
@@ -5832,8 +5840,10 @@ public class WebView extends AbsoluteLayout
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mAction = ev.getAction() & MotionEvent.ACTION_MASK; ted.mAction = ev.getAction() & MotionEvent.ACTION_MASK;
final int count = ev.getPointerCount(); final int count = ev.getPointerCount();
ted.mIds = new int[count];
ted.mPoints = new Point[count]; ted.mPoints = new Point[count];
for (int c = 0; c < count; c++) { for (int c = 0; c < count; c++) {
ted.mIds[c] = ev.getPointerId(c);
int x = viewToContentX((int) ev.getX(c) + mScrollX); int x = viewToContentX((int) ev.getX(c) + mScrollX);
int y = viewToContentY((int) ev.getY(c) + mScrollY); int y = viewToContentY((int) ev.getY(c) + mScrollY);
ted.mPoints[c] = new Point(x, y); ted.mPoints[c] = new Point(x, y);
@@ -5927,6 +5937,8 @@ public class WebView extends AbsoluteLayout
mWebViewCore.removeMessages(EventHub.TOUCH_EVENT); mWebViewCore.removeMessages(EventHub.TOUCH_EVENT);
} }
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mIds = new int[1];
ted.mIds[0] = 0;
ted.mPoints = new Point[1]; ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(x, y); ted.mPoints[0] = new Point(x, y);
ted.mAction = MotionEvent.ACTION_CANCEL; ted.mAction = MotionEvent.ACTION_CANCEL;
@@ -7054,6 +7066,8 @@ public class WebView extends AbsoluteLayout
if (inFullScreenMode() || mDeferTouchProcess) { if (inFullScreenMode() || mDeferTouchProcess) {
TouchEventData ted = new TouchEventData(); TouchEventData ted = new TouchEventData();
ted.mAction = WebViewCore.ACTION_LONGPRESS; ted.mAction = WebViewCore.ACTION_LONGPRESS;
ted.mIds = new int[1];
ted.mIds[0] = 0;
ted.mPoints = new Point[1]; ted.mPoints = new Point[1];
ted.mPoints[0] = new Point(viewToContentX((int) mLastTouchX + mScrollX), ted.mPoints[0] = new Point(viewToContentX((int) mLastTouchX + mScrollX),
viewToContentY((int) mLastTouchY + mScrollY)); viewToContentY((int) mLastTouchY + mScrollY));

View File

@@ -562,8 +562,8 @@ final class WebViewCore {
private native void nativeTouchUp(int touchGeneration, private native void nativeTouchUp(int touchGeneration,
int framePtr, int nodePtr, int x, int y); int framePtr, int nodePtr, int x, int y);
private native boolean nativeHandleTouchEvent(int action, int[] x, int[] y, private native boolean nativeHandleTouchEvent(int action, int[] idArray,
int count, int metaState); int[] xArray, int[] yArray, int count, int metaState);
private native void nativeUpdateFrameCache(); private native void nativeUpdateFrameCache();
@@ -828,6 +828,7 @@ final class WebViewCore {
static class TouchEventData { static class TouchEventData {
int mAction; int mAction;
int[] mIds; // Ids of the touch points
Point[] mPoints; Point[] mPoints;
int mMetaState; int mMetaState;
boolean mReprocess; boolean mReprocess;
@@ -1336,8 +1337,8 @@ final class WebViewCore {
mWebView.mPrivateHandler, mWebView.mPrivateHandler,
WebView.PREVENT_TOUCH_ID, WebView.PREVENT_TOUCH_ID,
ted.mAction, ted.mAction,
nativeHandleTouchEvent(ted.mAction, xArray, nativeHandleTouchEvent(ted.mAction, ted.mIds,
yArray, count, ted.mMetaState) ? 1 : 0, xArray, yArray, count, ted.mMetaState) ? 1 : 0,
ted.mReprocess ? ted : null).sendToTarget(); ted.mReprocess ? ted : null).sendToTarget();
break; break;
} }