From d7b95aa702f9d3f8694b1a066ae7ef44879ffb1a Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Mon, 21 Sep 2009 13:27:02 -0400 Subject: [PATCH] Always interpret (0,0) scrolls as top of title bar. Move the specialized code in NEW_PICTURE_MSG_ID to setContentScrollTo so that a scroll to (0,0), whether a result of a NEW_PICTURE_MSG_ID or from an initial layout (or otherwise) is treated as scrolling to the top of the content, including showing the title bar. Scrolls to (0,1) will trigger code that animates the title bar off screen. Change-Id: Ia6db6d4620dea2bfe62407c4394a8ead38501b2f --- core/java/android/webkit/WebView.java | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 910157818779b..95e2e43b2808e 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2505,16 +2505,26 @@ public class WebView extends AbsoluteLayout // saved scroll position, it is ok to skip this. return false; } - int vx = contentToViewX(cx); - int vy = contentToViewY(cy); + int vx; + int vy; + if ((cx | cy) == 0) { + // If the page is being scrolled to (0,0), do not add in the title + // bar's height, and simply scroll to (0,0). (The only other work + // in contentToView_ is to multiply, so this would not change 0.) + vx = 0; + vy = 0; + } else { + vx = contentToViewX(cx); + vy = contentToViewY(cy); + } // Log.d(LOGTAG, "content scrollTo [" + cx + " " + cy + "] view=[" + // vx + " " + vy + "]"); // Some mobile sites attempt to scroll the title bar off the page by - // scrolling to (0,0) or (0,1). If we are at the top left corner of the + // scrolling to (0,1). If we are at the top left corner of the // page, assume this is an attempt to scroll off the title bar, and // animate the title bar off screen slowly enough that the user can see // it. - if (cx == 0 && cy <= 1 && mScrollX == 0 && mScrollY == 0) { + if (cx == 0 && cy == 1 && mScrollX == 0 && mScrollY == 0) { pinScrollTo(vx, vy, true, SLIDE_TITLE_DURATION); // Since we are animating, we have not yet reached the desired // scroll position. Do not return true to request another attempt @@ -4862,17 +4872,8 @@ public class WebView extends AbsoluteLayout mMaxZoomScale = restoreState.mMaxScale; } setNewZoomScale(mLastScale, false); - if (getTitleHeight() != 0 && restoreState.mScrollX == 0 - && restoreState.mScrollY == 0) { - // If there is a title bar, and the page is being - // restored to (0,0), do not scroll the title bar - // off the page. - abortAnimation(); - scrollTo(0,0); - } else { - setContentScrollTo(restoreState.mScrollX, - restoreState.mScrollY); - } + setContentScrollTo(restoreState.mScrollX, + restoreState.mScrollY); if (useWideViewport && settings.getLoadWithOverviewMode()) { if (restoreState.mViewScale == 0