Skip to content

Commit bc8c2b2

Browse files
axgallokalenikaliaksandr
authored andcommitted
LibWeb: Use cell width instead available width to compute height
Overall available width should only affect later stages of the table layout algorithm and have no impact on cell measures.
1 parent 2a067b5 commit bc8c2b2

File tree

4 files changed

+42
-42
lines changed

4 files changed

+42
-42
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
22
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
3-
BlockContainer <body> at (8,8) content-size 784x64.875 children: inline
4-
line 0 width: 137.984375, height: 64.875, bottom: 64.875, baseline: 64.875
5-
frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 135.984375x62.875]
6-
BlockContainer <table> at (9,9) content-size 135.984375x62.875 inline-block [BFC] children: not-inline
7-
TableWrapper <(anonymous)> at (9,9) content-size 135.984375x62.875 inline-block [BFC] children: not-inline
8-
Box <(anonymous)> at (9,9) content-size 135.984375x62.875 inline-table table-box [TFC] children: not-inline
9-
Box <tbody> at (9,9) content-size 129.984375x56.875 table-row-group children: not-inline
3+
BlockContainer <body> at (8,8) content-size 784x46.9375 children: inline
4+
line 0 width: 137.984375, height: 46.9375, bottom: 46.9375, baseline: 46.9375
5+
frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 135.984375x44.9375]
6+
BlockContainer <table> at (9,9) content-size 135.984375x44.9375 inline-block [BFC] children: not-inline
7+
TableWrapper <(anonymous)> at (9,9) content-size 135.984375x44.9375 inline-block [BFC] children: not-inline
8+
Box <(anonymous)> at (9,9) content-size 135.984375x44.9375 inline-table table-box [TFC] children: not-inline
9+
Box <tbody> at (9,9) content-size 129.984375x38.9375 table-row-group children: not-inline
1010
Box <tr> at (11,11) content-size 129.984375x19.46875 table-row children: not-inline
1111
BlockContainer <td> at (12,12) content-size 87.90625x17.46875 table-cell [BFC] children: inline
1212
line 0 width: 15.734375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
@@ -18,32 +18,32 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
1818
frag 0 from TextNode start: 0, length: 4, rect: [103.90625,12 27.84375x17.46875]
1919
"null"
2020
TextNode <#text>
21-
Box <tr> at (11,32.46875) content-size 129.984375x37.40625 table-row children: not-inline
22-
BlockContainer <td> at (12,42.4375) content-size 87.90625x17.46875 table-cell [BFC] children: inline
21+
Box <tr> at (11,32.46875) content-size 129.984375x19.46875 table-row children: not-inline
22+
BlockContainer <td> at (12,33.46875) content-size 87.90625x17.46875 table-cell [BFC] children: inline
2323
line 0 width: 87.90625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
24-
frag 0 from TextNode start: 0, length: 11, rect: [12,42.4375 87.90625x17.46875]
24+
frag 0 from TextNode start: 0, length: 11, rect: [12,33.46875 87.90625x17.46875]
2525
"Is Selected"
2626
TextNode <#text>
27-
BlockContainer <td> at (103.90625,42.4375) content-size 38.078125x17.46875 table-cell [BFC] children: inline
27+
BlockContainer <td> at (103.90625,33.46875) content-size 38.078125x17.46875 table-cell [BFC] children: inline
2828
line 0 width: 38.078125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
29-
frag 0 from TextNode start: 0, length: 5, rect: [103.90625,42.4375 38.078125x17.46875]
29+
frag 0 from TextNode start: 0, length: 5, rect: [103.90625,33.46875 38.078125x17.46875]
3030
"false"
3131
TextNode <#text>
3232

