layout: Limit content_inline_size_for_table override to collapsed columns (#35209)

A box is usually sized by the formatting context in which it participates.
However, tables have some special sizing behaviors that we implemented
with a `content_inline_size_for_table` override.

However, breaking the assumptions of the formatting context isn't great.
It was also bad for performance that we could try to layout a table
among floats even though it wouldn't en up fitting because of a larger
min-content size.

Therefore, this changes the logic so that formatting contexts use some
special sizing for tables, and then tables only override that amount
when there are collapsed columns. Eventually, we should try to remove
that case too, see https://github.com/w3c/csswg-drafts/issues/11408

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-02-05 01:35:59 +01:00 committed by GitHub
parent 88d01f6303
commit e2bb772669
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 146 additions and 143 deletions

View file

@ -74,9 +74,9 @@ pub(crate) struct IndependentLayout {
/// <https://drafts.csswg.org/css2/visudet.html#root-height>
pub content_block_size: Au,
/// The contents of a table may force it to become wider than what we would expect
/// from 'width' and 'min-width'. It can also become smaller due to collapsed columns.
/// This is the resulting inline content size, or None for non-table layouts.
/// If a table has collapsed columns, it can become smaller than what the parent
/// formatting context decided. This is the resulting inline content size.
/// This is None for non-table layouts and for tables without collapsed columns.
pub content_inline_size_for_table: Option<Au>,
/// The offset of the last inflow baseline of this layout in the content area, if