| Index: android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java
|
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java b/android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java
|
| index e09259b0dde7c512091a63f5aeb50f51b2d2a8da..078afcabacd5aa271a7ba06e2d60403ba64bbe75 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java
|
| @@ -26,6 +26,7 @@ public class AwLayoutSizer {
|
| // Page scale factor. This is set to zero initially so that we don't attempt to do a layout if
|
| // we get the content size change notification first and a page scale change second.
|
| private double mPageScaleFactor = 0.0;
|
| + private double mLastMeasuredPageScaleFactor = 0.0;
|
|
|
| // Whether to postpone layout requests.
|
| private boolean mFreezeLayoutRequests;
|
| @@ -40,6 +41,7 @@ public class AwLayoutSizer {
|
| public interface Delegate {
|
| void requestLayout();
|
| void setMeasuredDimension(int measuredWidth, int measuredHeight);
|
| + void setAutoResizeMode(boolean enabled, int widthDip);
|
| }
|
|
|
| /**
|
| @@ -150,12 +152,10 @@ public class AwLayoutSizer {
|
| int contentHeightPix = (int) (mContentHeightCss * mPageScaleFactor * mDIPScale);
|
| int contentWidthPix = (int) (mContentWidthCss * mPageScaleFactor * mDIPScale);
|
|
|
| + mLastMeasuredPageScaleFactor = mPageScaleFactor;
|
| +
|
| // Always use the given size unless unspecified. This matches WebViewClassic behavior.
|
| mWidthMeasurementIsFixed = (widthMode != MeasureSpec.UNSPECIFIED);
|
| - // Freeze the height if an exact size is given by the parent or if the content size has
|
| - // exceeded the maximum size specified by the parent.
|
| - // TODO(mkosiba): Actually we'd like the reduction in content size to cause the WebView to
|
| - // shrink back again but only as a result of a page load.
|
| mHeightMeasurementIsFixed = (heightMode == MeasureSpec.EXACTLY) ||
|
| (heightMode == MeasureSpec.AT_MOST && contentHeightPix > heightSize);
|
|
|
| @@ -177,4 +177,27 @@ public class AwLayoutSizer {
|
|
|
| mDelegate.setMeasuredDimension(measuredWidth, measuredHeight);
|
| }
|
| +
|
| + public void onSizeChanged(int w, int h, int ow, int oh) {
|
| + // Both dimensions are explicitly specified by the partent view, no need for autosizing as
|
| + // the content size doesn't influence the view size.
|
| + if (mWidthMeasurementIsFixed && mHeightMeasurementIsFixed ||
|
| + mLastMeasuredPageScaleFactor == 0) {
|
| + mDelegate.setAutoResizeMode(false, 0);
|
| + return;
|
| + }
|
| +
|
| + final double dipAndPageScale = mLastMeasuredPageScaleFactor * mDIPScale;
|
| + final int contentWidthPix = (int) (mContentWidthCss * dipAndPageScale);
|
| +
|
| + int widthDip = (int) (w / dipAndPageScale);
|
| +
|
| + // Make sure that we don't introduce rounding errors if the viewport is to be exactly as
|
| + // wide as the contents.
|
| + if (w == contentWidthPix) {
|
| + widthDip = mContentWidthCss;
|
| + }
|
| +
|
| + mDelegate.setAutoResizeMode(true, widthDip);
|
| + }
|
| }
|
|
|