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.
This commit is contained in:
Andreas Kling 2020-11-29 12:39:10 +01:00
parent 9cdc16535c
commit d4b2e89875
Notes: sideshowbarker 2024-07-19 01:12:22 +09:00

View file

@ -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);
}