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

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

Issue 1251323002: Plumb smooth scrolling in Chromium compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 5 years, 3 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 ed98b2fdb6415b4b834b9a990d7fa84989bc24f8..827f3564c602fc8faa080d5c3a3815695805f49c 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -39,7 +39,6 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
-import android.widget.OverScroller;
import org.chromium.android_webview.permission.AwGeolocationCallback;
import org.chromium.android_webview.permission.AwPermissionRequest;
@@ -193,8 +192,8 @@ public class AwContents implements SmartClipProvider,
}
public AwScrollOffsetManager createScrollOffsetManager(
- AwScrollOffsetManager.Delegate delegate, OverScroller overScroller) {
- return new AwScrollOffsetManager(delegate, overScroller);
+ AwScrollOffsetManager.Delegate delegate) {
+ return new AwScrollOffsetManager(delegate);
}
}
@@ -572,6 +571,11 @@ public class AwContents implements SmartClipProvider,
}
@Override
+ public void smoothScroll(int targetX, int targetY, long durationMs) {
+ if (!isDestroyed()) nativeSmoothScroll(mNativeAwContents, targetX, targetY, durationMs);
+ }
+
+ @Override
public int getContainerViewScrollX() {
return mContainerView.getScrollX();
}
@@ -611,11 +615,6 @@ public class AwContents implements SmartClipProvider,
}
@Override
- public void onFlingCancelGesture() {
- mScrollOffsetManager.finishScroll();
- }
-
- @Override
public void onScrollUpdateGestureConsumed() {
mScrollAccessibilityHelper.postViewScrolledAccessibilityEventCallback();
}
@@ -719,8 +718,8 @@ public class AwContents implements SmartClipProvider,
mSettings.setDefaultVideoPosterURL(
mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL());
mSettings.setDIPScale(mDIPScale);
- mScrollOffsetManager = dependencyFactory.createScrollOffsetManager(
- new AwScrollOffsetManagerDelegate(), new OverScroller(mContext));
+ mScrollOffsetManager =
+ dependencyFactory.createScrollOffsetManager(new AwScrollOffsetManagerDelegate());
mScrollAccessibilityHelper = new ScrollAccessibilityHelper(mContainerView);
mEnablePageVisibility = CommandLine.getInstance().hasSwitch(ENABLE_PAGE_VISIBILITY);
@@ -1975,13 +1974,6 @@ public class AwContents implements SmartClipProvider,
*/
public void flingScroll(int velocityX, int velocityY) {
if (TRACE) Log.d(TAG, "flingScroll");
- // Cancel the current smooth scroll, if there is one.
- mScrollOffsetManager.finishScroll();
- // TODO(hush): crbug.com/493765. A hit test at 0, 0 may not
- // target the scroll at root scrolling layer. Instead, we
- // should add a method flingRootLayer to ContentViewCore
- // and call it here to specifically target the scroll at
- // the root layer.
mContentViewCore.flingViewport(SystemClock.uptimeMillis(), -velocityX, -velocityY);
}
@@ -2619,10 +2611,6 @@ public class AwContents implements SmartClipProvider,
mScrollOffsetManager.scrollContainerViewTo(x, y);
}
- public boolean isSmoothScrollingActive() {
- return mScrollOffsetManager.isSmoothScrollingActive();
- }
-
@CalledByNative
private void updateScrollState(int maxContainerViewScrollOffsetX,
int maxContainerViewScrollOffsetY, int contentWidthDip, int contentHeightDip,
@@ -3068,13 +3056,8 @@ public class AwContents implements SmartClipProvider,
@Override
public void computeScroll() {
- if (mScrollOffsetManager.isSmoothScrollingActive()) {
- mScrollOffsetManager.computeScrollAndAbsorbGlow(mOverScrollGlow);
- } else {
- if (isDestroyed()) return;
- nativeOnComputeScroll(
- mNativeAwContents, AnimationUtils.currentAnimationTimeMillis());
- }
+ if (isDestroyed()) return;
+ nativeOnComputeScroll(mNativeAwContents, AnimationUtils.currentAnimationTimeMillis());
}
}
@@ -3132,6 +3115,8 @@ public class AwContents implements SmartClipProvider,
private native void nativeOnSizeChanged(long nativeAwContents, int w, int h, int ow, int oh);
private native void nativeScrollTo(long nativeAwContents, int x, int y);
+ private native void nativeSmoothScroll(
+ long nativeAwContents, int targetX, int targetY, long durationMs);
private native void nativeSetViewVisibility(long nativeAwContents, boolean visible);
private native void nativeSetWindowVisibility(long nativeAwContents, boolean visible);
private native void nativeSetIsPaused(long nativeAwContents, boolean paused);

Powered by Google App Engine
This is Rietveld 408576698