LibWeb: Ensure anonymous wrappers inherit inline-block display

When restructuring a block node inside an inline parent, if the
nearest block ancestor is `display: inline-block`, ensure that
the generated anonymous wrappers also have `display: inline-block`.
This fixes layout issues with block elements nested
inside inline-block elements.
This commit is contained in:
Aziz Berkay Yesilyurt 2025-04-08 10:46:22 +02:00 committed by Jelle Raaijmakers
commit 6711438e0d
Notes: github-actions[bot] 2025-05-23 09:17:05 +00:00
4 changed files with 55 additions and 2 deletions

View file

@ -1053,6 +1053,12 @@ GC::Ref<NodeWithStyle> NodeWithStyle::create_anonymous_wrapper() const
wrapper->mutable_computed_values().set_text_decoration_thickness(computed_values().text_decoration_thickness());
wrapper->mutable_computed_values().set_text_decoration_color(computed_values().text_decoration_color());
wrapper->mutable_computed_values().set_text_decoration_style(computed_values().text_decoration_style());
// CSS 2.2 9.2.1.1 creates anonymous block boxes, but 9.4.1 states inline-block creates a BFC.
// Set wrapper to inline-block to participate correctly in the IFC within the parent inline-block.
if (display().is_inline_block() && !has_children()) {
wrapper->mutable_computed_values().set_display(CSS::Display::from_short(CSS::Display::Short::InlineBlock));
}
return *wrapper;
}