Commit 7e844251 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Add comment and test about preferred height quirksmode special-case

A webview's preferred content height is typically the minimum height required to
display the main document without scrollbars. This is not true for quirksmode
documents (documents without <!doctype html>) where the height will always fill
the viewport at a minimum. This is not obvious so a comment and test have been
added.

Change-Id: Id39755a81f2d258d4b078501f37c425f8dc2d8ba
Reviewed-on: https://chromium-review.googlesource.com/c/1259041
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596369}
parent 78e363c4
...@@ -272,9 +272,10 @@ class WebView : protected WebWidget { ...@@ -272,9 +272,10 @@ class WebView : protected WebWidget {
// Returns the "preferred" contents size, defined as the preferred minimum // Returns the "preferred" contents size, defined as the preferred minimum
// width of the main document's contents and the minimum height required to // width of the main document's contents and the minimum height required to
// display the main document without scrollbars. The returned size has the // display the main document without scrollbars. If the document is in quirks
// page zoom factor applied. The lifecycle must be updated to at least layout // mode (does not have <!doctype html>), the height will stretch to fill the
// before calling this (see: |UpdateLifecycle|). // viewport. The returned size has the page zoom factor applied. The lifecycle
// must be updated to at least layout before calling (see: |UpdateLifecycle|).
virtual WebSize ContentsPreferredMinimumSize() = 0; virtual WebSize ContentsPreferredMinimumSize() = 0;
// Sets the display mode of the web app. // Sets the display mode of the web app.
......
...@@ -4075,6 +4075,24 @@ TEST_F(WebViewTest, PreferredSize) { ...@@ -4075,6 +4075,24 @@ TEST_F(WebViewTest, PreferredSize) {
EXPECT_EQ(2, size.height); EXPECT_EQ(2, size.height);
} }
TEST_F(WebViewTest, PreferredMinimumSizeQuirksMode) {
WebViewImpl* web_view = web_view_helper_.Initialize();
web_view->Resize(WebSize(800, 600));
FrameTestHelpers::LoadHTMLString(
web_view->MainFrameImpl(),
R"HTML(<html>
<body style="margin: 0px;">
<div style="width: 99px; height: 100px; display: inline-block;"></div>
</body>
</html>)HTML",
URLTestHelpers::ToKURL("http://example.com/"));
WebSize size = web_view->ContentsPreferredMinimumSize();
EXPECT_EQ(99, size.width);
// When in quirks mode the preferred height stretches to fill the viewport.
EXPECT_EQ(600, size.height);
}
TEST_F(WebViewTest, PreferredSizeWithGrid) { TEST_F(WebViewTest, PreferredSizeWithGrid) {
WebViewImpl* web_view = web_view_helper_.Initialize(); WebViewImpl* web_view = web_view_helper_.Initialize();
WebURL base_url = URLTestHelpers::ToKURL("http://example.com/"); WebURL base_url = URLTestHelpers::ToKURL("http://example.com/");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment