Skip to content

CSS Grid 2/9: Grid layout algorithm - #1894

Open
intergalacticspacehighway wants to merge 3 commits into
react:mainfrom
intergalacticspacehighway:css-grid-2-algorithm
Open

intergalacticspacehighway wants to merge 3 commits into
react:mainfrom
intergalacticspacehighway:css-grid-2-algorithm

Conversation

@intergalacticspacehighway

Copy link
Copy Markdown
Collaborator

Summary

  • Core grid layout computation and dispatch integration
  • Includes AutoPlacement.h, GridLayout.h/cpp, TrackSizing.h
  • CalculateLayout.cpp grid dispatch, CMakeLists.txt updates

Split from #1865. Depends on #1893. Merge after 1/9.

@vercel

vercel Bot commented Feb 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
yoga-website Ready Ready Preview, Comment Mar 5, 2026 6:58pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed label Feb 25, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 25, 2026
Summary:
Add the core grid layout computation and integrate it into the layout
dispatcher.

Includes:
- AutoPlacement.h: auto-placement algorithm for grid items
- GridLayout.h/cpp: grid layout entry point
- TrackSizing.h: track sizing algorithm
- CalculateLayout.cpp: grid dispatch block and #include
- CMakeLists.txt: add algorithm/grid/*.cpp glob
- React Native mirror of all C++ changes

Differential Revision: D93946253

@NickGerleman NickGerleman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been looking through this, for about an hour.

I think we still need to chunk this change into steps, of smaller concerns, to be able to give it a real review (vs trivial nits) which I feel like I ought to do, if we want to maintain this long term. It's been tricky for me to understand how everything connects. That might be an indication, it's worth documenting some of the newly added structures, if what they're doing isn't intuitive.

Could we build this up, in small parts of spec/behavior/structures at a time?


namespace facebook::yoga {

struct GridTrack : GridTrackSize {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This organization is confusing to me. Why should style input, and calculations about it, have to be same/inherited object? We have two GridTrack.h, where the most public one is for GridTrackSize (maybe that should be GridTrackSize.h?).


namespace facebook::yoga {

struct TrackSizing {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping all this logic, in a single header, in a nested struct, without header explaining purpose of structure, is pretty hard for me to parse. Esp since everything is public. Is this to try to encapsulate since header only?

I think bc header only, we would also be needing to mark things as constexpr or inline.

float containingBlockHeight;
};

using CrossDimensionEstimator = std::function<float(const GridItem&)>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should avoid using std::function unnecessarily, compared to underlying functor type. It introduces overhead like heap reallocating capture group.

namespace facebook::yoga {

struct OccupancyGrid {
std::unordered_map<int32_t, std::vector<std::pair<int32_t, int32_t>>>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::unordered_map is quite expensive, heap allocating a node per inserted item. How many items is this usually be? Would it be better as a flat vector of items/binary searched vector? (sidenote, this is what std::flat_map is kinda meant to solve).

@intergalacticspacehighway

Copy link
Copy Markdown
Collaborator Author

Could we build this up, in small parts of spec/behavior/structures at a time?

Sure @NickGerleman. yeah i thought this might be needed 😅. Will split it and also address above mentioned points in them.

@intergalacticspacehighway

Copy link
Copy Markdown
Collaborator Author

@rozele I will split this PR further into chunks. Thanks for importing 1/N.

rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 8, 2026
Summary:
Pull Request resolved: react#57459

  First in a series of PRs splitting the grid layout algorithm into reviewable chunks. Addresses feedback from react/yoga#1894.

  ## Summary
  - Rename `style/GridTrack.h` to `style/GridTrackSize.h` to match the type it defines and CSS grid naming spec.
  - Remove layout state fields (`baseSize`, `growthLimit`, `infinitelyGrowable`) from `GridTrackSize` — these belong in the algorithm layer, not the style definition
  - Add `algorithm/grid/GridTrack.h`, wraps `GridTrackSize` with layout state via composition (removed inheritance)
  - Add `algorithm/grid/GridItem.h`,  represents a grid item with its resolved position (after autoplacement algorithm) and flags used during track sizing algorithm

X-link: react/yoga#1923

Differential Revision: D110780559

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 9, 2026
Summary:
Pull Request resolved: react#57459

  First in a series of PRs splitting the grid layout algorithm into reviewable chunks. Addresses feedback from react/yoga#1894.

  ## Summary
  - Rename `style/GridTrack.h` to `style/GridTrackSize.h` to match the type it defines and CSS grid naming spec.
  - Remove layout state fields (`baseSize`, `growthLimit`, `infinitelyGrowable`) from `GridTrackSize` — these belong in the algorithm layer, not the style definition
  - Add `algorithm/grid/GridTrack.h`, wraps `GridTrackSize` with layout state via composition (removed inheritance)
  - Add `algorithm/grid/GridItem.h`,  represents a grid item with its resolved position (after autoplacement algorithm) and flags used during track sizing algorithm

X-link: react/yoga#1923

Differential Revision: D110780559

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57459

  First in a series of PRs splitting the grid layout algorithm into reviewable chunks. Addresses feedback from react/yoga#1894.

  ## Summary
  - Rename `style/GridTrack.h` to `style/GridTrackSize.h` to match the type it defines and CSS grid naming spec.
  - Remove layout state fields (`baseSize`, `growthLimit`, `infinitelyGrowable`) from `GridTrackSize` — these belong in the algorithm layer, not the style definition
  - Add `algorithm/grid/GridTrack.h`, wraps `GridTrackSize` with layout state via composition (removed inheritance)
  - Add `algorithm/grid/GridItem.h`,  represents a grid item with its resolved position (after autoplacement algorithm) and flags used during track sizing algorithm

X-link: react/yoga#1923

Differential Revision: D110780559

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57532

Implements the CSS Grid auto placement algorithm ([§8.5](https://www.w3.org/TR/css-grid-1/#auto-placement-algo)).

## How?
- **AutoPlacement** — the four-step placement algorithm.
- **LinePlacement** — grid-line resolution ([§8.3](https://www.w3.org/TR/css-grid-1/#grid-placement-errors)), 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
- Stacked on react/yoga#1923 (data structures); until that lands this diff also shows its `GridItem.h` / `GridTrack.h` — those belong to react/yoga#1923.

cc - rozele This a small chunk from react/yoga#1894 PR.

X-link: react/yoga#1994

Differential Revision: D111722622

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57459

  First in a series of PRs splitting the grid layout algorithm into reviewable chunks. Addresses feedback from react/yoga#1894.

  ## Summary
  - Rename `style/GridTrack.h` to `style/GridTrackSize.h` to match the type it defines and CSS grid naming spec.
  - Remove layout state fields (`baseSize`, `growthLimit`, `infinitelyGrowable`) from `GridTrackSize` — these belong in the algorithm layer, not the style definition
  - Add `algorithm/grid/GridTrack.h`, wraps `GridTrackSize` with layout state via composition (removed inheritance)
  - Add `algorithm/grid/GridItem.h`,  represents a grid item with its resolved position (after autoplacement algorithm) and flags used during track sizing algorithm

X-link: react/yoga#1923

Differential Revision: D110780559

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57532

Implements the CSS Grid auto placement algorithm ([§8.5](https://www.w3.org/TR/css-grid-1/#auto-placement-algo)).

## How?
- **AutoPlacement** — the four-step placement algorithm.
- **LinePlacement** — grid-line resolution ([§8.3](https://www.w3.org/TR/css-grid-1/#grid-placement-errors)), 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
- Stacked on react/yoga#1923 (data structures); until that lands this diff also shows its `GridItem.h` / `GridTrack.h` — those belong to react/yoga#1923.

cc - rozele This a small chunk from react/yoga#1894 PR.

X-link: react/yoga#1994

Differential Revision: D111722622

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57459

  First in a series of PRs splitting the grid layout algorithm into reviewable chunks. Addresses feedback from react/yoga#1894.

  ## Summary
  - Rename `style/GridTrack.h` to `style/GridTrackSize.h` to match the type it defines and CSS grid naming spec.
  - Remove layout state fields (`baseSize`, `growthLimit`, `infinitelyGrowable`) from `GridTrackSize` — these belong in the algorithm layer, not the style definition
  - Add `algorithm/grid/GridTrack.h`, wraps `GridTrackSize` with layout state via composition (removed inheritance)
  - Add `algorithm/grid/GridItem.h`,  represents a grid item with its resolved position (after autoplacement algorithm) and flags used during track sizing algorithm

X-link: react/yoga#1923

Differential Revision: D110780559

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57459

  First in a series of PRs splitting the grid layout algorithm into reviewable chunks. Addresses feedback from react/yoga#1894.

  ## Summary
  - Rename `style/GridTrack.h` to `style/GridTrackSize.h` to match the type it defines and CSS grid naming spec.
  - Remove layout state fields (`baseSize`, `growthLimit`, `infinitelyGrowable`) from `GridTrackSize` — these belong in the algorithm layer, not the style definition
  - Add `algorithm/grid/GridTrack.h`, wraps `GridTrackSize` with layout state via composition (removed inheritance)
  - Add `algorithm/grid/GridItem.h`,  represents a grid item with its resolved position (after autoplacement algorithm) and flags used during track sizing algorithm

X-link: react/yoga#1923

Differential Revision: D110780559

Pulled By: rozele
rozele pushed a commit to rozele/react-native-macos that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: react#57532

Implements the CSS Grid auto placement algorithm ([§8.5](https://www.w3.org/TR/css-grid-1/#auto-placement-algo)).

## How?
- **AutoPlacement** — the four-step placement algorithm.
- **LinePlacement** — grid-line resolution ([§8.3](https://www.w3.org/TR/css-grid-1/#grid-placement-errors)), 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
- Stacked on react/yoga#1923 (data structures); until that lands this diff also shows its `GridItem.h` / `GridTrack.h` — those belong to react/yoga#1923.

cc - rozele This a small chunk from react/yoga#1894 PR.

X-link: react/yoga#1994

Differential Revision: D111722622

Pulled By: rozele
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 17, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 18, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 18, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 18, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 18, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 19, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Aug 31, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Sep 12, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Sep 13, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Sep 28, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 2, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 3, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 3, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 3, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 15, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
(cherry picked from commit 08d6986)
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 20, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

A third local fix, listed in README-VENDORED.md: the fit-content clamp in the inline axis was never applied, so a grid measured under a fit-content width reported its max-content width. It is now min(max-content, max(min-content, available)), its tracks sized again at the available width when the max-content exceeds it.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 20, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

A third local fix, listed in README-VENDORED.md: the fit-content clamp in the inline axis was never applied, so a grid measured under a fit-content width reported its max-content width. It is now min(max-content, max(min-content, available)), its tracks sized again at the available width when the max-content exceeds it.

A fourth: three steps of the track sizing gave an `auto` minimum an item's limited min-content contribution whenever Yoga's sizing mode was `MaxContent`, which is also how Yoga lays out an `auto` block size; that size is indefinite free space, not a max-content constraint, so a `0fr` row over an item with `min-height: 0` (the accordion idiom) stood as tall as the item's content. Only the inline axis is measured under a real max-content constraint now. `GridZeroFrRow-itest.js` pins it.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 20, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

A third local fix, listed in README-VENDORED.md: the fit-content clamp in the inline axis was never applied, so a grid measured under a fit-content width reported its max-content width. It is now min(max-content, max(min-content, available)), its tracks sized again at the available width when the max-content exceeds it.

A fourth: three steps of the track sizing gave an `auto` minimum an item's limited min-content contribution whenever Yoga's sizing mode was `MaxContent`, which is also how Yoga lays out an `auto` block size; that size is indefinite free space, not a max-content constraint, so a `0fr` row over an item with `min-height: 0` (the accordion idiom) stood as tall as the item's content. Only the inline axis is measured under a real max-content constraint now. `GridZeroFrRow-itest.js` pins it.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 20, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

A third local fix, listed in README-VENDORED.md: the fit-content clamp in the inline axis was never applied, so a grid measured under a fit-content width reported its max-content width. It is now min(max-content, max(min-content, available)), its tracks sized again at the available width when the max-content exceeds it.

A fourth: three steps of the track sizing gave an `auto` minimum an item's limited min-content contribution whenever Yoga's sizing mode was `MaxContent`, which is also how Yoga lays out an `auto` block size; that size is indefinite free space, not a max-content constraint, so a `0fr` row over an item with `min-height: 0` (the accordion idiom) stood as tall as the item's content. Only the inline axis is measured under a real max-content constraint now. `GridZeroFrRow-itest.js` pins it.

Co-authored-by: ide <379606+ide@users.noreply.github.com>
ide-agent pushed a commit to expo/react-native that referenced this pull request Oct 20, 2026
…pstream)

Grid lanes (css-grid-3) is defined on top of Grid's track sizing algorithm:
it imports <track-size>, minmax(), fr, repeat(), auto-fill/auto-fit and
line placement from css-grid-2 by name. That algorithm does not exist in
our tree — PR 1/9 of the upstream series landed the style types
(GridTrackSize, GridLine, gridTemplateColumns/Rows) but not the algorithm
behind them.

Rather than write a second one-axis track sizer, vendor the upstream
implementation verbatim:

  react/yoga#1894 "CSS Grid 2/9: Grid layout algorithm"
  by Nishan Bende (intergalacticspacehighway), open since 2026-02-25

  algorithm/grid/AutoPlacement.h   css-grid-1 §8.5 auto-placement
  algorithm/grid/GridLayout.{h,cpp} entry point, implicit tracks
  algorithm/grid/GridTrack.h        per-track layout state
  algorithm/grid/TrackSizing.h      css-grid-2 §12 track sizing

TrackSizing is parameterized by Dimension — it runs per axis — which is
exactly the shape grid lanes needs, since lanes sizes tracks in the grid
axis only and flows content in the other.

Not our code: nothing in algorithm/grid/ is modified, so that directory
can be deleted wholesale and replaced when the upstream series lands
instead of being merged. Only the integration points are ours, and only
because the PR could not supply them — our CalculateLayout.cpp has
diverged (block formatting contexts) and our Yoga is 197 commits behind:

  - CalculateLayout.cpp: the Display::Grid dispatch, next to Display::Block
  - yoga/CMakeLists.txt: an explicit algorithm/grid/*.cpp glob, since
    CMake's ** matches one level; Android builds through this same file
    and iOS globs recursively via the podspec

The PR's YGNodeStyle.cpp hunk is deliberately omitted: it adds a fallback
return to silence GCC -Wreturn-type, and our tree already handles those
switches better with fatalWithMessage("Unknown YGGridTrackType").

Verified, not assumed: verify-grid-vendor.sh builds yogacore with the
vendored directory and lays out

  display: grid; width: 600px; gap: 10px;
  grid-template-columns: 100px 1fr 2fr; grid-template-rows: 50px auto;

comparing every coordinate against the same CSS rendered by real Safari
(grid-vendor-verify.html, read via safaridriver). 25/25 values match
exactly, including fr distribution (160/320 of 480 remaining) and the
auto row resolving to its tallest item.

Upstream status: react#1894 is being re-split after review — react#1923 (data
structures) and react#1994 (auto-placement) are open, but the track-sizing
split has not been posted, which is why this vendors the original PR.
See algorithm/grid/README-VENDORED.md.

A third local fix, listed in README-VENDORED.md: the fit-content clamp in the inline axis was never applied, so a grid measured under a fit-content width reported its max-content width. It is now min(max-content, max(min-content, available)), its tracks sized again at the available width when the max-content exceeds it.

A fourth: three steps of the track sizing gave an `auto` minimum an item's limited min-content contribution whenever Yoga's sizing mode was `MaxContent`, which is also how Yoga lays out an `auto` block size; that size is indefinite free space, not a max-content constraint, so a `0fr` row over an item with `min-height: 0` (the accordion idiom) stood as tall as the item's content. Only the inline axis is measured under a real max-content constraint now. `GridZeroFrRow-itest.js` pins it.

Co-authored-by: ide <379606+ide@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — dbb7f1ef Deployed Mar 5, 2026 by vercel[bot]
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.

3 participants