-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use CSS spec for top layer #9093
Conversation
@annevk FYI |
Is there a corresponding fullscreen spec PR? |
The fullscreen PR is underway but not ready yet. I will post a link to it when it is ready. |
Yeah I'll be writing the fullscreen PR momentarily, when I've finished shifting all the relevant bits of it out into Position 4. |
Great to see this happen in my lifetime! Thanks for tackling it @tabatkins and @josepharhar. This seems to change the semantics for add. Is that intended? Does that have test coverage? (In the CSS draft.) Has a grammar issue. Now as for this PR: it doesn't seem to call "process top layer removals". It should as otherwise we have a leak. This also needs some amount of test coverage. |
Ah I forgot that, I just pushed a commit to add it. I also forgot to call remove from top layer immediately when any element is removed from the document, and I forgot to add a new user-agent style rule which prevents authors from triggering inconsistent states. Both of these have been added in the new commit. |
I believe you're referring to the removal of the "bubbling" behavior, where re-adding something to the top layer moves it to the top of the stack? If that's correct, then the reason for this removal was that it was "dead code" in the spec. All entrypoints to the "add" algorithm did a pre-check of one sort or another that ensured this bubbling was never executed. I believe all of those behaviors (e.g. calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit disappointed the CSS top layer spec wasn't defined to be a 1:1 replacement for the fullscreen top layer spec. I'm not necessarily opposed to these changes, but makes it harder to review. I have a lot of questions notably around the removal model.
The spec text I put into CSS was based on Rune's outline of behavior in #8189. The removal model defined there ensures that presence in the top layer is synced to rendering behavior; you can't drop out of the top layer list while still being painted in the top layer. (At least, not without invoking the "remove immediately" algo, which should be called only when necessary, such as the element being removed from the document, which also makes the painting update.) |
@tabatkins Can we put that spec text through CSSWG discussion potentially in w3c/csswg-drafts#4998? The CSSWG resolution was specifically about the
In the meanwhile, it would be nice if the spec matched the fullscreen spec (+ what the overlay property that was resolved on by the CSSWG if you want), rather than Chrome's implementation, these things that are fundamental to top layer are missing:
Thanks for taking the time to move the top layer spec to CSS btw, very much appreciated! Sorry I didn't look into Rune's comment in more detail before, it's hard to review an issue that covers so many things at once :) |
Sure
Those were all put in yesterday afternoon. |
Did someone do the archeology in Fullscreen to determine when it became "dead code" there? I'm pretty sure I added it for a reason. |
Hmm, I did not, and it’d probably be really good if someone verified that I’m right about it being dead. Perhaps there’s a corner case somewhere I missed. |
Diving backwards in blame, that algorithm was added to fullscreen in whatwg/fullscreen@766dc87. As part of that, the "fullscreen an element" algorithm was simplified to no longer manually "move it already present", and instead just called the "add to top layer" algo. This text is still present (https://fullscreen.spec.whatwg.org/#fullscreen-an-element), so per spec, the change to "add to top layer" that I put into Position would result in a behavior change - if you opened a modal dialog, then a second one on top, then fullscreened the first, it would be fullscreen under the second modal dialog. (Which is undesirable.) So either I need to revert that "add to top layer" change to match what Fullscreen previously said, or Fullscreen needs editting to restore the "move if already present" behavior manually. I'm going to assume that fixing Position is the right move for now; if all the other calling locations do manually implement the "remove and re-add" behavior anyway, having Position's algo do it as well won't affect them. |
@tabatkins moving if already present like the note in https://fullscreen.spec.whatwg.org/#top-layer-add says seems like the simpler approach here. It's hard to imagine a call site to "add to top layer" that isn't expecting the element to end up on top. |
Yep, you're right that I missed that (very!) corner case. We already discussed (PR here) throwing exceptions when two APIs are used at the same time. What about if we just throw an exception in the above corner case. I.e. Edit: it was recently pointed out that the fullscreen spec already outlaws dialog elements, so the above example (dialog A/dialog B/fullscreen A) isn't actually an example of a problem. I've come back to my position that the "pop to top" behavior is dead code. |
Assuming I'm reading this correctly ... With the current css-position-4 draft and this PR, the top layer ordering of the two dialogs A.showModal();
B.showModal();
A.close();
A.showModal(); |
Yeah, that niggled at me when I was making the fullscreen edits too. I should add an algo for checking if something is in the top layer, that pays attention to the pending removals, so we don't have this odd behavior. |
And done, https://w3c.github.io/csswg-drafts/css-position-4/#in-the-top-layer now checks if it's in the pending removals list too, so your example code will correctly put A on top. |
Also add a test for re-adding dialog elements to the top layer during an overlay transition. whatwg/html#9093 Bug: 1411264 Change-Id: Ic9dcd45cd2224995c1f64a7ae5caa01e788d17ee
Also add a test for re-adding dialog elements to the top layer during an overlay transition. whatwg/html#9093 Bug: 1411264 Change-Id: Ic9dcd45cd2224995c1f64a7ae5caa01e788d17ee
Also add a test for re-adding dialog elements to the top layer during an overlay transition. whatwg/html#9093 Bug: 1411264 Change-Id: Ic9dcd45cd2224995c1f64a7ae5caa01e788d17ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4431857 Auto-Submit: Rune Lillesveen <[email protected]> Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1131588}
Also add a test for re-adding dialog elements to the top layer during an overlay transition. whatwg/html#9093 Bug: 1411264 Change-Id: Ic9dcd45cd2224995c1f64a7ae5caa01e788d17ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4431857 Auto-Submit: Rune Lillesveen <[email protected]> Reviewed-by: Mason Freed <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1131588}
I believe it only involves fullscreen as represented by the WPT i linked |
As I commented on whatwg/fullscreen#223, I don't think the fullscreen behavior changes are necessary (notably the entry ones), we have exceptions that cover top layer conflicts? Please let me know if I'm missing something however. |
source
Outdated
<h3>The top layer</h3> | ||
|
||
<p>The <span>top layer</span> is defined by CSS, and HTML needs some top layer behavior to apply | ||
to all elements as follows:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a tad weird. Why does this not apply to SVG, MathML, or arbitrary elements?
Do we have a test where a null namespace element does have overlay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this not apply to SVG, MathML, or arbitrary elements?
Why does this sentence imply that the top layer logic does not apply to SVG etc. elements? Is it the namespace in the following CSS that does it?
Do we have a test where a null namespace element does have overlay?
Is this the right way to create a null namespace element? document.createElementNS(null, 'div')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the namespace makes that restriction.
And yeah, that's the right way. You also want to test an arbitrary string as namespace, for completeness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am adding a WPT here: web-platform-tests/wpt#40171
It looks like this user-agent style rule is intended to apply to all elements, not just HTML elements, so I am removing the @namespace
from this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also w3c/csswg-drafts#8573
See whatwg/html#9093 for HTML changes. Co-authored-by: Anne van Kesteren <[email protected]> Co-authored-by: Philip Jägenstedt <[email protected]>
This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b
This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b
This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Auto-Submit: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1150875}
This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Auto-Submit: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1150875}
This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Auto-Submit: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1150875}
Hope that helps! |
…testonly Automatic update from web-platform-tests Add WPT for overlay user-agent rules This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Auto-Submit: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1150875} -- wpt-commits: 363864de8e79f2a88a9ea97841e4c396384b7900 wpt-pr: 40171
Done
Done |
source
Outdated
<h3>The top layer</h3> | ||
|
||
<p>The <span>top layer</span> is defined by CSS, and HTML needs some top layer behavior to apply | ||
to all elements as follows:</p> | ||
|
||
<pre><code class="css">*|* { | ||
overlay: none !important | ||
}</code></pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already required by the CSS specification we rely on. We shouldn't be duplicating that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should the CSS spec have this user agent style rule in it instead of having it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required in the property definition: https://drafts.csswg.org/css-position-4/#overlay.
We can't duplicate normative requirements. So either that is done differently or we remove this. It makes some sense for it to be in CSS, although user agent style sheet requirements appearing all over the place is not great for implementers. (See also #9093 (comment).)
cc @tabatkins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see it here in that spec: https://drafts.csswg.org/css-position-4/#overlay:~:text=overlay%3A%20none%20!important
I removed this user-agent style from the PR
…testonly Automatic update from web-platform-tests Add WPT for overlay user-agent rules This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Auto-Submit: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1150875} -- wpt-commits: 363864de8e79f2a88a9ea97841e4c396384b7900 wpt-pr: 40171
…testonly Automatic update from web-platform-tests Add WPT for overlay user-agent rules This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <futharkchromium.org> Commit-Queue: Joey Arhar <jarharchromium.org> Auto-Submit: Joey Arhar <jarharchromium.org> Cr-Commit-Position: refs/heads/main{#1150875} -- wpt-commits: 363864de8e79f2a88a9ea97841e4c396384b7900 wpt-pr: 40171 UltraBlame original commit: 7cacc3ee42bfcc339942fa4bdf95af8719309de8
…testonly Automatic update from web-platform-tests Add WPT for overlay user-agent rules This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <futharkchromium.org> Commit-Queue: Joey Arhar <jarharchromium.org> Auto-Submit: Joey Arhar <jarharchromium.org> Cr-Commit-Position: refs/heads/main{#1150875} -- wpt-commits: 363864de8e79f2a88a9ea97841e4c396384b7900 wpt-pr: 40171 UltraBlame original commit: 7cacc3ee42bfcc339942fa4bdf95af8719309de8
…testonly Automatic update from web-platform-tests Add WPT for overlay user-agent rules This was asked for in the HTML PR here: whatwg/html#9093 (comment) Change-Id: I94e6960803a3fa9c6e1da4dc4393691b1c969c4b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4555988 Reviewed-by: Rune Lillesveen <futharkchromium.org> Commit-Queue: Joey Arhar <jarharchromium.org> Auto-Submit: Joey Arhar <jarharchromium.org> Cr-Commit-Position: refs/heads/main{#1150875} -- wpt-commits: 363864de8e79f2a88a9ea97841e4c396384b7900 wpt-pr: 40171 UltraBlame original commit: 7cacc3ee42bfcc339942fa4bdf95af8719309de8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @josepharhar, @tabatkins, and everyone else who helped out with this!
The top layer has been added to the CSS spec, and this patch moves the top layer references from the fullscreen spec to the CSS spec and uses new algorithms to add and remove from the top layer defined in the CSS spec.
Moving the top layer to the CSS spec has been discussed in these issues:
w3c/csswg-drafts#4998
w3c/csswg-drafts#6939
w3c/csswg-drafts#7845
w3c/csswg-drafts#8240
/infrastructure.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/popover.html ( diff )
/webappapis.html ( diff )