am 998c6777: Merge "Never show overscroll if the page scrolls at all." into gingerbread

Merge commit '998c67774aa2260ed05a39df45d983feb72e683c' into gingerbread-plus-aosp

* commit '998c67774aa2260ed05a39df45d983feb72e683c':
  Never show overscroll if the page scrolls at all.
This commit is contained in:
Mindy Pereira
2010-10-13 16:34:27 -07:00
committed by Android Git Automerger

View File

@@ -788,6 +788,11 @@ public class WebView extends AbsoluteLayout
private EdgeGlow mEdgeGlowBottom; private EdgeGlow mEdgeGlowBottom;
private EdgeGlow mEdgeGlowLeft; private EdgeGlow mEdgeGlowLeft;
private EdgeGlow mEdgeGlowRight; private EdgeGlow mEdgeGlowRight;
/*
* These manage the delta the user has pulled beyond the edges.
*/
private int mOverscrollDeltaX;
private int mOverscrollDeltaY;
// Used to match key downs and key ups // Used to match key downs and key ups
private boolean mGotKeyDown; private boolean mGotKeyDown;
@@ -2577,17 +2582,59 @@ public class WebView extends AbsoluteLayout
boolean clampedY) { boolean clampedY) {
mInOverScrollMode = false; mInOverScrollMode = false;
int maxX = computeMaxScrollX(); int maxX = computeMaxScrollX();
int maxY = computeMaxScrollY();
if (maxX == 0) { if (maxX == 0) {
// do not over scroll x if the page just fits the screen // do not over scroll x if the page just fits the screen
scrollX = pinLocX(scrollX); scrollX = pinLocX(scrollX);
} else if (scrollX < 0 || scrollX > maxX) { } else if (scrollX < 0 || scrollX > maxX) {
mInOverScrollMode = true; mInOverScrollMode = true;
} }
if (scrollY < 0 || scrollY > computeMaxScrollY()) { if (scrollY < 0 || scrollY > maxY) {
mInOverScrollMode = true; mInOverScrollMode = true;
} }
int oldX = mScrollX;
int oldY = mScrollY;
super.scrollTo(scrollX, scrollY); super.scrollTo(scrollX, scrollY);
// Only show overscroll bars if there was no movement in any direction
// as a result of scrolling.
if (mEdgeGlowTop != null && oldY == mScrollY && oldX == mScrollX) {
// Don't show left/right glows if we fit the whole content.
// Also don't show if there was vertical movement.
if (maxX > 0) {
final int pulledToX = oldX + mOverscrollDeltaX;
if (pulledToX < 0) {
mEdgeGlowLeft.onPull((float) mOverscrollDeltaX / getWidth());
if (!mEdgeGlowRight.isFinished()) {
mEdgeGlowRight.onRelease();
}
} else if (pulledToX > maxX) {
mEdgeGlowRight.onPull((float) mOverscrollDeltaX / getWidth());
if (!mEdgeGlowLeft.isFinished()) {
mEdgeGlowLeft.onRelease();
}
}
mOverscrollDeltaX = 0;
}
if (maxY > 0 || getOverScrollMode() == OVER_SCROLL_ALWAYS) {
final int pulledToY = oldY + mOverscrollDeltaY;
if (pulledToY < 0) {
mEdgeGlowTop.onPull((float) mOverscrollDeltaY / getHeight());
if (!mEdgeGlowBottom.isFinished()) {
mEdgeGlowBottom.onRelease();
}
} else if (pulledToY > maxY) {
mEdgeGlowBottom.onPull((float) mOverscrollDeltaY / getHeight());
if (!mEdgeGlowTop.isFinished()) {
mEdgeGlowTop.onRelease();
}
}
mOverscrollDeltaY = 0;
}
}
} }
/** /**
@@ -5580,42 +5627,16 @@ public class WebView extends AbsoluteLayout
final int oldY = mScrollY; final int oldY = mScrollY;
final int rangeX = computeMaxScrollX(); final int rangeX = computeMaxScrollX();
final int rangeY = computeMaxScrollY(); final int rangeY = computeMaxScrollY();
if (mEdgeGlowTop != null) {
// Save the deltas for overscroll glow.
mOverscrollDeltaX = deltaX;
mOverscrollDeltaY = deltaY;
}
overScrollBy(deltaX, deltaY, oldX, oldY, overScrollBy(deltaX, deltaY, oldX, oldY,
rangeX, rangeY, rangeX, rangeY,
mOverscrollDistance, mOverscrollDistance, true); mOverscrollDistance, mOverscrollDistance, true);
if (mEdgeGlowTop != null) {
// Don't show left/right glows if we fit the whole content.
if (rangeX > 0) {
final int pulledToX = oldX + deltaX;
if (pulledToX < 0) {
mEdgeGlowLeft.onPull((float) deltaX / getWidth());
if (!mEdgeGlowRight.isFinished()) {
mEdgeGlowRight.onRelease();
}
} else if (pulledToX > rangeX) {
mEdgeGlowRight.onPull((float) deltaX / getWidth());
if (!mEdgeGlowLeft.isFinished()) {
mEdgeGlowLeft.onRelease();
}
}
}
if (rangeY > 0 || getOverScrollMode() == OVER_SCROLL_ALWAYS) {
final int pulledToY = oldY + deltaY;
if (pulledToY < 0) {
mEdgeGlowTop.onPull((float) deltaY / getHeight());
if (!mEdgeGlowBottom.isFinished()) {
mEdgeGlowBottom.onRelease();
}
} else if (pulledToY > rangeY) {
mEdgeGlowBottom.onPull((float) deltaY / getHeight());
if (!mEdgeGlowTop.isFinished()) {
mEdgeGlowTop.onRelease();
}
}
}
}
} }
if (!getSettings().getBuiltInZoomControls()) { if (!getSettings().getBuiltInZoomControls()) {
boolean showPlusMinus = mMinZoomScale < mMaxZoomScale; boolean showPlusMinus = mMinZoomScale < mMaxZoomScale;