Skip to content

Commit

Permalink
LibWeb: Consider every row when calculating table width
Browse files Browse the repository at this point in the history
  • Loading branch information
Gingeh authored and AtkinsSJ committed Nov 5, 2024
1 parent c67ecf3 commit d1b967b
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 15 deletions.
30 changes: 16 additions & 14 deletions Tests/LibWeb/Layout/expected/table/clip-spans-to-table-end.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x117 children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 92.359375x117 [BFC] children: not-inline
Box <table> at (8,8) content-size 92.359375x117 table-box [TFC] children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 93.359375x117 [BFC] children: not-inline
Box <table> at (8,8) content-size 93.359375x117 table-box [TFC] children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tbody> at (8,8) content-size 92.359375x117 table-row-group children: not-inline
Box <tr> at (8,8) content-size 92.359375x39 table-row children: not-inline
Box <tbody> at (8,8) content-size 93.359375x117 table-row-group children: not-inline
Box <tr> at (8,8) content-size 93.359375x39 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (19,19) content-size 8.453125x17 table-cell [BFC] children: inline
Expand All @@ -27,9 +27,10 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (101.359375,27.5) content-size 0x0 table-cell [BFC] children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (8,47) content-size 92.359375x39 table-row children: not-inline
Box <tr> at (8,47) content-size 93.359375x39 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (19,58) content-size 8.453125x17 table-cell [BFC] children: inline
Expand All @@ -38,15 +39,15 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (49.453125,77.5) content-size 39.90625x17 table-cell [BFC] children: inline
BlockContainer <td> at (49.453125,77.5) content-size 40.90625x17 table-cell [BFC] children: inline
frag 0 from TextNode start: 0, length: 3, rect: [49.453125,77.5 24.046875x17] baseline: 13.296875
"6-9"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (8,86) content-size 92.359375x39 table-row children: not-inline
Box <tr> at (8,86) content-size 93.359375x39 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (19,97) content-size 8.453125x17 table-cell [BFC] children: inline
Expand All @@ -61,21 +62,22 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x117]
PaintableWithLines (TableWrapper(anonymous)) [8,8 92.359375x117]
PaintableBox (Box<TABLE>) [8,8 92.359375x117]
PaintableBox (Box<TBODY>) [8,8 92.359375x117]
PaintableBox (Box<TR>) [8,8 92.359375x39]
PaintableWithLines (TableWrapper(anonymous)) [8,8 93.359375x117]
PaintableBox (Box<TABLE>) [8,8 93.359375x117]
PaintableBox (Box<TBODY>) [8,8 93.359375x117]
PaintableBox (Box<TR>) [8,8 93.359375x39]
PaintableWithLines (BlockContainer<TD>) [8,8 30.453125x39]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<TD>) [38.453125,8 30.8125x39]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<TD>) [69.265625,8 31.09375x39]
TextPaintable (TextNode<#text>)
PaintableBox (Box<TR>) [8,47 92.359375x39]
PaintableWithLines (BlockContainer(anonymous)) [100.359375,8 1x39]
PaintableBox (Box<TR>) [8,47 93.359375x39]
PaintableWithLines (BlockContainer<TD>) [8,47 30.453125x39]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<TD>) [38.453125,47 61.90625x78]
PaintableWithLines (BlockContainer<TD>) [38.453125,47 62.90625x78]
TextPaintable (TextNode<#text>)
PaintableBox (Box<TR>) [8,86 92.359375x39]
PaintableBox (Box<TR>) [8,86 93.359375x39]
PaintableWithLines (BlockContainer<TD>) [8,86 30.453125x39]
TextPaintable (TextNode<#text>)
61 changes: 61 additions & 0 deletions Tests/LibWeb/Layout/expected/table/colspan-overflow-crash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x61 children: not-inline
TableWrapper <(anonymous)> at (8,8) content-size 27.90625x44 [BFC] children: not-inline
Box <table> at (8,8) content-size 27.90625x44 table-box [TFC] children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tbody> at (10,10) content-size 23.90625x40 table-row-group children: not-inline
Box <tr> at (10,10) content-size 23.90625x19 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (11,11) content-size 6.8125x17 table-cell [BFC] children: inline
frag 0 from TextNode start: 0, length: 1, rect: [11,11 6.34375x17] baseline: 13.296875
"1"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (20.8125,19.5) content-size 0x0 table-cell [BFC] children: not-inline
BlockContainer <(anonymous)> at (22.8125,19.5) content-size 11.09375x0 table-cell [BFC] children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
Box <tr> at (10,31) content-size 23.90625x19 table-row children: not-inline
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (11,32) content-size 8.8125x17 table-cell [BFC] children: inline
frag 0 from TextNode start: 0, length: 1, rect: [11,32 8.8125x17] baseline: 13.296875
"2"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <td> at (23.8125,32) content-size 9.09375x17 table-cell [BFC] children: inline
frag 0 from TextNode start: 0, length: 1, rect: [23.8125,32 9.09375x17] baseline: 13.296875
"3"
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> (not painted) children: inline
TextNode <#text>
BlockContainer <(anonymous)> at (8,52) content-size 784x17 children: inline
frag 0 from TextNode start: 1, length: 19, rect: [8,52 162.109375x17] baseline: 13.296875
"PASS (didn't crash)"
TextNode <#text>

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x61]
PaintableWithLines (TableWrapper(anonymous)) [8,8 27.90625x44]
PaintableBox (Box<TABLE>) [8,8 27.90625x44]
PaintableBox (Box<TBODY>) [10,10 23.90625x40]
PaintableBox (Box<TR>) [10,10 23.90625x19]
PaintableWithLines (BlockContainer<TD>) [10,10 8.8125x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [20.8125,10 0x19]
PaintableWithLines (BlockContainer(anonymous)) [22.8125,10 11.09375x19]
PaintableBox (Box<TR>) [10,31 23.90625x19]
PaintableWithLines (BlockContainer<TD>) [10,31 10.8125x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer<TD>) [22.8125,31 11.09375x19]
TextPaintable (TextNode<#text>)
PaintableWithLines (BlockContainer(anonymous)) [8,52 784x17]
TextPaintable (TextNode<#text>)
10 changes: 10 additions & 0 deletions Tests/LibWeb/Layout/input/table/colspan-overflow-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<table>
<tr>
<td>1</td>
</tr>
<tr>
<td colspan="2">2</td>
<td>3</td>
</tr>
</table>
PASS (didn't crash)
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/Layout/TableGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TableGrid TableGrid::calculate_row_column_grid(Box const& box, Vector<Cell>& cel
rowspan = node.row_span();
}

if (x_width < x_current + colspan && y_current == 0)
if (x_width < x_current + colspan)
x_width = x_current + colspan;
if (y_height < y_current + rowspan)
y_height = y_current + rowspan;
Expand Down

0 comments on commit d1b967b

Please sign in to comment.