Bug 1236828 part 3 - Allow setting position: absolute for top layer element and add test. r=heycam
MozReview-Commit-ID: 9BMGe88eq6g
--- a/dom/html/test/file_fullscreen-backdrop.html
+++ b/dom/html/test/file_fullscreen-backdrop.html
@@ -3,19 +3,28 @@
<head>
<meta charset="UTF-8">
<title>Test for Bug 1064843</title>
<style id="style"></style>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
<script type="text/javascript" src="file_fullscreen-utils.js"></script>
+ <style>
+ html {
+ overflow: hidden;
+ }
+ #placeholder {
+ height: 1000vh;
+ }
+ </style>
</head>
<body>
<div id="fullscreen"></div>
+<div id="placeholder"></div>
<script>
const gStyle = document.getElementById("style");
const gFullscreen = document.getElementById("fullscreen");
function is(a, b, msg) {
opener.is(a, b, "[backdrop] " + msg);
}
@@ -72,16 +81,25 @@ function enterFullscreen() {
setBackdropStyle("");
info("Content should return to black because we restore the backdrop");
assertWindowPureColor(window, "black");
gFullscreen.style.display = "none";
info("The backdrop should disappear with the fullscreen element");
assertWindowPureColor(window, "white");
+ gFullscreen.style.display = "";
+ setBackdropStyle("position: absolute");
+ info("Changing position shouldn't immediately affect the view");
+ assertWindowPureColor(window, "black");
+
+ window.scroll(0, screen.height);
+ info("Scrolled up the absolutely-positioned element");
+ assertWindowPureColor(window, "white");
+
addFullscreenChangeContinuation("exit", exitFullscreen);
document.exitFullscreen();
}
function exitFullscreen() {
opener.nextTest();
}
</script>
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -5851,24 +5851,18 @@ nsRuleNode::ComputeDisplayData(void* aSt
SetDiscrete(*aRuleData->ValueForPosition(), display->mPosition, conditions,
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
parentDisplay->mPosition,
NS_STYLE_POSITION_STATIC, 0, 0, 0, 0);
// If an element is put in the top layer, while it is not absolutely
// positioned, the position value should be computed to 'absolute' per
// the Fullscreen API spec.
if (display->mTopLayer != NS_STYLE_TOP_LAYER_NONE &&
- // XXX We currently only support fixed top layer element. But per
- // spec it should check IsAbsolutelyPositionedStyle() instead.
- // This should be fixed as soon as we support <dialog> element
- // in bug 840640. We have to restrict it now because addons may
- // mess with UA-only styles and cause crashes. See bug 1230508.
- display->mPosition != NS_STYLE_POSITION_FIXED) {
- // XXX And we should set other values to absolute instead of fixed.
- display->mPosition = NS_STYLE_POSITION_FIXED;
+ !display->IsAbsolutelyPositionedStyle()) {
+ display->mPosition = NS_STYLE_POSITION_ABSOLUTE;
// We cannot cache this struct because otherwise it may be used as
// an aStartStruct for some other elements.
conditions.SetUncacheable();
}
// clear: enum, inherit, initial
SetDiscrete(*aRuleData->ValueForClear(), display->mBreakType, conditions,
SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,