Conversation
|
@intergalacticspacehighway is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
74c932a to
3ad6a75
Compare
|
Oo, I haven't looked at the implementation yet, but I wanted to point you at https://github.com/DioxusLabs/taffy/tree/main/test_fixtures/grid where we have 250+ test cases for CSS Grid in almost the same format as Yoga's gentests (Taffy was originally a port/rewrite of Yoga to Rust, and it's test generation setup is very similar). There are a couple of slightly differences in the test format:
But the actual HTML snippets should be compatible, and you should be able to script a conversion fairly easily if you want to use them. |
|
Thanks @nicoburns. The tests were invaluable! There are a few tests which i haven't pushed which were failing because of some default styling in testsuite, looking into fixing those. And skipped some tests related to min-content/max-content sizing unit support as I kept it in later scope (which should be soon once the PR lands 😅). |
5366a48 to
02aa523
Compare
|
@intergalacticspacehighway I see you're adding benchmarks, and wanted to note that we have comparative benchmarks between Yoga and Taffy over at https://github.com/DioxusLabs/taffy/tree/main/benches which work by using the Rust bindings to Yoga (https://github.com/bschwind/yoga-rs) Currently only the Flexbox benchmarks have a Yoga version, but I would be very interested to see this extended to the Grid benchmarks now that Yoga is getting Grid support. |
196d320 to
32b7899
Compare
2d76996 to
9d1d1ae
Compare
NickGerleman
left a comment
There was a problem hiding this comment.
I want to take a closer look at all of this, now that I'm back from leave, but overall it seems pretty sane on a code level, and it seems like it is based on specced behavior, and well tested (I could see a few hundred fixture based tests with grid_ prefix passing).
Want to import it into internal tooling, which will run some more tests (though this seems pretty self-contained to not effect other display types), and help navigate all the generated files better than GitHub can.
gentest/gentest-driver.ts
Outdated
| import readline from 'node:readline/promises'; | ||
| import signedsource from 'signedsource'; | ||
|
|
||
| async function findHtmlFixtures(dir: string): Promise<string[]> { |
There was a problem hiding this comment.
nit: consider using either native fs.glob(), or the glob libraries pulled in by the package or repo to do this
| @@ -753,6 +853,16 @@ class YG_EXPORT Style { | |||
| Dimensions maxDimensions_{}; | |||
| StyleValueHandle aspectRatio_{}; | |||
|
|
|||
| // Grid properties | |||
| GridTrackList gridTemplateColumns_{}; | |||
| GridTrackList gridTemplateRows_{}; | |||
| GridTrackList gridAutoColumns_{}; | |||
| GridTrackList gridAutoRows_{}; | |||
| GridLine gridColumnStart_{}; | |||
| GridLine gridColumnEnd_{}; | |||
| GridLine gridRowStart_{}; | |||
| GridLine gridRowEnd_{}; | |||
There was a problem hiding this comment.
What does this translate to, in terms of size of yoga::Node?
There was a problem hiding this comment.
Tested with sizeof, yoga::Node went from 592 bytes (current main) to 728 bytes (this PR).
GridLine = 8 bytes, GridTrackList = 24 bytes. GridTrackList is vector of GridTrackSize and GridTrackSize is 28 bytes. Also, new enums are added in align, justify and display, so total init yoga::Node comes to 728 bytes.
There was a problem hiding this comment.
Can we do this now for Flex?
| // Fallback to safe center. TODO (T208209388): This should be aligned to | |
| // Start instead of FlexStart (for row-reverse containers) | |
| case Align::SpaceAround: | |
| case Align::SpaceEvenly: | |
| return Align::Start; |
There was a problem hiding this comment.
Yes, we can do that. Currently these are kept no-op for flex layout here. (Line no. 1831 CalculateLayout.cpp). Can implement in another PR.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this in D93552310. |
|
There are some errors when I import this into fbsource, bc of formatting, and some extra warnings enabled (like I'm going to have Claude do some automated fixup of those (should be mechanical), then have it split and resubmit this in a few parts, so we can review each piece. The files are mostly fixtures, but review tools have been struggling with this change 😅 |
|
I exported the split version, with mechanical changes, to appease all the various linters or checks in Meta monorepo, and to be small enough to review/merge each piece: https://github.com/facebook/yoga/pull/1887/commits |
Summary: Add the foundational data types, enums, style properties, and C API for expressing CSS Grid layouts in Yoga. Includes: - Grid style types (GridLine.h, GridTrack.h, GridTrackType.h) - Updated enums (Display::Grid, Align::Start/End, Justify::Auto/Stretch/Start/End) - Grid event (LayoutPassReason::kGridLayout) - Style property accessors and member variables - Public C API (YGGridTrackList.h/cpp, YGNodeStyle grid setters/getters) - Layout helpers updated for new enum values (Align.h, AbsoluteLayout.cpp, CalculateLayout.cpp/h partial) - Node.h: relativePosition made public - React Native mirror of all C++ changes Differential Revision: D93946262
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
Summary: Add grid layout benchmarks. Includes: - YGGridBenchmark.c: 14 benchmark scenarios - benchmarkgrid: shell script to run benchmarks - CMakeLists.txt: benchmarkgrid target Differential Revision: D93946260
Summary: Add hand-written C++ tests for the grid layout algorithm. Includes: - Hand-written tests: AutoPlacementTest.cpp, CreateGridTrackTest.cpp - Modified existing tests: YGAlignBaselineTest.cpp (+3 grid baseline tests), YGHadOverflowTest.cpp (+1 grid overflow test) Differential Revision: D93946259
Summary: Add Java/Kotlin bindings for CSS Grid support. Includes grid API classes (YogaGridTrackList, YogaGridTrackValue, YogaGridTrackType), JNI bridge updates, enum changes (YogaDisplay, YogaAlign, YogaJustify). Also includes React Native Android mirror of all Java/Kotlin changes. Differential Revision: D93946256
Summary: Add JavaScript/WASM bindings for CSS Grid support. Includes embind bindings, TypeScript types (YGEnums.ts), Node wrapper updates (wrapAssembly.ts). Existing generated JS tests are updated to import GridTrackType. Differential Revision: D93946255
Summary: Update gentest scripts to support CSS Grid properties. Adds grid style extraction, grid property setup, display:grid handling, and grid-aware LTR/RTL fixture support to the C++, Java, and JavaScript test emitters. Differential Revision: D93946258
Differential Revision: D94005983
Summary: Add HTML fixture files for CSS Grid tests and generated test output for C++, Java, and JavaScript. Includes: - HTML fixture files defining grid layout test cases - Generated C++ tests (YGGridTest.cpp, YGGridTestFlows.cpp, ~150 individual test files) - Generated Java tests (YGGridTest.java, YGGridTestFlows.java, ~150 individual test files) - Generated JavaScript tests (YGGridTest.test.ts, YGGridTestFlows.test.ts, ~150 individual test files) Differential Revision: D93946254
Summary: Pull Request resolved: facebook#1887 Add grid property support to the Yoga Playground website component. Includes: - Grid display mode support - Grid template columns/rows properties - Grid auto columns/rows properties - Grid column/row start/end properties (including span support) - Grid track value parsing (auto, fr, %, px, minmax) Differential Revision: D93959518
79fe6ec to
e97b4fd
Compare
Why?
How?
By extending Yoga to support CSS Grid spec. The implementation is open to suggestions, improvements, including anything I might have missed.
Supported APIs in this PR
Properties
grid-template-columns,grid-template-rows,grid-column-start,grid-column-end,grid-row-start,grid-row-end,grid-auto-columns,grid-auto-rowsSizing Functions/Units
minmax(),auto,Percentage,Fixed(pxunit),Flex(frunit)Unsupported APIs (Future scope)
To limit the scope of the PR below features are omitted. We can introduce them gradually.
grid-[column|row]-[start|end]for absolute grid items. Right now, grid container can only be the containing block for absolute items.grid-template-areasgrid-areamasonrygrid-auto-flowgrid-column/grid-rowshorthandsrepeat()auto-fill,auto-fit,fit-content,max-content,min-content)Spec differences
[justify|align]-contentis set to flex-start in yoga by default, it behaves asstartfor grid. We can introducenormalkeyword which is the default keyword for these properties. It's not introduced in this PR. Visually it should behave the same.max-contentfor intrinsic item size calculations for intrinsic track size operations. We can revisit this if we add min-content support in yoga.Notes for reviewer
Main files that include grid layout algorithm are:
AutoPlacement.h- Implements Grid Placement AlgorithmTrackSizing.h- Implements Grid Sizing Algorithm and Track Sizing AlgorithmGridLayout.cpp- Grid layout entry point. CallsAutoPlacement,TrackSizingand performs final layout of grid items.More
cc - @joevilches @NickGerleman