@@ -369,6 +369,10 @@ void GridFormattingContext::run(Box const& box, LayoutMode)
369
369
// FIXME: 4.2. For dense packing:
370
370
}
371
371
372
+ for (auto & positioned_box : positioned_boxes) {
373
+ (void )layout_inside (positioned_box.box , LayoutMode::Normal);
374
+ }
375
+
372
376
// https://drafts.csswg.org/css-grid/#overview-sizing
373
377
// 2.3. Sizing the Grid
374
378
// Once the grid items have been placed, the sizes of the grid tracks (rows and columns) are
@@ -965,6 +969,29 @@ void GridFormattingContext::run(Box const& box, LayoutMode)
965
969
if (grid_row.max_track_sizing_function .is_length () && grid_row.max_track_sizing_function .length ().is_auto ())
966
970
grid_row.base_size = max (grid_row.base_size , remaining_vertical_space / count_of_auto_max_row_tracks);
967
971
}
972
+
973
+ // Do layout
974
+ auto layout_box = [&](int row_start, int row_end, int column_start, int column_end, Box const & child_box) -> void {
975
+ auto & child_box_state = m_state.get_mutable (child_box);
976
+ float x_start = 0 ;
977
+ float x_end = 0 ;
978
+ float y_start = 0 ;
979
+ float y_end = 0 ;
980
+ for (int i = 0 ; i < column_start; i++)
981
+ x_start += grid_columns[i].base_size ;
982
+ for (int i = 0 ; i < column_end; i++)
983
+ x_end += grid_columns[i].base_size ;
984
+ for (int i = 0 ; i < row_start; i++)
985
+ y_start += grid_rows[i].base_size ;
986
+ for (int i = 0 ; i < row_end; i++)
987
+ y_end += grid_rows[i].base_size ;
988
+ child_box_state.set_content_width (x_end - x_start);
989
+ child_box_state.set_content_height (y_end - y_start);
990
+ child_box_state.offset = { x_start, y_start };
991
+ };
992
+
993
+ for (auto & positioned_box : positioned_boxes)
994
+ 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 );
968
995
}
969
996
970
997
}
0 commit comments