Don't update row baseline if cell is empty (#31831)

Gecko, Blink and WebKit agree that the if a row only has empty cells,
its baseline should be at the bottom, not at the top.

There isn't interoperability when the cells are just empty-ish, so this
patch takes the simplest approach, aligning with Blink: any out-of-flow
or in-flow content other than collapsed whitespace counts as not empty.
This commit is contained in:
Oriol Brufau 2024-03-25 10:39:02 +01:00 committed by GitHub
parent c50df5ccbe
commit dbe3cb8a3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 47 additions and 7 deletions

View file

@ -54,6 +54,12 @@ impl CellLayout {
fn outer_block_size(&self) -> Au {
self.layout.content_block_size + (self.border.block_sum() + self.padding.block_sum()).into()
}
/// Whether the cell has no in-flow or out-of-flow contents, other than collapsed whitespace.
/// Note this logic differs from 'empty-cells', which counts abspos contents as empty.
fn is_empty(&self) -> bool {
self.layout.fragments.is_empty()
}
}
/// Information stored during the layout of rows.
@ -1560,7 +1566,7 @@ impl<'a> TableLayout<'a> {
let row_block_offset = row_rect.start_corner.block;
let row_baseline = self.row_baselines[row_index];
if cell.effective_vertical_align() == VerticalAlignKeyword::Baseline {
if cell.effective_vertical_align() == VerticalAlignKeyword::Baseline && !layout.is_empty() {
let baseline = row_block_offset + row_baseline;
if row_index == 0 {
baselines.first = Some(baseline);