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

@ -533,10 +533,12 @@ impl ReplacedContents {
.into()
};
let (preferred_inline, min_inline, max_inline) = sizes.inline.resolve_each(
Direction::Inline,
automatic_size.inline,
Au::zero(),
inline_stretch_size,
get_inline_content_size,
false, /* is_table */
);
let inline_size = preferred_inline.clamp_between_extremums(min_inline, max_inline);
@ -560,10 +562,12 @@ impl ReplacedContents {
.into()
});
let block_size = sizes.block.resolve(
Direction::Block,
automatic_size.block,
Au::zero(),
block_stretch_size.unwrap_or_else(|| block_content_size.max_content),
|| *block_content_size,
false, /* is_table */
);
LogicalVec2 {