From cfa734a359083a518b0c37391c1a37d8c07c28a5 Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Tue, 22 Feb 2011 11:19:02 -0500 Subject: Scroll layers on touch events. Send the LayerAndroid unique id and the current scroll rect during motion up events and all touch events. Bug: 3442108 Change-Id: I09a18ded7b7ce15984f61a329b2666f7cfadd0dc --- core/java/android/webkit/WebView.java | 16 ++++++++++++++++ core/java/android/webkit/WebViewCore.java | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 74e6628d66ef..634aeed24cf6 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -5531,6 +5531,8 @@ public class WebView extends AbsoluteLayout ted.mPoints[0] = new Point(contentX, contentY); ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; + ted.mNativeLayer = nativeScrollableLayer( + contentX, contentY, ted.mNativeLayerRect, null); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); if (mDeferTouchProcess) { // still needs to set them for compute deltaX/Y @@ -5575,6 +5577,8 @@ public class WebView extends AbsoluteLayout ted.mPoints[0] = new Point(contentX, contentY); ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; + ted.mNativeLayer = mScrollingLayer; + ted.mNativeLayerRect.set(mScrollingLayerRect); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); mLastSentTouchTime = eventTime; if (mDeferTouchProcess) { @@ -5754,6 +5758,8 @@ public class WebView extends AbsoluteLayout ted.mPoints[0] = new Point(contentX, contentY); ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; + ted.mNativeLayer = mScrollingLayer; + ted.mNativeLayerRect.set(mScrollingLayerRect); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); } mLastTouchUpTime = eventTime; @@ -5773,6 +5779,9 @@ public class WebView extends AbsoluteLayout ted.mPoints[0] = new Point(contentX, contentY); ted.mMetaState = ev.getMetaState(); ted.mReprocess = mDeferTouchProcess; + ted.mNativeLayer = nativeScrollableLayer( + contentX, contentY, + ted.mNativeLayerRect, null); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); } else if (mPreventDefault != PREVENT_DEFAULT_YES){ mZoomManager.handleDoubleTap(mLastTouchX, mLastTouchY); @@ -6004,6 +6013,8 @@ public class WebView extends AbsoluteLayout ted.mPoints = new Point[1]; ted.mPoints[0] = new Point(x, y); ted.mAction = MotionEvent.ACTION_CANCEL; + ted.mNativeLayer = nativeScrollableLayer( + x, y, ted.mNativeLayerRect, null); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); mPreventDefault = PREVENT_DEFAULT_IGNORE; } @@ -7161,6 +7172,9 @@ public class WebView extends AbsoluteLayout // simplicity for now, we don't set it. ted.mMetaState = 0; ted.mReprocess = mDeferTouchProcess; + ted.mNativeLayer = nativeScrollableLayer( + ted.mPoints[0].x, ted.mPoints[0].y, + ted.mNativeLayerRect, null); mWebViewCore.sendMessage(EventHub.TOUCH_EVENT, ted); } else if (mPreventDefault != PREVENT_DEFAULT_YES) { mTouchMode = TOUCH_DONE_MODE; @@ -8033,6 +8047,8 @@ public class WebView extends AbsoluteLayout touchUpData.mNode = node; touchUpData.mX = x; touchUpData.mY = y; + touchUpData.mNativeLayer = nativeScrollableLayer( + x, y, touchUpData.mNativeLayerRect, null); mWebViewCore.sendMessage(EventHub.TOUCH_UP, touchUpData); } diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index da4ce43835dc..fb0f61ce595e 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -778,6 +778,8 @@ final class WebViewCore { int mNode; int mX; int mY; + int mNativeLayer; + Rect mNativeLayerRect = new Rect(); } static class TouchHighlightData { @@ -821,6 +823,8 @@ final class WebViewCore { int mMetaState; boolean mReprocess; MotionEvent mMotionEvent; + int mNativeLayer; + Rect mNativeLayerRect = new Rect(); } static class GeolocationPermissionsData { @@ -1304,6 +1308,10 @@ final class WebViewCore { case TOUCH_UP: TouchUpData touchUpData = (TouchUpData) msg.obj; + if (touchUpData.mNativeLayer != 0) { + nativeScrollLayer(touchUpData.mNativeLayer, + touchUpData.mNativeLayerRect); + } nativeTouchUp(touchUpData.mMoveGeneration, touchUpData.mFrame, touchUpData.mNode, touchUpData.mX, touchUpData.mY); @@ -1318,6 +1326,10 @@ final class WebViewCore { xArray[c] = ted.mPoints[c].x; yArray[c] = ted.mPoints[c].y; } + if (ted.mNativeLayer != 0) { + nativeScrollLayer(ted.mNativeLayer, + ted.mNativeLayerRect); + } Message.obtain( mWebView.mPrivateHandler, WebView.PREVENT_TOUCH_ID, @@ -2702,4 +2714,5 @@ final class WebViewCore { int slop); private native void nativeAutoFillForm(int queryId); + private native void nativeScrollLayer(int layer, Rect rect); } -- cgit v1.2.3-59-g8ed1b