Commit b80e551e authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fullscreen elements that were root level elements weren't sized properly.

Avoid setting position absolute on top layer elements that are the
documentElement. This matches what Firefox does.

The root element is special when it is in fullscreen mode because it does
not get the style applied that forces its dimensions and position to be
fixed.

BUG=876339

Change-Id: I42b18047dc9648585bc279510d66decd6d6a4516
Reviewed-on: https://chromium-review.googlesource.com/1186961
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585830}
parent 7e63ed80
<!DOCTYPE html>
<style>
html, body {
margin: 0px;
}
</style>
<title>fullscreen root block sizing</title>
<!-- This page intentionally has no content. It needs to have
no width or height. This is to ensure that the root element
gets sizing in fullscreen mode as it does in as it does not
in fullscreen mode.
-->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
async_test(t => {
document.onfullscreenchange = t.step_func_done(() => {
assert_equals(document.fullscreenElement, document.documentElement);
assert_true(document.documentElement.getBoundingClientRect().width > 0);
});
document.documentElement.addEventListener('click', e => {
document.documentElement.requestFullscreen();
}, {once: true});
test_driver.click(document.documentElement);
});
</script>
...@@ -573,9 +573,13 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state, ...@@ -573,9 +573,13 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
AdjustStyleForHTMLElement(style, ToHTMLElement(*element)); AdjustStyleForHTMLElement(style, ToHTMLElement(*element));
} }
if (style.Display() != EDisplay::kNone) { if (style.Display() != EDisplay::kNone) {
bool is_document_element =
element && element->GetDocument().documentElement() == element;
// Per the spec, position 'static' and 'relative' in the top layer compute // Per the spec, position 'static' and 'relative' in the top layer compute
// to 'absolute'. // to 'absolute'. Root elements that are in the top layer should just
if (IsInTopLayer(element, style) && // be left alone because the fullscreen.css doesn't apply any style to
// them.
if (IsInTopLayer(element, style) && !is_document_element &&
(style.GetPosition() == EPosition::kStatic || (style.GetPosition() == EPosition::kStatic ||
style.GetPosition() == EPosition::kRelative)) style.GetPosition() == EPosition::kRelative))
style.SetPosition(EPosition::kAbsolute); style.SetPosition(EPosition::kAbsolute);
...@@ -586,7 +590,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state, ...@@ -586,7 +590,7 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
(style.HasOutOfFlowPosition() || style.IsFloating())) (style.HasOutOfFlowPosition() || style.IsFloating()))
style.SetDisplay(EquivalentBlockDisplay(style.Display())); style.SetDisplay(EquivalentBlockDisplay(style.Display()));
if (element && element->GetDocument().documentElement() == element) if (is_document_element)
style.SetDisplay(EquivalentBlockDisplay(style.Display())); style.SetDisplay(EquivalentBlockDisplay(style.Display()));
// We don't adjust the first letter style earlier because we may change the // We don't adjust the first letter style earlier because we may change the
......
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