csswg-drafts icon indicating copy to clipboard operation
csswg-drafts copied to clipboard

[css-contain-2] Should `content-visibility` apply to elements when size containment has no effect?

Open Loirooriol opened this issue 3 years ago • 2 comments

https://drafts.csswg.org/css-contain/#content-visibility

Applies to: elements for which layout containment can apply

That is, if

Note that content-visibility can trigger:

  • Layout containment, which is guaranteed to work by "applies to".
  • Paint containment, which is guaranteed to work since it has the same requirements as layout containment.
  • Style containment, which is guaranteed to work since it applies to all elements.
  • Size containment

Size containment has similar requirements:

The difference is that layout containment has effect in a table and table-cell boxes, so content-visibility applies, but size containment has no effect.

Consider this testcase:

<!DOCTYPE html>
<style>table { border: solid } td { border: solid blue }</style>
<table><td style="content-visibility: hidden">Lorem</td></table>
<table style="content-visibility: hidden"><td>Ipsum</td></table>

"Lorem" is not painted in either Firefox nor Chromium. But in Firefox, due to the lack of size containment, the size of the cell takes the contents into account! Seems to follow the spec, but does this make sense? Chromium ignores the requirements and force-applies size containment.

"Ipsum" is similarly not painted in Firefox, while the table takes the size of the contents. Chromium just ignores content-visibility: hidden in this case.

So maybe say that content-visibility doesn't apply when size containment has no effect? And BTW I still think it would make more sense if size containment worked in table cells, see #1791.

Loirooriol avatar Aug 29 '22 19:08 Loirooriol

Agenda+ to see if we can change content-visibility to apply to elements for which size containment can apply.

frivoal avatar Sep 18 '22 00:09 frivoal

Minutes weren't added, but there was a resolution:

RESOLVED: content-visibility applies to elements that can have size containment

vmpstr avatar Oct 19 '22 16:10 vmpstr