LibWeb: Allow blockification across display: contents boundary

Flex/grid items are always blockified (have their CSS display forced
into "block") by style computation.

We were doing this by looking at the CSS display of the parent. However,
if the parent has `display: contents`, we must look at the *grandparent*
instead.

This corrects the layout of buttons underneath Reddit article cards.
This commit is contained in:
Andreas Kling 2025-08-17 10:27:39 +02:00 committed by Andreas Kling
commit efd4f63454
Notes: github-actions[bot] 2025-08-17 17:11:06 +00:00
3 changed files with 69 additions and 0 deletions

View file

@ -2337,6 +2337,10 @@ static BoxTypeTransformation required_box_type_transformation(ComputedProperties
// NOTE: If we're computing style for a pseudo-element, the effective parent will be the originating element itself, not its parent.
auto parent = element.element_to_inherit_style_from(pseudo_element);
// Climb out of `display: contents` context.
while (parent && parent->computed_properties() && parent->computed_properties()->display().is_contents())
parent = parent->element_to_inherit_style_from({});
// A parent with a grid or flex display value blockifies the boxs display type. [CSS-GRID-1] [CSS-FLEXBOX-1]
if (parent && parent->computed_properties()) {
auto const& parent_display = parent->computed_properties()->display();