diff options
author | Andreas Kling <kling@serenityos.org> | 2020-11-29 12:39:10 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-29 12:51:54 +0100 |
commit | d4b2e8987501102f0e6f9a6b5790aa1dae609cb7 (patch) | |
tree | f034c2b4c935e082a092195ce79ccf8a87cd5d57 | |
parent | 9cdc16535cfbc45eba3bb69757ed82f46e686d1c (diff) | |
download | serenity-d4b2e8987501102f0e6f9a6b5790aa1dae609cb7.zip |
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.
-rw-r--r-- | Libraries/LibWeb/Layout/TreeBuilder.cpp | 8 |
1 files 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); } |