3333
PaintableWithLines (Viewport<#document>) [0,0 800x600]
3434
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
35-
PaintableWithLines (BlockContainer<BODY>) [8,8 784x64.875]
36-
PaintableWithLines (BlockContainer<TABLE>) [8,8 137.984375x64.875]
37-
PaintableWithLines (TableWrapper(anonymous)) [9,9 135.984375x62.875]
38-
PaintableBox (Box(anonymous)) [9,9 135.984375x62.875]
39-
PaintableBox (Box<TBODY>) [9,9 129.984375x56.875] overflow: [9,9 133.984375x60.875]
35+
PaintableWithLines (BlockContainer<BODY>) [8,8 784x46.9375]
36+
PaintableWithLines (BlockContainer<TABLE>) [8,8 137.984375x46.9375]
37+
PaintableWithLines (TableWrapper(anonymous)) [9,9 135.984375x44.9375]
38+
PaintableBox (Box(anonymous)) [9,9 135.984375x44.9375]
39+
PaintableBox (Box<TBODY>) [9,9 129.984375x38.9375] overflow: [9,9 133.984375x42.9375]
4040
PaintableBox (Box<TR>) [11,11 129.984375x19.46875] overflow: [11,11 131.984375x19.46875]
4141
PaintableWithLines (BlockContainer<TD>) [11,11 89.90625x19.46875]
4242
TextPaintable (TextNode<#text>)
4343
PaintableWithLines (BlockContainer<TD>) [102.90625,11 40.078125x19.46875]
4444
TextPaintable (TextNode<#text>)
45-
PaintableBox (Box<TR>) [11,32.46875 129.984375x37.40625] overflow: [11,32.46875 131.984375x37.40625]
46-
PaintableWithLines (BlockContainer<TD>) [11,32.46875 89.90625x37.40625]
45+
PaintableBox (Box<TR>) [11,32.46875 129.984375x19.46875] overflow: [11,32.46875 131.984375x19.46875]
46+
PaintableWithLines (BlockContainer<TD>) [11,32.46875 89.90625x19.46875]
47+
TextPaintable (TextNode<#text>)
48+
PaintableWithLines (BlockContainer<TD>) [102.90625,32.46875 40.078125x19.46875]
4749
TextPaintable (TextNode<#text>)
48-
PaintableWithLines (BlockContainer<TD>) [102.90625,32.46875 40.078125x37.40625]
49-
TextPaintable (TextNode<#text>)
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
22
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
3-
BlockContainer <body> at (8,8) content-size 784x86.8125 children: not-inline
4-
TableWrapper <(anonymous)> at (8,8) content-size 81.4375x86.8125 [BFC] children: not-inline
5-
Box <table> at (9,9) content-size 79.4375x84.8125 table-box [TFC] children: not-inline
3+
BlockContainer <body> at (8,8) content-size 784x68.875 children: not-inline
4+
TableWrapper <(anonymous)> at (8,8) content-size 81.4375x68.875 [BFC] children: not-inline
5+
Box <table> at (9,9) content-size 79.4375x66.875 table-box [TFC] children: not-inline
66
BlockContainer <(anonymous)> (not painted) children: inline
77
TextNode <#text>
8-
Box <tbody> at (9,9) content-size 75.4375x78.8125 table-row-group children: not-inline
8+
Box <tbody> at (9,9) content-size 75.4375x60.875 table-row-group children: not-inline
99
Box <tr> at (11,11) content-size 75.4375x21.46875 table-row children: not-inline
1010
BlockContainer <td> at (13,13) content-size 71.4375x17.46875 table-cell [BFC] children: inline
1111
line 0 width: 7.9375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
@@ -14,30 +14,30 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
1414
TextNode <#text>
1515
BlockContainer <(anonymous)> (not painted) children: inline
1616
TextNode <#text>
17-
Box <tr> at (11,34.46875) content-size 75.4375x57.34375 table-row children: not-inline
18-
BlockContainer <td> at (13,45.4375) content-size 71.4375x35.40625 table-cell [BFC] children: inline
17+
Box <tr> at (11,34.46875) content-size 75.4375x39.40625 table-row children: not-inline
18+
BlockContainer <td> at (13,36.46875) content-size 71.4375x35.40625 table-cell [BFC] children: inline
1919
line 0 width: 71.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
20-
frag 0 from TextNode start: 0, length: 9, rect: [13,45.4375 71.4375x17.46875]
20+
frag 0 from TextNode start: 0, length: 9, rect: [13,36.46875 71.4375x17.46875]
2121
"*********"
2222
line 1 width: 63.5625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
23-
frag 0 from TextNode start: 10, length: 8, rect: [13,62.4375 63.5625x17.46875]
23+
frag 0 from TextNode start: 10, length: 8, rect: [13,53.46875 63.5625x17.46875]
2424
"***** **"
2525
TextNode <#text>
2626
BlockContainer <(anonymous)> (not painted) children: inline
2727
TextNode <#text>
28-
BlockContainer <(anonymous)> at (8,94.8125) content-size 784x0 children: inline
28+
BlockContainer <(anonymous)> at (8,76.875) content-size 784x0 children: inline
2929
TextNode <#text>
3030

3131
PaintableWithLines (Viewport<#document>) [0,0 800x600]
3232
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
33-
PaintableWithLines (BlockContainer<BODY>) [8,8 784x86.8125]
34-
PaintableWithLines (TableWrapper(anonymous)) [8,8 81.4375x86.8125]
35-
PaintableBox (Box<TABLE>) [8,8 81.4375x86.8125]
36-
PaintableBox (Box<TBODY>) [9,9 75.4375x78.8125] overflow: [9,9 77.4375x82.8125]
33+
PaintableWithLines (BlockContainer<BODY>) [8,8 784x68.875]
34+
PaintableWithLines (TableWrapper(anonymous)) [8,8 81.4375x68.875]
35+
PaintableBox (Box<TABLE>) [8,8 81.4375x68.875]
36+
PaintableBox (Box<TBODY>) [9,9 75.4375x60.875] overflow: [9,9 77.4375x64.875]
3737
PaintableBox (Box<TR>) [11,11 75.4375x21.46875]
3838
PaintableWithLines (BlockContainer<TD>) [11,11 75.4375x21.46875]
3939
TextPaintable (TextNode<#text>)
40-
PaintableBox (Box<TR>) [11,34.46875 75.4375x57.34375]
41-
PaintableWithLines (BlockContainer<TD>) [11,34.46875 75.4375x57.34375]
40+
PaintableBox (Box<TR>) [11,34.46875 75.4375x39.40625]
41+
PaintableWithLines (BlockContainer<TD>) [11,34.46875 75.4375x39.40625]
4242
TextPaintable (TextNode<#text>)
43-
PaintableWithLines (BlockContainer(anonymous)) [8,94.8125 784x0]
43+
PaintableWithLines (BlockContainer(anonymous)) [8,76.875 784x0]

Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void TableFormattingContext::compute_constrainedness()
219219
}
220220
}
221221

222-
void TableFormattingContext::compute_cell_measures(AvailableSpace const& available_space)
222+
void TableFormattingContext::compute_cell_measures()
223223
{
224224
// Implements https://www.w3.org/TR/css-tables-3/#computing-cell-measures.
225225
auto const& containing_block = m_state.get(*table_wrapper().containing_block());
@@ -241,10 +241,10 @@ void TableFormattingContext::compute_cell_measures(AvailableSpace const& availab
241241
CSSPixels border_left = use_collapsing_borders_model ? round(cell_state.border_left / 2) : computed_values.border_left().width;
242242
CSSPixels border_right = use_collapsing_borders_model ? round(cell_state.border_right / 2) : computed_values.border_right().width;
243243

244-
auto min_content_height = calculate_min_content_height(cell.box, available_space.width.to_px_or_zero());
245-
auto max_content_height = calculate_max_content_height(cell.box, available_space.width.to_px_or_zero());
246244
auto min_content_width = calculate_min_content_width(cell.box);
247245
auto max_content_width = calculate_max_content_width(cell.box);
246+
auto min_content_height = calculate_min_content_height(cell.box, max_content_width);
247+
auto max_content_height = calculate_max_content_height(cell.box, min_content_width);
248248

249249
// The outer min-content height of a table-cell is max(min-height, min-content height) adjusted by the cell intrinsic offsets.
250250
auto min_height = computed_values.min_height().to_px(cell.box, containing_block.content_height());
@@ -1673,7 +1673,7 @@ void TableFormattingContext::run(Box const& box, LayoutMode layout_mode, Availab
16731673
border_conflict_resolution();
16741674

16751675
// Compute the minimum width of each column.
1676-
compute_cell_measures(available_space);
1676+
compute_cell_measures();
16771677
compute_outer_content_sizes();
16781678
compute_table_measures<Column>();
16791679

Userland/Libraries/LibWeb/Layout/TableFormattingContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TableFormattingContext final : public FormattingContext {
3939
CSSPixels compute_capmin();
4040
void calculate_row_column_grid(Box const&);
4141
void compute_constrainedness();
42-
void compute_cell_measures(AvailableSpace const& available_space);
42+
void compute_cell_measures();
4343
void compute_outer_content_sizes();
4444
template<class RowOrColumn>
4545
void initialize_table_measures();

0 commit comments

Comments
 (0)