From 668578ddc08a059b542b5a11005d0ba5475467e2 Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Mon, 22 May 2023 02:59:10 +0000 Subject: [PATCH] LibWeb: Propagate children_are_inline in wrap_in_anonymous This fixes a crash in box_baseline, due to cells created for display: table expecting a box child and getting the inline node wrapper instead. Fixes #18972. --- .../display-table-inline-children.txt | 21 +++++++++++++++++++ .../input/display-table-inline-children.html | 20 ++++++++++++++++++ .../Libraries/LibWeb/Layout/TreeBuilder.cpp | 1 + 3 files changed, 42 insertions(+) create mode 100644 Tests/LibWeb/Layout/expected/display-table-inline-children.txt create mode 100644 Tests/LibWeb/Layout/input/display-table-inline-children.html diff --git a/Tests/LibWeb/Layout/expected/display-table-inline-children.txt b/Tests/LibWeb/Layout/expected/display-table-inline-children.txt new file mode 100644 index 0000000000..bedca064bd --- /dev/null +++ b/Tests/LibWeb/Layout/expected/display-table-inline-children.txt @@ -0,0 +1,21 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x616 [BFC] children: not-inline + BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline + TextNode <#text> + BlockContainer at (8,8) content-size 784x600 children: not-inline + BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline + TextNode <#text> + TableWrapper <(anonymous)> at (8,8) content-size 784x600 [BFC] children: not-inline + TableBox at (8,8) content-size 1200x600 [TFC] children: inline + TableRowBox <(anonymous)> at (8,8) content-size 1200x600 children: inline + TableCellBox <(anonymous)> at (8,8) content-size 1200x600 [BFC] children: inline + line 0 width: 1200, height: 600, bottom: 600, baseline: 600 + frag 0 from ImageBox start: 0, length: 0, rect: [8,8 1200x600] + TextNode <#text> + InlineNode + TextNode <#text> + ImageBox at (8,8) content-size 1200x600 children: not-inline + TextNode <#text> + TextNode <#text> + BlockContainer <(anonymous)> at (8,608) content-size 784x0 children: inline + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/display-table-inline-children.html b/Tests/LibWeb/Layout/input/display-table-inline-children.html new file mode 100644 index 0000000000..0eb1efdfb2 --- /dev/null +++ b/Tests/LibWeb/Layout/input/display-table-inline-children.html @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index c95f7853d1..7cb1fcda5b 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -526,6 +526,7 @@ static void wrap_in_anonymous(Vector>& sequence, Node* nearest_ parent.remove_child(*child); wrapper->append_child(*child); } + wrapper->set_children_are_inline(parent.children_are_inline()); if (nearest_sibling) parent.insert_before(*wrapper, *nearest_sibling); else