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

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

Issue 16255010: Hookup android_webview scroll offset delegation to Java side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests now pass Created 7 years, 6 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 49fb2d0b937bd66895fe087e8f0c3702930b20eb..f368d8827733760b7d621ae0f9118d69b5767582 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -119,6 +119,7 @@ public class AwContents {
private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate;
private final InternalAccessDelegate mInternalAccessAdapter;
private final AwLayoutSizer mLayoutSizer;
+ private final AwScrollOffsetManager mScrollOffsetManager;
private final AwZoomControls mZoomControls;
// This can be accessed on any thread after construction. See AwContentsIoThreadClient.
private final AwSettings mSettings;
@@ -280,6 +281,30 @@ public class AwContents {
}
//--------------------------------------------------------------------------------------------
+ private class AwScrollOffsetManagerDelegate implements AwScrollOffsetManager.Delegate {
+ @Override
+ public boolean scrollContainerViewTo(int xPix, int yPix) {
+ mContainerView.scrollTo(xPix, yPix);
+ return (xPix == mContainerView.getScrollX() && yPix == mContainerView.getScrollY());
+ }
+
+ @Override
+ public void scrollNativeTo(int xPix, int yPix) {
+ nativeScrollTo(mNativeAwContents, xPix, yPix);
+ }
+
+ @Override
+ public int getContainerViewScrollXPix() {
+ return mContainerView.getScrollX();
+ }
+
+ @Override
+ public int getContainerViewScrollYPix() {
+ return mContainerView.getScrollY();
+ }
+ }
+
+ //--------------------------------------------------------------------------------------------
private class AwPinchGestureStateListener implements ContentViewCore.PinchGestureStateListener {
@Override
public void onPinchGestureStart() {
@@ -384,6 +409,7 @@ public class AwContents {
mSettings.setDefaultVideoPosterURL(
mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL());
mContentsClient.setDIPScale(mDIPScale);
+ mScrollOffsetManager = new AwScrollOffsetManager(new AwScrollOffsetManagerDelegate());
setNewAwContents(nativeInit(browserContext));
}
@@ -421,6 +447,7 @@ public class AwContents {
mIoThreadClient, mInterceptNavigationDelegate);
mContentsClient.installWebContentsObserver(mContentViewCore);
mSettings.setWebContents(nativeWebContents);
+ nativeSetDipScale(mNativeAwContents, mDIPScale);
joth 2013/06/19 05:34:45 interesting - I thought we already had this in the
}
/**
@@ -547,6 +574,13 @@ public class AwContents {
return (int) Math.ceil(mContentViewCore.getContentWidthCss());
}
+ /**
+ * Called by the embedder when the scroll offset of the containing view has changed.
+ */
+ public void onContainerViewScrollChanged(int l, int t, int oldl, int oldt) {
+ mScrollOffsetManager.onContainerViewScrollChanged(l, t);
+ }
+
public Picture capturePicture() {
return nativeCapturePicture(mNativeAwContents);
}
@@ -1389,6 +1423,11 @@ public class AwContents {
mLayoutSizer.onPageScaleChanged(pageScaleFactor);
}
+ @CalledByNative
+ private void scrollContainerViewTo(int xPix, int yPix) {
+ mScrollOffsetManager.scrollContainerViewTo(xPix, yPix);
+ }
+
// -------------------------------------------------------------------------------------------
// Helper methods
// -------------------------------------------------------------------------------------------
@@ -1462,7 +1501,7 @@ public class AwContents {
private native void nativeAddVisitedLinks(int nativeAwContents, String[] visitedLinks);
private native boolean nativeOnDraw(int nativeAwContents, Canvas canvas,
- boolean isHardwareAccelerated, int scrollX, int ScrollY,
+ boolean isHardwareAccelerated, int scrollXPix, int ScrollYPix,
int clipLeft, int clipTop, int clipRight, int clipBottom);
private native void nativeFindAllAsync(int nativeAwContents, String searchString);
private native void nativeFindNext(int nativeAwContents, boolean forward);
@@ -1475,10 +1514,12 @@ public class AwContents {
private native void nativeUpdateLastHitTestData(int nativeAwContents);
private native void nativeOnSizeChanged(int nativeAwContents, int w, int h, int ow, int oh);
+ private native void nativeScrollTo(int nativeAwContents, int xPix, int yPix);
private native void nativeSetWindowViewVisibility(int nativeAwContents, boolean windowVisible,
boolean viewVisible);
private native void nativeOnAttachedToWindow(int nativeAwContents, int w, int h);
private native void nativeOnDetachedFromWindow(int nativeAwContents);
+ private native void nativeSetDipScale(int nativeAwContents, double dipScale);
// Returns null if save state fails.
private native byte[] nativeGetOpaqueState(int nativeAwContents);

Powered by Google App Engine
This is Rietveld 408576698