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); |