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

[css-contain] Clarify what happens when display: contents and contain: style are used together #7392

Closed
mrobinson opened this issue Jun 20, 2022 · 6 comments
Labels
Closed Accepted by CSSWG Resolution css-contain-2 Current Work Tested Memory aid - issue has WPT tests

Comments

@mrobinson
Copy link
Contributor

Regarding https://drafts.csswg.org/css-contain/#containment-style:

The other types of containment have language like this:

If the element does not generate a principal box (as is the case with display values of contents or none), or its principal box is an internal table box other than table-cell, or an internal ruby box, or a non-atomic inline-level box, paint containment has no effect.

This means these types of containment have no affect when display: contents is used. In the case of contain: style this text isn't there. Should elements that have contain: style and display: contents establish a new style boundary? It seems that in Chrome it does, though perhaps with some bugs. In Gecko, this behavior might be a bit trickier to implement.

@emilio
Copy link
Collaborator

emilio commented Jun 21, 2022

FWIW I think I think this should probably not work:

  • Other counter properties do nothing on display: contents elements.
  • Other containment types don't do anything on display: contents elements.

@tabatkins
Copy link
Member

Yeah, I don't think the difference in wording was intentional here, it was just that the definition of the other containments is much more dependent on a box existing so we called out the effects.

I'm happy to say that no containment has an effect if you don't have a principal box.

@frivoal frivoal added css-display-3 Current Work and removed css-contain-1 labels Aug 4, 2022
@fantasai fantasai removed the css-display-3 Current Work label Nov 18, 2022
@dholbert
Copy link
Member

dholbert commented Mar 2, 2023

Could we get the spec updated to reflect this? CC @frivoal; maybe this needs to be on the CSSWG agenda?

Assuming we're in agreement, we need to update at least one WPT since the expectations have changed:
http://wpt.live/css/css-contain/contain-style-counters-002.html

Right now that test has the following note in an assert meta-tag (emphasis added by me):

In this test, the div#test does not generate a principal box because of 'display: contents'. Despite that particular condition, 'contain: style' will have an effect on div#test

If we change the spec as discussed above, then the test should be updated to expect that contain:style has no effect.

@dholbert
Copy link
Member

dholbert commented Jun 7, 2023

[Ticking agenda+; I'm assuming this needs csswg discussion/resolution to move forward.]

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-contain] Clarify what happens when `display: contents` and `contain: style` are used together, and agreed to the following:

  • RESOLVED: No containments apply to elements that don't generate a principal box
The full IRC log of that discussion <TabAtkins> emilio: things like counters don't usually have an effect on things without boxes
<TabAtkins> emilio: it would be tricky/weird to have contain:style have an effect on display:contents elements
<TabAtkins> emilio: I think Tab agrees with this
<fantasai> TabAtkins: Agree this is fine. Just need to copy language over, and maybe generalize so that style containment doesn't apply to things without a box
<TabAtkins> astearns: concerns?
<TabAtkins> astearns: proposed resolution is to specify that style containment has no effect on elements without a principal box
<TabAtkins> TabAtkins: I think I'll just say that *no* containments work, but yeah
<TabAtkins> RESOLVED: No containments apply to elements that don't generate a principal box

@frivoal
Copy link
Collaborator

frivoal commented May 30, 2024

Fixed in 1340485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted by CSSWG Resolution css-contain-2 Current Work Tested Memory aid - issue has WPT tests
Projects
None yet
Development

No branches or pull requests

7 participants