@@ -368,6 +368,45 @@ void GridFormattingContext::run(Box const& box, LayoutMode)
368
368
369
369
// FIXME: 4.2. For dense packing:
370
370
}
371
+
372
+ // https://drafts.csswg.org/css-grid/#overview-sizing
373
+ // 2.3. Sizing the Grid
374
+ // Once the grid items have been placed, the sizes of the grid tracks (rows and columns) are
375
+ // calculated, accounting for the sizes of their contents and/or available space as specified in
376
+ // the grid definition.
377
+
378
+ // https://drafts.csswg.org/css-grid/#layout-algorithm
379
+ // 12. Grid Sizing
380
+ // This section defines the grid sizing algorithm, which determines the size of all grid tracks and,
381
+ // by extension, the entire grid.
382
+
383
+ // Each track has specified minimum and maximum sizing functions (which may be the same). Each
384
+ // sizing function is either:
385
+
386
+ // - A fixed sizing function (<length> or resolvable <percentage>).
387
+ // - An intrinsic sizing function (min-content, max-content, auto, fit-content()).
388
+ // - A flexible sizing function (<flex>).
389
+
390
+ // The grid sizing algorithm defines how to resolve these sizing constraints into used track sizes.
391
+
392
+ struct GridTrack {
393
+ CSS::GridTrackSize min_track_sizing_function;
394
+ CSS::GridTrackSize max_track_sizing_function;
395
+ float base_size { 0 };
396
+ float growth_limit { 0 };
397
+ };
398
+ Vector<GridTrack> grid_rows;
399
+ Vector<GridTrack> grid_columns;
400
+
401
+ for (auto & column_size : box.computed_values ().grid_template_columns ())
402
+ grid_columns.append ({ column_size, column_size });
403
+ for (auto & row_size : box.computed_values ().grid_template_rows ())
404
+ grid_rows.append ({ row_size, row_size });
405
+
406
+ for (int column_index = grid_columns.size (); column_index < static_cast <int >(occupation_grid[0 ].size ()); column_index++)
407
+ grid_columns.append ({ CSS::GridTrackSize::make_auto (), CSS::GridTrackSize::make_auto () });
408
+ for (int row_index = grid_rows.size (); row_index < static_cast <int >(occupation_grid.size ()); row_index++)
409
+ grid_rows.append ({ CSS::GridTrackSize::make_auto (), CSS::GridTrackSize::make_auto () });
371
410
}
372
411
373
412
}
0 commit comments