Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2208)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 15029006: Make it possible for the scroll offset delegate to intercept fling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reactivate the patch! Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index bd6433696783deb62c4fb9accb934faa7c257487..3ed9aec26d94ee3496b38e63060aec3033d282c7 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -31,6 +31,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.webkit.GeolocationPermissions;
import android.webkit.ValueCallback;
+import android.widget.OverScroller;
import com.google.common.annotations.VisibleForTesting;
@@ -374,10 +375,15 @@ public class AwContents {
public int getContainerViewScrollY() {
return mContainerView.getScrollY();
}
+
+ @Override
+ public void invalidate() {
+ mContainerView.invalidate();
+ }
}
//--------------------------------------------------------------------------------------------
- private class AwPinchGestureStateListener implements ContentViewCore.PinchGestureStateListener {
+ private class AwGestureStateListener implements ContentViewCore.GestureStateListener {
@Override
public void onPinchGestureStart() {
// While it's possible to re-layout the view during a pinch gesture, the effect is very
@@ -389,9 +395,20 @@ public class AwContents {
mLayoutSizer.freezeLayoutRequests();
}
+ @Override
public void onPinchGestureEnd() {
mLayoutSizer.unfreezeLayoutRequests();
}
+
+ @Override
+ public void onFlingStartGestureStart(int vx, int vy) {
+ mScrollOffsetManager.onFlingStartGestureStart(vx, vy);
+ }
+
+ @Override
+ public void onUnhandledFlingStartEvent() {
+ mScrollOffsetManager.onUnhandledFlingStartEvent();
+ }
}
//--------------------------------------------------------------------------------------------
@@ -426,7 +443,7 @@ public class AwContents {
private static ContentViewCore createAndInitializeContentViewCore(ViewGroup containerView,
InternalAccessDelegate internalDispatcher, int nativeWebContents,
- ContentViewCore.PinchGestureStateListener pinchGestureStateListener,
+ ContentViewCore.GestureStateListener pinchGestureStateListener,
ContentViewClient contentViewClient,
ContentViewCore.ZoomControlsDelegate zoomControlsDelegate) {
ContentViewCore contentViewCore = new ContentViewCore(containerView.getContext());
@@ -434,7 +451,7 @@ public class AwContents {
// compositor, not because input events are delivered immediately.
contentViewCore.initialize(containerView, internalDispatcher, nativeWebContents, null,
ContentViewCore.INPUT_EVENTS_DELIVERED_IMMEDIATELY);
- contentViewCore.setPinchGestureStateListener(pinchGestureStateListener);
+ contentViewCore.setGestureStateListener(pinchGestureStateListener);
contentViewCore.setContentViewClient(contentViewClient);
contentViewCore.setZoomControlsDelegate(zoomControlsDelegate);
return contentViewCore;
@@ -481,7 +498,8 @@ public class AwContents {
mSettings.setDefaultVideoPosterURL(
mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL());
mContentsClient.setDIPScale(mDIPScale);
- mScrollOffsetManager = new AwScrollOffsetManager(new AwScrollOffsetManagerDelegate());
+ mScrollOffsetManager = new AwScrollOffsetManager(new AwScrollOffsetManagerDelegate(),
+ new OverScroller(mContainerView.getContext()));
setOverScrollMode(mContainerView.getOverScrollMode());
@@ -515,7 +533,7 @@ public class AwContents {
int nativeWebContents = nativeGetWebContents(mNativeAwContents);
mContentViewCore = createAndInitializeContentViewCore(
mContainerView, mInternalAccessAdapter, nativeWebContents,
- new AwPinchGestureStateListener(), mContentsClient.getContentViewClient(),
+ new AwGestureStateListener(), mContentsClient.getContentViewClient(),
mZoomControls);
nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
mIoThreadClient, mInterceptNavigationDelegate);
@@ -874,6 +892,13 @@ public class AwContents {
}
/**
+ * @see View.computeScroll()
+ */
+ public void computeScroll() {
+ mScrollOffsetManager.computeScrollAndAbsorbGlow(mOverScrollGlow);
+ }
+
+ /**
* @see View#computeHorizontalScrollRange()
*/
public int computeHorizontalScrollRange() {
@@ -1277,6 +1302,10 @@ public class AwContents {
mOverScrollGlow.releaseAll();
}
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mScrollOffsetManager.onTouchDown();
+ }
+
return rv;
}
@@ -1662,7 +1691,7 @@ public class AwContents {
mOverScrollGlow.setOverScrollDeltas(deltaX, deltaY);
}
- mScrollOffsetManager.overscrollBy(deltaX, deltaY);
+ mScrollOffsetManager.overScrollBy(deltaX, deltaY);
if (mOverScrollGlow != null && mOverScrollGlow.isAnimating()) {
mContainerView.invalidate();

Powered by Google App Engine
This is Rietveld 408576698