From 4676b288a213a729c05d913a1ef39aa7b3f92c15 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 31 Oct 2023 17:41:41 +0100 Subject: [PATCH] LibWeb: Set table width to GRIDMAX if calculated value is max-content If the width of the table container is specified as max-content, then it seems sensible to resolve it as the sum of the maximum widths of the columns. --- .../expected/table/table-max-content-width.txt | 17 +++++++++++++++++ .../input/table/table-max-content-width.html | 7 +++++++ .../LibWeb/Layout/TableFormattingContext.cpp | 2 ++ 3 files changed, 26 insertions(+) create mode 100644 Tests/LibWeb/Layout/expected/table/table-max-content-width.txt create mode 100644 Tests/LibWeb/Layout/input/table/table-max-content-width.html diff --git a/Tests/LibWeb/Layout/expected/table/table-max-content-width.txt b/Tests/LibWeb/Layout/expected/table/table-max-content-width.txt new file mode 100644 index 0000000000..cfefdcb492 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/table/table-max-content-width.txt @@ -0,0 +1,17 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x140 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x124 children: not-inline + TableWrapper <(anonymous)> at (8,8) content-size 126x124 [BFC] children: not-inline + Box at (18,18) content-size 106x104 table-box [TFC] children: not-inline + Box at (18,18) content-size 102x100 table-row-group children: not-inline + Box at (20,20) content-size 102x100 table-row children: not-inline + BlockContainer at (21,70) content-size 100x0 table-cell [BFC] children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x140] + PaintableWithLines (BlockContainer) [8,8 784x124] + PaintableWithLines (TableWrapper(anonymous)) [8,8 126x124] + PaintableBox (Box.table) [8,8 126x124] + PaintableBox (Box) [18,18 102x100] overflow: [18,18 104x102] + PaintableBox (Box) [20,20 102x100] + PaintableWithLines (BlockContainer
) [20,20 102x100] diff --git a/Tests/LibWeb/Layout/input/table/table-max-content-width.html b/Tests/LibWeb/Layout/input/table/table-max-content-width.html new file mode 100644 index 0000000000..d288072ffd --- /dev/null +++ b/Tests/LibWeb/Layout/input/table/table-max-content-width.html @@ -0,0 +1,7 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 200e50abb2..6767976d52 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -503,6 +503,8 @@ void TableFormattingContext::compute_table_width() used_width = max(used_width, adjusted_used_width); } } + } else if (computed_values.width().is_max_content()) { + used_width = grid_max; } else { // If the table-root’s width property has a computed value (resolving to // resolved-table-width) other than auto, the used width is the greater