layout: Align table-cell contents safely (#39491)

As resolved in https://github.com/w3c/csswg-drafts/issues/12220, when
resolving `align-content: normal` on a table cell, we will now use safe
alignment.

The difference only matters when the contents of the cell are taller
than the cell, which doesn't typically happen. But in Servo it's
observable when there are collapsed rows.

Testing: Adding new tests. Some fail because we don't support
`align-content` yet.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-09-26 09:44:23 +02:00 committed by GitHub
parent 92dd54b1ec
commit 858208bd25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 260 additions and 4 deletions

View file

@ -2819,12 +2819,11 @@ impl TableSlotCell {
let cell_content_rect = cell_rect.deflate(&(layout.padding + layout.border));
let content_block_size = layout.layout.content_block_size;
let free_space = || Au::zero().max(cell_content_rect.size.block - content_block_size);
let vertical_align_offset = match self.effective_vertical_align() {
VerticalAlignKeyword::Top => Au::zero(),
VerticalAlignKeyword::Bottom => cell_content_rect.size.block - content_block_size,
VerticalAlignKeyword::Middle => {
(cell_content_rect.size.block - content_block_size).scale_by(0.5)
},
VerticalAlignKeyword::Bottom => free_space(),
VerticalAlignKeyword::Middle => free_space().scale_by(0.5),
_ => {
cell_baseline -
(layout.padding.block_start + layout.border.block_start) -