diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 2b44735ed6..8bb1a97bd9 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -256,6 +256,8 @@ float FormattingContext::compute_auto_height_for_block_level_element(LayoutState auto display = box.computed_values().display(); if (display.is_flex_inside()) return box_state.content_height(); + if (display.is_grid_inside()) + return box_state.content_height(); // https://www.w3.org/TR/CSS22/visudet.html#normal-block // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible' diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 4b9641d38d..a0e7c4ed52 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -369,8 +369,14 @@ void GridFormattingContext::run(Box const& box, LayoutMode) // FIXME: 4.2. For dense packing: } + auto& box_state = m_state.get_mutable(box); for (auto& positioned_box : positioned_boxes) { + auto& child_box_state = m_state.get_mutable(positioned_box.box); + if (child_box_state.content_height() > positioned_box.computed_height) + positioned_box.computed_height = child_box_state.content_height(); (void)layout_inside(positioned_box.box, LayoutMode::Normal); + if (child_box_state.content_height() > positioned_box.computed_height) + positioned_box.computed_height = child_box_state.content_height(); } // https://drafts.csswg.org/css-grid/#overview-sizing @@ -992,6 +998,11 @@ void GridFormattingContext::run(Box const& box, LayoutMode) for (auto& positioned_box : positioned_boxes) layout_box(positioned_box.row, positioned_box.row + positioned_box.row_span, positioned_box.column, positioned_box.column + positioned_box.column_span, positioned_box.box); + + float total_y = 0; + for (auto& grid_row : grid_rows) + total_y += grid_row.base_size; + box_state.set_content_height(total_y); } }