From 21a97ef9f2d907f910f4a5f5cff6f321aca825d3 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Tue, 16 Nov 2010 09:59:40 -0500 Subject: [PATCH] make tap initiated scrolls more reliable Programmatic scrolls fail when the scroll has not had a chance to start. In this case, the current position equals the last position; the logic erroneously cancels the scrolls, assuming that in this case the scroll has finished. Also, new scrolls should cancel the old velocity whether they are animated or not. This has a companion change in external/webkit, which is not required, but makes tap initiated scrolls work more reliably. bug:1331125 bug:3099569 Change-Id: I80ae8e8cdefce2d8d09532f79d1b2e1ae4738fa6 --- core/java/android/webkit/WebView.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 14dbfe22e3895..06800d516edd6 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2384,7 +2384,6 @@ public class WebView extends AbsoluteLayout Rect sendOurVisibleRect() { if (mZoomManager.isPreventingWebkitUpdates()) return mLastVisibleRectSent; - Rect rect = new Rect(); calcOurContentVisibleRect(rect); // Rect.equals() checks for null input. @@ -2937,7 +2936,8 @@ public class WebView extends AbsoluteLayout postInvalidate(); // So we draw again if (oldX != mScrollX || oldY != mScrollY) { onScrollChanged(mScrollX, mScrollY, oldX, oldY); - } else { + } else if (mScroller.getStartX() != mScrollX + || mScroller.getStartY() != mScrollY) { abortAnimation(); mPrivateHandler.removeMessages(RESUME_WEBCORE_PRIORITY); WebViewCore.resumePriority(); @@ -2970,6 +2970,7 @@ public class WebView extends AbsoluteLayout if ((dx | dy) == 0) { return false; } + abortAnimation(); if (animate) { // Log.d(LOGTAG, "startScroll: " + dx + " " + dy); mScroller.startScroll(mScrollX, mScrollY, dx, dy, @@ -2977,7 +2978,6 @@ public class WebView extends AbsoluteLayout awakenScrollBars(mScroller.getDuration()); invalidate(); } else { - abortAnimation(); // just in case scrollTo(x, y); } return true;