Don't ignore size updates that have a width and height == 0.

It is perfectly legal for the Android WebView to have a zero height,
this is frequenly how a new WebView is first laid out. Rejecting the
initial (width, 0) size update causes the initial layout to be
too narrow.

BUG=344885
TBR=aelias@chromium.org

Review URL: https://codereview.chromium.org/175043002

git-svn-id: svn://svn.chromium.org/blink/trunk@167594 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Change-Id: Id0c270907398458962e9e88f2f067bc386c9e642
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 1f9fd93..855bbbe 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -2999,7 +2999,7 @@
 
 void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription& description)
 {
-    if (!settings()->viewportEnabled() || !page() || !m_size.width || !m_size.height)
+    if (!settings()->viewportEnabled() || !page() || (!m_size.width && !m_size.height))
         return;
 
     ViewportDescription adjustedDescription = description;
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index f07df6d..e13e9e7 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -843,6 +843,23 @@
     EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->contentsSize().width());
 }
 
+TEST_F(WebFrameTest, ZeroHeightPositiveWidthNotIgnored)
+{
+    UseMockScrollbarSettings mockScrollbarSettings;
+
+    FixedLayoutTestWebViewClient client;
+    client.m_screenInfo.deviceScaleFactor = 1;
+    int viewportWidth = 1280;
+    int viewportHeight = 0;
+
+    FrameTestHelpers::WebViewHelper webViewHelper;
+    webViewHelper.initialize(true, 0, &client, enableViewportSettings);
+    webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
+
+    EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width());
+    EXPECT_EQ(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height());
+}
+
 TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
 {
     UseMockScrollbarSettings mockScrollbarSettings;