package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/compute_grid/Compute_grid/Named/index.html
Module Compute_grid.NamedSource
Internal resolver for named grid lines and areas.
This module resolves CSS Grid line names and area names into concrete line numbers during layout computation. It processes grid-template-areas, grid-template-columns, and grid-template-rows to build lookup tables mapping names to line indices.
Algorithm
Construction proceeds in three phases:
- Process grid-template-areas to extract area boundaries and generate implicit line names (e.g., "header-start", "header-end") for each area.
- Process grid-template-columns and grid-template-rows, iterating through line name sets and tracks. For repeat() tracks, expand repetitions using the computed auto-repetition count. Line name sets at repeat boundaries collapse with adjacent sets.
- Sort and deduplicate line indices for each name to handle names appearing at multiple lines.
Invariants
- Line indices are 1-based, matching CSS Grid specification.
- Each line name maps to a sorted, deduplicated list of line indices.
- Area counts (area_column_count, area_row_count) represent the minimum grid size implied by areas.
- Explicit counts (explicit_column_count, explicit_row_count) are set externally after grid sizing and used for fallback line resolution.
Resolver mapping grid line names and area names to line numbers.
create style column_auto_repetitions row_auto_repetitions initializes a resolver from grid style properties.
Processes grid-template-areas, grid-template-columns, and grid-template-rows to build name-to-line mappings. Auto-repetition counts determine how many times auto-fill/auto-fit repeat() tracks expand.
The explicit row/column counts are initialized to 0 and must be set later via set_explicit_column_count and set_explicit_row_count.
area_column_count t returns the number of columns implied by grid areas.
area_row_count t returns the number of rows implied by grid areas.
set_explicit_column_count t count sets the explicit column count used for fallback line resolution.
set_explicit_row_count t count sets the explicit row count used for fallback line resolution.
explicit_column_count t returns the current explicit column count.
val resolve_row_names :
t ->
Style.Grid.Placement.t Geometry.Line.t ->
Style.Grid.Placement.t Geometry.Line.tresolve_row_names t line resolves named lines in row-axis grid placement to line numbers.
Converts Named_line placements to Line placements using the row line name map. Non-named placements pass through unchanged.
val resolve_column_names :
t ->
Style.Grid.Placement.t Geometry.Line.t ->
Style.Grid.Placement.t Geometry.Line.tresolve_column_names t line resolves named lines in column-axis grid placement to line numbers.
Converts Named_line placements to Line placements using the column line name map. Non-named placements pass through unchanged.
val resolve_absolutely_positioned_grid_tracks :
Style.Grid.Origin_zero_placement.t Geometry.Line.t ->
int option Geometry.Line.tresolve_absolutely_positioned_grid_tracks oz_placement computes the final track range for absolutely positioned items.
Handles all combinations of Line, Span, and Auto placements according to CSS Grid positioning rules. When both start and end are lines, ensures start <= end. Returns None boundaries for underspecified placements.