diff options
| -rw-r--r-- | core/java/android/view/MotionEvent.java | 4 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 100 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 28 |
3 files changed, 46 insertions, 86 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 72263a72c109..88f59d4bdd21 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -2881,10 +2881,6 @@ public final class MotionEvent extends InputEvent implements Parcelable { msg.append(", id[").append(i).append("]=").append(getPointerId(i)); msg.append(", x[").append(i).append("]=").append(getX(i)); msg.append(", y[").append(i).append("]=").append(getY(i)); - msg.append(", pressure[").append(i).append("]=").append(getPressure(i)); - msg.append(", touchMajor[").append(i).append("]=").append(getTouchMajor(i)); - msg.append(", touchMinor[").append(i).append("]=").append(getTouchMinor(i)); - msg.append(", orientation[").append(i).append("]=").append(getOrientation(i)); msg.append(", toolType[").append(i).append("]=").append( toolTypeToString(getToolType(i))); } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index ffa52d10060c..7ba86a58a13a 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3467,40 +3467,6 @@ public class WebView extends AbsoluteLayout return Math.min(duration, MAX_DURATION); } - - // Helper to build a TouchEventData object from a MotionEvent object. - // A few fields are allocated now but will be set later: - // mAction, mPoints and mPointsInView. - private static TouchEventData buildTouchFromEvent(MotionEvent ev) { - TouchEventData ted = new TouchEventData(); - ted.mAction = ev.getActionMasked(); - ted.mEventTime = ev.getEventTime(); - - final int count = ev.getPointerCount(); - ted.mIds = new int[count]; - ted.mPoints = new Point[count]; - ted.mPointsInView = new Point[count]; - ted.mPressures = new float[count]; - ted.mTouchMajor = new int[count]; - ted.mTouchMinor = new int[count]; - ted.mOrientation = new float[count]; - for (int c = 0; c < count; c++) { - ted.mIds[c] = ev.getPointerId(c); - ted.mPressures[c] = ev.getPressure(c); - ted.mTouchMajor[c] = (int) ev.getTouchMajor(c); - ted.mTouchMinor[c] = (int) ev.getTouchMinor(c); - ted.mOrientation[c] = ev.getOrientation(c); - } - - if (ted.mAction == MotionEvent.ACTION_POINTER_DOWN - || ted.mAction == MotionEvent.ACTION_POINTER_UP) { - ted.mActionIndex = ev.getActionIndex(); - } - ted.mMetaState = ev.getMetaState(); - - return ted; - } - // helper to pin the scrollBy parameters (already in view coordinates) // returns true if the scroll was changed private boolean pinScrollBy(int dx, int dy, boolean animate, int animationDuration) { @@ -5899,10 +5865,15 @@ public class WebView extends AbsoluteLayout } // pass the touch events from UI thread to WebCore thread if (shouldForwardTouchEvent()) { - TouchEventData ted = buildTouchFromEvent(ev); + 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.mPointsInView = new Point[1]; ted.mPointsInView[0] = new Point(x, y); + ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; ted.mNativeLayer = nativeScrollableLayer( contentX, contentY, ted.mNativeLayerRect, null); @@ -5944,10 +5915,15 @@ public class WebView extends AbsoluteLayout // pass the touch events from UI thread to WebCore thread if (shouldForwardTouchEvent() && mConfirmMove && (firstMove || eventTime - mLastSentTouchTime > mCurrentTouchInterval)) { - TouchEventData ted = buildTouchFromEvent(ev); + 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.mPointsInView = new Point[1]; ted.mPointsInView[0] = new Point(x, y); + ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; ted.mNativeLayer = mScrollingLayer; ted.mNativeLayerRect.set(mScrollingLayerRect); @@ -6117,10 +6093,15 @@ public class WebView extends AbsoluteLayout if (!isFocused()) requestFocus(); // pass the touch events from UI thread to WebCore thread if (shouldForwardTouchEvent()) { - TouchEventData ted = buildTouchFromEvent(ev); + 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); + ted.mPointsInView = new Point[1]; ted.mPointsInView[0] = new Point(x, y); + ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; ted.mNativeLayer = mScrollingLayer; ted.mNativeLayerRect.set(mScrollingLayerRect); @@ -6137,10 +6118,15 @@ public class WebView extends AbsoluteLayout mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS); mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); if (inFullScreenMode() || mDeferTouchProcess) { - TouchEventData ted = buildTouchFromEvent(ev); + 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); + ted.mPointsInView = new Point[1]; ted.mPointsInView[0] = new Point(x, y); + ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; ted.mNativeLayer = nativeScrollableLayer( contentX, contentY, @@ -6272,14 +6258,24 @@ public class WebView extends AbsoluteLayout } private void passMultiTouchToWebKit(MotionEvent ev, long sequence) { - TouchEventData ted = buildTouchFromEvent(ev); - for (int c = 0; c < ev.getPointerCount(); c++) { + TouchEventData ted = new TouchEventData(); + ted.mAction = ev.getActionMasked(); + final int count = ev.getPointerCount(); + ted.mIds = new int[count]; + ted.mPoints = new Point[count]; + ted.mPointsInView = 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); ted.mPointsInView[c] = new Point((int) ev.getX(c), (int) ev.getY(c)); } + if (ted.mAction == MotionEvent.ACTION_POINTER_DOWN + || ted.mAction == MotionEvent.ACTION_POINTER_UP) { + ted.mActionIndex = ev.getActionIndex(); + } + ted.mMetaState = ev.getMetaState(); ted.mReprocess = true; ted.mMotionEvent = MotionEvent.obtain(ev); ted.mSequence = sequence; @@ -6353,11 +6349,7 @@ public class WebView extends AbsoluteLayout if (removeEvents) { mWebViewCore.removeMessages(EventHub.TOUCH_EVENT); } - TouchEventData ted = new TouchEventData(); - ted.mAction = MotionEvent.ACTION_CANCEL; - ted.mEventTime = mLastTouchTime; - ted.mMetaState = 0; ted.mIds = new int[1]; ted.mIds[0] = 0; ted.mPoints = new Point[1]; @@ -6366,15 +6358,7 @@ public class WebView extends AbsoluteLayout int viewX = contentToViewX(x) - mScrollX; int viewY = contentToViewY(y) - mScrollY; ted.mPointsInView[0] = new Point(viewX, viewY); - ted.mPressures = new float[1]; - ted.mPressures[0] = 1; - ted.mTouchMajor = new int[1]; - ted.mTouchMajor[0] = 1; - ted.mTouchMinor = new int[1]; - ted.mTouchMinor[0] = 1; - ted.mOrientation = new float[1]; - ted.mOrientation[0] = 0; - + ted.mAction = MotionEvent.ACTION_CANCEL; ted.mNativeLayer = nativeScrollableLayer( x, y, ted.mNativeLayerRect, null); ted.mSequence = mTouchEventQueue.nextTouchSequence(); @@ -8053,7 +8037,6 @@ public class WebView extends AbsoluteLayout if (inFullScreenMode() || mDeferTouchProcess) { TouchEventData ted = new TouchEventData(); ted.mAction = WebViewCore.ACTION_LONGPRESS; - ted.mEventTime = mLastTouchTime; ted.mIds = new int[1]; ted.mIds[0] = 0; ted.mPoints = new Point[1]; @@ -8061,15 +8044,6 @@ public class WebView extends AbsoluteLayout viewToContentY(mLastTouchY + mScrollY)); ted.mPointsInView = new Point[1]; ted.mPointsInView[0] = new Point(mLastTouchX, mLastTouchY); - ted.mPressures = new float[1]; - ted.mPressures[0] = 1; - ted.mTouchMajor = new int[1]; - ted.mTouchMajor[0] = 1; - ted.mTouchMinor = new int[1]; - ted.mTouchMinor[0] = 1; - ted.mOrientation = new float[1]; - ted.mOrientation[0] = 0; - // metaState for long press is tricky. Should it be the // state when the press started or when the press was // released? Or some intermediary key state? For diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 3357220ec28e..4f97066aa381 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -577,10 +577,8 @@ public final class WebViewCore { private native void nativeTouchUp(int touchGeneration, int framePtr, int nodePtr, int x, int y); - private native boolean nativeHandleTouchEvent(int action, long eventTime, - int[] idArray, int[] xArray, int[] yArray, float[] pressureArray, - int[] touchMajorArray, int[] touchMinorArray, float[] orientationArray, - int count, int actionIndex, int metaState); + private native boolean nativeHandleTouchEvent(int action, int[] idArray, + int[] xArray, int[] yArray, int count, int actionIndex, int metaState); private native void nativeUpdateFrameCache(); @@ -835,21 +833,16 @@ public final class WebViewCore { static class TouchEventData { int mAction; - long mEventTime; // Time (in ms) this event was generated. - int[] mIds; // Ids of the touch points. + int[] mIds; // Ids of the touch points Point[] mPoints; - Point[] mPointsInView; // Point coordinates in view axis. - float[] mPressures; // Pressures of the touch points. - int[] mTouchMajor; // Length of the major axis of the touch area. - int[] mTouchMinor; // Length of the minor axis of the touch area. - float[] mOrientation; // The orientation of the touch area. - int mActionIndex; // Associated pointer index for ACTION_POINTER_DOWN/UP. + Point[] mPointsInView; // the point coordinates in view axis. + int mActionIndex; // Associated pointer index for ACTION_POINTER_DOWN/UP int mMetaState; boolean mReprocess; - MotionEvent mMotionEvent; // Only used for multi-touch. + MotionEvent mMotionEvent; int mNativeLayer; Rect mNativeLayerRect = new Rect(); - long mSequence; // For queuing the events. + long mSequence; boolean mNativeResult; } @@ -1358,11 +1351,8 @@ public final class WebViewCore { nativeScrollLayer(ted.mNativeLayer, ted.mNativeLayerRect); } - ted.mNativeResult = nativeHandleTouchEvent( - ted.mAction, ted.mEventTime, ted.mIds, - xArray, yArray, ted.mPressures, - ted.mTouchMajor, ted.mTouchMinor, ted.mOrientation, - count, ted.mActionIndex, ted.mMetaState); + ted.mNativeResult = nativeHandleTouchEvent(ted.mAction, ted.mIds, + xArray, yArray, count, ted.mActionIndex, ted.mMetaState); Message.obtain( mWebView.mPrivateHandler, WebView.PREVENT_TOUCH_ID, |