Merge change 24747 into eclair

* changes:
  Use floor to calculate the range to avoid the rounding error triggered scrollbar. The worst case is that you can never scroll down to the last pixel. The old special case can cause problem when getViewWidth/Height have changed which do not match mLastXXSent any more.
This commit is contained in:
Android (Google) Code Review
2009-09-14 12:27:40 -04:00

View File

@@ -2049,12 +2049,9 @@ public class WebView extends AbsoluteLayout
protected int computeHorizontalScrollRange() { protected int computeHorizontalScrollRange() {
if (mDrawHistory) { if (mDrawHistory) {
return mHistoryWidth; return mHistoryWidth;
} else if (mLastWidthSent == mContentWidth) {
// special case to avoid rounding error. Otherwise we may get a
// faked scrollbar sometimes.
return getViewWidth();
} else { } else {
return contentToViewDimension(mContentWidth); // to avoid rounding error caused unnecessary scrollbar, use floor
return (int) Math.floor(mContentWidth * mActualScale);
} }
} }
@@ -2066,18 +2063,8 @@ public class WebView extends AbsoluteLayout
if (mDrawHistory) { if (mDrawHistory) {
return mHistoryHeight; return mHistoryHeight;
} else { } else {
int height; // to avoid rounding error caused unnecessary scrollbar, use floor
// special case to avoid rounding error. Otherwise we may get a return (int) Math.floor(mContentHeight * mActualScale);
// faked scrollbar sometimes.
if (mLastHeightSent == mContentHeight) {
height = getViewHeight();
} else {
height = contentToViewDimension(mContentHeight);
}
if (mFindIsUp) {
height += FIND_HEIGHT;
}
return height;
} }
} }
@@ -4582,8 +4569,7 @@ public class WebView extends AbsoluteLayout
} }
private int computeMaxScrollY() { private int computeMaxScrollY() {
int maxContentH = contentToViewDimension(mContentHeight) int maxContentH = computeVerticalScrollRange() + getTitleHeight();
+ getTitleHeight();
return Math.max(maxContentH - getHeight(), 0); return Math.max(maxContentH - getHeight(), 0);
} }
@@ -5023,8 +5009,8 @@ public class WebView extends AbsoluteLayout
int measuredWidth = widthSize; int measuredWidth = widthSize;
// Grab the content size from WebViewCore. // Grab the content size from WebViewCore.
int contentHeight = Math.round(mContentHeight * mActualScale); int contentHeight = contentToViewDimension(mContentHeight);
int contentWidth = Math.round(mContentWidth * mActualScale); int contentWidth = contentToViewDimension(mContentWidth);
// Log.d(LOGTAG, "------- measure " + heightMode); // Log.d(LOGTAG, "------- measure " + heightMode);