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

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

Issue 20990009: Handle root layer fling Java-side in android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix findbugs 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 2a084d27de32f80dda40de685e198b90ad9c9649..0f9678856331ae2f75cd4ebb8ad147705a5d6cec 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;
@@ -372,10 +373,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
@@ -387,9 +393,26 @@ public class AwContents {
mLayoutSizer.freezeLayoutRequests();
}
+ @Override
public void onPinchGestureEnd() {
mLayoutSizer.unfreezeLayoutRequests();
}
+
+ @Override
+ public void onFlingStartGesture(int velocityX, int velocityY) {
+ mScrollOffsetManager.onFlingStartGesture(velocityX, velocityY);
+ }
+
+
+ @Override
+ public void onFlingCancelGesture() {
+ mScrollOffsetManager.onFlingCancelGesture();
+ }
+
+ @Override
+ public void onUnhandledFlingStartEvent() {
+ mScrollOffsetManager.onUnhandledFlingStartEvent();
+ }
}
//--------------------------------------------------------------------------------------------
@@ -424,7 +447,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());
@@ -432,7 +455,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;
@@ -479,7 +502,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());
@@ -513,7 +537,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);
@@ -870,6 +894,13 @@ public class AwContents {
}
/**
+ * @see View.computeScroll()
+ */
+ public void computeScroll() {
+ mScrollOffsetManager.computeScrollAndAbsorbGlow(mOverScrollGlow);
+ }
+
+ /**
* @see View#computeHorizontalScrollRange()
*/
public int computeHorizontalScrollRange() {
@@ -1176,8 +1207,8 @@ public class AwContents {
/**
* @see android.webkit.WebView#flingScroll(int, int)
*/
- public void flingScroll(int vx, int vy) {
- mContentViewCore.flingScroll(vx, vy);
+ public void flingScroll(int velocityX, int velocityY) {
+ mContentViewCore.flingScroll(velocityX, velocityY);
}
/**
@@ -1658,7 +1689,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