Module taffy::compute::grid::track_sizing

source Β·
Expand description

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

Structs§

  • 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§

  • 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§

  • 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
  • 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 (in each axis) whether the item crosses any flexible tracks
  • 11.5.1. Distributing Extra Space Across Spanned Tracks https://www.w3.org/TR/css-grid-1/#extra-space
  • 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
  • Helper function for distributing space to tracks evenly Used by both distribute_item_space_to_base_size and maximise_tracks steps
  • 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.
  • 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.
  • 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.
  • 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.
  • 11.5 Resolve Intrinsic Track Sizes
  • 11.5.1 Shim baseline-aligned items so their intrinsic size contributions reflect their baseline alignment.
  • Convert origin-zero coordinates track placement in grid track vector indexes
  • 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 Note: Gutters are treated as empty fixed-size tracks for the purpose of the track sizing algorithm.