From 29352f570ac67c706782f4112e307b1b0613a9b5 Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Sat, 26 Aug 2023 00:48:06 +0000 Subject: [PATCH] LibWeb: Fix table column constrainedness Adjust implementation to reflect the CSS 2.1 definition of width. --- ...eyword-value-does-not-constrain-column.txt | 25 +++++++++++++++++++ ...yword-value-does-not-constrain-column.html | 5 ++++ .../LibWeb/Layout/TableFormattingContext.cpp | 10 +++++--- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/table/keyword-value-does-not-constrain-column.txt create mode 100644 Tests/LibWeb/Layout/input/table/keyword-value-does-not-constrain-column.html diff --git a/Tests/LibWeb/Layout/expected/table/keyword-value-does-not-constrain-column.txt b/Tests/LibWeb/Layout/expected/table/keyword-value-does-not-constrain-column.txt new file mode 100644 index 00000000000..f914e342f3f --- /dev/null +++ b/Tests/LibWeb/Layout/expected/table/keyword-value-does-not-constrain-column.txt @@ -0,0 +1,25 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x23.46875 children: not-inline + TableWrapper <(anonymous)> at (8,8) content-size 37.609375x23.46875 [BFC] children: not-inline + Box at (8,8) content-size 37.609375x23.46875 table-box [TFC] children: not-inline + Box at (8,8) content-size 33.609375x19.46875 table-row-group children: not-inline + Box at (10,10) content-size 33.609375x19.46875 table-row children: not-inline + BlockContainer at (11,11) content-size 31.609375x17.46875 table-cell [BFC] children: inline + line 0 width: 31.609375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 3, rect: [11,11 31.609375x17.46875] + "A B" + TextNode <#text> + BlockContainer <(anonymous)> at (8,31.46875) content-size 784x0 children: inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x600] + PaintableWithLines (BlockContainer) [8,8 784x23.46875] + PaintableWithLines (TableWrapper(anonymous)) [8,8 37.609375x23.46875] + PaintableBox (Box
) [8,8 37.609375x23.46875] + PaintableBox (Box) [8,8 33.609375x19.46875] overflow: [8,8 35.609375x21.46875] + PaintableBox (Box) [10,10 33.609375x19.46875] + PaintableWithLines (BlockContainer
.ab) [10,10 33.609375x19.46875] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer(anonymous)) [8,31.46875 784x0] diff --git a/Tests/LibWeb/Layout/input/table/keyword-value-does-not-constrain-column.html b/Tests/LibWeb/Layout/input/table/keyword-value-does-not-constrain-column.html new file mode 100644 index 00000000000..5dea3be1b9e --- /dev/null +++ b/Tests/LibWeb/Layout/input/table/keyword-value-does-not-constrain-column.html @@ -0,0 +1,5 @@ +
A B
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 37219338874..44918d5b29a 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -62,11 +62,13 @@ CSSPixels TableFormattingContext::run_caption_layout(LayoutMode layout_mode, CSS void TableFormattingContext::compute_constrainedness() { // Definition of constrainedness: https://www.w3.org/TR/css-tables-3/#constrainedness + // NB: The definition uses https://www.w3.org/TR/CSS21/visudet.html#propdef-width for width, which doesn't include + // keyword values. The remaining checks can be simplified to checking whether the size is a length. size_t column_index = 0; TableGrid::for_each_child_box_matching(table_box(), is_table_column_group, [&](auto& column_group_box) { TableGrid::for_each_child_box_matching(column_group_box, is_table_column, [&](auto& column_box) { auto const& computed_values = column_box.computed_values(); - if (!computed_values.width().is_auto() && !computed_values.width().is_percentage()) { + if (computed_values.width().is_length()) { m_columns[column_index].is_constrained = true; } auto const& col_node = static_cast(*column_box.dom_node()); @@ -77,18 +79,18 @@ void TableFormattingContext::compute_constrainedness() for (auto& row : m_rows) { auto const& computed_values = row.box->computed_values(); - if (!computed_values.height().is_auto() && !computed_values.height().is_percentage()) { + if (computed_values.height().is_length()) { row.is_constrained = true; } } for (auto& cell : m_cells) { auto const& computed_values = cell.box->computed_values(); - if (!computed_values.width().is_auto() && !computed_values.width().is_percentage()) { + if (computed_values.width().is_length()) { m_columns[cell.column_index].is_constrained = true; } - if (!computed_values.height().is_auto() && !computed_values.height().is_percentage()) { + if (computed_values.height().is_length()) { m_rows[cell.row_index].is_constrained = true; } }