Skip to content
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

Specify the rendering of <details> in more detail. #10265

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

dbaron
Copy link
Member

@dbaron dbaron commented Apr 9, 2024

This makes a number of related changes to specify the rendering of the <details> element:

  • It specifies the structure of the user agent shadow tree. This appears largely interoperable between implementations with the exception of the style or link element for the default summary styles: Gecko uses a link element as the first child, Chromium uses a style element as the last child, and WebKit does not use a style element (see below). This specifies a style or link as the last child with a note that the order is not observable.
  • It specifies the existence of the default summary and the presence of UA dependent text inside of it. This is present in all of Chromium, Gecko, and WebKit.
  • It specifies the styles needed for the default summary. These match Chromium and Gecko. (These are not present in WebKit because WebKit's mechanism for styling the marker does not match the existing spec; see bug 157323.)
  • It removes the restriction that <details> is a block and cannot be changed. This is prototyped in Chromium and Gecko. This fixes Don't force <details> to be a block. #9830.
  • It specifies that the summary element is display: block by default. This matches all of Chromium, Gecko, and WebKit.
  • It specifies which element matches the ::details-content pseudo-element. This is prototyped in Chromium.
  • It makes a potentially riskier change by making the slot element that matches ::details-content be display: block all the time (rather than only when closed). This is prototyped in Chromium (more recently than the other changes).

See w3c/csswg-drafts#9879 and w3c/csswg-drafts#9951 for more background.

(See WHATWG Working Mode: Changes for more details.)


/infrastructure.html ( diff )
/rendering.html ( diff )

This makes a number of related changes to specify the rendering of the
<details> element:

* It specifies the structure of the user agent shadow tree.  This
  appears largely interoperable between implementations with the
  exception of the style or link element for the default summary styles:
  Gecko uses a link element as the first child, Chromium uses a style
  element as the last child, and WebKit does not use a style element
  (see below).  This specifies a style or link as the first child.
* It specifies the existence of the default summary and the presence of
  UA dependent text inside of it.  This is present in all of Chromium,
  Gecko, and WebKit.
* It specifies the styles needed for the default summary.  These match
  Chromium and Gecko.  (These are not present in WebKit because WebKit's
  mechanism for styling the marker does not match the existing spec.)
* It removes the restriction that <details> is a block and cannot be
  changed.  This is prototyped in Chromium and Gecko.  This fixes whatwg#9830.
* It specifies that the summary element is display: block by default.
  This matches all of Chromium, Gecko, and WebKit.
* It specifies which element matches the ::details-content
  pseudo-element.  (TODO: This needs to be specified in CSS)  This is
  prototyped in Chromium.

See w3c/csswg-drafts#9879 and
w3c/csswg-drafts#9951 for more background.
@dbaron
Copy link
Member Author

dbaron commented Apr 9, 2024

Sorry, apparently Shift-enter submits the form, I wasn't quite ready to submit and I'll continue editing the above comment.

@domenic
Copy link
Member

domenic commented Apr 11, 2024

  • It specifies the structure of the user agent shadow tree. This appears largely interoperable between implementations with the exception of the style or link element for the default summary styles: Gecko uses a link element as the first child, Chromium uses a style element as the last child, and WebKit does not use a style element (see below). This specifies a style or link as the first child.

Are these differences observable? If not, then perhaps the spec can be clearer about that, so that people understand any implementation strategy that achieves equivalent results is fine.

@dbaron
Copy link
Member Author

dbaron commented Apr 11, 2024

Are these differences observable? If not, then perhaps the spec can be clearer about that, so that people understand any implementation strategy that achieves equivalent results is fine.

That's a good question. When I wrote it I was (for some reason) thinking that the ordering was observable via selectors, but now that I think about it again I think it's not. We do need to get the exact CSS definitions of what does and doesn't apply sorted out, though, to make sure. But I think as long as (a) link or style in the shadow tree are display:none and can't be changed and (b) the relative positions of the elements in the shadow tree can't be determined by selectors, then I think it's not observable. (The relative positions of displayable elements in the shadow tree can be determined by layout differences, probably most easily with display: grid.)

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we describe it as two child elements and an associated style sheet? It seems like it should be immaterial how the style sheet is associated with the shadow tree. It just needs to have one.

<p>The second child element is a <code>slot</code> that is expected to take the
<code>details</code> element's first <code>summary</code> element child, if any. This element
has a single child <code>summary</code> element called the <dfn>default summary</dfn> which has
text content that is <span>implementation-defined</span> (and probably locale-specific).</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we recommend here that it follows from the node's language? I think that's what we do for form controls today even though it's not (yet) implemented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the current wording for the default text of submit/reset buttons and (except for "possibly" versus "probably") the text of the "Choose file" button in <input type=file>. The only wording I found that seems like what you're thinking of was the wording about presentation of dates, times, and numbers. This seems more similar to submit/reset and to the file chooser button than it it does to presentation of dates, in that it feels a bit odd to make this differ from those.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that when we changed the wording for dates, times, and numbers, the button language was overlooked. But I guess we can sort that out in a follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #10437 to follow up.

source Outdated
Comment on lines 134215 to 134216
<!-- TODO: link to CSS definition when spec is ready -->
<p>This element is expected to match the '::details-content' pseudo-element.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be mentioned in HTML's Selectors section?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. The one existing pseudo-element (::file-selector-button) is not currently mentioned there. It seems like it might be useful to mention the pseudo-elements in that section, but it also seems like maybe (unlike for the pseudo-classes) if we do so, perhaps the pseudo-elements part of that section should be more like an index than the location of the formal definition?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess that's correct. In which case maybe it's not worth it.

@dbaron
Copy link
Member Author

dbaron commented Apr 18, 2024

Are these differences observable? If not, then perhaps the spec can be clearer about that, so that people understand any implementation strategy that achieves equivalent results is fine.

Can we describe it as two child elements and an associated style sheet? It seems like it should be immaterial how the style sheet is associated with the shadow tree. It just needs to have one.

I've revised the change to go mostly in this direction: I still describe the style as an element, explicitly note that the order isn't observable, and note that its association using an element isn't observable either (although I don't know what other standard mechanism we'd describe the styles with). I also now describe it as the third child rather than the first, since in hindsight it seems nice to use "first" and "second" for the first and second rendered children. But I didn't go so far as to just handwave about how the association is made. Does that seem reasonable?

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editorially LGTM. Happy to merge when we have the checkboxes filled out. Let us know if you have other people (e.g. @emilio) whose reviews you want to block on before merging.

@emilio
Copy link
Contributor

emilio commented Apr 22, 2024

I've revised the change to go mostly in this direction: I still describe the style as an element, explicitly note that the order isn't observable, and note that its association using an element isn't observable either (although I don't know what other standard mechanism we'd describe the styles with).

Adopted stylesheets would be an option fwiw.

I also now describe it as the third child rather than the first, since in hindsight it seems nice to use "first" and "second" for the first and second rendered children. But I didn't go so far as to just handwave about how the association is made. Does that seem reasonable?

Works for me.

<li>
<p>The third child element is either a <code>link</code> or <code>style</code>
element with the following styles for the <span>default summary</span>:</p>
<pre><code class="css">:host summary {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably use :host > summary for parallelism with the rule below right? (or just summary?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbaron, ping to make sure you saw this, as I agree it seems strange for these two lines to diverge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for missing this. I've now made them consistent by changing the second selector, since that matches both Chrome's code and Firefox's code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Can you be sure this distinction is tested?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's untestable, since it's styling the UA shadow DOM, and the only summary in that shadow DOM is in fact a child of the host.

(But when I was adjusting for consistency it seemed to make sense to match the existing implementations even when the difference didn't matter.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, actually... maybe it's not a child of the host and the old style was just wrong!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's not, because it's the slot fallback.

@dbaron
Copy link
Member Author

dbaron commented Jun 3, 2024

One substantive thing that I'm thinking of changing here: right now the ::details-content is a pseudo-element that addresses an element that is internally a <slot>. <slot> elements default to display: contents. This is somewhat inconvenient since some styles don't work on elements that are display: contents. So I think probably it should be display: block by default all of the time (rather than only when it's hidden).

(This has tripped me up multiple times while writing examples, and I think it's probably better to change it if it doesn't break anything, which I don't think it will.)

@bramus
Copy link

bramus commented Jun 3, 2024

I think probably it should be display: block by default all of the time (rather than only when it's hidden).

In all my experiments (here, here, and here) I have done this, so +1 on using display: block by default.

dbaron added a commit to w3c/csswg-drafts that referenced this pull request Jun 5, 2024
This simplifies the example in two ways:

1. By depending on the animation rules defined in
https://drafts.csswg.org/css-contain-3/#content-visibility-animation the
step-end and step-start values are not needed.  (I had forgotten about
these.)

2. By depending on the change in
whatwg/html#10265 (comment)
and
whatwg/html@fb3033a
the display: block is no longer needed.
@dbaron
Copy link
Member Author

dbaron commented Jun 18, 2024

I think this is ready for another look. There are a few additional changes since the last round of reviews; the draft commit message above is updated to reflect them.

(There's one checkbox still unchecked, but that's just because I'm waiting to make a PR to make the tests not tentative until the last tentative test lands, hopefully later today or Thursday.)

yisibl added a commit to yisibl/csswg-drafts that referenced this pull request Jun 20, 2024
1. By depending on the animation rules defined in
https://drafts.csswg.org/css-contain-3/#content-visibility-animation the
step-end and step-start values are not needed.

2. 2. By depending on the change in
[whatwg/html#10265 (comment)](whatwg/html#10265 (comment))
and
whatwg/html@fb3033a
the display: block is no longer needed.
yisibl added a commit to yisibl/csswg-drafts that referenced this pull request Jun 20, 2024
1. By depending on the animation rules defined in
https://drafts.csswg.org/css-contain-3/#content-visibility-animation the
step-end and step-start values are not needed.

2. 2. By depending on the change in
whatwg/html#10265 (comment)
and
whatwg/html@fb3033a
the `display: block` is no longer needed.
dbaron added a commit to dbaron/web-platform-tests that referenced this pull request Jun 20, 2024
This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
dbaron pushed a commit to w3c/csswg-drafts that referenced this pull request Jun 20, 2024
1. By depending on the animation rules defined in
https://drafts.csswg.org/css-contain-3/#content-visibility-animation the
step-end and step-start values are not needed.

2. 2. By depending on the change in
whatwg/html#10265 (comment)
and
whatwg/html@fb3033a
the `display: block` is no longer needed.
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo last question about more tests.

It looks like since this last got a detailed look from @annevk and @emilio, we changed ::details-content to be display: block. (Is that tested too?)

So, I'll give them a few more days to chime in, and plan on merging this around Wednesday Japan time if nothing further comes in.

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sounds good trying to make the slot display: block unconditionally.

<p>This element is expected to match the <span>'::details-content'</span> pseudo-element.</p>

<p>This element is expected to have its <code data-x="attr-style">style</code> attribute set to
"<code data-x="">display: block; content-visibility: hidden;</code>" when the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be slightly nicer to make the display: block change part of the UA sheet. Maybe slot + slot { display: block }? Same with the content-visibility one for what is worth (we do this), but I guess it doesn't matter much and it's not really observable. It's just less magic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My inclination is that it is probably reasonable to do that as a separate change, but I'd prefer not to make this change bigger (this is an issue that already exists prior to this PR), and I'd probably also like to check it by implementing it and making sure it actually works the way we think it does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sorry should've clarified that my comment wasn't meant to be blocking in any way. Sounds good. Maybe file a follow-up issue for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #10438 to follow up.

@domenic domenic merged commit e0e3b26 into whatwg:main Jun 26, 2024
2 checks passed
dbaron added a commit to web-platform-tests/wpt that referenced this pull request Jun 26, 2024
)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Jun 29, 2024
… no longer be tentative., a=testonly

Automatic update from web-platform-tests
Make tests for new details styling rules no longer be tentative. (#46847)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
--

wpt-commits: fa175971884023f4012147551ca6fb187c8c417b
wpt-pr: 46847
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jun 29, 2024
… no longer be tentative., a=testonly

Automatic update from web-platform-tests
Make tests for new details styling rules no longer be tentative. (#46847)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
--

wpt-commits: fa175971884023f4012147551ca6fb187c8c417b
wpt-pr: 46847
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 1, 2024
… no longer be tentative., a=testonly

Automatic update from web-platform-tests
Make tests for new details styling rules no longer be tentative. (#46847)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
--

wpt-commits: fa175971884023f4012147551ca6fb187c8c417b
wpt-pr: 46847

UltraBlame original commit: 5cd2d3944f207a6f45e6be3222e018d674202e7b
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 1, 2024
… no longer be tentative., a=testonly

Automatic update from web-platform-tests
Make tests for new details styling rules no longer be tentative. (#46847)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
--

wpt-commits: fa175971884023f4012147551ca6fb187c8c417b
wpt-pr: 46847

UltraBlame original commit: 5cd2d3944f207a6f45e6be3222e018d674202e7b
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Jul 2, 2024
… no longer be tentative., a=testonly

Automatic update from web-platform-tests
Make tests for new details styling rules no longer be tentative. (#46847)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
--

wpt-commits: fa175971884023f4012147551ca6fb187c8c417b
wpt-pr: 46847
sadym-chromium pushed a commit to web-platform-tests/wpt that referenced this pull request Jul 18, 2024
)

This removes the ".tentative" from the filename of tests that are
testing the changes specified in
whatwg/html#10265 and removes one test (testing
that the display property is ignored) that is obsoleted by those
changes.  (A number of the other tests test what the display property
does.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Don't force <details> to be a block.
5 participants