Skip to content

Commit 5f3c08a

Browse files
committed
fix monkey scrolling crash
bug:6336994 Depends on external/webkit change: https://android-git.corp.google.com/g/#/c/186186/ Change-Id: Ib019ca68f6e57f98e30b022949c624bab4695294
1 parent 8ccfbdd commit 5f3c08a

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

core/java/android/webkit/WebViewClassic.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,7 +3735,7 @@ public void computeScroll() {
37353735
private void scrollLayerTo(int x, int y) {
37363736
int dx = mScrollingLayerRect.left - x;
37373737
int dy = mScrollingLayerRect.top - y;
3738-
if (dx == 0 && dy == 0) {
3738+
if ((dx == 0 && dy == 0) || mNativeClass == 0) {
37393739
return;
37403740
}
37413741
if (mSelectingText) {
@@ -3756,7 +3756,7 @@ private void scrollLayerTo(int x, int y) {
37563756
mEditTextContentBounds.offset(dx, dy);
37573757
mAutoCompletePopup.resetRect();
37583758
}
3759-
nativeScrollLayer(mCurrentScrollingLayerId, x, y);
3759+
nativeScrollLayer(mNativeClass, mCurrentScrollingLayerId, x, y);
37603760
mScrollingLayerRect.left = x;
37613761
mScrollingLayerRect.top = y;
37623762
mWebViewCore.sendMessage(WebViewCore.EventHub.SCROLL_LAYER, mCurrentScrollingLayerId,
@@ -5699,10 +5699,13 @@ void onPinchToZoomAnimationEnd(ScaleGestureDetector detector) {
56995699
// See if there is a layer at x, y and switch to TOUCH_DRAG_LAYER_MODE if a
57005700
// layer is found.
57015701
private void startScrollingLayer(float x, float y) {
5702+
if (mNativeClass == 0)
5703+
return;
5704+
57025705
int contentX = viewToContentX((int) x + getScrollX());
57035706
int contentY = viewToContentY((int) y + getScrollY());
5704-
mCurrentScrollingLayerId = nativeScrollableLayer(contentX, contentY,
5705-
mScrollingLayerRect, mScrollingLayerBounds);
5707+
mCurrentScrollingLayerId = nativeScrollableLayer(mNativeClass,
5708+
contentX, contentY, mScrollingLayerRect, mScrollingLayerBounds);
57065709
if (mCurrentScrollingLayerId != 0) {
57075710
mTouchMode = TOUCH_DRAG_LAYER_MODE;
57085711
}
@@ -5808,8 +5811,12 @@ private void handleTouchEventCommon(MotionEvent event, int action, int x, int y)
58085811
data.mX = contentX;
58095812
data.mY = contentY;
58105813
data.mNativeLayerRect = new Rect();
5811-
data.mNativeLayer = nativeScrollableLayer(
5812-
contentX, contentY, data.mNativeLayerRect, null);
5814+
if (mNativeClass != 0) {
5815+
data.mNativeLayer = nativeScrollableLayer(mNativeClass,
5816+
contentX, contentY, data.mNativeLayerRect, null);
5817+
} else {
5818+
data.mNativeLayer = 0;
5819+
}
58135820
data.mSlop = viewToContentDimension(mNavSlop);
58145821
removeTouchHighlight();
58155822
if (!mBlockWebkitViewMessages) {
@@ -8604,16 +8611,17 @@ private native boolean nativeSetBaseLayer(int nativeInstance,
86048611
private native void nativeUseHardwareAccelSkia(boolean enabled);
86058612

86068613
// Returns a pointer to the scrollable LayerAndroid at the given point.
8607-
private native int nativeScrollableLayer(int x, int y, Rect scrollRect,
8614+
private native int nativeScrollableLayer(int nativeInstance, int x, int y, Rect scrollRect,
86088615
Rect scrollBounds);
86098616
/**
86108617
* Scroll the specified layer.
8618+
* @param nativeInstance Native WebView instance
86118619
* @param layer Id of the layer to scroll, as determined by nativeScrollableLayer.
86128620
* @param newX Destination x position to which to scroll.
86138621
* @param newY Destination y position to which to scroll.
86148622
* @return True if the layer is successfully scrolled.
86158623
*/
8616-
private native boolean nativeScrollLayer(int layer, int newX, int newY);
8624+
private native boolean nativeScrollLayer(int nativeInstance, int layer, int newX, int newY);
86178625
private native void nativeSetIsScrolling(boolean isScrolling);
86188626
private native int nativeGetBackgroundColor();
86198627
native boolean nativeSetProperty(String key, String value);

0 commit comments

Comments
 (0)