From c1401b37c4bab2a9742594f96cbc6eaee48d7288 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 15 Nov 2022 22:17:27 +0300 Subject: LibWeb: Join out-of-flow block nodes in last parent child if possible Join out-of-flow block nodes into last child of parent node if last child has inline children. --- Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index e4c7ceb04b..c0deb7af22 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -83,13 +83,15 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo return layout_parent; } - if (!layout_parent.children_are_inline()) { - // Parent block has block-level children, insert this block into parent. - return layout_parent; - } - if (layout_node.is_floating() || layout_node.is_absolutely_positioned()) { // Block is out-of-flow, it can have inline siblings if necessary. + if (layout_parent.last_child()->children_are_inline()) { + return *layout_parent.last_child(); + } + } + + if (!layout_parent.children_are_inline()) { + // Parent block has block-level children, insert this block into parent. return layout_parent; } -- cgit v1.2.3