Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java b/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java |
| index 9ed9a14ff6f0d1ddf05cca819f81b9a858cee1eb..ca33bb102031618d32fe8b51b93feb660cc989a0 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/AwScrollOffsetManager.java |
| @@ -26,6 +26,8 @@ public class AwScrollOffsetManager { |
| // Time for the longest scroll animation. |
| private static final int MAX_SCROLL_ANIMATION_DURATION_MILLISEC = 750; |
| + private boolean mIsAnimatingScroll = false; |
|
boliu
2015/05/29 19:42:47
what's the difference between mIsAnimatingScroll a
hush (inactive)
2015/06/05 21:47:22
I was silly there.
mIsAnimatingScroll is equal to
|
| + |
| /** |
| * The interface that all users of AwScrollOffsetManager should implement. |
| * |
| @@ -66,7 +68,7 @@ public class AwScrollOffsetManager { |
| private boolean mProcessingTouchEvent; |
| // Don't skip computeScrollAndAbsorbGlow just because isFling is called in between. |
| - private boolean mWasFlinging; |
| + private boolean mWasSmoothScrolling; |
|
hush (inactive)
2015/06/05 21:47:22
This field is not needed any more. It is used to g
|
| // Whether (and to what value) to update the native side scroll offset after we've finished |
| // processing a touch event. |
| @@ -163,10 +165,12 @@ public class AwScrollOffsetManager { |
| scrollRangeX, scrollRangeY, mProcessingTouchEvent); |
| } |
| - public boolean isFlingActive() { |
| - boolean flinging = mScroller.computeScrollOffset(); |
| - mWasFlinging |= flinging; |
| - return flinging; |
| + // This is used temporarily until animateScrollTo path of Android WebView (pageUp, pageDown) |
| + // is unified with Chrome smooth scrolling. |
| + public boolean isSmoothScrollingActive() { |
| + boolean smoothScrolling = mScroller.computeScrollOffset(); |
| + mWasSmoothScrolling |= smoothScrolling; |
| + return smoothScrolling; |
| } |
| // Called by the native side to over-scroll the container view. |
| @@ -258,32 +262,19 @@ public class AwScrollOffsetManager { |
| mScroller.forceFinished(true); |
| } |
| - // Called when a fling gesture is not handled by the renderer. |
| - // We explicitly ask the renderer not to handle fling gestures targeted at the root |
| - // scroll layer. |
| - public void onUnhandledFlingStartEvent(int velocityX, int velocityY) { |
| - flingScroll(-velocityX, -velocityY); |
| - } |
| - |
| - // Starts the fling animation. Called both as a response to a fling gesture and as via the |
| - // public WebView#flingScroll(int, int) API. |
| - public void flingScroll(int velocityX, int velocityY) { |
| - final int scrollX = mDelegate.getContainerViewScrollX(); |
| - final int scrollY = mDelegate.getContainerViewScrollY(); |
| - final int scrollRangeX = computeMaximumHorizontalScrollOffset(); |
| - final int scrollRangeY = computeMaximumVerticalScrollOffset(); |
| - |
| - mScroller.fling(scrollX, scrollY, velocityX, velocityY, |
| - 0, scrollRangeX, 0, scrollRangeY); |
| - mDelegate.invalidate(); |
| + // This is used temporarily until animateScrollTo path of Android WebView (pageUp, pageDown) |
| + // is unified with Chrome smooth scrolling. |
| + public boolean willComputeScroll() { |
| + if (mScroller.isFinished()) mIsAnimatingScroll = false; |
|
boliu
2015/05/29 19:42:47
not quite the same as mIsAnimatingScroll = mScroll
hush (inactive)
2015/06/05 21:47:21
Sorry. Same as I said above. This function should
|
| + return mIsAnimatingScroll && !mScroller.isFinished(); |
| } |
| // Called immediately before the draw to update the scroll offset. |
| public void computeScrollAndAbsorbGlow(OverScrollGlow overScrollGlow) { |
| - if (!mScroller.computeScrollOffset() && !mWasFlinging) { |
| + if (!mScroller.computeScrollOffset() && !mWasSmoothScrolling) { |
| return; |
| } |
| - mWasFlinging = false; |
| + mWasSmoothScrolling = false; |
| final int oldX = mDelegate.getContainerViewScrollX(); |
| final int oldY = mDelegate.getContainerViewScrollY(); |
| @@ -323,6 +314,8 @@ public class AwScrollOffsetManager { |
| if (dx == 0 && dy == 0) return false; |
| + mIsAnimatingScroll = true; |
| + |
| mScroller.startScroll(scrollX, scrollY, dx, dy, computeDurationInMilliSec(dx, dy)); |
| mDelegate.invalidate(); |