Cell occupancy tracking for CSS Grid auto-placement.
Tracks which grid cells are occupied during auto-placement using a dynamically expanding 2D matrix. Maintains counts of implicit and explicit tracks in both axes.
Coordinates use the OriginZero system where negative implicit tracks have negative indices, explicit tracks start at 0, and positive implicit tracks follow the explicit ones.
Grid Expansion
The matrix expands automatically in all four directions when items are placed outside current bounds. Track counts update accordingly to maintain correct coordinate mappings.
Key Invariants
Out-of-bounds cells are treated as unoccupied
Track counts must accurately reflect the matrix dimensions after expansion
Coordinate conversions depend on track counts being synchronized with matrix size
mark_area_as t primary_axis primary_span secondary_span value marks the specified area as occupied, expanding the matrix if necessary.
Spans are in OriginZero line coordinates. Automatically resolves to track ranges and expands the grid if the area extends beyond current bounds. Re-resolves coordinates after expansion since track indices may shift.