1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:27:45 +00:00

LibWeb: Ignore "display: contents" boxes while inserting inline nodes

With this change "display: contents" ancestors are not considered as
insertion point for inline nodes similar to how we already ignore them
for non-inline nodes.

Fixes https://github.com/SerenityOS/serenity/issues/22396
This commit is contained in:
Aliaksandr Kalenik 2023-12-23 20:10:42 +01:00 committed by Andreas Kling
parent 67522fab2e
commit 0a7e4a0d22
3 changed files with 23 additions and 2 deletions

View file

@ -148,8 +148,15 @@ void TreeBuilder::insert_node_into_inline_or_block_ancestor(Layout::Node& node,
return;
if (display.is_inline_outside()) {
// Inlines can be inserted into the nearest ancestor.
auto& insertion_point = insertion_parent_for_inline_node(m_ancestor_stack.last());
// Inlines can be inserted into the nearest ancestor without "display: contents".
auto& nearest_ancestor_without_display_contents = [&]() -> Layout::NodeWithStyle& {
for (auto& ancestor : m_ancestor_stack.in_reverse()) {
if (!ancestor->display().is_contents())
return ancestor;
}
VERIFY_NOT_REACHED();
}();
auto& insertion_point = insertion_parent_for_inline_node(nearest_ancestor_without_display_contents);
if (mode == AppendOrPrepend::Prepend)
insertion_point.prepend_child(node);
else