am 8a878dde: Merge "Pass WebKit scrollbar mode to Java. When scrollbar is alwaysOff, don\'t trigger scroll." into froyo

Merge commit '8a878dde9d15f75446bb5ca3137fccef8426ddd7' into froyo-plus-aosp

* commit '8a878dde9d15f75446bb5ca3137fccef8426ddd7':
  Pass WebKit scrollbar mode to Java. When scrollbar
This commit is contained in:
Grace Kloba
2010-04-14 16:26:55 -07:00
committed by Android Git Automerger
2 changed files with 33 additions and 4 deletions

View File

@@ -540,10 +540,10 @@ public class WebView extends AbsoluteLayout
static final int FIND_AGAIN = 126; static final int FIND_AGAIN = 126;
static final int CENTER_FIT_RECT = 127; static final int CENTER_FIT_RECT = 127;
static final int REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID = 128; static final int REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID = 128;
static final int SET_SCROLLBAR_MODES = 129;
private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID; private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
private static final int LAST_PACKAGE_MSG_ID private static final int LAST_PACKAGE_MSG_ID = SET_SCROLLBAR_MODES;
= REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID;
static final String[] HandlerPrivateDebugString = { static final String[] HandlerPrivateDebugString = {
"REMEMBER_PASSWORD", // = 1; "REMEMBER_PASSWORD", // = 1;
@@ -586,7 +586,8 @@ public class WebView extends AbsoluteLayout
"RETURN_LABEL", // = 125; "RETURN_LABEL", // = 125;
"FIND_AGAIN", // = 126; "FIND_AGAIN", // = 126;
"CENTER_FIT_RECT", // = 127; "CENTER_FIT_RECT", // = 127;
"REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID" // = 128; "REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID", // = 128;
"SET_SCROLLBAR_MODES" // = 129;
}; };
// If the site doesn't use the viewport meta tag to specify the viewport, // If the site doesn't use the viewport meta tag to specify the viewport,
@@ -657,6 +658,14 @@ public class WebView extends AbsoluteLayout
private static final int DRAW_EXTRAS_SELECTION = 2; private static final int DRAW_EXTRAS_SELECTION = 2;
private static final int DRAW_EXTRAS_CURSOR_RING = 3; private static final int DRAW_EXTRAS_CURSOR_RING = 3;
// keep this in sync with WebCore:ScrollbarMode in WebKit
private static final int SCROLLBAR_AUTO = 0;
private static final int SCROLLBAR_ALWAYSOFF = 1;
// as we auto fade scrollbar, this is ignored.
private static final int SCROLLBAR_ALWAYSON = 2;
private int mHorizontalScrollBarMode = SCROLLBAR_AUTO;
private int mVerticalScrollBarMode = SCROLLBAR_AUTO;
// Used to match key downs and key ups // Used to match key downs and key ups
private boolean mGotKeyDown; private boolean mGotKeyDown;
@@ -2277,6 +2286,8 @@ public class WebView extends AbsoluteLayout
protected int computeHorizontalScrollRange() { protected int computeHorizontalScrollRange() {
if (mDrawHistory) { if (mDrawHistory) {
return mHistoryWidth; return mHistoryWidth;
} else if (mHorizontalScrollBarMode == SCROLLBAR_ALWAYSOFF) {
return computeHorizontalScrollExtent();
} else { } else {
// to avoid rounding error caused unnecessary scrollbar, use floor // to avoid rounding error caused unnecessary scrollbar, use floor
return (int) Math.floor(mContentWidth * mActualScale); return (int) Math.floor(mContentWidth * mActualScale);
@@ -2287,6 +2298,8 @@ public class WebView extends AbsoluteLayout
protected int computeVerticalScrollRange() { protected int computeVerticalScrollRange() {
if (mDrawHistory) { if (mDrawHistory) {
return mHistoryHeight; return mHistoryHeight;
} else if (mVerticalScrollBarMode == SCROLLBAR_ALWAYSOFF) {
return computeVerticalScrollExtent();
} else { } else {
// to avoid rounding error caused unnecessary scrollbar, use floor // to avoid rounding error caused unnecessary scrollbar, use floor
return (int) Math.floor(mContentHeight * mActualScale); return (int) Math.floor(mContentHeight * mActualScale);
@@ -5024,7 +5037,9 @@ public class WebView extends AbsoluteLayout
if (settings.supportZoom() if (settings.supportZoom()
&& settings.getBuiltInZoomControls() && settings.getBuiltInZoomControls()
&& !getZoomButtonsController().isVisible() && !getZoomButtonsController().isVisible()
&& mMinZoomScale < mMaxZoomScale) { && mMinZoomScale < mMaxZoomScale
&& (mHorizontalScrollBarMode != SCROLLBAR_ALWAYSOFF
|| mVerticalScrollBarMode != SCROLLBAR_ALWAYSOFF)) {
mZoomButtonsController.setVisible(true); mZoomButtonsController.setVisible(true);
int count = settings.getDoubleTapToastCount(); int count = settings.getDoubleTapToastCount();
if (mInZoomOverview && count > 0) { if (mInZoomOverview && count > 0) {
@@ -6641,6 +6656,11 @@ public class WebView extends AbsoluteLayout
centerFitRect(r.left, r.top, r.width(), r.height()); centerFitRect(r.left, r.top, r.width(), r.height());
break; break;
case SET_SCROLLBAR_MODES:
mHorizontalScrollBarMode = msg.arg1;
mVerticalScrollBarMode = msg.arg2;
break;
default: default:
super.handleMessage(msg); super.handleMessage(msg);
break; break;

View File

@@ -2453,6 +2453,15 @@ final class WebViewCore {
new Rect(x, y, x + width, y + height)).sendToTarget(); new Rect(x, y, x + width, y + height)).sendToTarget();
} }
// called by JNI
private void setScrollbarModes(int hMode, int vMode) {
if (mWebView == null) {
return;
}
mWebView.mPrivateHandler.obtainMessage(WebView.SET_SCROLLBAR_MODES,
hMode, vMode).sendToTarget();
}
private native void nativePause(); private native void nativePause();
private native void nativeResume(); private native void nativeResume();
private native void nativeFreeMemory(); private native void nativeFreeMemory();