layout: Only prevent fixed table layout when inline-size is auto (#35882)

We were ignoring `table-layout: fixed` both for `inline-size: auto` and
`inline-size: max-content`. However, the CSSWG resolved that fixed table
layout should be triggered except when `inline-size` is `auto`.
https://github.com/w3c/csswg-drafts/issues/10937#issuecomment-2669150397

Blink has already adopted this change, and they modified the WPT
`/css/css-tables/fixed-layout-2.html` accordingly. Here I'm doing some
further cosmetic cleanups to the test.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-03-10 15:09:43 +01:00 committed by GitHub
parent 79e25a3e77
commit 56da4ad959
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 33 deletions

View file

@ -240,15 +240,11 @@ impl Zero for CellOrTrackMeasure {
impl<'a> TableLayout<'a> {
fn new(table: &'a Table) -> TableLayout<'a> {
// It's not clear whether `inline-size: stretch` allows fixed table mode or not,
// we align with Gecko and Blink.
// <https://github.com/w3c/csswg-drafts/issues/10937>.
let is_in_fixed_mode = table.style.get_table().clone_table_layout() ==
TableLayoutMode::Fixed &&
!matches!(
table.style.box_size(table.style.writing_mode).inline,
Size::Initial | Size::MaxContent
);
// The CSSWG resolved that only `inline-size: auto` can prevent fixed table mode.
// <https://github.com/w3c/csswg-drafts/issues/10937#issuecomment-2669150397>
let style = &table.style;
let is_in_fixed_mode = style.get_table().table_layout == TableLayoutMode::Fixed &&
!style.box_size(style.writing_mode).inline.is_initial();
Self {
table,
pbm: PaddingBorderMargin::zero(),