Skip to content

[css-view-transitions] Rendering consolidation section should special-case root element #11772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
emilio opened this issue Feb 25, 2025 · 9 comments
Labels
css-view-transitions-1 View Transitions; Bugs only

Comments

@emilio
Copy link
Collaborator

emilio commented Feb 25, 2025

https://drafts.csswg.org/css-view-transitions-1/#named-and-transitioning has:

Elements captured in a view transition during a view transition or whose view-transition-name computed value is not none (at any time):

  • Form a stacking context.
  • Are flattened in 3D transforms.
  • Form a backdrop root.

Interpreted literally, it means that the root element box would become a stacking context always (via :root { view-transition-name: root } in the UA sheet). That seems unintended and doesn't match implementations.

My understanding is that the root element is "special" and gets propagated to the whole snapshot-containing-block rect / doesn't need its own stacking context.

The spec should reflect that, unless I'm missing something?

cc @chrishtr @noamr @nt1m @vmpstr

@emilio emilio added the css-view-transitions-1 View Transitions; Bugs only label Feb 25, 2025
@noamr
Copy link
Collaborator

noamr commented Mar 12, 2025

@emilio
Copy link
Collaborator Author

emilio commented Mar 12, 2025

https://www.w3.org/TR/CSS2/visuren.html#x43:~:text=The%20root%20element%20forms,%27%20%5BCSS3COLOR%5D

That is not "the root element box" tho. There is a root stacking context, but it's not generated by the actual root element box.

https://drafts.csswg.org/css-position-4/#paint-a-stacking-context:~:text=Assert%3A%20root%20is%20a%20box%2C%20and%20generates%20a%20stacking%20context.
assert that the root element creates a stacking context already.

That I think you misread? root there is an argument, not the root element.

Is that what you're missing or is there something I'm missing? :)

In Gecko for example (haven't checked webkit) the root element can create a stacking context on its own:

<!doctype html>
<style>
  :root {
    isolation: isolate;
    background-color: red;
  }
  div {
    position: fixed;
    width: 100px;
    height: 100px;
    background-color: green;
    mix-blend-mode: exclusion;
  }
</style>
<div></div>

It seems Blink will not isolate the root box in that case. But you can do fairly wild stuff with that box like making it absolutely-positioned or something, so I'd expect this:

<!doctype html>
<style>
  :root {
    position: absolute;
    isolation: isolate;
    width: 50px;
    height: 50px;
    background-color: red;
    border: 50px solid blue;
  }
  div {
    position: fixed;
    width: 100px;
    height: 100px;
    background-color: green;
    mix-blend-mode: exclusion;
  }
</style>
<div></div>

To behave similar to this:

<!doctype html>
<style>
  :root {
    background-color: red;
  }
  .root {
    position: absolute;
    isolation: isolate;
    width: 50px;
    height: 50px;
    border: 50px solid blue;
  }
  div {
    position: fixed;
    width: 100px;
    height: 100px;
    background-color: green;
    mix-blend-mode: exclusion;
  }
</style>
<div class="root">
  <div></div>
</div>

Yet neither Blink or Gecko do that.

https://drafts.fxtf.org/compositing-1/#pagebackdrop doesn't seem to say if the inner root box is able to create a stacking context or not, though it says that a lot of the compositing effects specified on the root element get propagated to the root group...

Anyways I think at least some clarification here is in order, even if not view-transition specific in the end... :)

@noamr
Copy link
Collaborator

noamr commented Mar 12, 2025

Look at: https://drafts.csswg.org/css-position-4/#paint-a-document

It calls "paint a stacking context" with the root element, which then asserts that it's a stacking context.

@emilio
Copy link
Collaborator Author

emilio commented Mar 12, 2025

Yes, but my point is that there are two boxes involved, not one. Nobody is debating that the outer / viewport / root box is a stacking context. Whether the "inner" box (the abspos in my example above) is / should be a stacking context is the question.

@noamr
Copy link
Collaborator

noamr commented Mar 12, 2025

Yes, but my point is that there are two boxes involved, not one. Nobody is debating that the outer / viewport / root box is a stacking context. Whether the "inner" box (the abspos in my example above) is / should be a stacking context is the question.

OK. As you said, not sure if this is a view transitions issue.

@Loirooriol
Copy link
Contributor

Also see #8353

@chrishtr
Copy link
Contributor

chrishtr commented May 1, 2025

the "inner" box (the abspos in my example above)

Which example are you referring to? Is the html element (aka :root) the element you're talking about?

Blink forces the document element (aka the html element in HTML documents) to be a stacking context here, regardless of its style. It's in CSS2 here.

LMK if I'm still not understanding what you are saying, I think I might be..

@chrishtr
Copy link
Contributor

chrishtr commented May 2, 2025

This issue/comment from Oriol indicates that Blink and Webkit always make the root element a stacking context, but Firefox does not. Can Firefox just change its behavior? Given the current Firefox behavior is apparently compatible with websites, I would think that changing it will also be compatible.

@emilio
Copy link
Collaborator Author

emilio commented May 2, 2025

I think it's a bit more complicated. At least when I did that there were a bunch of test issues related to blending and what not.

I'll look into it and report back (I fixed some of these compositing of the root group issues for view transitions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-view-transitions-1 View Transitions; Bugs only
Projects
None yet
Development

No branches or pull requests

4 participants