From 24c4d7fb4622b58b60d507fc8fe30d1cd3003a2d Mon Sep 17 00:00:00 2001 From: martinfalisse Date: Sat, 5 Nov 2022 19:10:46 +0100 Subject: [PATCH] LibWeb: Calculate available space for children of the grid Previously were not passing along any information to the children of the grid, as were simply passing the same AvailableSpace that was received for the grid itself. Now, each child is given an available space in accordance with the layout of the grid. --- Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index d9d9e80c36..e3dd9b1dd5 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -661,8 +661,6 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const 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(); - if (auto independent_formatting_context = layout_inside(positioned_box.box, LayoutMode::Normal, available_space)) - independent_formatting_context->parent_context_did_dimension_child_root_box(); if (child_box_state.content_height() > positioned_box.computed_height) positioned_box.computed_height = child_box_state.content_height(); if (auto min_content_height = calculate_min_content_height(positioned_box.box, available_space.width); min_content_height > positioned_box.computed_height) @@ -1470,6 +1468,10 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const child_box_state.set_content_width(x_end - x_start); child_box_state.set_content_height(y_end - y_start); child_box_state.offset = { x_start, y_start }; + + auto available_space_for_children = AvailableSpace(AvailableSize::make_definite(child_box_state.content_width()), AvailableSize::make_definite(child_box_state.content_height())); + if (auto independent_formatting_context = layout_inside(child_box, LayoutMode::Normal, available_space_for_children)) + independent_formatting_context->parent_context_did_dimension_child_root_box(); }; for (auto& positioned_box : positioned_boxes) {