Skip to content

CSS Grid algorithm 2/N: auto-placement#1994

Open
intergalacticspacehighway wants to merge 4 commits into
react:mainfrom
intergalacticspacehighway:css-grid-2-auto-placement-57459
Open

CSS Grid algorithm 2/N: auto-placement#1994
intergalacticspacehighway wants to merge 4 commits into
react:mainfrom
intergalacticspacehighway:css-grid-2-auto-placement-57459

Conversation

@intergalacticspacehighway

@intergalacticspacehighway intergalacticspacehighway commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the CSS Grid auto placement algorithm (§8.5).

How?

  • AutoPlacement — the four-step placement algorithm.
  • LinePlacement — grid-line resolution (§8.3), including invalid-input handling: line 0 is treated as auto, and span 0 / negative spans clamp to 1.
  • OccupancyGrid — overlap tracking for placed items.
  • Unit tests (line resolution), algorithm tests, and regression tests for the invalid-input cases.

Not yet implemented

These will be introduced later. Default grid-auto-flow is row so it won't be an issue.

  • Dense packing (grid-auto-flow: dense)
  • Column flow (grid-auto-flow: column)

Notes

cc - @rozele This a small chunk from #1894 PR.

Implements the CSS Grid item placement algorithm for grid-auto-flow: row with
sparse packing, per the spec:
https://www.w3.org/TR/css-grid-1/#auto-placement-algo

- AutoPlacement: the four-step placement algorithm
- LinePlacement: grid-line resolution, including invalid-input handling
  (line 0 is treated as auto; span 0 and negative spans clamp to 1)
- OccupancyGrid: overlap tracking for placed items
- C++ unit and integration tests

Dense packing and column flow (grid-auto-flow: dense / column) are not yet
implemented.
@meta-cla meta-cla Bot added the CLA Signed label Jul 11, 2026
@intergalacticspacehighway intergalacticspacehighway marked this pull request as ready for review July 11, 2026 15:23
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant