merge in klp-factoryrom-release history after reset to klp-dev
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
index 43e9a68..78d6cf4 100644
--- a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
@@ -75,11 +75,6 @@
Send(new AwViewMsg_SetTextZoomLevel(web_contents()->GetRoutingID(), level));
}
-void AwRenderViewHostExt::SetFixedLayoutSize(const gfx::Size& size) {
- DCHECK(CalledOnValidThread());
- Send(new AwViewMsg_SetFixedLayoutSize(web_contents()->GetRoutingID(), size));
-}
-
void AwRenderViewHostExt::ResetScrollAndScaleState() {
DCHECK(CalledOnValidThread());
Send(new AwViewMsg_ResetScrollAndScaleState(web_contents()->GetRoutingID()));
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.h b/android_webview/browser/renderer_host/aw_render_view_host_ext.h
index 18b3ab3..3007f15 100644
--- a/android_webview/browser/renderer_host/aw_render_view_host_ext.h
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.h
@@ -11,7 +11,6 @@
#include "base/callback_forward.h"
#include "base/threading/non_thread_safe.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/size.h"
class GURL;
@@ -67,8 +66,6 @@
// Text Autosizing.
void SetTextZoomLevel(double level);
- void SetFixedLayoutSize(const gfx::Size& size);
-
void ResetScrollAndScaleState();
// Sets the initial page scale. This overrides initial scale set by
diff --git a/android_webview/common/render_view_messages.h b/android_webview/common/render_view_messages.h
index b53bcfa..96d1758 100644
--- a/android_webview/common/render_view_messages.h
+++ b/android_webview/common/render_view_messages.h
@@ -67,11 +67,6 @@
IPC_MESSAGE_ROUTED1(AwViewMsg_SetInitialPageScale,
double /* page_scale_factor */)
-// Makes the WebKit::WebView use the given size for layout regardless of what
-// the size of the RenderWidget or viewport settings are.
-IPC_MESSAGE_ROUTED1(AwViewMsg_SetFixedLayoutSize,
- gfx::Size /* size */)
-
// Sets the base background color for this view.
IPC_MESSAGE_ROUTED1(AwViewMsg_SetBackgroundColor,
SkColor);
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 51eb7ce..bd64c81 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -343,11 +343,6 @@
public void setMeasuredDimension(int measuredWidth, int measuredHeight) {
mInternalAccessAdapter.setMeasuredDimension(measuredWidth, measuredHeight);
}
-
- @Override
- public void setFixedLayoutSize(int widthDip, int heightDip) {
- nativeSetFixedLayoutSize(mNativeAwContents, widthDip, heightDip);
- }
}
//--------------------------------------------------------------------------------------------
@@ -1524,8 +1519,17 @@
if (mNativeAwContents == 0) return;
mScrollOffsetManager.setContainerViewSize(w, h);
mContentViewCore.onPhysicalBackingSizeChanged(w, h);
- mContentViewCore.onSizeChanged(w, h, ow, oh);
- mLayoutSizer.onSizeChanged(w, h, ow, oh);
+ double pageScaleFactor = mLayoutSizer.getPageScaleFactorAtLastOnMeasure();
+ if (pageScaleFactor == 0) {
+ // The renderer hadn't sent us the pageScale yet. Assume 1.0. If it's different later
+ // on we'll go through one more round of layout anyway.
+ pageScaleFactor = 1.0;
+ }
+ // This method results in a change of the logical viewport. ContentViewCore assumes that
+ // the parameters are in DIP-scaled pixels which is why we need to remove the
+ // pageScaleFactor.
+ mContentViewCore.onSizeChanged((int)(w / pageScaleFactor), (int)(h / pageScaleFactor),
+ (int) (ow / pageScaleFactor), (int) (oh / pageScaleFactor));
nativeOnSizeChanged(mNativeAwContents, w, h, ow, oh);
}
@@ -1919,7 +1923,6 @@
private native void nativeSetDipScale(int nativeAwContents, float dipScale);
private native void nativeSetDisplayedPageScaleFactor(int nativeAwContents,
float pageScaleFactor);
- private native void nativeSetFixedLayoutSize(int nativeAwContents, int widthDip, int heightDip);
// Returns null if save state fails.
private native byte[] nativeGetOpaqueState(int nativeAwContents);
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 b0f42e1..4a78e62 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwLayoutSizer.java
@@ -14,8 +14,6 @@
* Helper methods used to manage the layout of the View that contains AwContents.
*/
public class AwLayoutSizer {
- public static final int FIXED_LAYOUT_HEIGHT = 0;
-
// These are used to prevent a re-layout if the content size changes within a dimension that is
// fixed by the view system.
private boolean mWidthMeasurementIsFixed;
@@ -28,8 +26,8 @@
// 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;
- // The page scale factor that was used in the most recent onMeasure call.
- private double mLastMeasuredPageScaleFactor = 0.0;
+ // See dosc for getPageScaleFactorAtLastOnMeasure().
+ private double mPageScaleFactorAtLastOnMeasure = 0.0;
// Whether to postpone layout requests.
private boolean mFreezeLayoutRequests;
@@ -38,18 +36,12 @@
private double mDIPScale;
- // Was our heightSpec is AT_MOST the last time onMeasure was called?
- private boolean mHeightMeasurementLimited;
- // If mHeightMeasurementLimited is true then this contains the height limit.
- private int mHeightMeasurementLimit;
-
// Callback object for interacting with the View.
private Delegate mDelegate;
public interface Delegate {
void requestLayout();
void setMeasuredDimension(int measuredWidth, int measuredHeight);
- void setFixedLayoutSize(int widthDip, int heightDip);
}
/**
@@ -122,16 +114,22 @@
doUpdate(mContentWidthCss, mContentHeightCss, pageScaleFactor);
}
+ /**
+ * The page scale factor that was used to calculate the physical size of the view at the most
+ * recent call to onMeasure. It is assumed that the values we get in onSizeChanged are scaled
+ * by this factor.
+ */
+ public double getPageScaleFactorAtLastOnMeasure() {
+ return mPageScaleFactorAtLastOnMeasure;
+ }
+
private void doUpdate(int widthCss, int heightCss, double pageScaleFactor) {
// We want to request layout only if the size or scale change, however if any of the
// measurements are 'fixed', then changing the underlying size won't have any effect, so we
// ignore changes to dimensions that are 'fixed'.
- final int heightPix = (int) (heightCss * mPageScaleFactor * mDIPScale);
boolean anyMeasurementNotFixed = !mWidthMeasurementIsFixed || !mHeightMeasurementIsFixed;
- boolean contentHeightChangeMeaningful = !mHeightMeasurementIsFixed &&
- (!mHeightMeasurementLimited || heightPix < mHeightMeasurementLimit);
boolean layoutNeeded = (mContentWidthCss != widthCss && !mWidthMeasurementIsFixed) ||
- (mContentHeightCss != heightCss && contentHeightChangeMeaningful) ||
+ (mContentHeightCss != heightCss && !mHeightMeasurementIsFixed) ||
(mPageScaleFactor != pageScaleFactor && anyMeasurementNotFixed);
mContentWidthCss = widthCss;
@@ -157,28 +155,29 @@
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ int measuredHeight = heightSize;
+ int measuredWidth = widthSize;
+
int contentHeightPix = (int) (mContentHeightCss * mPageScaleFactor * mDIPScale);
int contentWidthPix = (int) (mContentWidthCss * mPageScaleFactor * mDIPScale);
- int measuredHeight = contentHeightPix;
- int measuredWidth = contentWidthPix;
-
- mLastMeasuredPageScaleFactor = mPageScaleFactor;
+ mPageScaleFactorAtLastOnMeasure = mPageScaleFactor;
// Always use the given size unless unspecified. This matches WebViewClassic behavior.
mWidthMeasurementIsFixed = (widthMode != MeasureSpec.UNSPECIFIED);
- mHeightMeasurementIsFixed = (heightMode == MeasureSpec.EXACTLY);
- mHeightMeasurementLimited = (heightMode == MeasureSpec.AT_MOST);
- mHeightMeasurementLimit = heightSize;
+ // 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);
- final boolean measuredHeightClipped =
- mHeightMeasurementLimited && (contentHeightPix > heightSize);
- if (mHeightMeasurementIsFixed || measuredHeightClipped) {
- measuredHeight = heightSize;
+ if (!mHeightMeasurementIsFixed) {
+ measuredHeight = contentHeightPix;
}
- if (mWidthMeasurementIsFixed) {
- measuredWidth = widthSize;
+ if (!mWidthMeasurementIsFixed) {
+ measuredWidth = contentWidthPix;
}
if (measuredHeight < contentHeightPix) {
@@ -191,36 +190,4 @@
mDelegate.setMeasuredDimension(measuredWidth, measuredHeight);
}
-
- public void onSizeChanged(int w, int h, int ow, int oh) {
- // If the WebView's measuredDimension depends on the size of it's contents (which is the
- // case if any of the measurement modes are AT_MOST or UNSPECIFIED) the viewport size
- // cannot be directly calculated from the size as that can result in the layout being
- // unstable or unpredictable.
- // If both the width and height are fixed (specified by the parent) then content size
- // changes will not cause subsequent layout passes and so we don't need to do anything
- // special.
- if ((mWidthMeasurementIsFixed && mHeightMeasurementIsFixed) ||
- mLastMeasuredPageScaleFactor == 0) {
- mDelegate.setFixedLayoutSize(0, 0);
- return;
- }
-
- final double dipAndPageScale = mLastMeasuredPageScaleFactor * mDIPScale;
- final int contentWidthPix = (int) (mContentWidthCss * dipAndPageScale);
-
- int widthDip = (int) Math.ceil(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;
- }
-
- // This is workaround due to the fact that in wrap content mode we need to use a fixed
- // layout size independent of view height, otherwise things like <div style="height:120%">
- // cause the webview to grow indefinitely. We need to use a height independent of the
- // webview's height. 0 is the value used in WebViewClassic.
- mDelegate.setFixedLayoutSize(widthDip, FIXED_LAYOUT_HEIGHT);
- }
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidViewIntegrationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidViewIntegrationTest.java
index 023dc46..f4ba4d4 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidViewIntegrationTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidViewIntegrationTest.java
@@ -204,23 +204,16 @@
assertTrue(mOnContentSizeChangedHelper.getHeight() > 0);
}
- private String makeHtmlPageOfSize(int widthCss, int heightCss, boolean heightPercent) {
- String content = "<div class=\"normal\">a</div>";
- if (heightPercent)
- content += "<div class=\"heightPercent\"></div>";
+ private String makeHtmlPageOfSize(int widthCss, int heightCss) {
return CommonResources.makeHtmlPageFrom(
"<style type=\"text/css\">" +
"body { margin:0px; padding:0px; } " +
- ".normal { " +
+ "div { " +
"width:" + widthCss + "px; " +
"height:" + heightCss + "px; " +
"background-color: red; " +
"} " +
- ".heightPercent { " +
- "height: 150%; " +
- "background-color: blue; " +
- "} " +
- "</style>", content);
+ "</style>", "<div/>");
}
private void waitForContentSizeToChangeTo(OnContentSizeChangedHelper helper, int callCount,
@@ -239,10 +232,9 @@
}
private void loadPageOfSizeAndWaitForSizeChange(AwContents awContents,
- OnContentSizeChangedHelper helper, int widthCss, int heightCss,
- boolean heightPercent) throws Exception {
+ OnContentSizeChangedHelper helper, int widthCss, int heightCss) throws Exception {
- final String htmlData = makeHtmlPageOfSize(widthCss, heightCss, heightPercent);
+ final String htmlData = makeHtmlPageOfSize(widthCss, heightCss);
final int contentSizeChangeCallCount = helper.getCallCount();
loadDataAsync(awContents, htmlData, "text/html", false);
@@ -261,15 +253,7 @@
final int contentHeightCss = 180;
loadPageOfSizeAndWaitForSizeChange(testContainerView.getAwContents(),
- mOnContentSizeChangedHelper, contentWidthCss, contentHeightCss, false);
- }
-
- public void waitForNoLayoutsPending() throws InterruptedException {
- // This is to make sure that there are no more pending size change notifications. Ideally
- // we'd assert that the renderer is idle (has no pending layout passes) but that would
- // require quite a bit of plumbing, so we just wait a bit and make sure the size hadn't
- // changed.
- Thread.sleep(CONTENT_SIZE_CHANGE_STABILITY_TIMEOUT_MS);
+ mOnContentSizeChangedHelper, contentWidthCss, contentHeightCss);
}
@SmallTest
@@ -292,36 +276,14 @@
final int expectedHeightCss = contentHeightCss;
loadPageOfSizeAndWaitForSizeChange(testContainerView.getAwContents(),
- mOnContentSizeChangedHelper, expectedWidthCss, expectedHeightCss, false);
+ mOnContentSizeChangedHelper, expectedWidthCss, expectedHeightCss);
- waitForNoLayoutsPending();
+ // This is to make sure that there are no more pending size change notifications. Ideally
+ // we'd assert that the renderer is idle (has no pending layout passes) but that would
+ // require quite a bit of plumbing, so we just wait a bit and make sure the size hadn't
+ // changed.
+ Thread.sleep(CONTENT_SIZE_CHANGE_STABILITY_TIMEOUT_MS);
assertEquals(expectedWidthCss, mOnContentSizeChangedHelper.getWidth());
assertEquals(expectedHeightCss, mOnContentSizeChangedHelper.getHeight());
}
-
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testViewSizedCorrectlyInWrapContentModeWithDynamicContents() throws Throwable {
- final TestAwContentsClient contentsClient = new TestAwContentsClient();
- final AwTestContainerView testContainerView = createCustomTestContainerViewOnMainSync(
- contentsClient, View.VISIBLE);
- assertZeroHeight(testContainerView);
-
- final double deviceDIPScale =
- DeviceDisplayInfo.create(testContainerView.getContext()).getDIPScale();
-
- final int contentWidthCss = 142;
- final int contentHeightCss = 180;
- final int expectedHeightCss = contentHeightCss +
- // The second div in the contents is styled to have 150% of the viewport height, hence
- // the 1.5.
- (int) (AwLayoutSizer.FIXED_LAYOUT_HEIGHT * 1.5);
-
- loadPageOfSizeAndWaitForSizeChange(testContainerView.getAwContents(),
- mOnContentSizeChangedHelper, contentWidthCss, contentHeightCss, true);
-
- waitForNoLayoutsPending();
- assertEquals(contentWidthCss, mOnContentSizeChangedHelper.getWidth());
- assertEquals(expectedHeightCss, mOnContentSizeChangedHelper.getHeight());
- }
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
index 1d75dd8..88fd733 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwLayoutSizerTest.java
@@ -10,7 +10,6 @@
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.android_webview.AwLayoutSizer;
-import org.chromium.base.test.util.Feature;
public class AwLayoutSizerTest extends InstrumentationTestCase {
static class LayoutSizerDelegate implements AwLayoutSizer.Delegate {
@@ -18,8 +17,6 @@
public boolean setMeasuredDimensionCalled;
public int measuredWidth;
public int measuredHeight;
- public int fixedLayoutWidth;
- public int fixedLayoutHeight;
@Override
public void requestLayout() {
@@ -32,12 +29,6 @@
this.measuredWidth = measuredWidth;
this.measuredHeight = measuredHeight;
}
-
- @Override
- public void setFixedLayoutSize(int widthDip, int heightDip) {
- fixedLayoutWidth = widthDip;
- fixedLayoutHeight = heightDip;
- }
}
private static final int FIRST_CONTENT_WIDTH = 101;
@@ -52,8 +43,6 @@
private static final double INITIAL_PAGE_SCALE = 1.0;
private static final double DIP_SCALE = 1.0;
- @SmallTest
- @Feature({"AndroidWebView"})
public void testCanQueryContentSize() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -73,8 +62,6 @@
assertEquals(contentHeight, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testContentSizeChangeRequestsLayout() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -89,8 +76,6 @@
assertEquals(requestLayoutCallCount + 1, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testContentSizeChangeDoesNotRequestLayoutIfMeasuredExcatly() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -107,8 +92,6 @@
assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testDuplicateContentSizeChangeDoesNotRequestLayout() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -125,8 +108,6 @@
assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testContentHeightGrowsTillAtMostSize() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -149,46 +130,6 @@
assertEquals(AT_MOST_MEASURE_SIZE, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
}
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testContentHeightShrinksAfterAtMostSize() {
- AwLayoutSizer layoutSizer = new AwLayoutSizer();
- LayoutSizerDelegate delegate = new LayoutSizerDelegate();
- layoutSizer.setDelegate(delegate);
- layoutSizer.setDIPScale(DIP_SCALE);
-
- layoutSizer.onPageScaleChanged(INITIAL_PAGE_SCALE);
- layoutSizer.onContentSizeChanged(SMALLER_CONTENT_SIZE, SMALLER_CONTENT_SIZE);
- layoutSizer.onMeasure(
- MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST));
- assertEquals(AT_MOST_MEASURE_SIZE, delegate.measuredWidth);
- assertEquals(SMALLER_CONTENT_SIZE, delegate.measuredHeight);
-
- layoutSizer.onContentSizeChanged(TOO_LARGE_CONTENT_SIZE, TOO_LARGE_CONTENT_SIZE);
- layoutSizer.onMeasure(
- MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST));
- assertEquals(AT_MOST_MEASURE_SIZE, delegate.measuredWidth & View.MEASURED_SIZE_MASK);
- assertEquals(AT_MOST_MEASURE_SIZE, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
-
- int requestLayoutCallCount = delegate.requestLayoutCallCount;
- layoutSizer.onContentSizeChanged(TOO_LARGE_CONTENT_SIZE, TOO_LARGE_CONTENT_SIZE + 1);
- layoutSizer.onContentSizeChanged(TOO_LARGE_CONTENT_SIZE, TOO_LARGE_CONTENT_SIZE);
- assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
-
- requestLayoutCallCount = delegate.requestLayoutCallCount;
- layoutSizer.onContentSizeChanged(SMALLER_CONTENT_SIZE, SMALLER_CONTENT_SIZE);
- assertEquals(requestLayoutCallCount + 1, delegate.requestLayoutCallCount);
- layoutSizer.onMeasure(
- MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST),
- MeasureSpec.makeMeasureSpec(AT_MOST_MEASURE_SIZE, MeasureSpec.AT_MOST));
- assertEquals(AT_MOST_MEASURE_SIZE, delegate.measuredWidth);
- assertEquals(SMALLER_CONTENT_SIZE, delegate.measuredHeight);
- }
-
- @SmallTest
- @Feature({"AndroidWebView"})
public void testScaleChangeRequestsLayout() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -206,8 +147,6 @@
assertEquals(requestLayoutCallCount + 1, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testDuplicateScaleChangeDoesNotRequestLayout() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -224,8 +163,6 @@
assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testScaleChangeGrowsTillAtMostSize() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -250,8 +187,6 @@
assertEquals(AT_MOST_MEASURE_SIZE, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testFreezeAndUnfreezeDoesntCauseLayout() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -264,8 +199,6 @@
assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testFreezeInhibitsLayoutRequest() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -279,8 +212,6 @@
assertEquals(requestLayoutCallCount, delegate.requestLayoutCallCount);
}
- @SmallTest
- @Feature({"AndroidWebView"})
public void testUnfreezeIssuesLayoutRequest() {
AwLayoutSizer layoutSizer = new AwLayoutSizer();
LayoutSizerDelegate delegate = new LayoutSizerDelegate();
@@ -295,142 +226,4 @@
layoutSizer.unfreezeLayoutRequests();
assertEquals(requestLayoutCallCount + 1, delegate.requestLayoutCallCount);
}
-
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testViewportWithExactMeasureSpec() {
- AwLayoutSizer layoutSizer = new AwLayoutSizer();
- LayoutSizerDelegate delegate = new LayoutSizerDelegate();
- layoutSizer.setDelegate(delegate);
-
- final float dipScale = 2.0f;
- final int measuredWidth = 800;
- final int measuredHeight = 400;
-
- layoutSizer.setDIPScale(dipScale);
-
- layoutSizer.onContentSizeChanged(FIRST_CONTENT_WIDTH, FIRST_CONTENT_HEIGHT);
- layoutSizer.onPageScaleChanged(INITIAL_PAGE_SCALE);
- layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY));
- assertEquals(measuredWidth, delegate.measuredWidth & View.MEASURED_SIZE_MASK);
- assertEquals(measuredHeight, delegate.measuredHeight & View.MEASURED_SIZE_MASK);
-
- layoutSizer.onSizeChanged(measuredWidth, measuredHeight, 0, 0);
-
- assertEquals(0, delegate.fixedLayoutWidth);
- assertEquals(0, delegate.fixedLayoutHeight);
-
- layoutSizer.onPageScaleChanged(2.0f);
-
- assertEquals(0, delegate.fixedLayoutWidth);
- assertEquals(0, delegate.fixedLayoutHeight);
- }
-
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testViewportDipSizeOverrideRounding() {
- AwLayoutSizer layoutSizer = new AwLayoutSizer();
- LayoutSizerDelegate delegate = new LayoutSizerDelegate();
- layoutSizer.setDelegate(delegate);
-
- final float dipScale = 0.666f;
-
- int contentWidth = 9;
- int contentHeight = 6;
-
- layoutSizer.setDIPScale(dipScale);
- layoutSizer.onContentSizeChanged(contentWidth, contentHeight);
- layoutSizer.onPageScaleChanged(INITIAL_PAGE_SCALE);
- layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
-
- assertTrue(delegate.setMeasuredDimensionCalled);
- int measuredWidth = delegate.measuredWidth & View.MEASURED_SIZE_MASK;
- int measuredHeight = delegate.measuredHeight & View.MEASURED_SIZE_MASK;
- assertFalse((int) Math.ceil(measuredWidth / dipScale) == contentWidth);
- assertFalse((int) Math.ceil(measuredHeight / dipScale) == contentHeight);
-
- layoutSizer.onSizeChanged(measuredWidth, measuredHeight, 0, 0);
- }
-
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testViewportWithWrapContentMeasureSpec() {
- AwLayoutSizer layoutSizer = new AwLayoutSizer();
- LayoutSizerDelegate delegate = new LayoutSizerDelegate();
- layoutSizer.setDelegate(delegate);
-
- final float dipScale = 1.5f;
- final int pageScale = 2;
- final int dipAndPageScale = (int) (dipScale * pageScale);
-
-
- int contentWidth = 800;
- int contentHeight = 400;
- int atMostWidth = contentWidth * dipAndPageScale;
- int atMostHeight = contentHeight * dipAndPageScale;
-
- layoutSizer.setDIPScale(dipScale);
- layoutSizer.onContentSizeChanged(contentWidth, contentHeight);
- layoutSizer.onPageScaleChanged(pageScale);
- layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
-
- assertTrue(delegate.setMeasuredDimensionCalled);
- int measuredWidth = delegate.measuredWidth & View.MEASURED_SIZE_MASK;
- int measuredHeight = delegate.measuredHeight & View.MEASURED_SIZE_MASK;
-
- int sizeWidth = measuredWidth;
- int sizeHeight = measuredHeight;
- layoutSizer.onSizeChanged(sizeWidth, sizeHeight, 0, 0);
-
- assertEquals(contentWidth, delegate.fixedLayoutWidth);
- assertEquals(AwLayoutSizer.FIXED_LAYOUT_HEIGHT, delegate.fixedLayoutHeight);
-
- sizeWidth = measuredWidth * 2;
- sizeHeight = measuredHeight * 2;
- layoutSizer.onSizeChanged(sizeWidth, sizeHeight, 0, 0);
-
- assertEquals(sizeWidth / dipAndPageScale, delegate.fixedLayoutWidth);
- assertEquals(AwLayoutSizer.FIXED_LAYOUT_HEIGHT, delegate.fixedLayoutHeight);
-
- sizeWidth = measuredWidth / 2;
- sizeHeight = measuredHeight / 2;
- layoutSizer.onSizeChanged(sizeWidth, sizeHeight, 0, 0);
-
- assertEquals(sizeWidth / dipAndPageScale, delegate.fixedLayoutWidth);
- assertEquals(AwLayoutSizer.FIXED_LAYOUT_HEIGHT, delegate.fixedLayoutHeight);
- }
-
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testFixedLayoutViewportGoesBackToZeroWithWrapContentMeasureSpec() {
- AwLayoutSizer layoutSizer = new AwLayoutSizer();
- LayoutSizerDelegate delegate = new LayoutSizerDelegate();
- layoutSizer.setDelegate(delegate);
- layoutSizer.setDIPScale(DIP_SCALE);
-
- layoutSizer.onContentSizeChanged(FIRST_CONTENT_WIDTH, FIRST_CONTENT_HEIGHT);
- layoutSizer.onPageScaleChanged(INITIAL_PAGE_SCALE);
- layoutSizer.onMeasure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
- layoutSizer.onSizeChanged((int) (FIRST_CONTENT_WIDTH * DIP_SCALE),
- (int) (FIRST_CONTENT_HEIGHT * DIP_SCALE), 0, 0);
-
- assertTrue(delegate.fixedLayoutWidth != 0);
- assertEquals(AwLayoutSizer.FIXED_LAYOUT_HEIGHT, delegate.fixedLayoutHeight);
-
- layoutSizer.onContentSizeChanged(FIRST_CONTENT_WIDTH, AwLayoutSizer.FIXED_LAYOUT_HEIGHT);
- layoutSizer.onSizeChanged((int) (FIRST_CONTENT_WIDTH * DIP_SCALE),
- (int) (FIRST_CONTENT_HEIGHT * DIP_SCALE), 0, 0);
- assertTrue(delegate.fixedLayoutWidth != 0);
- assertEquals(0, delegate.fixedLayoutHeight);
-
- layoutSizer.onContentSizeChanged(FIRST_CONTENT_WIDTH, 0);
- layoutSizer.onSizeChanged((int) (FIRST_CONTENT_WIDTH * DIP_SCALE),
- (int) (FIRST_CONTENT_HEIGHT * DIP_SCALE), 0, 0);
- assertTrue(delegate.fixedLayoutWidth != 0);
- assertEquals(0, delegate.fixedLayoutHeight);
- }
}
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 598d918..c79b454 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -4,8 +4,6 @@
#include "android_webview/native/aw_contents.h"
-#include <limits>
-
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_browser_main_parts.h"
#include "android_webview/browser/gpu_memory_buffer_factory_impl.h"
@@ -57,7 +55,6 @@
#include "ui/base/l10n/l10n_util_android.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/image/image.h"
-#include "ui/gfx/size.h"
struct AwDrawSWFunctionTable;
struct AwDrawGLFunctionTable;
@@ -777,21 +774,14 @@
env, obj.obj(), overscroll_delta.x(), overscroll_delta.y());
}
-void AwContents::SetDipScale(JNIEnv* env, jobject obj, jfloat dip_scale) {
- browser_view_renderer_->SetDipScale(dip_scale);
+void AwContents::SetDipScale(JNIEnv* env, jobject obj, jfloat dipScale) {
+ browser_view_renderer_->SetDipScale(dipScale);
}
void AwContents::SetDisplayedPageScaleFactor(JNIEnv* env,
jobject obj,
- jfloat page_scale_factor) {
- browser_view_renderer_->SetPageScaleFactor(page_scale_factor);
-}
-
-void AwContents::SetFixedLayoutSize(JNIEnv* env,
- jobject obj,
- jint width_dip,
- jint height_dip) {
- render_view_host_ext_->SetFixedLayoutSize(gfx::Size(width_dip, height_dip));
+ jfloat pageScaleFactor) {
+ browser_view_renderer_->SetPageScaleFactor(pageScaleFactor);
}
void AwContents::ScrollTo(JNIEnv* env, jobject obj, jint xPix, jint yPix) {
diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h
index 6722086..60dd1c2 100644
--- a/android_webview/native/aw_contents.h
+++ b/android_webview/native/aw_contents.h
@@ -171,14 +171,11 @@
jint ReleasePopupAwContents(JNIEnv* env, jobject obj);
void ScrollTo(JNIEnv* env, jobject obj, jint xPix, jint yPix);
- void SetDipScale(JNIEnv* env, jobject obj, jfloat dip_scale);
+ void SetDipScale(JNIEnv* env, jobject obj, jfloat dipScale);
void SetDisplayedPageScaleFactor(JNIEnv* env,
jobject obj,
- jfloat page_scale_factor);
- void SetFixedLayoutSize(JNIEnv* env,
- jobject obj,
- jint width_dip,
- jint height_dip);
+ jfloat pageScaleFactor);
+
void SetSaveFormData(bool enabled);
// Sets the java delegate
diff --git a/android_webview/renderer/aw_render_view_ext.cc b/android_webview/renderer/aw_render_view_ext.cc
index eb5d635..9c51836 100644
--- a/android_webview/renderer/aw_render_view_ext.cc
+++ b/android_webview/renderer/aw_render_view_ext.cc
@@ -164,8 +164,6 @@
IPC_MESSAGE_HANDLER(AwViewMsg_ResetScrollAndScaleState,
OnResetScrollAndScaleState)
IPC_MESSAGE_HANDLER(AwViewMsg_SetInitialPageScale, OnSetInitialPageScale)
- IPC_MESSAGE_HANDLER(AwViewMsg_SetFixedLayoutSize,
- OnSetFixedLayoutSize)
IPC_MESSAGE_HANDLER(AwViewMsg_SetBackgroundColor, OnSetBackgroundColor)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -306,13 +304,6 @@
page_scale_factor);
}
-void AwRenderViewExt::OnSetFixedLayoutSize(const gfx::Size& size) {
- if (!render_view() || !render_view()->GetWebView())
- return;
- DCHECK(render_view()->GetWebView()->isFixedLayoutModeEnabled());
- render_view()->GetWebView()->setFixedLayoutSize(size);
-}
-
void AwRenderViewExt::OnSetBackgroundColor(SkColor c) {
if (!render_view() || !render_view()->GetWebView())
return;
diff --git a/android_webview/renderer/aw_render_view_ext.h b/android_webview/renderer/aw_render_view_ext.h
index 8969ec2..031d513 100644
--- a/android_webview/renderer/aw_render_view_ext.h
+++ b/android_webview/renderer/aw_render_view_ext.h
@@ -10,7 +10,6 @@
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/web/WebPermissionClient.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/size.h"
namespace WebKit {
@@ -50,9 +49,6 @@
void OnResetScrollAndScaleState();
void OnSetInitialPageScale(double page_scale_factor);
-
- void OnSetFixedLayoutSize(const gfx::Size& size);
-
void OnSetBackgroundColor(SkColor c);
void UpdatePageScaleFactor();