From d4b2e8987501102f0e6f9a6b5790aa1dae609cb7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 29 Nov 2020 12:39:10 +0100 Subject: [PATCH] LibWeb: Blocks can have non-block (but non-inline) parents We were messing up the box tree for tables by hoisting cells up to become children of the table row group (instead of the table row.) Table rows are non-block boxes, and it's fine for them to have cell (block) children. Fixes #4225. --- Libraries/LibWeb/Layout/TreeBuilder.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index 981b881be9..7d7b349433 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -115,15 +115,15 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node) insertion_point.append_child(*layout_node); insertion_point.set_children_are_inline(true); } else { - // Blocks can't be inserted into an inline parent, so find the nearest block ancestor. - auto& nearest_block_ancestor = [&]() -> Layout::Node& { + // Blocks can't be inserted into an inline parent, so find the nearest non-inline ancestor. + auto& nearest_non_inline_ancestor = [&]() -> Layout::Node& { for (ssize_t i = m_parent_stack.size() - 1; i >= 0; --i) { - if (m_parent_stack[i]->is_block()) + if (!m_parent_stack[i]->is_inline()) return *m_parent_stack[i]; } ASSERT_NOT_REACHED(); }(); - auto& insertion_point = insertion_parent_for_block_node(nearest_block_ancestor, *layout_node); + auto& insertion_point = insertion_parent_for_block_node(nearest_non_inline_ancestor, *layout_node); insertion_point.append_child(*layout_node); insertion_point.set_children_are_inline(false); }