From 3331f2be93902694ccda848d88b4008eb3a22baa Mon Sep 17 00:00:00 2001 From: Mindy Pereira Date: Fri, 3 Dec 2010 09:58:37 -0800 Subject: [PATCH] Make webview edges behave the same way abslistview overscroll edges do. The assets are not scaled to start before the left or after the right edge of the view. For the top edge, start the canvas for rendering the glow after the title bar (if it is visible) or most of the glow gets cut off. Change-Id: Ia1a513fda4d1106d671919bb289aa83f8800c2c2 --- core/java/android/webkit/OverScrollGlow.java | 18 +++++++++--------- core/java/android/webkit/WebView.java | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/core/java/android/webkit/OverScrollGlow.java b/core/java/android/webkit/OverScrollGlow.java index af56a2f2d0270..ff5b30bd0f3ff 100644 --- a/core/java/android/webkit/OverScrollGlow.java +++ b/core/java/android/webkit/OverScrollGlow.java @@ -168,18 +168,18 @@ public class OverScrollGlow { if (!mEdgeGlowTop.isFinished()) { final int restoreCount = canvas.save(); - canvas.translate(-width / 2 + scrollX, Math.min(0, scrollY)); - mEdgeGlowTop.setSize(width * 2, height); + canvas.translate(scrollX, mHostView.getVisibleTitleHeight() + Math.min(0, scrollY)); + mEdgeGlowTop.setSize(width, height); invalidateForGlow |= mEdgeGlowTop.draw(canvas); canvas.restoreToCount(restoreCount); } if (!mEdgeGlowBottom.isFinished()) { final int restoreCount = canvas.save(); - canvas.translate(-width / 2 + scrollX, - Math.max(mHostView.computeMaxScrollY(), scrollY) + height); + canvas.translate(-width + scrollX, Math.max(mHostView.computeMaxScrollY(), scrollY) + + height); canvas.rotate(180, width, 0); - mEdgeGlowBottom.setSize(width * 2, height); + mEdgeGlowBottom.setSize(width, height); invalidateForGlow |= mEdgeGlowBottom.draw(canvas); canvas.restoreToCount(restoreCount); } @@ -187,8 +187,8 @@ public class OverScrollGlow { final int restoreCount = canvas.save(); canvas.rotate(270); - canvas.translate(-height * 1.5f - scrollY, Math.min(0, scrollX)); - mEdgeGlowLeft.setSize(height * 2, width); + canvas.translate(-height - scrollY, Math.min(0, scrollX)); + mEdgeGlowLeft.setSize(height, width); invalidateForGlow |= mEdgeGlowLeft.draw(canvas); canvas.restoreToCount(restoreCount); } @@ -196,9 +196,9 @@ public class OverScrollGlow { final int restoreCount = canvas.save(); canvas.rotate(90); - canvas.translate(-height / 2 + scrollY, + canvas.translate(scrollY, -(Math.max(mHostView.computeMaxScrollX(), scrollX) + width)); - mEdgeGlowRight.setSize(height * 2, width); + mEdgeGlowRight.setSize(height, width); invalidateForGlow |= mEdgeGlowRight.draw(canvas); canvas.restoreToCount(restoreCount); } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 063623b60996e..bb8f5d7e50cb4 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3553,6 +3553,9 @@ public class WebView extends AbsoluteLayout // When drawing the title bar, move it horizontally to always show // at the top of the WebView. mTitleBar.offsetLeftAndRight(mScrollX - mTitleBar.getLeft()); + int newTop = Math.min(0, mScrollY); + mTitleBar.setBottom(newTop + getTitleHeight()); + mTitleBar.setTop(newTop); } return super.drawChild(canvas, child, drawingTime); }