Commit Graph

603 Commits

Author SHA1 Message Date
Mateo Guzmán
024d360e3c Migrate YogaConfigJNIBase to Kotlin 2025-08-24 10:54:52 +02:00
Nivaldo Bondança
dc2581f229 Codemod format for trailing commas change
Reviewed By: VladimirMakaev

Differential Revision: D80576929

fbshipit-source-id: 1310f77f5d9d489b780b14875454ebda7f7adfc9
2025-08-19 18:15:18 -07:00
Nivaldo Bondança
f16fee8c2e Codemod format for trailing commas incoming change [300/n] (#1848)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1848

X-link: https://github.com/facebook/react-native/pull/53338

Adding trailing commas to folders:
- xplat/js/react-native-github/packages/react-native
- xplat/kotlin/ast_tools/core/src
- xplat/kotlin_compiler_plugins/template/src/main
- xplat/kotlin/kotlin_multiplatform_template/src/commonMain
- xplat/libraries/bloks/bloks-debugging/src
- xplat/libraries/bloks/bloks-lispy/src
- xplat/libraries/bloks/bloks-step-debugger/src
- xplat/mdv/uifiddle-prototype/android-server/playground
- xplat/mdv/uifiddle-prototype/android-server/server
- xplat/oxygen/common/src/test
- xplat/oxygen/mpts/src/main
- xplat/oxygen/mpts/src/test
- xplat/prototypes/smartglasses/AndroidStudioProjects/MetaAccessoryTest
- xplat/prototypes/smartglasses/AndroidStudioProjects/MetaWearableSDKSampleApp
- xplat/prototypes/smartglasses/AndroidStudioProjects/MetaWearableSDK
- xplat/prototypes/smartglasses/AndroidStudioProjects/Voice
- xplat/ReactNative/react-native-cxx/react/renderer
- xplat/rtc/media/tools/audio
- xplat/security/prodsec/android/codetransparency
- xplat/security/prodsec/siggy/java
- xplat/simplesql/codegen/java/com
- xplat/sonar/android/plugins/jetpack-compose
- xplat/sonar/android/plugins/leakcanary2
- xplat/sonar/android/plugins/litho
- xplat/sonar/android/plugins/retrofit2-protobuf
- xplat/sonar/android/sample/src
- xplat/sonar/android/src/facebook

Reviewed By: dtolnay

Differential Revision: D80452590

fbshipit-source-id: 2bc79edba21e913f6121a25a269c1a4258f5f31c
2025-08-18 10:24:50 -07:00
Mateo Guzmán
89fc160151 Migrate YogaConfig to Kotlin (#1841)
Summary:
Migrate com.facebook.yoga.YogaConfig to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1841

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897694

Pulled By: cortinico

fbshipit-source-id: 0eff36f47bbb8da6a91087f2ea69bc4e40a732ac
2025-08-14 07:29:26 -07:00
Nivaldo Bondança
d1246f6f0d Codemod format for trailing commas incoming change [5/n] (#1847)
Summary:
X-link: https://github.com/facebook/react-native/pull/53260

Pull Request resolved: https://github.com/facebook/yoga/pull/1847

Adding trailing commas.

Reviewed By: cortinico

Differential Revision: D80174965

fbshipit-source-id: 5438fa9ebce13525b1286dd30704138ef99703cb
2025-08-14 07:24:42 -07:00
Mateo Guzmán
93bea17635 Migrate YogaValue to Kotlin (#1838)
Summary:
Migrate com.facebook.yoga.YogaValue to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1838

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897668

Pulled By: cortinico

fbshipit-source-id: dffe2b29087c35e4797f46dea756c51f841590d8
2025-08-13 16:45:06 -07:00
Mateo Guzmán
c582f7caa6 Migrate YogaNative to Kotlin (#1839)
Summary:
Migrate com.facebook.yoga.YogaNative to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1839

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897725

Pulled By: cortinico

fbshipit-source-id: 6fc98565368d831b8698464fe26ad47f8fff6a74
2025-08-13 08:56:03 -07:00
Mateo Guzmán
bf1cbd29c0 Migrate YogaConfigFactory to Kotlin (#1833)
Summary:
Migrate com.facebook.yoga.YogaConfigFactory to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1833

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897762

Pulled By: cortinico

fbshipit-source-id: 9457b307204f2066a02690f96a88fce6755f915e
2025-08-13 06:46:48 -07:00
Mateo Guzmán
499a825836 Migrate DoNotStrip to Kotlin (#1840)
Summary:
Migrate com.facebook.yoga.annotations.DoNotStrip to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1840

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897758

Pulled By: cortinico

fbshipit-source-id: 79585e6ab793bd72e04440581d866f7721667db3
2025-08-12 10:54:27 -07:00
Mateo Guzmán
8087edaafe Migrate YogaLayoutType to Kotlin (#1837)
Summary:
Migrate com.facebook.yoga.YogaLayoutType to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1837

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897708

Pulled By: cortinico

fbshipit-source-id: e3c8a3cc60f806d151d2be956b26dd98963254a6
2025-08-12 09:49:31 -07:00
Mateo Guzmán
c90aecbdfe Migrate LayoutPassReason to Kotlin (#1836)
Summary:
Migrate com.facebook.yoga.LayoutPassReason to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1836

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897685

Pulled By: cortinico

fbshipit-source-id: 87d2e4b95fbdbfe48d84019e9ffb50deb9286d8c
2025-08-12 09:10:30 -07:00
Mateo Guzmán
c54215fd77 Migrate YogaNodeFactory to Kotlin (#1832)
Summary:
Migrate com.facebook.yoga.YogaNodeFactory to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1832

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: zielinskimz

Differential Revision: D79897733

Pulled By: cortinico

fbshipit-source-id: 3ea4f5635eb8c910719c13d3087356b96b6f0746
2025-08-12 08:57:43 -07:00
Mateo Guzmán
cf50bc9adf Migrate YogaMeasureOutput to Kotlin (#1842)
Summary:
Migrate com.facebook.yoga.YogaMeasureOutput to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1842

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897681

Pulled By: cortinico

fbshipit-source-id: 63280b6aed9bbeeb1e71458a1793c9647dcf0726
2025-08-12 07:55:41 -07:00
Mateo Guzmán
d1037226c0 Migrate YogaMeasureFunction to Kotlin (#1835)
Summary:
Migrate com.facebook.yoga.YogaMeasureFunction to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1835

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: mdvacca

Differential Revision: D79897728

Pulled By: cortinico

fbshipit-source-id: 959ae976622838147685cf6088674dce25f5cc99
2025-08-12 07:40:31 -07:00
Mateo Guzmán
714d4b2ebe Migrate YogaStyleInputs to Kotlin (#1830)
Summary:
Migrate com.facebook.yoga.YogaStyleInputs to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1830

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897662

Pulled By: cortinico

fbshipit-source-id: a4063a8c0f608050162cd3707834040e35f9ebf7
2025-08-12 03:34:21 -07:00
Mateo Guzmán
d4b5220e6c Migrate YogaBaselineFunction to Kotlin (#1831)
Summary:
Migrate com.facebook.yoga.YogaBaselineFunction to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1831

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: joevilches, mdvacca

Differential Revision: D79897676

Pulled By: cortinico

fbshipit-source-id: 2f175bf60a871c4635d1575faec1096f9c970f48
2025-08-11 10:51:55 -07:00
Mateo Guzmán
da5ba7f7c6 Migrate YogaLogger to Kotlin (#1834)
Summary:
Migrate com.facebook.yoga.YogaLogger to Kotlin.

Pull Request resolved: https://github.com/facebook/yoga/pull/1834

Test Plan:
RN
```sh
yarn android
yarn test-android
```

Yoga
```sh
./gradlew :yoga:assembleDebug
```

Reviewed By: rshest

Differential Revision: D79897742

Pulled By: cortinico

fbshipit-source-id: 79b926a7abadce9038fc55ad0f608e92bc77a55a
2025-08-11 08:47:34 -07:00
Mateo Guzmán
8bf7a34d02 Initial Kotlin setup and migrate YogaConstants (#1829)
Summary:
X-link: https://github.com/facebook/react-native/pull/53133

# Changelog:
[Internal] -

As part of the ongoing effort to migrate the React Native codebase to Kotlin, this PR introduces the initial setup required for Kotlin support in Yoga.

- Added initial basic Kotlin configuration to the project.
- Migrated `YogaConstants` as an initial file to try out the first migration steps.

Pull Request resolved: https://github.com/facebook/yoga/pull/1829

Test Plan:
- Tested the migrated class directly against facebook/react-native, see the PR [here](https://github.com/facebook/react-native/pull/52998).
- Run: `./gradlew :yoga:assembleDebug` & `./gradlew :yoga:compileDebugSources`

I am not able to run the Java tests in this repo (even before the initial Kotlin setup) – not sure if I am missing something there but any pointers are welcome – it seems like there is some missing configuration. Currently trying with `./gradlew :yoga:test`

Reviewed By: cortinico

Differential Revision: D79545992

Pulled By: rshest

fbshipit-source-id: 8257ff53e6b6f2436980be98b6c94e1ac526b207
2025-08-07 08:17:56 -07:00
Nick Gerleman
4b5ca50117 Reland Fix possible invalid measurements when width or height is zero pixels (#1823)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1823

X-link: https://github.com/facebook/react-native/pull/52348

Fixes https://github.com/facebook/yoga/issues/1819

Yoga has a fast path when measuring a node, if it thinks it knows its dimensions ahead of time.

This path has some eroneous logic, to set both axis to owner size, if *either* will evaluate to zero, while having an `YGMeasureModeAtMost`/`FitContent` constraint. This means that if a node is given a zero width, and Yoga later measures with with `FitContent`, its height will become the maximum allowable height, even if it shouldn't be that large.

We can fix this, by only allowing if both axis are this fixed case, instead of just one.

This bug has existed for about a decade (going back to at least D3312496).

Changelog:
[General][Fixed] - Fix possible invalid measurements with width or height is zero pixels

Reviewed By: yungsters

Differential Revision: D76851589

fbshipit-source-id: 6f5a0e6beccc51f591726c9e83e9b90f3350ed0f
2025-06-30 20:46:39 -07:00
FBLite Revert Bot
30291398f3 Revert D76793705: Fix possible invalid measurements when width or height is zero pixels
Differential Revision:
D76793705

Original commit changeset: ea4c00e68891

Original Phabricator Diff: D76793705

fbshipit-source-id: 95d6b66ab08e073da9fb07fd4094a7e30e2f453b
2025-06-17 14:33:32 -07:00
Nick Gerleman
27d632c697 Fix possible invalid measurements when width or height is zero pixels (#1820)
Summary:
X-link: https://github.com/facebook/react-native/pull/52073

Pull Request resolved: https://github.com/facebook/yoga/pull/1820

Fixes https://github.com/facebook/yoga/issues/1819

Yoga has a fast path when measuring a node, if it thinks it knows its dimensions ahead of time.

This path has some eroneous logic, to set both axis to owner size, if *either* will evaluate to zero, while having an `YGMeasureModeAtMost`/`FitContent` constraint. This means that if a node is given a zero width, and Yoga later measures with with `FitContent`, its height will become the maximum allowable height, even if it shouldn't be that large.

We can fix this, by only allowing if both axis are this fixed case, instead of just one.

This bug has existed for about a decade (going back to at least D3312496).

Changelog:
[General][Fixed] - Fix possible invalid measurements with width or height is zero pixels

Reviewed By: yungsters

Differential Revision: D76793705

fbshipit-source-id: ea4c00e688912a58c08801e4a14ddf1b293a5d86
2025-06-17 12:15:55 -07:00
Mihaela Ogrezeanu
c2ae39167e Update yoga aar targets (#1786)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1786

Follow up on comments from D68152410

- Removes minsdk version from manifest
- Update to MIT licence
- Rename targets that don't export existing libs

I've looked into using yoga_java_library and adding a param to pass what libs to exclude, but ultimately provided_deps does what we need and it simpler to maintain; we still need to add the different targets because the aar needs to depend on :jni-server and not :jni.

Reviewed By: NickGerleman

Differential Revision: D69455682

fbshipit-source-id: aa08bc030495d13da9545ec368ab63a7a946dad0
2025-02-12 02:28:59 -08:00
Mihaela Ogrezeanu
49ee855f99 Add aar BUCK targets to export Litho libraries as aars (#1782)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1782

This adds fb_native.android_aar targets for resources that are needed by Litho at runtime and cannot be exported as jars.
- resource modules referenced by Litho
- Yoga library. Some dependencies required by Yoga neded to be added as "provided_deps" so they don't get exported with the aar

Reviewed By: astreet

Differential Revision: D68152410

fbshipit-source-id: 7dc2ffa0b60a4ca160a011d16d2dc5ab91f608a6
2025-01-24 07:57:56 -08:00
Joe Vilches
909e4bea6e Fix test util to measure text properly based on flex direction (#1768)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1768

Depending on the flex direction text will either be capped to the measured size or to the longest word, so I added that functionality

Reviewed By: mlord93

Differential Revision: D67106199

fbshipit-source-id: 0b4691768809004043a847f3fc5f7b94e92f1575
2024-12-12 11:11:49 -08:00
Nicola Corti
13f4adbbcd Add 16K support for standalone Yoga (#1766)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1766

While we added support for 16K pages for yoga through React Native,
the standalone version we upload to Maven Central wasn't handled.
This fixes it.

Reviewed By: NickGerleman

Differential Revision: D66975933

fbshipit-source-id: 36a8404e2f2a60a44b9a39e478b23d1829bc542e
2024-12-10 09:34:38 -08:00
heoblitz
ae2d06d0f5 Update YGNodeStyleGetGap to return YGValue (#1753)
Summary:
X-link: https://github.com/facebook/react-native/pull/47973

Gap can be styled using both `points` and `percentages`, but YGNodeStyleGetGap currently returns a float value.

To maintain alignment with the `padding` and `margin` functionalities and allow it to be handled in bridging code, this function has been updated to return YGValue.

Pull Request resolved: https://github.com/facebook/yoga/pull/1753

Reviewed By: joevilches

Differential Revision: D66513236

Pulled By: NickGerleman

fbshipit-source-id: b7110855c037f20780f031f22a945bde4446687d
2024-12-09 13:38:05 -08:00
Joe Vilches
e177477144 Add text based intrinsic sizing tests (#1759)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1759

We just have block based tests right now. Intrinsic sizing is commonly used with text so lets add a few there.

Reviewed By: NickGerleman

Differential Revision: D66662940

fbshipit-source-id: f8b91419c89d22d79a91d3bd8c7da70429c827fb
2024-12-02 17:29:49 -08:00
Joe Vilches
76ffdbc25d Back out "Back out "[yoga][gentest][intrinsic sizing] Gentest and initial tests for intrinsic sizing"" (#1758)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1758

Original commit changeset: 52d6cc754cb9

Original Phabricator Diff: D66332308

Reviewed By: NickGerleman

Differential Revision: D66662663

fbshipit-source-id: fb3a0d10ec0f0149aeee510148f26ada8eff7e47
2024-12-02 17:29:49 -08:00
Joe Vilches
f99e657acd Back out "Back out "[yoga][intrinsic sizing] Update public API for intrinsic sizing setters""
Summary:
Original commit changeset: 793f77dad021

Original Phabricator Diff: D66332309

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66662661

fbshipit-source-id: 22ed3ac9492f0a563c041ce4cb5fba4b65b53211
2024-12-02 17:29:49 -08:00
Joe Vilches
a9246bc7db Back out "Back out "[yoga][intrinsic sizing] Modify private apis to set, store, and get intrinsic sizing keywords"" (#1756)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1756

X-link: https://github.com/facebook/react-native/pull/48049

Changelog: [Internal]

Original commit changeset: 1d596964e0c8

Original Phabricator Diff: D66332307

Reviewed By: NickGerleman

Differential Revision: D66662662

fbshipit-source-id: 4f9ac2b1557b848f519dcd728d7097b52f1190b3
2024-12-02 17:29:49 -08:00
Joe Vilches
be00354b71 Back out "Modify private apis to set, store, and get intrinsic sizing keywords" (#1750)
Summary:
X-link: https://github.com/facebook/react-native/pull/47895

Pull Request resolved: https://github.com/facebook/yoga/pull/1750

These APIs were only added so that we could do TDD as we work on intrinsic sizing functionality. As of right now they do nothing. We are aiming on publishing a new version of Yoga soon so for the time being we are going to back these out so as not to confuse anyone with this new functionality. Ideally we get to a point where we have some temporary experimental header to stage these in but this is a bit time sensitive so just backing out for now

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66332307

fbshipit-source-id: 1d596964e0c893091c541988506e8b80fa6d1957
2024-11-25 00:40:03 -08:00
Joe Vilches
0c995496c8 Back out "Update public API for intrinsic sizing setters" (#1752)
Summary:
X-link: https://github.com/facebook/react-native/pull/47896

Pull Request resolved: https://github.com/facebook/yoga/pull/1752

These APIs were only added so that we could do TDD as we work on intrinsic sizing functionality. As of right now they do nothing. We are aiming on publishing a new version of Yoga soon so for the time being we are going to back these out so as not to confuse anyone with this new functionality. Ideally we get to a point where we have some temporary experimental header to stage these in but this is a bit time sensitive so just backing out for now

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66332309

fbshipit-source-id: 793f77dad021fa5e57b52c36ae954307636bcbf0
2024-11-25 00:40:03 -08:00
Joe Vilches
c12e732fab Back out "Gentest and initial tests for intrinsic sizing" (#1751)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1751

Original commit changeset: 1e3e7214fab0

Original Phabricator Diff: D64145117

Reviewed By: NickGerleman

Differential Revision: D66332308

fbshipit-source-id: 52d6cc754cb931e851e444bac2c946907a098235
2024-11-25 00:40:03 -08:00
phuccvx12
77c9987012 Fix: Correct Layout Behavior for Combined align-content and align-items (#1742)
Summary:
X-link: https://github.com/facebook/react-native/pull/47732

This pull request addresses the issue where combining align-content and align-items properties resulted in incorrect layout behavior in Yoga version 3.1.0, as reported in [Issue https://github.com/facebook/yoga/issues/1739](https://github.com/facebook/yoga/issues/1739).

# Changes Made:

Alignment Logic Update: Modified the alignment calculations to ensure that the combination of align-content and align-items properties produces the expected layout, consistent with CSS Flexbox standards and previous Yoga versions.

Test Cases Added: Introduced new test cases to cover scenarios involving various combinations of align-content and align-items properties to prevent future regressions.

# Testing:

All existing tests pass successfully.

New test cases confirm that the layout behaves as expected when align-content and align-items are used together.

# Impact:

This fix ensures that layouts using both align-content and align-items properties render correctly, aligning with the behavior observed in Yoga version 1.19.0 and standard web browsers.

Pull Request resolved: https://github.com/facebook/yoga/pull/1742

Reviewed By: joevilches

Differential Revision: D65953882

Pulled By: zeyap

fbshipit-source-id: 7e12a21b1d442b35c3f3536cad32dc4b82130d15
2024-11-20 19:59:42 -08:00
Joe Vilches
26b21ae23c Update some Justify tests following Chrome changes (#1746)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1746

Chrome made some changes for how overflowed row-reverse containers are laid out which was causing some issues on CI. I updated them here and skipped the new failing tests which we would want to followup on.

For LTR, the differences are seen below
|Before|After|
|--|
|{F1962694149} | {F1962694151}|

The extra space is now extending past the flex start edge vs flex end. RTL is the opposite. NickGerleman had deviated from the spec back in the day to match Chrome and it seems they made the adjustment recently. T208209388 is tracking the followup to align with the spec again. Basically, there is a notion of fallback alignment when certain justification/alignment values cannot actually apply. Right now we are falling back to flex start in all cases but we should fallback to start sometimes.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66138361

fbshipit-source-id: c46d2e9b0cd297069b9cc544e3bded995e4867a6
2024-11-19 15:43:04 -08:00
Joe Vilches
867bfae3a3 Gentest and initial tests for intrinsic sizing (#1723)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1723

Adds gentest support for intrinsic sizing keywords and creates an initial batch of somewhat interesting tests for these keywords on `width`, `height`, `min-width`, `min-height`, `max-width`, `max-height`, and `flex-basis`

Reviewed By: NickGerleman

Differential Revision: D64145117

fbshipit-source-id: 1e3e7214fab062ab6f260cfe7bdfaf3c0aca3bf7
2024-11-04 16:02:37 -08:00
Joe Vilches
488288e291 Update public API for intrinsic sizing setters (#1722)
Summary:
X-link: https://github.com/facebook/react-native/pull/46939

Pull Request resolved: https://github.com/facebook/yoga/pull/1722

tsia! opted for one function for each keyword just like auto. This is kinda annoying and not the most sustainable, so maybe it makes more sense to make a new enum here and just add one function

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D64002837

fbshipit-source-id: f15fae9fc0103175e1d85850fc9aa68579989fd3
2024-11-04 16:02:37 -08:00
Joe Vilches
f52ec78584 Modify private apis to set, store, and get intrinsic sizing keywords (#1721)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1721

X-link: https://github.com/facebook/react-native/pull/46938

The private internals of how we store styles needed to change a bit to support 3 new keyword values. Right now the only other keyword that can be stored is `auto`. As a result there isn't much fancy logic to support storing this and its just stored as a specific type inside of `StyleValueHandle`. There are only 3 bits for types (8 values), so it is not sustainable to just stuff every keyword in there. So the change writes the keyword as a value with a new `keyword` `Type`.

I chose not to put `auto` in there even though it is a keyword since it is a hot path, I did not want to regress perf when I did not need to.

I also make a new `StyleSizeValue` class to store size values - so values for `width`, `height`, etc. This way these new keywords are kept specific to sizes and we will not be able to create, for example, a margin: `max-content`.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63927512

fbshipit-source-id: 7285469d37ac4b05226183b56275c77f0c06996c
2024-11-04 16:02:37 -08:00
Alan Lee
e696b8c456 Bump to Gradle 8.9, AGP 8.7.1 and NDK 27
Summary:
Bumping Gradle to 8.9 and NDK to 27.1.12297006 in prep to build native libraries with 16KB page size support

See:
- Changelog r27: https://github.com/android/ndk/wiki/Changelog-r27
- 16KB page sizes: https://developer.android.com/guide/practices/page-sizes

Changelog:
[Android][Updated] - Bump Gradle to 8.9, AGP to 8.7.1 and NDK to 27

Reviewed By: cortinico

Differential Revision: D64381441

fbshipit-source-id: 5e4236c166568a3990deabfd628f0f34e52ea855
2024-10-24 13:34:03 -07:00
Jakub Piasecki
68bb2343d2 Add support for display: contents style (#1726)
Summary:
X-link: https://github.com/facebook/react-native/pull/47035

This PR adds support for `display: contents` style by effectively skipping nodes with `display: contents` set during layout.

This required changes in the logic related to children traversal - before this PR a node would be always laid out in the context of its direct parent. After this PR that assumption is no longer true - `display: contents` allows nodes to be skipped, i.e.:

```html
<div id="node1">
  <div id="node2" style="display: contents;">
    <div id="node3" />
  </div>
</div>
```

`node3` will be laid out as if it were a child of `node1`.

Because of this, iterating over direct children of a node is no longer correct to achieve the correct layout. This PR introduces `LayoutableChildren::Iterator` which can traverse the subtree of a given node in a way that nodes with `display: contents` are replaced with their concrete children.

A tree like this:
```mermaid
flowchart TD
    A((A))
    B((B))
    C((C))
    D((D))
    E((E))
    F((F))
    G((G))
    H((H))
    I((I))
    J((J))

    A --> B
    A --> C
    B --> D
    B --> E
    C --> F
    D --> G
    F --> H
    G --> I
    H --> J

    style B fill:https://github.com/facebook/yoga/issues/050
    style C fill:https://github.com/facebook/yoga/issues/050
    style D fill:https://github.com/facebook/yoga/issues/050
    style H fill:https://github.com/facebook/yoga/issues/050
    style I fill:https://github.com/facebook/yoga/issues/050
```

would be laid out as if the green nodes (ones with `display: contents`) did not exist. It also changes the logic where children were accessed by index to use the iterator instead as random access would be non-trivial to implement and it's not really necessary - the iteration was always sequential and indices were only used as boundaries.

There's one place where knowledge of layoutable children is required to calculate the gap. An optimization for this is for a node to keep a counter of how many `display: contents` nodes are its children. If there are none, a short path of just returning the size of the children vector can be taken, otherwise it needs to iterate over layoutable children and count them, since the structure may be complex.

One more major change this PR introduces is `cleanupContentsNodesRecursively`. Since nodes with `display: contents` would be entirely skipped during the layout pass, they would keep previous metrics, would be kept as dirty, and, in the case of nested `contents` nodes, would not be cloned, breaking `doesOwn` relation. All of this is handled in the new method which clones `contents` nodes recursively, sets empty layout, and marks them as clean and having a new layout so that it can be used on the React Native side.

Relies on https://github.com/facebook/yoga/pull/1725

Changelog: [Internal]

Pull Request resolved: https://github.com/facebook/yoga/pull/1726

Test Plan: Added tests for `display: contents` based on existing tests for `display: none` and ensured that all the tests were passing.

Reviewed By: joevilches

Differential Revision: D64404340

Pulled By: NickGerleman

fbshipit-source-id: f6f6e9a6fad82873f18c8a0ead58aad897df5d09
2024-10-18 22:05:41 -07:00
Nick Gerleman
568718242d Remove legacy absolute positioning path (#1725)
Summary:
X-link: https://github.com/facebook/react-native/pull/46984

Pull Request resolved: https://github.com/facebook/yoga/pull/1725

The legacy (wrong) absolute positioning path positions in two places, including work that is definitely always overwritten in the new absolute layout path.

This came up before for position: static, but we didn't clean this up at the time. This code is also now leading display: contents impl being more annoying.

This diff tries to converge to the more spec correct implementation of positioning here, that also only happens in one place.

Previous path would potentially also incorrectly justify when `justify-content` was non-default, but not handled in the previous few cases? We don't have access to the flexLine at this point later, and apart from the existing tests now passing I reused the new correct logic for justification (spec says we should position child as if its the only child in the container https://www.w3.org/TR/css-flexbox-1/#abspos-items).

I added a new, more scoped errata `AbsolutePositionWithoutInsetsExcludesPadding` to preserve some of the legacy behavior that showed as very breaking.

I also did not try removing `AbsolutePercentAgainstInnerSize` which I suspect would be more breaking than this change.

Changelog:
[General][Breaking] - More spec compliant absolute positioning

Reviewed By: joevilches

Differential Revision: D64244949

fbshipit-source-id: ca97570e0de82e8f0424a0912adfd0b05254559e
2024-10-17 22:40:16 -07:00
Joe Vilches
820a4d5bf6 Let gentest properly create *Auto methods for sizes (#1719)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1719

Right now there is no way to test fixtures with `auto` widths, heights, or flex basis - even though we expose those functions. I updated gentest to generate those functions. Notably, position and margin (the other auto-able props) already account for this.

 I also created `YGAutoTest.html` to test this. Not really testing the capabilities of `auto` here, just if we can create a test about it.

Reviewed By: NickGerleman

Differential Revision: D64125522

fbshipit-source-id: 291ec82003cf53f99c21943142a63e2ef30402a5
2024-10-09 19:20:15 -07:00
Joe Vilches
e69fcb26bb Fix issue where padding for box sizing is resolved against wrong reference length (#1715)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1715

X-link: https://github.com/facebook/react-native/pull/46799

Content box impl had a bug where we resolved padding % against the same reference length as the dimensions. Padding should always be against containing block's width. This is also true for width, but not for height, which should be against containing block's height.

This just pipes the width into our box sizing functions.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63787577

fbshipit-source-id: e512338770f25b66506cabab5a7cde8f04397ea0
2024-10-04 17:07:05 -07:00
Joe Vilches
990ec920ad Add default test for box sizing (#1716)
Summary:
X-link: https://github.com/facebook/react-native/pull/46800

Pull Request resolved: https://github.com/facebook/yoga/pull/1716

Had a mini heart attack thinking I set the default to content box. Wrote this to double check and it passed. Might as well check it in

Technically the default to BoxSizing.h is ContentBox, but in the style we override that. Regardless I switched that around so border box was the default.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63802722

fbshipit-source-id: 49ed29657c964bc12a2bf70988061ab4599267ec
2024-10-03 12:21:16 -07:00
Joe Vilches
bc236947d0 More niche box sizing tests (#1712)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1712

tsia, add some more advanced tests checking

* percent widths/heights/padding/border
* absolute positioned nodes with content box
* containing block with content box + static
* flex basis (fails now, needs follow up)
* relative padding/border values

All pass but flex basis

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63423302

fbshipit-source-id: d117d305072e254af57eaab03a6349176e759327
2024-10-01 15:19:22 -07:00
Joe Vilches
671ae61a39 Impl of content box (#1711)
Summary:
X-link: https://github.com/facebook/react-native/pull/46741

Pull Request resolved: https://github.com/facebook/yoga/pull/1711

box sizing is really just a reinterpretation of what length properties (like `width`, `height`, `max-width`, etc) mean. So to implement this I just add the border and padding if we are in content box when we ask for any of these properties. All the math that gets done by the algorithm is still in border box land, and the layout we return is to be interpreted as the border box (this is actually the expected behavior per https://drafts.csswg.org/css-sizing/#box-sizing). This makes this implementation pretty simple actually.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63416833

fbshipit-source-id: fd76132cf51e8a5092129802c3a12ab24023018b
2024-10-01 15:19:22 -07:00
Michael Troger
22b018c957 Fix YogaConfig getting garbage collected #1678 (#1703)
Summary:
X-link: https://github.com/facebook/react-native/pull/46651

Fixes [https://github.com/facebook/yoga/issues/1678](https://github.com/facebook/yoga/issues/1678)

As described in the linked Issue, the problem is that the `YogaConfig` can get garbage collected by the JVM, while a `YogaNode` is still referring to it. This at some point leads to unexpected behaviour (0 values for `layoutWidth`/`layoutHeight`). The change coming with this PR makes sure the `YogaConfig` can not get garbage collected while it's used by a `YogaNode`.

Demo project to confirm the fix https://github.com/michaeltroger/yogabug

Kudos to rtPag, who helped identifying the issue.

Pull Request resolved: https://github.com/facebook/yoga/pull/1703

Reviewed By: mdvacca

Differential Revision: D63416127

Pulled By: NickGerleman

fbshipit-source-id: efd87dac897e44d3664c228c40cda90f1e11c4f6
2024-09-25 23:53:17 -07:00
Joe Vilches
c722caa6b2 Add more fixtures for box sizing (#1702)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1702

tsia

Reviewed By: jorge-cab

Differential Revision: D63151874

fbshipit-source-id: f362f9114df006c5885a9771e6fd2115364833df
2024-09-25 15:46:55 -07:00
Joe Vilches
8277df7e1f Update gentest to account for box sizing (#1700)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1700

tsia, need to teach gentest to write box sizing now.

Reviewed By: NickGerleman

Differential Revision: D63138372

fbshipit-source-id: 29072b3e602fe77edb14a8857a83e5bba4c92205
2024-09-25 15:46:55 -07:00
Joe Vilches
43d920eab0 Expose box sizing getters and setters in Yoga (#1701)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1701

X-link: https://github.com/facebook/react-native/pull/46630

I would like to write some tests for box sizing that will drive a lot of my development as I implement content box. To do that, I need this publicly exposed. Obviously not that ideal since this currently does not do anything. Maybe we can name the value in such a way that its clear it is in development?

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63135970

fbshipit-source-id: 7520823bf925364eae45341531e012e80ec92284
2024-09-25 15:46:55 -07:00