package toffee

  1. Overview
  2. Docs
CSS layout engine for OCaml (Flexbox, Grid, Block)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/compute_grid/Compute_grid/Implicit_grid/index.html

Module Compute_grid.Implicit_gridSource

Performance optimization for grid size estimation.

This module estimates grid dimensions before auto-placement to pre-size vectors and reduce allocations. It is not required for CSS Grid spec compliance but improves performance by analyzing child placements to predict implicit grid bounds.

Sourceval compute_grid_size_estimate : explicit_col_count:int -> explicit_row_count:int -> child_styles_iter:Style.t Stdlib.Seq.t -> Grid_track_counts.t * Grid_track_counts.t

compute_grid_size_estimate ~explicit_col_count ~explicit_row_count ~child_styles_iter estimates grid size before auto-placement.

Returns (column_counts, row_counts) with exact counts for explicit and negative implicit tracks. The positive implicit track count is a lower bound since auto-placement can expand the grid unpredictably.

Algorithm:

  1. Scan all children to find minimum/maximum origin-zero grid lines and maximum span per axis
  2. Compute negative implicit tracks from minimum lines (exact)
  3. Compute positive implicit tracks from maximum lines (lower bound)
  4. Adjust positive tracks if any span exceeds total track count

The function mixes grid track numbers and grid line numbers internally for efficiency.