From d82bc5158c764bdd30b7d22f32258ad3c2c0c0f6 Mon Sep 17 00:00:00 2001 From: Grace Kloba Date: Wed, 9 Sep 2009 13:30:15 -0700 Subject: [PATCH] Avoid the rounding error, as Math.round(Math.round(viewWidth * mInvActualScale) * mActualScale) not necessary to be viewWidth, we special case when the content exactly fit in the view case. Fix http://b/issue?id=2099889 --- core/java/android/webkit/WebView.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 018fc64cd626f..8446475234317 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2049,6 +2049,10 @@ public class WebView extends AbsoluteLayout protected int computeHorizontalScrollRange() { if (mDrawHistory) { return mHistoryWidth; + } else if (mLastWidthSent == mContentWidth) { + // special case to avoid rounding error. Otherwise we may get a + // faked scrollbar sometimes. + return getViewWidth(); } else { return contentToViewDimension(mContentWidth); } @@ -2062,7 +2066,14 @@ public class WebView extends AbsoluteLayout if (mDrawHistory) { return mHistoryHeight; } else { - int height = contentToViewDimension(mContentHeight); + int height; + // special case to avoid rounding error. Otherwise we may get a + // faked scrollbar sometimes. + if (mLastHeightSent == mContentHeight) { + height = getViewHeight(); + } else { + height = contentToViewDimension(mContentHeight); + } if (mFindIsUp) { height += FIND_HEIGHT; }