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 24116574210740c60d59b72c3ff00e95e523318d..c600972043e9d7781ea33ae4f5bf39b4524e6f98 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
@@ -28,6 +28,8 @@ import android.view.inputmethod.InputConnection; |
import android.webkit.GeolocationPermissions; |
import android.webkit.ValueCallback; |
+import com.google.common.annotations.VisibleForTesting; |
+ |
import org.chromium.base.CalledByNative; |
import org.chromium.base.JNINamespace; |
import org.chromium.base.ThreadUtils; |
@@ -92,23 +94,13 @@ public class AwContents { |
void setMeasuredDimension(int measuredWidth, int measuredHeight); |
} |
- /** |
- * Listener for renderer state change notifications coming through ContentViewCore. |
- */ |
- private class AwContentStateChangeListener |
- implements ContentViewCore.ContentSizeChangeListener { |
- @Override |
- public void onContentSizeChanged(int contentWidthPix, int contentHeightPix) { |
- mLayoutSizer.onContentSizeChanged(contentWidthPix, contentHeightPix); |
- } |
- } |
- |
private int mNativeAwContents; |
private AwBrowserContext mBrowserContext; |
private ViewGroup mContainerView; |
private ContentViewCore mContentViewCore; |
private AwContentsClient mContentsClient; |
private AwContentsClientBridge mContentsClientBridge; |
+ private AwWebContentsDelegate mWebContentsDelegate; |
private AwContentsIoThreadClient mIoThreadClient; |
private InterceptNavigationDelegateImpl mInterceptNavigationDelegate; |
private InternalAccessDelegate mInternalAccessAdapter; |
@@ -137,6 +129,7 @@ public class AwContents { |
private CleanupReference mCleanupReference; |
+ //-------------------------------------------------------------------------------------------- |
private class IoThreadClientImpl implements AwContentsIoThreadClient { |
// All methods are called on the IO thread. |
@@ -198,6 +191,7 @@ public class AwContents { |
} |
} |
+ //-------------------------------------------------------------------------------------------- |
private class InterceptNavigationDelegateImpl implements InterceptNavigationDelegate { |
private String mLastLoadUrlAddress; |
@@ -242,6 +236,7 @@ public class AwContents { |
} |
} |
+ //-------------------------------------------------------------------------------------------- |
private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate { |
@Override |
public void requestLayout() { |
@@ -254,6 +249,25 @@ public class AwContents { |
} |
} |
+ //-------------------------------------------------------------------------------------------- |
+ private class AwPageScaleChangeListener |
+ implements ContentViewCore.PageScaleChangeListener { |
+ @Override |
+ public void onScaleChanged(float oldScale, float newScale) { |
+ mContentsClient.onScaleChanged(oldScale, newScale); |
+ mLayoutSizer.onPageScaleChanged(newScale); |
joth
2013/03/26 22:12:49
my gut instinct is these two calls should be in th
mkosiba (inactive)
2013/03/27 16:46:41
Good find!
|
+ } |
+ } |
+ |
+ //-------------------------------------------------------------------------------------------- |
+ private class PreferredSizeChangedListener implements |
+ AwWebContentsDelegateAdapter.PreferredSizeChangedListener { |
+ @Override |
+ public void updatePreferredSize(int widthCss, int heightCss) { |
+ mLayoutSizer.onContentSizeChanged(widthCss, heightCss); |
joth
2013/03/26 22:12:49
would it be evil for LayoutSize to just implement
mkosiba (inactive)
2013/03/27 16:46:41
not terribly, no. The only reason I wanted to keep
|
+ } |
+ } |
+ |
/** |
* @param browserContext the browsing context to associate this view contents with. |
* @param containerView the view-hierarchy item this object will be bound to. |
@@ -272,8 +286,9 @@ public class AwContents { |
mContentViewCore = new ContentViewCore(containerView.getContext(), |
ContentViewCore.PERSONALITY_VIEW); |
mContentsClientBridge = new AwContentsClientBridge(contentsClient); |
- mNativeAwContents = nativeInit(contentsClient.getWebContentsDelegate(), |
- mContentsClientBridge); |
+ mWebContentsDelegate = new AwWebContentsDelegateAdapter(contentsClient, |
+ new PreferredSizeChangedListener()); |
+ mNativeAwContents = nativeInit(mWebContentsDelegate, mContentsClientBridge); |
mContentsClient = contentsClient; |
mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeAwContents)); |
@@ -283,8 +298,7 @@ public class AwContents { |
new AwNativeWindow(mContainerView.getContext()), |
isAccessFromFileURLsGrantedByDefault); |
mContentViewCore.setContentViewClient(mContentsClient); |
- mLayoutSizer = new AwLayoutSizer(new AwLayoutSizerDelegate()); |
- mContentViewCore.setContentSizeChangeListener(new AwContentStateChangeListener()); |
+ mContentViewCore.setPageScaleChangeListener(new AwPageScaleChangeListener()); |
mContentsClient.installWebContentsObserver(mContentViewCore); |
mSettings = new AwSettings(mContentViewCore.getContext(), nativeWebContents); |
@@ -299,11 +313,13 @@ public class AwContents { |
mContentsClient.setDIPScale(mDIPScale); |
mSettings.setDIPScale(mDIPScale); |
+ mLayoutSizer = new AwLayoutSizer(new AwLayoutSizerDelegate(), mDIPScale); |
+ |
ContentVideoView.registerContentVideoViewContextDelegate( |
new AwContentVideoViewDelegate(contentsClient, containerView.getContext())); |
} |
- // TODO(mkosiba): Remove this once we move the embedding layer to use methods on AwContents. |
+ @VisibleForTesting |
public ContentViewCore getContentViewCore() { |
return mContentViewCore; |
} |
@@ -330,7 +346,7 @@ public class AwContents { |
// We explicitly do not null out the mContentViewCore reference here |
// because ContentViewCore already has code to deal with the case |
// methods are called on it after it's been destroyed, and other |
- // code relies on AwContents.getContentViewCore to return non-null. |
+ // code relies on AwContents.mContentViewCore to be non-null. |
mCleanupReference.cleanupNow(); |
mNativeAwContents = 0; |
} |
@@ -422,7 +438,7 @@ public class AwContents { |
*/ |
public int getMostRecentProgress() { |
// WebContentsDelegateAndroid conveniently caches the most recent notified value for us. |
- return mContentsClient.getWebContentsDelegate().getMostRecentProgress(); |
+ return mWebContentsDelegate.getMostRecentProgress(); |
} |
public Bitmap getFavicon() { |