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. |
c394ca6 to
69cf662
Compare
f5dc467 to
ded011f
Compare
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. |
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. |
087b644 to
196d320
Compare
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 😅 |
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