Expand description
Implements the track sizing algorithm https://www.w3.org/TR/css-grid-1/#layout-algorithm
StructsΒ§
- Intrisic
Size πMeasurer - This struct captures a bunch of variables which are used to compute the intrinsic sizes of children so that those variables donβt have to be passed around all over the place below. It then has methods that implement the intrinsic sizing computations
- Item
Batcher π - Takes an axis, and a list of grid items sorted firstly by whether they cross a flex track in the specified axis (items that donβt cross a flex track first) and then by the number of tracks they cross in specified axis (ascending order).
EnumsΒ§
- Intrinsic
Contribution πType - Whether it is a minimum or maximum sizeβs space being distributed This controls behaviour of the space distribution algorithm when distributing beyond limits See βdistributing space beyond limitsβ at https://www.w3.org/TR/css-grid-1/#extra-space
FunctionsΒ§
- cmp_
by_ πcross_ flex_ then_ span_ then_ start - To make track sizing efficient we want to order tracks
Here a placement is either a Line
representing a row-start/row-end or a column-start/column-end - compute_
alignment_ πgutter_ adjustment - When applying the track sizing algorithm and estimating the size in the other axis for content sizing items we should take into account align-content/justify-content if both the grid container and all items in the other axis have definite sizes. This function computes such a per-gutter additional size adjustment.
- determine_
if_ πitem_ crosses_ flexible_ or_ intrinsic_ tracks - Determine (in each axis) whether the item crosses any flexible tracks
- distribute_
item_ πspace_ to_ base_ size - 11.5.1. Distributing Extra Space Across Spanned Tracks https://www.w3.org/TR/css-grid-1/#extra-space
- distribute_
item_ πspace_ to_ growth_ limit - 11.5.1. Distributing Extra Space Across Spanned Tracks This is simplified (and faster) version of the algorithm for growth limits https://www.w3.org/TR/css-grid-1/#extra-space
- distribute_
space_ πup_ to_ limits - Helper function for distributing space to tracks evenly Used by both distribute_item_space_to_base_size and maximise_tracks steps
- expand_
flexible_ πtracks - 11.7. Expand Flexible Tracks This step sizes flexible tracks using the largest value it can assign to an fr without exceeding the available space.
- find_
size_ πof_ fr - 11.7.1. Find the Size of an fr This algorithm finds the largest size that an fr unit can be without exceeding the target size. It must be called with a set of grid tracks and some quantity of space to fill.
- flush_
planned_ πbase_ size_ increases - Add any planned base size increases to the base size after a round of distributing space to base sizes Reset the planed base size increase to zero ready for the next round.
- flush_
planned_ πgrowth_ limit_ increases - Add any planned growth limit increases to the growth limit after a round of distributing space to growth limits Reset the planed growth limit increase to zero ready for the next round.
- initialize_
track_ πsizes - 11.4 Initialise Track sizes Initialize each trackβs base size and growth limit.
- maximise_
tracks π - 11.6 Maximise Tracks Distributes free space (if any) to tracks with FINITE growth limits, up to their limits.
- resolve_
intrinsic_ πtrack_ sizes - 11.5 Resolve Intrinsic Track Sizes
- resolve_
item_ πbaselines - 11.5.1 Shim baseline-aligned items so their intrinsic size contributions reflect their baseline alignment.
- resolve_
item_ πtrack_ indexes - Convert origin-zero coordinates track placement in grid track vector indexes
- stretch_
auto_ πtracks - 11.8. Stretch auto Tracks This step expands tracks that have an auto max track sizing function by dividing any remaining positive, definite free space equally amongst them.
- track_
sizing_ πalgorithm - Track sizing algorithm Note: Gutters are treated as empty fixed-size tracks for the purpose of the track sizing algorithm.