LibWeb: Set width in compute_width_for_table_wrapper()

Width of table wrapper need to be set to to calculate width of table
box inside. Otherwise TFC will set wrong width assuming width of
containing block is 0.
This commit is contained in:
Aliaksandr Kalenik 2023-05-07 02:53:11 +03:00 committed by Andreas Kling
parent 88e060907b
commit 3a605d8c19
Notes: sideshowbarker 2024-07-16 21:42:29 +09:00
3 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,31 @@
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 784x40.9375 children: inline
line 0 width: 131.984375, height: 40.9375, bottom: 40.9375, baseline: 35
frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 129.984375x38.9375]
BlockContainer <table> at (9,9) content-size 129.984375x38.9375 inline-block [BFC] children: not-inline
TableWrapper <(anonymous)> at (9,9) content-size 129.984375x38.9375 inline-block [BFC] children: not-inline
TableBox <(anonymous)> at (9,9) content-size 129.984375x38.9375 inline-table [TFC] children: not-inline
TableRowGroupBox <tbody> at (9,9) content-size 129.984375x38.9375 children: not-inline
TableRowBox <tr> at (9,9) content-size 129.984375x19.46875 children: not-inline
TableCellBox <td> at (10,10) content-size 87.90625x17.46875 [BFC] children: inline
line 0 width: 15.734375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 2, rect: [10,10 15.734375x17.46875]
"ID"
TextNode <#text>
TableCellBox <td> at (99.90625,10) content-size 38.078125x17.46875 [BFC] children: inline
line 0 width: 27.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 4, rect: [99.90625,10 27.84375x17.46875]
"null"
TextNode <#text>
TableRowBox <tr> at (9,28.46875) content-size 129.984375x19.46875 children: not-inline
TableCellBox <td> at (10,29.46875) content-size 87.90625x17.46875 [BFC] children: inline
line 0 width: 87.90625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 11, rect: [10,29.46875 87.90625x17.46875]
"Is Selected"
TextNode <#text>
TableCellBox <td> at (99.90625,29.46875) content-size 38.078125x17.46875 [BFC] children: inline
line 0 width: 38.078125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 5, rect: [99.90625,29.46875 38.078125x17.46875]
"false"
TextNode <#text>

View file

@ -0,0 +1,10 @@
<style type="text/css">
* {
font-family: 'SerenitySans';
}
table {
border: 1px solid #333;
display: inline-block;
}
</style><table><tr><td>ID</td><td>null</td></tr><tr><td>Is Selected</td><td>false</td></tr></table>

View file

@ -375,6 +375,7 @@ CSSPixels BlockFormattingContext::compute_width_for_table_wrapper(Box const& box
auto available_width = width_of_containing_block - margin_left.to_px(box) - margin_right.to_px(box);
LayoutState throwaway_state(&m_state);
throwaway_state.get_mutable(box).set_content_width(available_width);
auto context = create_independent_formatting_context_if_needed(throwaway_state, box);
VERIFY(context);
context->run(box, LayoutMode::IntrinsicSizing, m_state.get(box).available_inner_space_or_constraints_from(available_space));