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.
This commit is contained in:
Aliaksandr Kalenik 2023-10-31 17:41:41 +01:00 committed by Andreas Kling
parent 387ab57eb1
commit 4676b288a2
Notes: sideshowbarker 2024-07-16 22:14:49 +09:00
3 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,17 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x140 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x124 children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 126x124 [BFC] children: not-inline
Box <table.table> at (18,18) content-size 106x104 table-box [TFC] children: not-inline
Box <tbody> at (18,18) content-size 102x100 table-row-group children: not-inline
Box <tr> at (20,20) content-size 102x100 table-row children: not-inline
BlockContainer <td> at (21,70) content-size 100x0 table-cell [BFC] children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x140]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x124]
PaintableWithLines (TableWrapper(anonymous)) [8,8 126x124]
PaintableBox (Box<TABLE>.table) [8,8 126x124]
PaintableBox (Box<TBODY>) [18,18 102x100] overflow: [18,18 104x102]
PaintableBox (Box<TR>) [20,20 102x100]
PaintableWithLines (BlockContainer<TD>) [20,20 102x100]

View file

@ -0,0 +1,7 @@
<!DOCTYPE html><style type="text/css">
.table {
width: max-content;
background-color: magenta;
border: 10px solid gold;
}
</style><table class="table"><tr style="height: 100px"><td style="width: 100px"></td></tr></table>

View file

@ -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-roots width property has a computed value (resolving to
// resolved-table-width) other than auto, the used width is the greater