Module track_sizing

Source
Expand description

Implements the track sizing algorithm https://www.w3.org/TR/css-grid-1/#layout-algorithm

StructsΒ§

IntrisicSizeMeasurer πŸ”’
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
ItemBatcher πŸ”’
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Β§

IntrinsicContributionType πŸ”’
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.