Closed rwlbuis closed 4 months ago
If I get it right, https://fullscreen.spec.whatwg.org/#new-stacking-layer says
It is rendered as an atomic unit as if it were a sibling of its root.
which seems to imply the dialog is reparented in the box tree. Then the transformed div is not an ancestor of the positioned div in the box tree. And this is a requirement https://drafts.csswg.org/css-position/#fixed-cb
The containing block is established by the nearest ancestor box that establishes an fixed positioning containing block
So the transformed div should not be the containing block.
Instead, I guess the containing block should be the viewport, since the dialog doesn't have a transform or something that makes it establish a fixed positioning containing block.
Alternatively, <dialog>
could automagically establish a fixed positioning containing block if that's considered to be better behavior.
@tabatkins WDYT?
Right, this probably does still need a little more clarification, but anything moving to the top layer is reparented for rendering purposes. Everything Oriol said is correct. Assuming the dialog
itself isn't doing anything, its fixpos descendants will just see the ICB as normal.
I think it probably makes sense to make top layer elements a containing block for all descendants like transform / etc do, though...
So how should the following behave:
<dialog style="position:absolute"> <!--- after showModal --->
<div style="position:fixed"></div>
</dialog>
With the proposal (top layer is containing block for fixed) then the position:fixed
will scroll with the document.
@emilio Why do you think that's a better behavior than letting fixpos "work normally" in the top layer? Top layer just moves where in the order it paints, it doesn't create any essential separate painting contexts like transform/etc does.
The CSS Working Group just discussed [css-position-3] Containing block of dialog fixed position children
, and agreed to the following:
RESOLVED: Clarify that due to the box-tree reparenting, an ancestor outside the dialog can't be a fixpos CB for children of the dialog
Firefox, Safari and Chrome all have interop on this example, which has a fixed-pos element below a dialog with abs-pos. So I think we should keep the spec as is and not make <dialog>
a container for fixed-pos descendants.
Firefox, Safari and Chrome all have interop on this example, which has a fixed-pos element below a dialog with abs-pos. So I think we should keep the spec as is and not make
<dialog>
a container for fixed-pos descendants.
If you add a transformed div containing the dialog in this testcase then Firefox, Safari, and Chrome all have different renderings.
@emilio Why do you think that's a better behavior than letting fixpos "work normally" in the top layer? Top layer just moves where in the order it paints, it doesn't create any essential separate painting contexts like transform/etc does.
It also changes the containing block of the elements in a way that it escapes transformed ancestors etc.
It also causes layout ordering issues in some cases. E.g., if you have a top layer with a regular fixed-pos inside, what is the hypothetical position of that fixed-pos?
I think the two realistic options are:
Otherwise you have layout cycles (since the fixed pos hypothetical position depends on the top layer being already laid out, but the top layer could be in a regular fixed pos too).
The former has a risk of making the internal top layer list that the HTML spec uses out of sync with the CSS top layer, so I have a preference for the later.
Otherwise you have layout cycles (since the fixed pos hypothetical position depends on the top layer being already laid out, but the top layer could be in a regular fixed pos too).
I don't see how the top layer can "be in a regular fixed pos". If an element has an ancestor that is position:fixed, then while the element is in the top layer, that position:fixed element does not affect the element's layout. The top layer reparents the element in the layout tree.
In other words, the element gets put in a different place in the layout tree, and then its layout, containing block and so on is determined according to that adjusted tree, with the usual rules.
The CSS Working Group just discussed [css-position-3] Containing block of dialog fixed position children
.
If you add a transformed div containing the dialog in this testcase then Firefox, Safari, and Chrome all have different renderings.
Chrome renders this example correctly (which has a transform) according to the current specification. Firefox doesn't seem to render either this or the earlier one right, not sure why.
It also changes the containing block of the elements in a way that it escapes transformed ancestors etc.
Yes, it does, but that is on purpose and a good thing, because it lets the top layer render on top and outside of its parented boxes (by reparenting the boxes in the layout tree. I think that is well-defined and makes sense because the top layer is a special stacking context on top of and outside of other page contents.
It also causes layout ordering issues in some cases. E.g., if you have a top layer with a regular fixed-pos inside, what is the hypothetical position of that fixed-pos?
The containing block of that fixed position element's box is the containing box that is a container for fixed position (not the containing DOM element). So if there was a transformed element ancestor box of it within the top layer then the fixed position element would be contained by it. Otherwise it would be contained by the root (aka LayoutView in Chromium, aka viewport).
Agenda+ to propose closing this issue as no change to specification.
I'm ok with that as long as we fix https://github.com/w3c/csswg-drafts/issues/9939 too :)
I'm ok with that as long as we fix #9939 too :)
Agreed!
The CSS Working Group just discussed [css-position-3] Containing block of dialog fixed position children
, and agreed to the following:
RESOLVED: No change to specification
I wonder what the cb should be of the fixed positioned dialog child:
If this test is valid then the fixed positioned dialog child'cb is html aka viewport: https://wpt.fyi/results/html/semantics/interactive-elements/the-dialog-element/top-layer-stacking.html?label=experimental&label=master&aligned
I have heard some opinions though that the dialog itself should be the cb.
I can't really conclude from the spec what the cb should be, for one thing what should qualify something to be a fixed positioning containing block seems not specified in one location/spec. Is there something I am missing in the spec and/or what do people think should be the cb in the example?