mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Propagate font-size & line-height into generated table boxes
The final used values for these properties is stored in the layout node, so we need to make sure they are propagated there as well when doing table box fixup.
This commit is contained in:
parent
8eb10b135d
commit
589a1e9325
Notes:
sideshowbarker
2024-07-17 07:38:17 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/589a1e9325 Pull-request: https://github.com/SerenityOS/serenity/pull/20956 Reviewed-by: https://github.com/AtkinsSJ ✅
@ -0,0 +1,20 @@
|
||||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x116 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x100 children: not-inline
|
||||
TableWrapper <(anonymous)> at (8,8) content-size 69.078125x100 [BFC] children: not-inline
|
||||
Box <div> at (8,8) content-size 69.078125x100 table-box [TFC] children: inline
|
||||
Box <(anonymous)> at (8,8) content-size 69.078125x100 table-row children: inline
|
||||
BlockContainer <(anonymous)> at (8,8) content-size 69.078125x100 table-cell [BFC] children: inline
|
||||
line 0 width: 69.078125, height: 100, bottom: 100, baseline: 59
|
||||
frag 0 from TextNode start: 0, length: 5, rect: [8,8 69.078125x100]
|
||||
"hello"
|
||||
TextNode <#text>
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x116]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x100]
|
||||
PaintableWithLines (TableWrapper(anonymous)) [8,8 69.078125x100]
|
||||
PaintableBox (Box<DIV>) [8,8 69.078125x100]
|
||||
PaintableBox (Box(anonymous)) [8,8 69.078125x100]
|
||||
PaintableWithLines (BlockContainer(anonymous)) [8,8 69.078125x100]
|
||||
TextPaintable (TextNode<#text>)
|
@ -0,0 +1,8 @@
|
||||
<!doctype html><style>
|
||||
* { outline: 1px solid black; }
|
||||
div { display: table; }
|
||||
body {
|
||||
font-size: 30px;
|
||||
line-height: 100px;
|
||||
}
|
||||
</style><body><div>hello
|
@ -585,6 +585,7 @@ static void wrap_in_anonymous(Vector<JS::Handle<Node>>& sequence, Node* nearest_
|
||||
}
|
||||
wrapper->set_children_are_inline(parent.children_are_inline());
|
||||
wrapper->set_line_height(parent.line_height());
|
||||
wrapper->set_font(parent.font());
|
||||
if (nearest_sibling)
|
||||
parent.insert_before(*wrapper, *nearest_sibling);
|
||||
else
|
||||
@ -664,13 +665,15 @@ Vector<JS::Handle<Box>> TreeBuilder::generate_missing_parents(NodeWithStyle& roo
|
||||
auto* nearest_sibling = table_box->next_sibling();
|
||||
auto& parent = *table_box->parent();
|
||||
|
||||
CSS::ComputedValues wrapper_computed_values;
|
||||
CSS::ComputedValues wrapper_computed_values = table_box->computed_values().clone_inherited_values();
|
||||
table_box->transfer_table_box_computed_values_to_wrapper_computed_values(wrapper_computed_values);
|
||||
|
||||
auto wrapper = parent.heap().allocate_without_realm<TableWrapper>(parent.document(), nullptr, move(wrapper_computed_values));
|
||||
|
||||
parent.remove_child(*table_box);
|
||||
wrapper->append_child(*table_box);
|
||||
wrapper->set_font(parent.font());
|
||||
wrapper->set_line_height(parent.line_height());
|
||||
|
||||
if (nearest_sibling)
|
||||
parent.insert_before(*wrapper, *nearest_sibling);
|
||||
@ -705,6 +708,8 @@ static void fixup_row(Box& row_box, TableGrid const& table_grid, size_t row_inde
|
||||
// Ensure that the cell (with zero content height) will have the same height as the row by setting vertical-align to middle.
|
||||
cell_computed_values.set_vertical_align(CSS::VerticalAlign::Middle);
|
||||
auto cell_box = row_box.heap().template allocate_without_realm<BlockContainer>(row_box.document(), nullptr, cell_computed_values);
|
||||
cell_box->set_font(row_box.font());
|
||||
cell_box->set_line_height(row_box.line_height());
|
||||
row_box.append_child(cell_box);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user