Compare commits

...

99 Commits

Author SHA1 Message Date
Nivaldo Bondança
0ef6192b16 Codemod format for trailing commas incoming change [10/n]
Summary: Adding trailing commas.

Differential Revision: D80174963
2025-08-13 10:31:29 -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
Dmitry Polukhin
82671c0132 Disable modernize-avoid-c-arrays in xplat/yoga/tests
Reviewed By: JuanBesa, rshest

Differential Revision: D79247609

fbshipit-source-id: 529ba950ab200c46493152b81dece6bd76f6fdbd
2025-07-30 03:39:00 -07:00
Alexey Medvedev
9f2a9476e5 Make yoga/Yoga.h an umbrell header (#1828)
Summary:
X-link: https://github.com/facebook/react-native/pull/52817

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

X-link: https://github.com/facebook/litho/pull/1070

This diff makes the Yoga/Yoga.h header an umbrella header, which means that it includes all of Yoga's public headers. The code changes in each file include adding the IWYU pragma export to each header file, which is a way to tell the compiler to export the header file's symbols to other files that include it. This is necessary for the header file to be used as an umbrella header.

Changelog:
[General][Added] - Code quality fixes

Reviewed By: corporateshark

Differential Revision: D78692457

fbshipit-source-id: 7fcd53d2a6f268fa4377dbd5bd6ba6eebc94b5f8
2025-07-24 16:51:13 -07:00
Jakub Piasecki
c7c85621fc Fix display: contents nodes not being cloned with the wrong owner (#1826)
Summary:
X-link: https://github.com/facebook/react-native/pull/52530

This PR fixes two issues with `display: contents` implementation:
1. When a node with `display: contents` set is a leaf, it won't be cloned after the initial tree is built. The added test case covers this scenario.
2. It was possible for the subtree of `display: contents` nodes not to be cloned during layout. I don't have a minimal reproduction for this one, unfortunately. It was discovered in the Expensify app: https://github.com/Expensify/App/issues/65268, along with a consistent reproduction. In that specific case, it seems to be heavily tied to `react-native-onyx`, which is a state management library.

Changelog: [GENERAL][FIXED] - Fixed nodes with `display: contents` set being cloned with the wrong owner

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

Reviewed By: adityasharat, NickGerleman

Differential Revision: D78084270

Pulled By: j-piasecki

fbshipit-source-id: eb81f6d7dcd1665974d07261ba693e2abea239bb
2025-07-11 02:16:35 -07:00
Nolan O'Brien
73980a3cf8 Fix exhaustive switches
Summary:
X-link: https://github.com/facebook/react-native/pull/52379

Changelog: [General][Fixed] - Add `default:` case to avoid warnings/errors for targets that compile with `-Wswitch-enum` and `-Wswitch-default` enabled

Reviewed By: aary, yungsters, astreet

Differential Revision: D77051152

fbshipit-source-id: 100b10f97cb3a5d73f1e3dcaf1b284baf6a43982
2025-07-02 14:21:18 -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
Nicola Corti
117fa494f7 Migrate from OSSRH to Central Portal (#1816)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1816

This migrates Yoga to publish to Central Portal rather than OSSRC

Reviewed By: NickGerleman

Differential Revision: D76436235

fbshipit-source-id: ddaaa95472054aa2b09399b5cc8d821dae51234f
2025-06-11 16:12:06 -07:00
Nicola Corti
073c136117 Remove unnecessary gradle-enterprise.gradle.kts from Yoga (#1817)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1817

This file is not really necessary. As we don't have a Gradle Enterprise instance anymore, let's just remove it and inline it.

Reviewed By: mdvacca

Differential Revision: D76436236

fbshipit-source-id: 27fcc48574905415b147f67dd4a8f57dffbeda3e
2025-06-11 11:46:34 -07:00
Nick Gerleman
1232761571 YGPersistentNodeCloningTest (#1813)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1813

This adds a unit test to Yoga, which emulates the model of "persistent Yoga nodes" and cloning used by React Fabric, including the private (but relied on) Yoga APIs.

It models the over-invalidation exposed in D75287261, which reproduces (due to Yoga incorrectly measuring flex-basis under fit-content, and that constraint changing when sibling changes) but this test for now sets a definite height on A, to show that we only clone what is neccesary, when measure constraints do not have to change.

Having a minimal version of Fabric's model in Yoga unit tests should make some of these interesting interactions a bit easier to debug.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D75572762

fbshipit-source-id: cda8b3fdd6e538a55dd100494518688c864bd233
2025-06-02 19:32:45 -07:00
Nick Gerleman
c935fd5e10 Resubmit: Expose Unsnapped Dimensions (#1811)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1811

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

## Resubmit

This was backed out due to being up the stack from another change that was backed out, but should be safe by itself.

## Original

We want to know if an artifact created during measurement can fully be reused after final layout, but the final layout is allowed to be slightly larger due to pixel grid rounding (while still allowing reuse). It's hard to tell after the fact, whether it is larger because of this rounding (though the measure is used), or if it may be a pixel larger for valid reasons.

We can expose the unsnapped dimensions of a node to give us this information, and to correlate measurement artifacts.

This is most of the time the same as the layout's measured dimension, though I don't think it's safe to use this, since anything else measuring the node after could clobber this (I think `YGNodeLayoutGetOverflow` may also be prone to this as a bug).

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D74673119

fbshipit-source-id: 06d2eb21e28b76458ec88f4dfcaec809707d0390
2025-05-13 18:21:04 -07:00
Yannick Loriot
624325302c Revert D74292949: Expose Unsnapped Dimensions
Differential Revision:
D74292949

Original commit changeset: 05011c66a9a9

Original Phabricator Diff: D74292949

fbshipit-source-id: c6ca51c7b882950d54b6a43e206973774db40429
2025-05-09 01:45:16 -07:00
Nick Gerleman
37a94a86de Expose Unsnapped Dimensions (#1809)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1809

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

We want to know if an artifact created during measurement can fully be reused after final layout, but the final layout is allowed to be slightly larger due to pixel grid rounding (while still allowing reuse). It's hard to tell after the fact, whether it is larger because of this rounding (though the measure is used), or if it may be a pixel larger for valid reasons.

We can expose the unsnapped dimensions of a node to give us this information, and to correlate measurement artifacts.

This is most of the time the same as the layout's measured dimension, though I don't think it's safe to use this, since anything else measuring the node after could clobber this (I think `YGNodeLayoutGetOverflow` may also be prone to this as a bug).

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D74292949

fbshipit-source-id: 05011c66a9a9480544313eb1dfe2c46bf7742bac
2025-05-08 17:45:16 -07:00
Santhosh Kumar
4abc1a7d5f Fix documentation of 'alignContent' property configured with spaces (#1808)
Summary:
The documentation shall be corrected to specify in which axis the spaces are distributed when flex container is configured 'alignContent' property.

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

Reviewed By: joevilches

Differential Revision: D74347272

Pulled By: philIip

fbshipit-source-id: 1b05840028bca774c9d4a68562bcf537d5a72500
2025-05-07 14:40:02 -07:00
Yurii Nakonechnyi
51e6095005 LayoutData - added explicit default fields values initialization (#1802)
Summary:
X-link: https://github.com/facebook/react-native/pull/50227

Explicit defaults add 'strictness' and take the guesswork out of what's going on in places like this:

6455a848a7/yoga/algorithm/CalculateLayout.cpp (L2345)

Changelog: [Internal]

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

Reviewed By: javache

Differential Revision: D71687310

Pulled By: NickGerleman

fbshipit-source-id: f11d18aa68ce7ccd17fb1d5af0e729e8c0711cf9
2025-03-24 12:23:46 -07:00
Yurii Nakonechnyi
79cef614ce fatalWithMessage() - added warning suppression: unused 'message' argument (#1803)
Summary:
X-link: https://github.com/facebook/react-native/pull/50148

## Changelog:

[Internal] - suppression: unused 'message' argument

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

Reviewed By: NickGerleman

Differential Revision: D71492528

Pulled By: lunaleaps

fbshipit-source-id: 6fc7a665066351d15e09f0b6c82ed1fe3f688a94
2025-03-19 19:06:50 -07:00
Rob Hogan
6455a848a7 Update GHA actions/upload-artifact to v4, unbreak CI (#1799)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1799

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

`actions/upload-artifact@v3` is deprecated and will no longer execute, causing CI to fail - eg:

https://github.com/facebook/yoga/actions/runs/13789185831/job/38564343959

See https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/ for context

Reviewed By: NickGerleman

Differential Revision: D70986391

fbshipit-source-id: 66cec50bb485e89c0948c752ba7dc2a4f42617d6
2025-03-11 13:40:51 -07:00
Nicola Corti
1b7d2c8d48 Enable RTTI to fix exception pointer issue on React Native (#1791)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1791

Disabling RTTI for Yoga is causing std::exception to don't work properly in OSS.
Fixes: https://github.com/facebook/react-native/issues/48027

Not sure why we originally disabled RTTI for Yoga, but we have it enable for the whole
React Native build so it probably makes sense to have it enabled for Yoga as well.

Changelog:
[Internal] [Changed] - Enable RTTI to fix exception pointer issue on React Native

bypass-github-export-checks

Reviewed By: javache, NickGerleman

Differential Revision: D70386744

fbshipit-source-id: 36e3a1ddb38346d31979d5c1b77d6e9796d6a855
2025-03-04 04:51:38 -08:00
Nicola Corti
3aa594c1f9 Gradle to 8.13 (#1790)
Summary:
X-link: https://github.com/facebook/react-native/pull/49689

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

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

I'm bumping Gradle to the latest minor.
https://docs.gradle.org/8.13/release-notes.html

I'm also changing the distribution from `all` to `bin` as
this reduces the download time of the distribution.

Changelog:
[Android] [Changed] - Gradle to 8.13

Reviewed By: NickGerleman

Differential Revision: D70239710

fbshipit-source-id: 89808242a93344f540bfe82f4178cf6db72597d1
2025-02-27 03:13:26 -08: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
Nick Gerleman
b12e0a2a15 Fix CI after GHA Update to Ubuntu 24.04 (#1781)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1781

This new image removed preinstalled libc++, and the ability to install old version of Clang Format we were installing.

This manually installs libc++ when setting up Clang jobs, and fully removes the clang-format validation job, since it wasn't correctly running before, and it's probably more a pain to ask people to run this than to just run Arcanist when importing a change.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D68455129

fbshipit-source-id: b5767be832b2b5d46db7e60e18b66823819ba15a
2025-01-21 13:34:22 -08:00
Ruslan Shestopalyuk
9591210a7a Add more unit tests for rounding values to pixel grid (#1776)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1776

# Changelog:
[Internal] -

I was looking into some profiling results and noticed that Yoga has some quirky custom logic when it comes to rounding to the pixel grid, especially for the values that are halfway through.

There are already unit tests in place, but those cases weren't covered, so I am adding these extra corner cases here, to make sure they are covered in case that the actual rounding function may get modified (which it might make sense to, as it's currently can be more expensive than it could have been in some scenarios).

Reviewed By: christophpurrer

Differential Revision: D67712673

fbshipit-source-id: da1b7339a8939ced8d91f15441bc7d1f8af768c8
2024-12-30 12:38:48 -08:00
Ruslan Shestopalyuk
91997d6cd3 Avoid calling fmod twice in roundLayoutResultsToPixelGrid (#1775)
Summary:
X-link: https://github.com/facebook/litho/pull/1036

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

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

## Changelog:
[Internal] -

This popped up when profiling some heavy UI performance, calling `fmod` operation in Yoga's `roundLayoutResultsToPixelGrid` in `PixelGrid.cpp` can be expensive, furthermore it turns out that some of the calls were redundant.

This replaces the duplicate calls to fmod with an equivalent single round operation, which for e.g. clang compiler on Windows brings the code in question from ~50 instructions (including 4 call instructions to the fmod function) down to ~30 instructions (without any external calls), and the layout operation being **~1% more efficient** for the particular benchmark I was looking into.

Reviewed By: christophpurrer

Differential Revision: D67689065

fbshipit-source-id: 2a074a1cb81bd7f7a3c414050b9ddda2ba90180f
2024-12-30 12:38:48 -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
5478812db3 Use crossAxisOwnerSize instead of ownerHeight in cross axis bound call (#1763)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1763

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

Small bug that I noticed while doing intrinsic sizing. We have the ownerHeight as the axis size despite bounding the length of the cross axis. This should therefore be the crossAxisOwnerSize, which might be the width in some cases

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66736539

fbshipit-source-id: 528fc438b3327cd6f7890ea0ba408e4ce7b0f02c
2024-12-06 15:34:06 -08:00
Joe Vilches
050ac8a413 Properly camelcase mainAxisownerSize in FlexLine (#1762)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1762

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

OCD strikes again. Grepped this time to make sure we didn't miss any cases for this specific param name

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66715777

fbshipit-source-id: 3e881a15b3b2836a4a55b11d7ec621541b92a05d
2024-12-03 19:16:56 -08:00
Nick Gerleman
733ba24064 Add Yoga 3.2 Release notes (#1761)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1761

Whips up some release notes for what is new since Yoga 3.1.

https://github.com/facebook/yoga/compare/v3.1.0...v3.2.0

The relevant packages have already been published.

Reviewed By: joevilches

Differential Revision: D66679637

fbshipit-source-id: dd94e2a52f2bdc80541c331d1fb39de82669cc7a
2024-12-02 17:39:41 -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
be72b8e8aa Align order of params between calculateLayoutInternal and calculateLayoutImpl (#1755)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1755

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

I've been working with callsites here and its annoying if you switch these that you need to move these params around too. Let's just make them the same order

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66519836

fbshipit-source-id: 2e98e671270a053c6e62372e2003f1ca67774ec9
2024-11-26 22:48:24 -08:00
Joe Vilches
b876f596d9 Camel case LengthValue in Node.cpp (#1754)
Summary:
X-link: https://github.com/facebook/react-native/pull/47971

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

This was annoying me

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66510734

fbshipit-source-id: d1b952f2e82e7018b16dc0c572d9b98aec18c0e5
2024-11-26 15:23:08 -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
Eric Rozell
0b25796676 Update docusaurus to 3.6.0 (#1749)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1749

Resolves a few NPM security vulnerabilities in webpack and cookie dependencies.

Reviewed By: NickGerleman

Differential Revision: D66299077

fbshipit-source-id: 805eff24486ab120bc5658c0c5d0de1e4db81ba0
2024-11-21 11:09:17 -08:00
Jakub Piasecki
262f868ce0 Fix the nodes' owners not being updated when display: contents is used (#1743)
Summary:
X-link: https://github.com/facebook/react-native/pull/47733

In https://github.com/facebook/yoga/pull/1729 I moved the cleanup of `display: contents` nodes to happen before all the early returns, but that change also made it be called **before** `cloneChildrenIfNeeded`. It actually needs to be called after `cloneChildrenIfNeeded` to make sure that children of `display: contents` nodes are properly owned.

It also needs to be called in every short-path, so it's being called in four places in this PR. Please let me know whether it's ok or not.

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

Reviewed By: NickGerleman

Differential Revision: D65953902

Pulled By: zeyap

fbshipit-source-id: 0b18a5651f19c23564f5b3aa2a50833426e9ca5f
2024-11-20 20:01:50 -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
Eric Rozell
5b962c0801 Revert "Extra log for case where availableHeight is undefined and sizing mode != max content (#1687)" (#1741)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1741

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

Reverting https://github.com/facebook/yoga/pull/1687 as it appears to regress Yoga performance anywhere from 10-33%.

## Changelog

[Internal]

Reviewed By: rshest

Differential Revision: D65863569

fbshipit-source-id: e6992e05dd59ba75548a5d633cb7f5c3fa99a6e4
2024-11-13 06:29:35 -08:00
Nick Gerleman
8f69ac776e Minor display: contents optimizations (#1736)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1736

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

`LayoutableChildren<yoga::Node>::Iterator` showed up to a surprising extent on a recent trace. Part of this was during pixel grid rounding, which does full tree traversal (we should fix that...), where the iterator is the first thing to read from the node.

I ran Yoga microbenchmark with Yoga compiled with `-O2`, where we saw a regression of synthetic performance by ~10%, but it turns out this build also had ASAN and some other heavy bits enabled, so the real impact was quite lower (~6%).

I was able to make some optimizations in the meantime against that, which still show some minor wins, reducing that overhead to ~4% in the properly optimized build (and a bit more before that). This is still measurable on the beefy server, and the code is a bit cleaner, so let's commit these!

Note that, in real scenarios, measure functions may dominate layout time, so display: contents does not mean end-to-end 4% regression, even after this change.

This change makes a few different optimizations
1. Removes redundant copies
2. Removes redundant index keeping
3. Mark which branches are likely vs unlikely
4. Shrink iterator size from 6 pointers to 3 pointers
5. Avoid usage in pixel grid rounding (so we don't need to have cache read for style)

In "Huge nested layout" example

| Before display: contents support | After display: contents support | After optimizations |
| 9.77ms | 10.39ms | 10.17ms |

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D65336148

fbshipit-source-id: 01c592771ed7accf2d87dddd5a3a9e0225098b56
2024-11-05 11:28:37 -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
Jakub Piasecki
6fed4dfe30 Add tests for LayoutableChildren iterator (#1731)
Summary:
Adds unit tests that directly cover the order in which `LayoutableChildren` iterator goes over the descendant nodes. The covered cases are as follows (nodes with `display: contents` are marked green):

### Single `display: contents` node

```mermaid
flowchart TD
R((R)) --> A((A))
R --> B((B))
R --> C((C))

B --> D((D))
B --> E((E))

style B fill:https://github.com/facebook/yoga/issues/090
```

Correct order: `A, D, E, C`

### Multiple `display: contents` nodes

```mermaid
flowchart TD
R((R)) --> A((A))
R --> B((B))
R --> C((C))

A --> D((D))
A --> E((E))

B --> F((F))
B --> G((G))

C --> H((H))
C --> I((I))

style A fill:https://github.com/facebook/yoga/issues/090
style B fill:https://github.com/facebook/yoga/issues/090
style C fill:https://github.com/facebook/yoga/issues/090
```

Correct order: `D, E, F, G, H, I`

### Nested `display: contents` nodes

```mermaid
flowchart TD
R((R)) --> A((A))
R --> B((B))
R --> C((C))

B --> D((D))
B --> E((E))

E --> F((F))
E --> G((G))

style B fill:https://github.com/facebook/yoga/issues/090
style E fill:https://github.com/facebook/yoga/issues/090
```

Correct order: `A, D, F, G, C`

### Leaf `display: contents` node

```mermaid
flowchart TD
R((R)) --> A((A))
R --> B((B))
R --> C((C))

style B fill:https://github.com/facebook/yoga/issues/090
```

Correct order: `A, C`

### Root `display: contents` node

```mermaid
flowchart TD
R((R)) --> A((A))
R --> B((B))
R --> C((C))

style R fill:https://github.com/facebook/yoga/issues/090
```

Correct order: `A, B, C` - `LayoutableChildren` goes over the children with `display: contents` property, setting it on the root node should have no effect.

Changelog: [Internal]

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

Reviewed By: joevilches

Differential Revision: D64981779

Pulled By: NickGerleman

fbshipit-source-id: ee39759c663a40f96ad313f1b775d53ab68fb442
2024-10-25 18:01:20 -07:00
Jakub Piasecki
8dc2fa52c1 Fix for nodes with display: contents not being cleaned in some cases (#1729)
Summary:
X-link: https://github.com/facebook/react-native/pull/47194

Fixes a case where a node with `display: contents` would not be cleaned up in some cases. This was caused by it being called after some early returns handling different quick paths. This PR moves the call to `cleanupContentsNodesRecursively` earlier so that it's always called.

The problem here wasn't mutating before cloning, but leaving a node marked as dirty after the layout has finished.

The exact case in which I found this was a node with a single `display: contents` child which needs to be a leaf. Then in the parent node [this](b0b842d5e7/yoga/algorithm/CalculateLayout.cpp (L1339)) condition is true, so `cleanupContentsNodesRecursively` doesn't get called and the child node is never visited and cleaned. I assume the same will happen in the other paths with an early return here.

Changelog:
[General][Fixed] - Fix for nodes with `display: contents` not being cleaned in some cases

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

Reviewed By: rozele

Differential Revision: D64910099

Pulled By: NickGerleman

fbshipit-source-id: 6d56f8fbf687b7ee5af889c0b868406213c9cee8
2024-10-25 17:34:36 -07: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
43be5888c4 Add boxsizing to playground (#1724)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1724

tsia!

Reviewed By: NickGerleman

Differential Revision: D64200150

fbshipit-source-id: f3ee6df648ec8ff29d8e26b0a3b3a5980fc8926b
2024-10-11 09:55:12 -07:00
Joe Vilches
2437d26ca5 Sunset the value namespace (#1720)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1720

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

This is not really needed anymore, we can just use `StyleLength` statics instead

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63922280

fbshipit-source-id: cd953bae8e9f68574463eafc49c33c2e85ac1856
2024-10-09 19:20:15 -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
ef9ae63268 Make it so that we can console.log in browser to debug gentest (#1718)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1718

Our gentest works by console.logging the contents of the test it is generating to the browser powered by the driver. The driver then reads the logs and writes it to a file. An unfortunate side effect here is that we cannot console.log to debug how the gentest logic actually works since the driver is expecting formatted code. To get around this I had the driver filter out logs with a certain prefix and add that a helper that logs a message with this prefix to the scripts.

Reviewed By: NickGerleman

Differential Revision: D64011035

fbshipit-source-id: 1f113fde425d1d7db1c16ab85f4bb16b0e18f41d
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
Nick Gerleman
3351e8eb45 Add "SPM Supported" Badge to README (#1717)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1717

CocoaPods is EOL (though we will still support it for a while), and Yoga has SPM support, so let's add a badge!

SPM does not have a central registry (it instead uses our Git branch), so there isn't a badge to show the current vesion, we instead just mention that we support it, which is what I found other projects do.

Reviewed By: nmn

Differential Revision: D63845470

fbshipit-source-id: d033700fa04b8d708890b1c51d0a37fab8251a43
2024-10-03 11:26:49 -07:00
Joe Vilches
84312c54a4 Camel case *AxisownerSize (#1714)
Summary:
X-link: https://github.com/facebook/react-native/pull/46744

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

This was annoying me :)

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63424778

fbshipit-source-id: 8f9df4e92bde251214f4c1d61ff8282d56f87816
2024-10-01 15:19:22 -07:00
Joe Vilches
dc1f0a68f9 Let flex basis support content box (#1713)
Summary:
X-link: https://github.com/facebook/react-native/pull/46740

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

The flex basis length applies to the value of `box-sizing` per the spec: https://drafts.csswg.org/css-flexbox-1/#flex-basis-property

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63424590

fbshipit-source-id: f73bffd30cc7b673453a55089ecc880819d3d788
2024-10-01 15:19:22 -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
Joe Vilches
bc5098fc80 Clean up calls to dimension() with a hardcoded FlexDirection (#1710)
Summary:
X-link: https://github.com/facebook/react-native/pull/46739

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

This is a bit more clear, imo

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63408245

fbshipit-source-id: cea9723914f69d2697e18c8bfe2b55c830af2b6a
2024-10-01 15:19:22 -07:00
Joe Vilches
b02caa8e06 Rename Node.h's getResolvedDimension to getProcessedDimension (#1705)
Summary:
X-link: https://github.com/facebook/react-native/pull/46649

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

To get the height and width we call a function currently named `getResolvedDimension`. This returns a `Style::Length`, which in most cases we "resolve" immediately by calling `resolve`. This is a bit confusing that you need to `resolve` something that is already `resolved`.

I plan on adding a new function soon for `contentBox` which would resolve the length for you, so I think this should be renamed.

Also deleted unused `getResolvedDimensions`

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63407730

fbshipit-source-id: e855c17d9c99817be308b7263fcb5d43559ede14
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
jewhyena
6212e561ad fix: word misspelling in about-yoga.md (#1698)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1698

Reviewed By: joevilches

Differential Revision: D63059081

Pulled By: realsoelynn

fbshipit-source-id: 73d6d10685c7b4ddef828f17b7113f314397f90d
2024-09-19 17:25:39 -07:00
Joe Vilches
a112a07e6a Make it so that aspect ratio behaves like auto if it is 0 or inf (#1696)
Summary:
X-link: https://github.com/facebook/react-native/pull/46428

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

We do not validate the aspect ratio to ensure it is non zero and non inf in a lot of places. Per the spec, these values should act like auto. There is no auto keyword, but it is the default so I just set the style to a default FloatOptional in this case

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62473161

fbshipit-source-id: 6857de819538a7a87ce0a652e99f5a49992921ae
2024-09-12 14:28:33 -07:00
Alan Lee
dc4ab5ad57 update compileSdk to 35 (#1692)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1692

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

Update compileSdk to 35 before adding relating work for Android 15

Changelog:
[Android][Added] - Update compileSdk to 35

Reviewed By: cortinico

Differential Revision: D61874541

fbshipit-source-id: f7c92dc15aa68a53bcd626450c515d2f24e9e40f
2024-08-29 09:17:42 -07:00
Dawid
6d6f69bee7 Fix handling 'auto' checks in absolute layout (#1689)
Summary:
X-link: https://github.com/facebook/react-native/pull/46216

Regarding [issue](https://github.com/facebook/react-native/issues/45817) with incorrect layout when `left` is set to `auto`. This PR introduces handling `auto` whenever inline or flex position is checked to be defined and it fixes above issue.

Changelog:
[General][Fixed] - Fix handling 'auto' checks in absolute layout

## Tests:
 I have run the provided unit tests and everything passes.

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

Reviewed By: cipolleschi

Differential Revision: D61737876

Pulled By: NickGerleman

fbshipit-source-id: 531199a91c5e122b930b49725ea567cbb1d592ce
2024-08-27 06:00:34 -07:00
Joe Vilches
596f8dff3c Extra log for case where availableHeight is undefined and sizing mode != max content (#1687)
Summary:
X-link: https://github.com/facebook/react-native/pull/45965

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

We are seeing some crashes that are hard to wrap our head around. Lets add more logs. I chose these values based on what could make the height/width undefined from looking at the code. We might need more but this should give us some more direction.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D61054392

fbshipit-source-id: 654ff96f94aa89605a603e2e36335bb48b61f4a2
2024-08-19 16:13:44 -07:00
Joe Vilches
ae8ede9b53 Fix crash when you layout multiple absolute nodes in the same static subtree (#1686)
Summary:
X-link: https://github.com/facebook/react-native/pull/45952

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

https://en.wikipedia.org/wiki/Short-circuit_evaluation 🫠

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60997231

fbshipit-source-id: 11d70086eecfb5481c578477f288138370016a83
2024-08-08 22:41:29 -07:00
Nick Gerleman
5009f5c1ac Fix misc-misplaced-const warnings in Yoga tests (#1677)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1677

We have Clang Tidy warnings enabled internally, that will flag `const YG*Ref` as misleading, as a const pointer to non-const, instead of non-const pointer to const.

Let's remove all the misleading const in existing tests, and generated tests.

Reviewed By: joevilches

Differential Revision: D59335968

fbshipit-source-id: c66af878904ba7900f8ffcd99162968d90f8e5c7
2024-07-03 17:30:10 -07:00
Andrew Coates
e4fe14ab3e Add config version, and invalidate layout on config change (#1674)
Summary:
X-link: https://github.com/facebook/react-native/pull/45259

This is a continuation of the previous PR: https://github.com/facebook/react-native/pull/45047

I made the change more generic for allowing any kind of config change to invalidate layout.

Changelog: [Internal]

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

Reviewed By: rozele

Differential Revision: D59286992

Pulled By: NickGerleman

fbshipit-source-id: f46f35b03d5d9a743b798844ee3e1a02c271ccde
2024-07-03 12:46:18 -07:00
Joe Vilches
a1e9abb9b3 Fix case where absolute nodes would sometimes not be cloned (#1675)
Summary:
X-link: https://github.com/facebook/react-native/pull/45240

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

There was a bug where some crash would happen if a tree was cloned that had static/absolute parent/child pair inside it. This was because we were no longer calling `cloneChildrenIfNeeded` on the static parent, but would still layout the absolute child. So that child's owner would be stale and have new layout. In React Native this would lead to a failed assert which causes the crash.

The fix here is to clone the children of static nodes during `layoutAbsoluteDescendants` so that we guarantee the node is either cloned if it is going to have new layout.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D59175629

fbshipit-source-id: 4d110a08ba5368704327d5ab69a8695b28e746f4
2024-07-02 15:14:33 -07:00
Nick Gerleman
b9e335ebfd Put generated Java tests in a "generated" folder (#1673)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1673

Separate the generated Java tests from the non-generated ones, like all the other tests.

Reviewed By: javache

Differential Revision: D58989535

fbshipit-source-id: 4ffe92d079acdf3ba24731f7f1ef1ae6eba97da5
2024-06-26 10:56:18 -07:00
Maddie Lord
1a3bc6bfbc Add test support for intrinsic sized nodes (#1671)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1671

This diff adds support for intrinsic sizing in generated tests. This is done by importing a testing font called "Ahem" which, as used, has an exact width and height of 10px for each character. Support has been added for C++, Java, and Javascript generated tests.

Reviewed By: NickGerleman

Differential Revision: D58307002

fbshipit-source-id: e1dcc1e03310d35a32e0c70f71994880d8f7de55
2024-06-26 10:00:17 -07:00
Nick Gerleman
0888b20098 Make gentest-validate more graceful of different file organization (#1672)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1672

`gentest-validate` checks signedsource for generated tests. D58307002 adds a new directory under `java/tests/com/facebook/yoga/`, which [confuses](https://github.com/facebook/yoga/actions/runs/9653979292/job/26627690870) the current directory traversal logic.

This replaces the traversal with `glob`, and makes us skip files without a signature, instead of special-casing the Java directory.

Reviewed By: yungsters

Differential Revision: D58987293

fbshipit-source-id: a5640f5faee4aa40879c266211c5e736a0b077be
2024-06-26 01:24:08 -07:00
Nick Gerleman
53e4421178 Yoga 3.1.0 Release Notes (#1669)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1669

I made a new branch and release of Yoga corresponding to the version used by RN 0.75. This documents the changes.

Reviewed By: christophpurrer, joevilches

Differential Revision: D58922338

fbshipit-source-id: 9c29f5c30cf1fb2d0bac6d5ba33cba4945d4e4f2
2024-06-25 23:27:25 -07:00
Nick Gerleman
db383714d3 Update to docusaurus 3.4.0 (#1668)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1668

Updates to latest Docusaurus

Reviewed By: christophpurrer

Differential Revision: D58921432

fbshipit-source-id: 45ce2fc2559b2321f72b77b2434c5dff395f1cb0
2024-06-24 08:07:45 -07:00
Nick Gerleman
7970b972e5 Update lockfile dependencies with CVEs (#1667)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1667

Fixes https://github.com/facebook/yoga/pull/1666
Fixes https://github.com/facebook/yoga/pull/1634
Fixes https://github.com/facebook/yoga/pull/1642
Fixes https://github.com/facebook/yoga/pull/1636

All of these are for local Docusaurus development... but... keep the repo health robots happy, and align with the newest versions of these constraints already used in fbsource.

Reviewed By: yungsters

Differential Revision: D58921369

fbshipit-source-id: 61fd8a869940543567278bc8a6e7c88ca9dd506c
2024-06-24 08:07:45 -07:00
Nick Gerleman
1f7faf4c61 Make documentation embeds less ugly (#1670)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1670

Embeds to Yoga's documentation reuse a tiny rasterized favicon, blown up, and full of jpeg artifacts.

{F1714492025}

This bothered me enough to make the previews look better.

This change adds a quickly whipped up opengraph sized image, replaces the favicon with one derived from logo SVG, and fixes a missing description on the homepage.

 {F1714566402}

Reviewed By: yungsters

Differential Revision: D58923501

fbshipit-source-id: 249a23034f50667e32970121a90eccc380e566a3
2024-06-24 07:38:05 -07:00
234 changed files with 33083 additions and 6603 deletions

View File

@@ -1,23 +0,0 @@
name: Clang Format
inputs:
directory:
description: Directory to Lint
required: true
version:
description: LLVM version to use # Should be kept roughly in sync with arcanist
required: false
default: 12
runs:
using: "composite"
steps:
- name: Install
shell: bash
run: sudo apt-get install -y clang-format-${{ inputs.version }}
- name: clang-format
working-directory: ${{ inputs.directory }}
shell: bash
env:
BASHOPTS: extglob:nullglob
run: clang-format-${{ inputs.version }} --dry-run --Werror **/*.{h,hh,hpp,c,cpp,cc,m,mm}

View File

@@ -16,6 +16,7 @@ runs:
if: ${{ inputs.toolchain == 'Clang' }}
shell: bash
run: |
sudo apt-get install -y libc++-dev libc++abi-dev
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV

View File

@@ -6,7 +6,7 @@ runs:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: yarn
cache-dependency-path: yarn.lock
env:

View File

@@ -24,7 +24,7 @@ jobs:
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: 'snapshot-artifacts'
path: '~/.m2/repository/'

View File

@@ -23,7 +23,7 @@ jobs:
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: 'snapshot-artifacts'
path: '~/.m2/repository/'

View File

@@ -97,13 +97,3 @@ jobs:
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
cmake --build build
working-directory: capture
clang-format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: clang-format
uses: ./.github/actions/clang-format

View File

@@ -110,7 +110,7 @@ jobs:
run: yarn pack --filename yoga-layout.tar.gz
working-directory: javascript
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: npm-package
path: javascript/yoga-layout.tar.gz

3
.gitignore vendored
View File

@@ -73,3 +73,6 @@ local.properties
# Docusarus build
.docusaurus
# Android Studio
.idea

View File

@@ -1,4 +1,4 @@
# Yoga [![Support Ukraine](https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat&labelColor=005BBB)](https://opensource.fb.com/support-ukraine) [![CocoaPods](https://img.shields.io/cocoapods/v/Yoga.svg)](http://cocoapods.org/pods/Yoga) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![Maven Central](https://img.shields.io/maven-central/v/com.facebook.yoga/yoga)](https://search.maven.org/artifact/com.facebook.yoga/yoga)
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/Yoga.svg)](http://cocoapods.org/pods/Yoga) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![Maven Central](https://img.shields.io/maven-central/v/com.facebook.yoga/yoga)](https://search.maven.org/artifact/com.facebook.yoga/yoga) ![SPM](https://img.shields.io/badge/SPM-Supported-blue.svg)
Yoga is an embeddable and performant flexbox layout engine with bindings for multiple languages.

View File

@@ -6,9 +6,10 @@
*/
plugins {
id("com.android.library") version "8.2.1" apply false
id("com.android.application") version "8.2.1" apply false
id("com.android.library") version "8.7.1" apply false
id("com.android.application") version "8.7.1" apply false
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id 'org.jetbrains.kotlin.android' version '2.1.20' apply false
}
allprojects {
@@ -34,6 +35,8 @@ nexusPublishing {
sonatype {
username.set(sonatypeUsername)
password.set(sonatypePassword)
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}
}
}

View File

@@ -225,17 +225,17 @@ static void serializeTreeImpl(
appendEdges<&YGNodeStyleGetPosition>(
j, "position", node, defaultNode.get());
appendFloatIfNotDefault(
appendYGValueIfNotDefault(
j["style"],
"gap",
YGNodeStyleGetGap(node, YGGutterAll),
YGNodeStyleGetGap(defaultNode.get(), YGGutterAll));
appendFloatIfNotDefault(
appendYGValueIfNotDefault(
j["style"],
"column-gap",
YGNodeStyleGetGap(node, YGGutterColumn),
YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn));
appendFloatIfNotDefault(
appendYGValueIfNotDefault(
j["style"],
"row-gap",
YGNodeStyleGetGap(node, YGGutterRow),

View File

@@ -19,8 +19,8 @@ add_compile_options(
# Enable warnings and warnings as errors
/W4
/WX
# Disable RTTI
$<$<COMPILE_LANGUAGE:CXX>:/GR->
# Enable RTTI
$<$<COMPILE_LANGUAGE:CXX>:/GR>
# Use /O2 (Maximize Speed)
$<$<CONFIG:RELEASE>:/O2>)
@@ -34,8 +34,8 @@ add_compile_options(
# Enable warnings and warnings as errors
-Wall
-Werror
# Disable RTTI
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
# Enable RTTI
$<$<COMPILE_LANGUAGE:CXX>:-frtti>
# Use -O2 (prioritize speed)
$<$<CONFIG:RELEASE>:-O2>
# Enable separate sections per function/data item

View File

@@ -4,12 +4,19 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import os
ENUMS = {
"Direction": ["Inherit", "LTR", "RTL"],
"Unit": ["Undefined", "Point", "Percent", "Auto"],
"Unit": [
"Undefined",
"Point",
"Percent",
"Auto",
"MaxContent",
"FitContent",
"Stretch",
],
"FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"],
"Justify": [
"FlexStart",
@@ -32,8 +39,9 @@ ENUMS = {
"SpaceEvenly",
],
"PositionType": ["Static", "Relative", "Absolute"],
"Display": ["Flex", "None"],
"Display": ["Flex", "None", "Contents"],
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
"BoxSizing": ["BorderBox", "ContentBox"],
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
"Dimension": ["Width", "Height"],
"Edge": [
@@ -61,9 +69,10 @@ ENUMS = {
# Allows main-axis flex basis to be stretched without flexGrow being
# set (previously referred to as "UseLegacyStretchBehaviour")
("StretchFlexBasis", 1 << 0),
# Positioning of absolute nodes will have various bugs related to
# justification, alignment, and insets
("AbsolutePositioningIncorrect", 1 << 1),
# Absolute position in a given axis will be relative to the padding
# edge of the parent container instead of the content edge when a
# specific inset (top/bottom/left/right) is not set.
("AbsolutePositionWithoutInsetsExcludesPadding", 1 << 1),
# Absolute nodes will resolve percentages against the inner size of
# their containing node, not the padding box
("AbsolutePercentAgainstInnerSize", 1 << 2),

View File

@@ -2,6 +2,18 @@
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
</div>
<div id="absolute_layout_width_height_left_auto_right" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: auto; right: 10px;"></div>
</div>
<div id="absolute_layout_width_height_left_right_auto" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: 10px; right: auto;"></div>
</div>
<div id="absolute_layout_width_height_left_auto_right_auto" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: auto; right: auto;"></div>
</div>
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
</div>

View File

@@ -448,3 +448,32 @@
</div>
<div style="height: 50px; width: 50px; margin-left: 20px;"></div>
</div>
<div id="align_content_stretch_and_align_items_flex_end_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: flex-end;">
<div style="height: 50px; width: 150px; align-self: flex-start;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
<div id="align_content_stretch_and_align_items_flex_start_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: flex-start;">
<div style="height: 50px; width: 150px; align-self: flex-end;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
<div id="align_content_stretch_and_align_items_center_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: center;">
<div style="height: 50px; width: 150px; align-self: flex-end;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
<div id="align_content_stretch_and_align_items_stretch_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: stretch;">
<div style="height: 50px; width: 150px; align-self: flex-end;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>

View File

@@ -240,3 +240,14 @@
<div style="position:relative; width:50px; height:50px;">
</div>
</div>
<div id="align_items_non_stretch_s526008"
style="flex-direction: column; width: 400px; height: 400px;">
<div style="flex-direction: row;">
<div style="flex-direction: column; align-items: flex-start;">
<div>
<div style="width: 0; height: 10px;"></div>
</div>
</div>
</div>
</div>

View File

@@ -2,10 +2,10 @@
<div id="aspect_ratio_does_not_stretch_cross_axis_dim" data-disabled="true" style="width: 300px; height: 300px;">
<div style="flex: 1; overflow: scroll;">
<div style="flex-direction: row;">
<div style="flex: 2; aspect-ratio: 1;"></div>
<div style="width: 5px"></div>
<div style="flex: 1">
<div style="flex: 1; aspect-ratio: 1;">
<div style="flex: 2; aspect-ratio: 1;"></div>
<div style="width: 5px"></div>
<div style="flex: 1">
<div style="flex: 1; aspect-ratio: 1;">
<div style="width: 5px"></div>
<div style="flex: 1; aspect-ratio: 1;"></div>
</div>
@@ -13,3 +13,7 @@
</div>
</div>
</div>
<div id="zero_aspect_ratio_behaves_like_auto" style="width: 300px; height: 300px;">
<div style="aspect-ratio: 0; width: 50px"></div>
</div>

View File

@@ -0,0 +1,25 @@
<div id="auto_width" style="width: auto; height: 50px; flex-direction: row;">
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
</div>
<div id="auto_height" style="width: 50px; height: auto;">
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
</div>
<div id="auto_flex_basis" style="width: 50px; flex-basis: auto;">
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
</div>
<div id="auto_position" style="width: 50px; height: 50px;">
<div style="width: 25px; height: 25px; right: auto"></div>
</div>
<div id="auto_margin" style="width: 50px; height: 50px;">
<div style="width: 25px; height: 25px; margin-left: auto"></div>
</div>

View File

@@ -0,0 +1,252 @@
<div id="box_sizing_content_box_simple"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_simple"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 25%; padding: 4px; border-width: 16px; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 25%; padding: 4px; border-width: 16px; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_absolute" style="width: 100px; height: 100px;">
<div style="width: 50; height: 25%; padding: 12px; border-width: 8px; box-sizing: content-box; position: absolute;">
</div>
</div>
<div id="box_sizing_border_box_absolute" style="width: 100px; height: 100px;">
<div style="width: 50; height: 25%; padding: 12px; border-width: 8px; box-sizing: border-box; position: absolute;">
</div>
</div>
<div id="box_sizing_content_box_comtaining_block"
style="width: 100px; height: 100px; padding: 12px; border-width: 8px; box-sizing: content-box; ">
<div style="width: 75; height: 75; position: static;">
<div style="width: 50px; height: 25%; position: absolute;">
</div>
</div>
</div>
<div id="box_sizing_border_box_comtaining_block"
style="width: 100px; height: 100px; padding: 12px; border-width: 8px; box-sizing: border-box; ">
<div style="width: 75; height: 75; position: static;">
<div style="width: 50px; height: 25%; position: absolute;">
</div>
</div>
</div>
<div id="box_sizing_content_box_padding_only"
style="width: 100px; height: 100px; padding: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_content_box_padding_only_percent" style="width: 100px; height: 150px;">
<div style="width: 50px; height: 75px; padding: 10%; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_padding_only" style="width: 100px; height: 100px; padding: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_border_box_padding_only_percent" style="width: 100px; height: 150px;">
<div style="width: 50px; height: 75px; padding: 10%; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_border_only"
style="width: 100px; height: 100px; border-width: 10px; box-sizing: content-box">
</div>
<div id="box_sizing_content_box_border_only_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 75; border-width: 10%; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_border_only"
style="width: 100px; height: 100px; border-width: 10px; box-sizing: border-box">
</div>
<div id="box_sizing_border_box_border_only_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 75; border-width: 10%; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_no_padding_no_border" style="width: 100px; height: 100px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_no_padding_no_border" style="width: 100px; height: 100px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_children"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: content-box">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_children"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: border-box">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_siblings" style="width: 100px; height: 100px;">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px; box-sizing: content-box; padding: 10px; border-width: 10px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_siblings" style="width: 100px; height: 100px;">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px; box-sizing: border-box; padding: 10px; border-width: 10px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_max_width" style="width: 100px; height: 100px;">
<div style="max-width: 50px; height: 25px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_max_width" style="width: 100px; height: 100px;">
<div style="max-width: 50px; height: 25px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_max_height" style="width: 100px; height: 100px;">
<div style="width: 50px; max-height: 50px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_max_height" style="width: 100px; height: 100px;">
<div style="width: 50px; max-height: 50px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_min_width" style="width: 100px; height: 100px;">
<div style="min-width: 50px; height: 25px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_min_width" style="width: 100px; height: 100px;">
<div style="min-width: 50px; height: 25px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_min_height" style="width: 100px; height: 100px;">
<div style="width: 50px; min-height: 50px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_min_height" style="width: 100px; height: 100px;">
<div style="width: 50px; min-height: 50px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_no_height_no_width" style="width: 100px; height: 100px;">
<div style="box-sizing: content-box; padding: 2px; border-width: 7px">
</div>
</div>
<div id="box_sizing_border_box_no_height_no_width" style="width: 100px; height: 100px;">
<div style="box-sizing: border-box; padding: 2px; border-width: 7px">
</div>
</div>
<div id="box_sizing_content_box_nested"
style="width: 100px; height: 100px; box-sizing: content-box; padding: 15px; border-width: 3px;">
<div style="width: 20px; height: 20px; box-sizing: content-box; padding: 2px; border-width: 7px">
<div style="width: 10px; height: 5px; box-sizing: content-box; padding: 1px; border-width: 2px"></div>
</div>
</div>
<div id="box_sizing_border_box_nested"
style="width: 100px; height: 100px; box-sizing: border-box; padding: 15px; border-width: 3px;">
<div style="width: 20px; height: 20px; box-sizing: border-box; padding: 2px; border-width: 7px">
<div style="width: 10px; height: 5px; box-sizing: border-box; padding: 1px; border-width: 2px"></div>
</div>
</div>
<div id="box_sizing_content_box_nested_alternating"
style="width: 100px; height: 100px; box-sizing: content-box; padding: 3px; border-width: 2px;">
<div style="width: 40px; height: 40px; box-sizing: border-box; padding: 8px; border-width: 2px">
<div style="width: 20px; height: 25px; box-sizing: content-box; padding: 3px; border-width: 6px">
<div style="width: 10px; height: 5px; box-sizing: border-box; padding: 1px; border-width: 1px">
</div>
</div>
</div>
</div>
<div id="box_sizing_border_box_nested_alternating"
style="width: 100px; height: 100px; box-sizing: border-box; padding: 3px; border-width: 2px;">
<div style="width: 40px; height: 40px; box-sizing: content-box; padding: 8px; border-width: 2px">
<div style="width: 20px; height: 25px; box-sizing: border-box; padding: 3px; border-width: 6px">
<div style="width: 10px; height: 5px; box-sizing: content-box; padding: 1px; border-width: 1px">
</div>
</div>
</div>
</div>
<div data-disabled="true" id="box_sizing_content_box_flex_basis_row"
style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_flex_basis_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: border-box">
</div>
</div>
<div data-disabled="true" id="box_sizing_content_box_flex_basis_column"
style="width: 100px; height: 100px; flex-direction: column;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_flex_basis_column" style="width: 100px; height: 100px; flex-direction: column;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_padding_start"
style="width: 100px; height: 100px; padding-start: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_padding_start"
style="width: 100px; height: 100px; padding-start: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_padding_end"
style="width: 100px; height: 100px; padding-end: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_padding_end"
style="width: 100px; height: 100px; padding-end: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_border_start"
style="width: 100px; height: 100px; border-start-width: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_border_start"
style="width: 100px; height: 100px; border-start-width: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_border_end"
style="width: 100px; height: 100px; border-end-width: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_border_end"
style="width: 100px; height: 100px; border-end-width: 5px; box-sizing: border-box">
</div>

View File

@@ -29,3 +29,61 @@
<div id="display_none_with_position_absolute" style="width: 100px; height: 100px;">
<div style="display:none; position: absolute; width: 100px; height: 100px"></div>
</div>
<div id="display_contents" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_fixed_size" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; width: 50px; height: 50px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_with_margin" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 20px; height: 20px; display: contents; margin: 10px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="display_contents_with_padding" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; padding: 10px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_with_position" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; top: 10px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_with_position_absolute" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; position: absolute; width: 50px; height: 50px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_nested" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents;">
<div style="display: contents;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
</div>
<div id="display_contents_with_siblings" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex: 1; height: 30px;"></div>
<div style="display: contents;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
<div style="flex: 1; height: 30px;"></div>
</div>

View File

@@ -0,0 +1,568 @@
<div id="contains_inner_text_long_word" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;">
LoremipsumdolorsitametconsecteturadipiscingelitSedeleifasdfettortoracauctorFuscerhoncusipsumtemporerosaliquamconsequatPraesentsoda
</div>
</div>
<div id="contains_inner_text_no_width_no_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_no_width_no_height_long_word_in_paragraph"
style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus
loremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumlorem
Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_fixed_width" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;width:100px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_no_width_fixed_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_fixed_width_fixed_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;width: 50px; height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_max_width_max_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;max-width: 50px; max-height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_max_width_max_height_column" style="width:2000px; align-items: flex-start;">
<div style="max-width: 50px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_max_width" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;max-width:100px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_fixed_width_shorter_text" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;width:100px">
Lorem ipsum
</div>
</div>
<div id="contains_inner_text_fixed_height_shorter_text" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;height:100px">
Lorem ipsum
</div>
</div>
<div id="contains_inner_text_max_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;max-height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="max_content_width" style="flex-direction: row; width:max-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
<div data-disabled="true" id="fit_content_width" style="width: 90px;">
<div style="flex-direction: row; width: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div id="stretch_width" style="width: 500px;">
<div style="flex-direction: row; width: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div id="max_content_height" style="height:max-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
<div data-disabled="true" id="fit_content_height" style="height: 90px; ">
<div style="height: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div data-disabled="true" id="stretch_height" style="height: 500px;">
<div style="height: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div id="max_content_flex_basis_column" style="flex-basis: max-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
<div data-disabled="true" id="fit_content_flex_basis_column" style="height: 90px;">
<div style="flex-basis: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div id="stretch_flex_basis_column" style="height: 500px;">
<div style="flex-basis: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div data-disabled="true" id="max_content_flex_basis_row" style="flex-direction: row; flex-basis: max-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 500px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
<div data-disabled="true" id="fit_content_flex_basis_row" style="width: 90px;">
<div style="flex-direction: row; flex-basis: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div data-disabled="true" id="stretch_flex_basis_row" style="width: 500px;">
<div style="flex-direction: row; flex-basis: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div data-disabled="true" id="max_content_max_width"
style="flex-direction: row; max-width:max-content; width: 200px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
<div data-disabled="true" id="fit_content_max_width" style="width: 90px;">
<div style="flex-direction: row; max-width: fit-content; width: 110px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div data-disabled="true" id="stretch_max_width" style="width: 500px;">
<div style="flex-direction: row; max-width: -webkit-fill-available; width: 600px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div data-disabled="true" id="max_content_min_width"
style="flex-direction: row; min-width:max-content; width: 100px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
<div data-disabled="true" id="fit_content_min_width" style="width: 90px;">
<div style="flex-direction: row; min-width: fit-content; width: 90px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div data-disabled="true" id="stretch_min_width" style="width: 500px;">
<div style="flex-direction: row; min-width: -webkit-fill-available; width: 400px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 100px; height: 50px;">
</div>
<div style="width: 25px; height: 50px;">
</div>
</div>
</div>
<div data-disabled="true" id="max_content_max_height" style="max-height:max-content; height: 200px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
<div data-disabled="true" id="fit_content_max_height" style="height: 90px;">
<div style="max-height: fit-content; height: 110px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div data-disabled="true" id="stretch_max_height" style="height: 500px;">
<div style="max-height: -webkit-fill-available; flex-wrap: wrap; height: 600px;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div data-disabled="true" id="max_content_min_height" style="min-height:max-content; height: 100px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
<div data-disabled="true" id="fit_content_min_height" style="height: 90px;">
<div style="min-height: fit-content; height: 90px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div data-disabled="true" id="stretch_min_height" style="height: 500px;">
<div style="min-height: -webkit-fill-available; flex-wrap: wrap; height: 400px;">
<div style="width: 50px; height: 50px;">
</div>
<div style="width: 50px; height: 100px;">
</div>
<div style="width: 50px; height: 25px;">
</div>
</div>
</div>
<div data-disabled="true" id="text_max_content_width" style="width: 200px">
<div style="width: max-content;">
<div style="flex-direction:row;">
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_stretch_width" style="width: 200px">
<div style="width: -webkit-fill-available;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_fit_content_width" style="width: 200px">
<div style="width: fit-content;">
<div style="flex-direction:row;">
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_max_content_min_width" style="width: 200px">
<div style="min-width: max-content; width: 200px;">
<div style="flex-direction:row;">
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_stretch_min_width" style="width: 200px">
<div style="min-width: -webkit-fill-available; width: 100px;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" data-disabled="true" id="text_fit_content_min_width" style="width: 200px">
<div style="min-width: fit-content; width: 300px">
<div style="flex-direction:row;">
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_max_content_max_width" style="width: 200px">
<div style="max-width: max-content; width: 2000px;">
<div style="flex-direction:row;">
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_stretch_max_width" style="width: 200px">
<div style="max-width: -webkit-fill-available; width: 300px;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet
</div>
</div>
</div>
<div data-disabled="true" id="text_fit_content_max_width" style="width: 200px">
<div style="max-width: fit-content; width: 1000px">
<div style="flex-direction:row;">
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
</div>
</div>
</div>

View File

@@ -157,13 +157,15 @@
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_reverse_space_around" style="width: 102px; height: 102px; flex-direction: row-reverse; justify-content: space-around;">
<!-- TODO T208209388: fallback to start vs flexstart in overflowed cases -->
<div data-disabled="true" id="justify_content_overflow_row_reverse_space_around" style="width: 102px; height: 102px; flex-direction: row-reverse; justify-content: space-around;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_reverse_space_evenly" style="width: 102px; height: 102px; flex-direction: row-reverse; justify-content: space-evenly;">
<!-- TODO T208209388: fallback to start vs flexstart in overflowed cases -->
<div data-disabled="true" id="justify_content_overflow_row_reverse_space_evenly" style="width: 102px; height: 102px; flex-direction: row-reverse; justify-content: space-evenly;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>

View File

@@ -693,3 +693,20 @@
style="height: 50%; width: 50%; position: absolute; border-width: 3px 2px 1px 4px; padding: 7px 5px 4px 3px; margin: 11px 15px 1px 12px">
</div>
</div>
<div id="static_position_absolute_child_multiple">
<div style="width: 400px; height: 400px; padding: 100px; position: relative">
<div style="height:100px; width: 100px; position: static">
<div style="height: 50px; width: 10%; position: absolute">
</div>
</div>
<div style="height:100px; width: 100px; position: static">
<div style="height: 50px; width: 50%; position: absolute">
</div>
<div style="height: 50px; width: 50%; position: absolute">
</div>
</div>
<div style="height: 50px; width: 25px; position: absolute">
</div>
</div>
</div>

BIN
gentest/fonts/Ahem.ttf Normal file

Binary file not shown.

View File

@@ -12,15 +12,44 @@ function toValueCpp(value) {
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
function toFunctionName(value) {
function toFunctionNameCpp(value) {
if (value.indexOf('%') >= 0) {
return 'Percent';
} else if (value.indexOf('Auto') >= 0) {
return 'Auto';
} else if (value.indexOf('MaxContent') >= 0) {
return 'MaxContent';
} else if (value.indexOf('FitContent') >= 0) {
return 'FitContent';
} else if (value.indexOf('Stretch') >= 0) {
return 'Stretch';
}
return '';
}
function keywordFunctionCpp(functionPrefix, nodeName, value) {
const functionSuffix = toFunctionNameCpp(value);
if (
functionSuffix == 'Auto' ||
functionSuffix == 'MaxContent' ||
functionSuffix == 'FitContent' ||
functionSuffix == 'Stretch'
) {
return functionPrefix + functionSuffix + '(' + nodeName + ');';
} else {
return (
functionPrefix +
functionSuffix +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');'
);
}
}
const CPPEmitter = function () {
Emitter.call(this, 'cpp', ' ');
};
@@ -30,7 +59,12 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
emitPrologue: {
value: function () {
this.push(['#include <gtest/gtest.h>', '#include <yoga/Yoga.h>', '']);
this.push([
'#include <gtest/gtest.h>',
'#include <yoga/Yoga.h>',
'#include "../util/TestUtil.h"',
'',
]);
},
},
@@ -44,7 +78,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
this.push('');
}
this.push('const YGConfigRef config = YGConfigNew();');
this.push('YGConfigRef config = YGConfigNew();');
for (const i in experiments) {
this.push(
'YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeature' +
@@ -58,9 +92,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
emitTestTreePrologue: {
value: function (nodeName) {
this.push(
'const YGNodeRef ' + nodeName + ' = YGNodeNewWithConfig(config);',
);
this.push('YGNodeRef ' + nodeName + ' = YGNodeNewWithConfig(config);');
},
},
@@ -133,12 +165,20 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGWrapWrap: {value: 'YGWrapWrap'},
YGWrapWrapReverse: {value: 'YGWrapWrapReverse'},
YGBoxSizingBorderBox: {value: 'YGBoxSizingBorderBox'},
YGBoxSizingContentBox: {value: 'YGBoxSizingContentBox'},
YGUndefined: {value: 'YGUndefined'},
YGDisplayFlex: {value: 'YGDisplayFlex'},
YGDisplayNone: {value: 'YGDisplayNone'},
YGDisplayContents: {value: 'YGDisplayContents'},
YGAuto: {value: 'YGAuto'},
YGMaxContent: {value: 'MaxContent'},
YGFitContent: {value: 'FitContent'},
YGStretch: {value: 'Stretch'},
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
this.push(
@@ -225,7 +265,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetAspectRatio' +
toFunctionName(value) +
toFunctionNameCpp(value) +
'(' +
nodeName +
', ' +
@@ -267,15 +307,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetFlexBasis: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetFlexBasis' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
this.push(keywordFunctionCpp('YGNodeStyleSetFlexBasis', nodeName, value));
},
},
@@ -319,20 +351,6 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetHeight' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
},
},
YGNodeStyleSetJustifyContent: {
value: function (nodeName, value) {
this.push(
@@ -355,7 +373,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}
this.push(
'YGNodeStyleSetMargin' +
toFunctionName(value) +
toFunctionNameCpp(value) +
'(' +
nodeName +
', ' +
@@ -366,59 +384,39 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(keywordFunctionCpp('YGNodeStyleSetHeight', nodeName, value));
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(keywordFunctionCpp('YGNodeStyleSetWidth', nodeName, value));
},
},
YGNodeStyleSetMaxHeight: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMaxHeight' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
this.push(keywordFunctionCpp('YGNodeStyleSetMaxHeight', nodeName, value));
},
},
YGNodeStyleSetMaxWidth: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMaxWidth' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
this.push(keywordFunctionCpp('YGNodeStyleSetMaxWidth', nodeName, value));
},
},
YGNodeStyleSetMinHeight: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMinHeight' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
this.push(keywordFunctionCpp('YGNodeStyleSetMinHeight', nodeName, value));
},
},
YGNodeStyleSetMinWidth: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMinWidth' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
this.push(keywordFunctionCpp('YGNodeStyleSetMinWidth', nodeName, value));
},
},
@@ -434,7 +432,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, edge, value) {
this.push(
'YGNodeStyleSetPadding' +
toFunctionName(value) +
toFunctionNameCpp(value) +
'(' +
nodeName +
', ' +
@@ -448,15 +446,20 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
let valueStr = toValueCpp(value);
if (valueStr != 'YGAuto') {
valueStr = ', ' + valueStr;
} else {
valueStr = '';
}
this.push(
'YGNodeStyleSetPosition' +
toFunctionName(value) +
toFunctionNameCpp(value) +
'(' +
nodeName +
', ' +
edge +
', ' +
toValueCpp(value) +
valueStr +
');',
);
},
@@ -474,25 +477,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetWidth' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
},
},
YGNodeStyleSetGap: {
value: function (nodeName, gap, value) {
this.push(
'YGNodeStyleSetGap' +
toFunctionName(value) +
toFunctionNameCpp(value) +
'(' +
nodeName +
', ' +
@@ -503,4 +492,21 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
);
},
},
YGNodeStyleSetBoxSizing: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetBoxSizing(' + nodeName + ', ' + toValueCpp(value) + ');',
);
},
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText, _) {
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
this.push(
`YGNodeSetMeasureFunc(${nodeName}, &facebook::yoga::test::IntrinsicSizeMeasure);`,
);
},
},
});

View File

@@ -100,15 +100,21 @@ for (const fileName of fixtures) {
await driver.get('file://' + process.cwd() + '/test.html');
const logs = await driver.manage().logs().get(logging.Type.BROWSER);
await fs.writeFile(
`${yogaDir}/tests/generated/${fileNameNoExtension}.cpp`,
addSignatureToSourceCode(JSON.parse(logs[0].message.replace(/^[^"]*/, ''))),
const testLogs = logs.filter(
log => !log.message.replace(/^[^"]*/, '').startsWith('"gentest-log:'),
);
await fs.writeFile(
`${yogaDir}/java/tests/com/facebook/yoga/${fileNameNoExtension}.java`,
`${yogaDir}/tests/generated/${fileNameNoExtension}.cpp`,
addSignatureToSourceCode(
JSON.parse(logs[1].message.replace(/^[^"]*/, '')).replace(
JSON.parse(testLogs[0].message.replace(/^[^"]*/, '')),
),
);
await fs.writeFile(
`${yogaDir}/java/tests/generated/com/facebook/yoga/${fileNameNoExtension}.java`,
addSignatureToSourceCode(
JSON.parse(testLogs[1].message.replace(/^[^"]*/, '')).replace(
'YogaTest',
fileNameNoExtension,
),
@@ -118,7 +124,7 @@ for (const fileName of fixtures) {
await fs.writeFile(
`${yogaDir}/javascript/tests/generated/${fileNameNoExtension}.test.ts`,
addSignatureToSourceCode(
JSON.parse(logs[2].message.replace(/^[^"]*/, '')).replace(
JSON.parse(testLogs[2].message.replace(/^[^"]*/, '')).replace(
'YogaTest',
fileNameNoExtension,
),

View File

@@ -17,10 +17,38 @@ function toMethodName(value) {
return 'Percent';
} else if (value.indexOf('AUTO') >= 0) {
return 'Auto';
} else if (value.indexOf('MAX_CONTENT') >= 0) {
return 'MaxContent';
} else if (value.indexOf('FIT_CONTENT') >= 0) {
return 'FitContent';
} else if (value.indexOf('STRETCH') >= 0) {
return 'Stretch';
}
return '';
}
function keywordMethod(methodPrefix, nodeName, value) {
const methodSuffix = toMethodName(value);
if (
methodSuffix == 'Auto' ||
methodSuffix == 'MaxContent' ||
methodSuffix == 'FitContent' ||
methodSuffix == 'Stretch'
) {
return nodeName + '.' + methodPrefix + methodSuffix + '();';
} else {
return (
nodeName +
'.' +
methodPrefix +
methodSuffix +
'(' +
toValueJava(value) +
'f);'
);
}
}
const JavaEmitter = function () {
Emitter.call(this, 'java', ' ');
};
@@ -55,6 +83,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
'import org.junit.Test;',
'import org.junit.runner.RunWith;',
'import org.junit.runners.Parameterized;',
'import com.facebook.yoga.utils.TestUtils;',
'',
'@RunWith(Parameterized.class)',
'public class YogaTest {',
@@ -177,12 +206,20 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGDisplayFlex: {value: 'YogaDisplay.FLEX'},
YGDisplayNone: {value: 'YogaDisplay.NONE'},
YGDisplayContents: {value: 'YogaDisplay.CONTENTS'},
YGAuto: {value: 'YogaConstants.AUTO'},
YGWrapNoWrap: {value: 'YogaWrap.NO_WRAP'},
YGWrapWrap: {value: 'YogaWrap.WRAP'},
YGWrapWrapReverse: {value: 'YogaWrap.WRAP_REVERSE'},
YGBoxSizingBorderBox: {value: 'YogaBoxSizing.BORDER_BOX'},
YGBoxSizingContentBox: {value: 'YogaBoxSizing.CONTENT_BOX'},
YGMaxContent: {value: 'MAX_CONTENT'},
YGFitContent: {value: 'FIT_CONTENT'},
YGStretch: {value: 'STRETCH'},
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
this.push(node + '.setDirection(' + dir + ');');
@@ -269,14 +306,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetFlexBasis: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setFlexBasis' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
this.push(keywordMethod('setFlexBasis', nodeName, value));
},
},
@@ -304,19 +334,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setHeight' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
},
},
YGNodeStyleSetJustifyContent: {
value: function (nodeName, value) {
this.push(nodeName + '.setJustifyContent(' + toValueJava(value) + ');');
@@ -344,55 +361,39 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(keywordMethod('setHeight', nodeName, value));
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(keywordMethod('setWidth', nodeName, value));
},
},
YGNodeStyleSetMaxHeight: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setMaxHeight' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
this.push(keywordMethod('setMaxHeight', nodeName, value));
},
},
YGNodeStyleSetMaxWidth: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setMaxWidth' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
this.push(keywordMethod('setMaxWidth', nodeName, value));
},
},
YGNodeStyleSetMinHeight: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setMinHeight' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
this.push(keywordMethod('setMinHeight', nodeName, value));
},
},
YGNodeStyleSetMinWidth: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setMinWidth' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
this.push(keywordMethod('setMinWidth', nodeName, value));
},
},
@@ -419,15 +420,21 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
let valueStr = toValueJava(value);
if (valueStr == 'YogaConstants.AUTO') {
valueStr = '';
} else {
valueStr = ', ' + valueStr + 'f';
}
this.push(
nodeName +
'.setPosition' +
toMethodName(value) +
'(' +
edge +
', ' +
toValueJava(value) +
'f);',
valueStr +
');',
);
},
},
@@ -438,19 +445,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setWidth' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
},
},
YGNodeStyleSetGap: {
value: function (nodeName, gap, value) {
this.push(
@@ -465,4 +459,19 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
);
},
},
YGNodeStyleSetBoxSizing: {
value: function (nodeName, value) {
this.push(nodeName + '.setBoxSizing(' + toValueJava(value) + ');');
},
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText, _) {
this.push(`${nodeName}.setData("${innerText}");`);
this.push(
`${nodeName}.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());`,
);
},
},
});

View File

@@ -15,6 +15,9 @@ function toValueJavascript(value) {
if (value.match(/^[0-9.e+-]+px$/i)) return parseFloat(value);
if (value.match(/^[0-9.e+-]+%/i)) return JSON.stringify(value);
if (value == 'Yoga.AUTO') return '"auto"';
if (value == 'max-content') return '"max-content"';
if (value == 'fit-content') return '"fit-content"';
if (value == 'stretch') return '"stretch"';
return value;
}
@@ -23,10 +26,14 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
emitPrologue: {
value: function () {
this.push(
"import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'",
);
this.push("import Yoga from 'yoga-layout';");
this.push('import {');
this.pushIndent();
this.push('Align,');
this.push('BoxSizing,');
this.push('Direction,');
this.push('Display,');
this.push('Edge,');
@@ -167,6 +174,14 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGDisplayFlex: {value: 'Display.Flex'},
YGDisplayNone: {value: 'Display.None'},
YGDisplayContents: {value: 'Display.Contents'},
YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'},
YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'},
YGMaxContent: {value: 'max-content'},
YGFitContent: {value: 'fit-content'},
YGStretch: {value: 'stretch'},
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
@@ -361,14 +376,22 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
this.push(
nodeName +
'.setPosition(' +
toValueJavascript(edge) +
', ' +
toValueJavascript(value) +
');',
);
const valueStr = toValueJavascript(value);
if (valueStr == "'auto'") {
this.push(
nodeName + '.setPositionAuto(' + toValueJavascript(edge) + ');',
);
} else {
this.push(
nodeName +
'.setPosition(' +
toValueJavascript(edge) +
', ' +
valueStr +
');',
);
}
},
},
@@ -398,4 +421,20 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
);
},
},
YGNodeStyleSetBoxSizing: {
value: function (nodeName, value) {
this.push(nodeName + '.setBoxSizing(' + toValueJavascript(value) + ');');
},
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText, flexDirection) {
this.push(
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "${innerText}", flexDirection: ${toValueJavascript(
flexDirection,
)}}));`,
);
},
},
});

11
gentest/gentest-log.js Normal file
View File

@@ -0,0 +1,11 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// eslint-disable-next-line no-unused-vars
function gentestLog(message) {
console.log('gentest-log: ', message);
}

View File

@@ -11,30 +11,33 @@ import * as fs from 'node:fs/promises';
import {dirname} from 'path';
import {fileURLToPath} from 'url';
import signedsource from 'signedsource';
import {glob} from 'glob';
const yogaDir = dirname(dirname(fileURLToPath(import.meta.url)));
const cppTestDir = `${yogaDir}/tests/generated`;
const jsTestDir = `${yogaDir}/javascript/tests/generated`;
const javaTestDir = `${yogaDir}/java/tests/com/facebook/yoga`;
const testDirs = [cppTestDir, jsTestDir, javaTestDir];
const yogaRootDir = dirname(dirname(fileURLToPath(import.meta.url)));
for (const testDir of testDirs) {
const tests = await fs.readdir(testDir);
const filesToValidate = await glob(
[
'tests/generated/**/*.{h,cpp}',
'javascript/tests/generated/**/*.test.ts',
'java/tests/generated/com/facebook/yoga/**/*.java',
],
{
cwd: yogaRootDir,
},
);
for (const test of tests) {
const testData = await fs.readFile(`${testDir}/${test}`, 'utf8');
try {
const validSignature = signedsource.verifySignature(testData);
if (!validSignature) {
console.error(`Invalid signature for ${test}`);
process.exitCode = 1;
}
} catch (e) {
// Java test dir does not separate generated tests from non-generated ones
if (testDir != javaTestDir) {
console.error(`${test}: ${e}`);
process.exitCode = 1;
}
console.log(`Found ${filesToValidate.length} files to validate`);
for (const file of filesToValidate) {
const content = await fs.readFile(`${yogaRootDir}/${file}`, 'utf8');
if (signedsource.isSigned(content)) {
console.log(`Checking ${file}`);
const validSignature = signedsource.verifySignature(content);
if (!validSignature) {
console.error(`Invalid signature "${file}"`);
process.exitCode = 1;
}
} else {
console.log(`Skipped ${file}`);
}
}

View File

@@ -175,6 +175,7 @@ function checkDefaultValues() {
{style: 'right', value: 'undefined'},
{style: 'bottom', value: 'undefined'},
{style: 'display', value: 'flex'},
{style: 'box-sizing', value: 'border-box'},
].forEach(item => {
assert(
isDefaultStyleValue(item.style, item.value),
@@ -193,7 +194,6 @@ function setupTestTree(
index,
) {
e.emitTestTreePrologue(nodeName);
for (const style in node.style) {
// Skip position info for root as it messes up tests
if (
@@ -207,7 +207,6 @@ function setupTestTree(
) {
continue;
}
if (!isDefaultStyleValue(style, node.style[style])) {
switch (style) {
case 'aspect-ratio':
@@ -520,6 +519,11 @@ function setupTestTree(
case 'display':
e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style]));
break;
case 'box-sizing':
e.YGNodeStyleSetBoxSizing(
nodeName,
boxSizingValue(e, node.style[style]),
);
}
}
}
@@ -528,6 +532,14 @@ function setupTestTree(
e.YGNodeInsertChild(parentName, nodeName, index);
}
if (node.innerText && node.children.length === 0) {
e.YGNodeSetMeasureFunc(
nodeName,
node.innerText,
flexDirectionValue(e, node.style['flex-direction']),
);
}
for (let i = 0; i < node.children.length; i++) {
e.push('');
const childName = nodeName + '_child' + i;
@@ -646,6 +658,13 @@ function pointValue(e, value) {
return e.YGAuto;
case 'undefined':
return e.YGUndefined;
case 'max-content':
return e.YGMaxContent;
case 'fit-content':
return e.YGFitContent;
case 'stretch':
case '-webkit-fill-available':
return e.YGStretch;
default:
return value;
}
@@ -657,6 +676,17 @@ function displayValue(e, value) {
return e.YGDisplayFlex;
case 'none':
return e.YGDisplayNone;
case 'contents':
return e.YGDisplayContents;
}
}
function boxSizingValue(e, value) {
switch (value) {
case 'border-box':
return e.YGBoxSizingBorderBox;
case 'content-box':
return e.YGBoxSizingContentBox;
}
}
@@ -723,6 +753,7 @@ function calculateTree(root, parentOffsetLeft, parentOffsetTop) {
? child.dataset.experiments.split(' ')
: [],
disabled: child.dataset.disabled === 'true',
innerText: child.innerText,
};
const size = getRoundedSize(child);
@@ -777,6 +808,7 @@ function getYogaStyle(node) {
'row-gap',
'display',
'aspect-ratio',
'box-sizing',
].reduce((map, key) => {
map[key] =
node.style[key] || getComputedStyle(node, null).getPropertyValue(key);

View File

@@ -3,8 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"gentest": "node --loader=babel-register-esm ./gentest-driver.ts",
"gentest-validate": "node --loader=babel-register-esm ./gentest-validate.ts"
"gentest": "node --disable-warning=ExperimentalWarning --loader=babel-register-esm ./gentest-driver.ts",
"gentest-validate": "node --disable-warning=ExperimentalWarning --loader=babel-register-esm ./gentest-validate.ts"
},
"type": "module",
"dependencies": {
@@ -19,6 +19,7 @@
"@types/minimist": "^1.2.5",
"@types/node": "^20.10.3",
"@types/selenium-webdriver": "^4.1.21",
"babel-register-esm": "^1.2.5"
"babel-register-esm": "^1.2.5",
"glob": "^10.4.2"
}
}

View File

@@ -1,70 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>%s</title>
<script src="gentest.js"></script>
<script src="gentest-cpp.js"></script>
<script src="gentest-java.js"></script>
<script src="gentest-javascript.js"></script>
<style>
body {
padding: 0;
margin: 0;
font-family: Helvetica;
font-size: 14px;
font-weight: 100;
}
<head>
<meta charset="UTF-8">
<title>%s</title>
<script src="gentest.js"></script>
<script src="gentest-cpp.js"></script>
<script src="gentest-java.js"></script>
<script src="gentest-javascript.js"></script>
<script src="gentest-log.js"></script>
div, span {
box-sizing: border-box;
position: relative;
border: 0 solid black;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: stretch;
align-content: flex-start;
justify-content: flex-start;
flex-shrink: 0;
}
<style>
@font-face {
font-family: 'Ahem';
src: url('./fonts/Ahem.ttf') format('truetype');
}
body > * {
position: absolute;
}
body {
padding: 0;
margin: 0;
font: 10px/1 Ahem;
font-weight: 100;
}
#ltr-container > * {
position: absolute;
direction: ltr;
}
div,
span {
box-sizing: border-box;
position: relative;
border: 0 solid black;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: stretch;
align-content: flex-start;
justify-content: flex-start;
flex-shrink: 0;
}
#rtl-container > * {
position: absolute;
direction: rtl;
}
</style>
</head>
body>* {
position: absolute;
}
<body>
<div id='ltr-container'>
#ltr-container>* {
position: absolute;
direction: ltr;
}
%s
#rtl-container>* {
position: absolute;
direction: rtl;
}
<div id='default'></div>
</div>
<div id='rtl-container'>
</style>
</head>
%s
<body>
<div id='ltr-container'>
<div id='default'></div>
</div>
%s
<div>
<div id='default'></div>
</div>
<div id='rtl-container'>
%s
%s
<div id='default'></div>
</div>
<div>
%s
</div>
</body>
</div>
</body>
</html>

View File

@@ -1,17 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// You can use this script to configure the gradleEnterprise{} block in your build.
// You need to rename this file to ./gradle/gradle-enterprise.gradle.kts in order for
// this to be processed.
extensions.getByName("gradleEnterprise").withGroovyBuilder {
setProperty("server", "https://your-gradle-enterprise-instance.example.com")
getProperty("buildScan").withGroovyBuilder {
"publishAlways"()
"tag"(if(System.getenv("CI") != null) "CI" else "Local")
}
}

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

26
gradlew vendored
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +85,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +133,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +147,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +204,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

22
gradlew.bat vendored
View File

@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View File

@@ -1,4 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Meta Platforms, Inc. and affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.yoga"
android:versionCode="1"
android:versionName="1.0"
>
<application/>

View File

@@ -9,6 +9,7 @@ plugins {
id("com.android.library")
id("maven-publish")
id("signing")
id("org.jetbrains.kotlin.android")
}
group = "com.facebook.yoga"
@@ -21,15 +22,16 @@ val ndkVersionProperty: String by rootProject.extra
android {
namespace = "com.facebook.yoga"
compileSdk = 34
buildToolsVersion = "34.0.0"
ndkVersion = "26.0.10792818"
compileSdk = 35
buildToolsVersion = "35.0.0"
ndkVersion = "27.1.12297006"
defaultConfig {
minSdk = 21
consumerProguardFiles("proguard-rules.pro")
ndk { abiFilters.addAll(setOf("x86", "x86_64", "armeabi-v7a", "arm64-v8a")) }
externalNativeBuild { cmake { arguments("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON") } }
}
externalNativeBuild { cmake { path("CMakeLists.txt") } }
@@ -47,6 +49,8 @@ android {
}
}
kotlinOptions { jvmTarget = "1.8" }
publishing {
multipleVariants {
withSourcesJar()
@@ -59,6 +63,7 @@ android {
dependencies {
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("com.facebook.soloader:soloader:0.10.5")
implementation("androidx.core:core-ktx:1.16.0")
testImplementation("junit:junit:4.12")
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
public enum LayoutPassReason {
INITIAL(0),
ABS_LAYOUT(1),
STRETCH(2),
MULTILINE_STRETCH(3),
FLEX_LAYOUT(4),
MEASURE(5),
ABS_MEASURE(6),
FLEX_MEASURE(7);
private final int mIntValue;
LayoutPassReason(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static LayoutPassReason fromInt(int value) {
switch (value) {
case 0: return INITIAL;
case 1: return ABS_LAYOUT;
case 2: return STRETCH;
case 3: return MULTILINE_STRETCH;
case 4: return FLEX_LAYOUT;
case 5: return MEASURE;
case 6: return ABS_MEASURE;
case 7: return FLEX_MEASURE;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
public enum class LayoutPassReason(public val intValue: Int) {
INITIAL(0),
ABS_LAYOUT(1),
STRETCH(2),
MULTILINE_STRETCH(3),
FLEX_LAYOUT(4),
MEASURE(5),
ABS_MEASURE(6),
FLEX_MEASURE(7);
public companion object {
@JvmStatic
public fun fromInt(value: Int): LayoutPassReason =
when (value) {
0 -> INITIAL
1 -> ABS_LAYOUT
2 -> STRETCH
3 -> MULTILINE_STRETCH
4 -> FLEX_LAYOUT
5 -> MEASURE
6 -> ABS_MEASURE
7 -> FLEX_MEASURE
else -> throw IllegalArgumentException("Unknown enum value: $value")
}
}
}

View File

@@ -5,12 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
package com.facebook.yoga
public interface YogaBaselineFunction {
public fun interface YogaBaselineFunction {
/**
* Return the baseline of the node in points. When no baseline function is set the baseline
* default to the computed height of the node.
*/
float baseline(YogaNode node, float width, float height);
public fun baseline(node: YogaNode, width: Float, height: Float): Float
}

View File

@@ -5,17 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/
// @generated by enums.py
package com.facebook.yoga;
public enum YogaLayoutType {
LAYOUT(0),
MEASURE(1),
CACHED_LAYOUT(2),
CACHED_MEASURE(3);
public enum YogaBoxSizing {
BORDER_BOX(0),
CONTENT_BOX(1);
private final int mIntValue;
YogaLayoutType(int intValue) {
YogaBoxSizing(int intValue) {
mIntValue = intValue;
}
@@ -23,12 +23,10 @@ public enum YogaLayoutType {
return mIntValue;
}
public static YogaLayoutType fromInt(int value) {
public static YogaBoxSizing fromInt(int value) {
switch (value) {
case 0: return LAYOUT;
case 1: return MEASURE;
case 2: return CACHED_LAYOUT;
case 3: return CACHED_MEASURE;
case 0: return BORDER_BOX;
case 1: return CONTENT_BOX;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

View File

@@ -5,10 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
package com.facebook.yoga
public abstract class YogaConfigFactory {
public static YogaConfig create() {
return new YogaConfigJNIFinalizer();
}
public object YogaConfigFactory {
@JvmStatic public fun create(): YogaConfig = YogaConfigJNIFinalizer()
}

View File

@@ -1,25 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
public class YogaConstants {
public static final float UNDEFINED = Float.NaN;
public static boolean isUndefined(float value) {
return Float.compare(value, UNDEFINED) == 0;
}
public static boolean isUndefined(YogaValue value) {
return value.unit == YogaUnit.UNDEFINED;
}
public static float getUndefined() {
return UNDEFINED;
}
}

View File

@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
public object YogaConstants {
@JvmField public val UNDEFINED: Float = Float.NaN
@JvmStatic public fun isUndefined(value: Float): Boolean = value.compareTo(UNDEFINED) == 0
@JvmStatic public fun isUndefined(value: YogaValue): Boolean = value.unit == YogaUnit.UNDEFINED
@JvmStatic public fun getUndefined(): Float = UNDEFINED
}

View File

@@ -11,7 +11,8 @@ package com.facebook.yoga;
public enum YogaDisplay {
FLEX(0),
NONE(1);
NONE(1),
CONTENTS(2);
private final int mIntValue;
@@ -27,6 +28,7 @@ public enum YogaDisplay {
switch (value) {
case 0: return FLEX;
case 1: return NONE;
case 2: return CONTENTS;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

View File

@@ -12,7 +12,7 @@ package com.facebook.yoga;
public enum YogaErrata {
NONE(0),
STRETCH_FLEX_BASIS(1),
ABSOLUTE_POSITIONING_INCORRECT(2),
ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING(2),
ABSOLUTE_PERCENT_AGAINST_INNER_SIZE(4),
ALL(2147483647),
CLASSIC(2147483646);
@@ -31,7 +31,7 @@ public enum YogaErrata {
switch (value) {
case 0: return NONE;
case 1: return STRETCH_FLEX_BASIS;
case 2: return ABSOLUTE_POSITIONING_INCORRECT;
case 2: return ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING;
case 4: return ABSOLUTE_PERCENT_AGAINST_INNER_SIZE;
case 2147483647: return ALL;
case 2147483646: return CLASSIC;

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
public enum class YogaLayoutType(public val intValue: Int) {
LAYOUT(0),
MEASURE(1),
CACHED_LAYOUT(2),
CACHED_MEASURE(3);
public companion object {
@JvmStatic
public fun fromInt(value: Int): YogaLayoutType =
when (value) {
0 -> LAYOUT
1 -> MEASURE
2 -> CACHED_LAYOUT
3 -> CACHED_MEASURE
else -> throw IllegalArgumentException("Unknown enum value: $value")
}
}
}

View File

@@ -5,16 +5,15 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
package com.facebook.yoga
import com.facebook.yoga.annotations.DoNotStrip;
import com.facebook.yoga.annotations.DoNotStrip
/**
* Interface for receiving logs from native layer. Use by setting YogaNode.setLogger(myLogger);
* See YogaLogLevel for the different log levels.
* Interface for receiving logs from native layer. Use by setting YogaNode.setLogger(myLogger); See
* YogaLogLevel for the different log levels.
*/
@DoNotStrip
public interface YogaLogger {
@DoNotStrip
void log(YogaLogLevel level, String message);
public fun interface YogaLogger {
@DoNotStrip public fun log(level: YogaLogLevel, message: String)
}

View File

@@ -1,20 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
public interface YogaMeasureFunction {
/**
* Return a value created by YogaMeasureOutput.make(width, height);
*/
long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
public fun interface YogaMeasureFunction {
/** Return a value created by YogaMeasureOutput.make(width, height); */
public fun measure(
node: YogaNode,
width: Float,
widthMode: YogaMeasureMode,
height: Float,
heightMode: YogaMeasureMode
): Long
}

View File

@@ -1,32 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
/**
* Helpers for building measure output value.
*/
public class YogaMeasureOutput {
public static long make(float width, float height) {
final int wBits = Float.floatToRawIntBits(width);
final int hBits = Float.floatToRawIntBits(height);
return ((long) wBits) << 32 | ((long) hBits);
}
public static long make(int width, int height) {
return make((float) width, (float) height);
}
public static float getWidth(long measureOutput) {
return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32)));
}
public static float getHeight(long measureOutput) {
return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput));
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
/** Helpers for building measure output value. */
public object YogaMeasureOutput {
@JvmStatic
public fun make(width: Float, height: Float): Long {
val wBits = java.lang.Float.floatToRawIntBits(width)
val hBits = java.lang.Float.floatToRawIntBits(height)
return (wBits.toLong()) shl 32 or (hBits.toLong())
}
@JvmStatic
public fun make(width: Int, height: Int): Long = make(width.toFloat(), height.toFloat())
@JvmStatic
public fun getWidth(measureOutput: Long): Float =
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and (measureOutput shr 32)).toInt())
@JvmStatic
public fun getHeight(measureOutput: Long): Float =
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and measureOutput).toInt())
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
import com.facebook.yoga.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
@DoNotStrip
public class YogaNative {
static {
SoLoader.loadLibrary("yoga");
}
// JNI methods that use Vanilla JNI
// YGConfig related
static native long jni_YGConfigNewJNI();
static native void jni_YGConfigFreeJNI(long nativePointer);
static native void jni_YGConfigSetExperimentalFeatureEnabledJNI(long nativePointer, int feature, boolean enabled);
static native void jni_YGConfigSetUseWebDefaultsJNI(long nativePointer, boolean useWebDefaults);
static native void jni_YGConfigSetPointScaleFactorJNI(long nativePointer, float pixelsInPoint);
static native void jni_YGConfigSetErrataJNI(long nativePointer, int errata);
static native int jni_YGConfigGetErrataJNI(long nativePointer);
static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger);
// YGNode related
static native long jni_YGNodeNewJNI();
static native long jni_YGNodeNewWithConfigJNI(long configPointer);
static native void jni_YGNodeFinalizeJNI(long nativePointer);
static native void jni_YGNodeResetJNI(long nativePointer);
static native void jni_YGNodeInsertChildJNI(long nativePointer, long childPointer, int index);
static native void jni_YGNodeSwapChildJNI(long nativePointer, long childPointer, int index);
static native void jni_YGNodeSetIsReferenceBaselineJNI(long nativePointer, boolean isReferenceBaseline);
static native boolean jni_YGNodeIsReferenceBaselineJNI(long nativePointer);
static native void jni_YGNodeRemoveAllChildrenJNI(long nativePointer);
static native void jni_YGNodeRemoveChildJNI(long nativePointer, long childPointer);
static native void jni_YGNodeCalculateLayoutJNI(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNIBase[] nodes);
static native void jni_YGNodeMarkDirtyJNI(long nativePointer);
static native boolean jni_YGNodeIsDirtyJNI(long nativePointer);
static native void jni_YGNodeCopyStyleJNI(long dstNativePointer, long srcNativePointer);
static native int jni_YGNodeStyleGetDirectionJNI(long nativePointer);
static native void jni_YGNodeStyleSetDirectionJNI(long nativePointer, int direction);
static native int jni_YGNodeStyleGetFlexDirectionJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexDirectionJNI(long nativePointer, int flexDirection);
static native int jni_YGNodeStyleGetJustifyContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetJustifyContentJNI(long nativePointer, int justifyContent);
static native int jni_YGNodeStyleGetAlignItemsJNI(long nativePointer);
static native void jni_YGNodeStyleSetAlignItemsJNI(long nativePointer, int alignItems);
static native int jni_YGNodeStyleGetAlignSelfJNI(long nativePointer);
static native void jni_YGNodeStyleSetAlignSelfJNI(long nativePointer, int alignSelf);
static native int jni_YGNodeStyleGetAlignContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetAlignContentJNI(long nativePointer, int alignContent);
static native int jni_YGNodeStyleGetPositionTypeJNI(long nativePointer);
static native void jni_YGNodeStyleSetPositionTypeJNI(long nativePointer, int positionType);
static native int jni_YGNodeStyleGetFlexWrapJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexWrapJNI(long nativePointer, int wrapType);
static native int jni_YGNodeStyleGetOverflowJNI(long nativePointer);
static native void jni_YGNodeStyleSetOverflowJNI(long nativePointer, int overflow);
static native int jni_YGNodeStyleGetDisplayJNI(long nativePointer);
static native void jni_YGNodeStyleSetDisplayJNI(long nativePointer, int display);
static native float jni_YGNodeStyleGetFlexJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexJNI(long nativePointer, float flex);
static native float jni_YGNodeStyleGetFlexGrowJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexGrowJNI(long nativePointer, float flexGrow);
static native float jni_YGNodeStyleGetFlexShrinkJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexShrinkJNI(long nativePointer, float flexShrink);
static native long jni_YGNodeStyleGetFlexBasisJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexBasisJNI(long nativePointer, float flexBasis);
static native void jni_YGNodeStyleSetFlexBasisPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetFlexBasisAutoJNI(long nativePointer);
static native long jni_YGNodeStyleGetMarginJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetMarginJNI(long nativePointer, int edge, float margin);
static native void jni_YGNodeStyleSetMarginPercentJNI(long nativePointer, int edge, float percent);
static native void jni_YGNodeStyleSetMarginAutoJNI(long nativePointer, int edge);
static native long jni_YGNodeStyleGetPaddingJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPaddingJNI(long nativePointer, int edge, float padding);
static native void jni_YGNodeStyleSetPaddingPercentJNI(long nativePointer, int edge, float percent);
static native float jni_YGNodeStyleGetBorderJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetBorderJNI(long nativePointer, int edge, float border);
static native long jni_YGNodeStyleGetPositionJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPositionJNI(long nativePointer, int edge, float position);
static native void jni_YGNodeStyleSetPositionPercentJNI(long nativePointer, int edge, float percent);
static native long jni_YGNodeStyleGetWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetWidthAutoJNI(long nativePointer);
static native long jni_YGNodeStyleGetHeightJNI(long nativePointer);
static native void jni_YGNodeStyleSetHeightJNI(long nativePointer, float height);
static native void jni_YGNodeStyleSetHeightPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetHeightAutoJNI(long nativePointer);
static native long jni_YGNodeStyleGetMinWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinWidthJNI(long nativePointer, float minWidth);
static native void jni_YGNodeStyleSetMinWidthPercentJNI(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMinHeightJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinHeightJNI(long nativePointer, float minHeight);
static native void jni_YGNodeStyleSetMinHeightPercentJNI(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMaxWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxWidthJNI(long nativePointer, float maxWidth);
static native void jni_YGNodeStyleSetMaxWidthPercentJNI(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMaxHeightJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxHeightJNI(long nativePointer, float maxheight);
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength);
static native void jni_YGNodeStyleSetGapPercentJNI(long nativePointer, int gutter, float gapLength);
static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodeSetHasBaselineFuncJNI(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodeSetStyleInputsJNI(long nativePointer, float[] styleInputsArray, int size);
static native long jni_YGNodeCloneJNI(long nativePointer);
static native void jni_YGNodeSetAlwaysFormsContainingBlockJNI(long nativePointer, boolean alwaysFormContainingBlock);
}

View File

@@ -0,0 +1,331 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
import com.facebook.soloader.SoLoader
import com.facebook.yoga.annotations.DoNotStrip
@DoNotStrip
public object YogaNative {
init {
SoLoader.loadLibrary("yoga")
}
// JNI methods that use Vanilla JNI
// YGConfig related
@JvmStatic public external fun jni_YGConfigNewJNI(): Long
@JvmStatic public external fun jni_YGConfigFreeJNI(nativePointer: Long)
@JvmStatic
public external fun jni_YGConfigSetExperimentalFeatureEnabledJNI(
nativePointer: Long,
feature: Int,
enabled: Boolean
)
@JvmStatic
public external fun jni_YGConfigSetUseWebDefaultsJNI(nativePointer: Long, useWebDefaults: Boolean)
@JvmStatic
public external fun jni_YGConfigSetPointScaleFactorJNI(nativePointer: Long, pixelsInPoint: Float)
@JvmStatic public external fun jni_YGConfigSetErrataJNI(nativePointer: Long, errata: Int)
@JvmStatic public external fun jni_YGConfigGetErrataJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGConfigSetLoggerJNI(nativePointer: Long, logger: YogaLogger)
// YGNode related
@JvmStatic public external fun jni_YGNodeNewJNI(): Long
@JvmStatic public external fun jni_YGNodeNewWithConfigJNI(configPointer: Long): Long
@JvmStatic public external fun jni_YGNodeFinalizeJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeResetJNI(nativePointer: Long)
@JvmStatic
public external fun jni_YGNodeInsertChildJNI(nativePointer: Long, childPointer: Long, index: Int)
@JvmStatic
public external fun jni_YGNodeSwapChildJNI(nativePointer: Long, childPointer: Long, index: Int)
@JvmStatic
public external fun jni_YGNodeSetIsReferenceBaselineJNI(
nativePointer: Long,
isReferenceBaseline: Boolean
)
@JvmStatic public external fun jni_YGNodeIsReferenceBaselineJNI(nativePointer: Long): Boolean
@JvmStatic public external fun jni_YGNodeRemoveAllChildrenJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeRemoveChildJNI(nativePointer: Long, childPointer: Long)
@JvmStatic
public external fun jni_YGNodeCalculateLayoutJNI(
nativePointer: Long,
width: Float,
height: Float,
nativePointers: LongArray,
nodes: Array<YogaNodeJNIBase>
)
@JvmStatic public external fun jni_YGNodeMarkDirtyJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeIsDirtyJNI(nativePointer: Long): Boolean
@JvmStatic
public external fun jni_YGNodeCopyStyleJNI(dstNativePointer: Long, srcNativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetDirectionJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGNodeStyleSetDirectionJNI(nativePointer: Long, direction: Int)
@JvmStatic public external fun jni_YGNodeStyleGetFlexDirectionJNI(nativePointer: Long): Int
@JvmStatic
public external fun jni_YGNodeStyleSetFlexDirectionJNI(nativePointer: Long, flexDirection: Int)
@JvmStatic public external fun jni_YGNodeStyleGetJustifyContentJNI(nativePointer: Long): Int
@JvmStatic
public external fun jni_YGNodeStyleSetJustifyContentJNI(nativePointer: Long, justifyContent: Int)
@JvmStatic public external fun jni_YGNodeStyleGetAlignItemsJNI(nativePointer: Long): Int
@JvmStatic
public external fun jni_YGNodeStyleSetAlignItemsJNI(nativePointer: Long, alignItems: Int)
@JvmStatic public external fun jni_YGNodeStyleGetAlignSelfJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGNodeStyleSetAlignSelfJNI(nativePointer: Long, alignSelf: Int)
@JvmStatic public external fun jni_YGNodeStyleGetAlignContentJNI(nativePointer: Long): Int
@JvmStatic
public external fun jni_YGNodeStyleSetAlignContentJNI(nativePointer: Long, alignContent: Int)
@JvmStatic public external fun jni_YGNodeStyleGetPositionTypeJNI(nativePointer: Long): Int
@JvmStatic
public external fun jni_YGNodeStyleSetPositionTypeJNI(nativePointer: Long, positionType: Int)
@JvmStatic public external fun jni_YGNodeStyleGetBoxSizingJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGNodeStyleSetBoxSizingJNI(nativePointer: Long, boxSizing: Int)
@JvmStatic public external fun jni_YGNodeStyleGetFlexWrapJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGNodeStyleSetFlexWrapJNI(nativePointer: Long, wrapType: Int)
@JvmStatic public external fun jni_YGNodeStyleGetOverflowJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGNodeStyleSetOverflowJNI(nativePointer: Long, overflow: Int)
@JvmStatic public external fun jni_YGNodeStyleGetDisplayJNI(nativePointer: Long): Int
@JvmStatic public external fun jni_YGNodeStyleSetDisplayJNI(nativePointer: Long, display: Int)
@JvmStatic public external fun jni_YGNodeStyleGetFlexJNI(nativePointer: Long): Float
@JvmStatic public external fun jni_YGNodeStyleSetFlexJNI(nativePointer: Long, flex: Float)
@JvmStatic public external fun jni_YGNodeStyleGetFlexGrowJNI(nativePointer: Long): Float
@JvmStatic public external fun jni_YGNodeStyleSetFlexGrowJNI(nativePointer: Long, flexGrow: Float)
@JvmStatic public external fun jni_YGNodeStyleGetFlexShrinkJNI(nativePointer: Long): Float
@JvmStatic
public external fun jni_YGNodeStyleSetFlexShrinkJNI(nativePointer: Long, flexShrink: Float)
@JvmStatic public external fun jni_YGNodeStyleGetFlexBasisJNI(nativePointer: Long): Long
@JvmStatic
public external fun jni_YGNodeStyleSetFlexBasisJNI(nativePointer: Long, flexBasis: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetFlexBasisPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisAutoJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetFlexBasisStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetMarginJNI(nativePointer: Long, edge: Int): Long
@JvmStatic
public external fun jni_YGNodeStyleSetMarginJNI(nativePointer: Long, edge: Int, margin: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetMarginPercentJNI(
nativePointer: Long,
edge: Int,
percent: Float
)
@JvmStatic public external fun jni_YGNodeStyleSetMarginAutoJNI(nativePointer: Long, edge: Int)
@JvmStatic public external fun jni_YGNodeStyleGetPaddingJNI(nativePointer: Long, edge: Int): Long
@JvmStatic
public external fun jni_YGNodeStyleSetPaddingJNI(nativePointer: Long, edge: Int, padding: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetPaddingPercentJNI(
nativePointer: Long,
edge: Int,
percent: Float
)
@JvmStatic public external fun jni_YGNodeStyleGetBorderJNI(nativePointer: Long, edge: Int): Float
@JvmStatic
public external fun jni_YGNodeStyleSetBorderJNI(nativePointer: Long, edge: Int, border: Float)
@JvmStatic public external fun jni_YGNodeStyleGetPositionJNI(nativePointer: Long, edge: Int): Long
@JvmStatic
public external fun jni_YGNodeStyleSetPositionJNI(nativePointer: Long, edge: Int, position: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetPositionPercentJNI(
nativePointer: Long,
edge: Int,
percent: Float
)
@JvmStatic public external fun jni_YGNodeStyleSetPositionAutoJNI(nativePointer: Long, edge: Int)
@JvmStatic public external fun jni_YGNodeStyleGetWidthJNI(nativePointer: Long): Long
@JvmStatic public external fun jni_YGNodeStyleSetWidthJNI(nativePointer: Long, width: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetWidthPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetWidthAutoJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetWidthMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetWidthFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetWidthStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetHeightJNI(nativePointer: Long): Long
@JvmStatic public external fun jni_YGNodeStyleSetHeightJNI(nativePointer: Long, height: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetHeightPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetHeightAutoJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetHeightMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetHeightFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetHeightStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetMinWidthJNI(nativePointer: Long): Long
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthJNI(nativePointer: Long, minWidth: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetMinWidthPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMinWidthStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetMinHeightJNI(nativePointer: Long): Long
@JvmStatic
public external fun jni_YGNodeStyleSetMinHeightJNI(nativePointer: Long, minHeight: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetMinHeightPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetMinHeightMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMinHeightFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMinHeightStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetMaxWidthJNI(nativePointer: Long): Long
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthJNI(nativePointer: Long, maxWidth: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetMaxWidthPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMaxWidthStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetMaxHeightJNI(nativePointer: Long): Long
@JvmStatic
public external fun jni_YGNodeStyleSetMaxHeightJNI(nativePointer: Long, maxheight: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetMaxHeightPercentJNI(nativePointer: Long, percent: Float)
@JvmStatic public external fun jni_YGNodeStyleSetMaxHeightMaxContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMaxHeightFitContentJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleSetMaxHeightStretchJNI(nativePointer: Long)
@JvmStatic public external fun jni_YGNodeStyleGetAspectRatioJNI(nativePointer: Long): Float
@JvmStatic
public external fun jni_YGNodeStyleSetAspectRatioJNI(nativePointer: Long, aspectRatio: Float)
@JvmStatic public external fun jni_YGNodeStyleGetGapJNI(nativePointer: Long, gutter: Int): Long
@JvmStatic
public external fun jni_YGNodeStyleSetGapJNI(nativePointer: Long, gutter: Int, gapLength: Float)
@JvmStatic
public external fun jni_YGNodeStyleSetGapPercentJNI(
nativePointer: Long,
gutter: Int,
gapLength: Float
)
@JvmStatic
public external fun jni_YGNodeSetHasMeasureFuncJNI(nativePointer: Long, hasMeasureFunc: Boolean)
@JvmStatic
public external fun jni_YGNodeSetHasBaselineFuncJNI(nativePointer: Long, hasMeasureFunc: Boolean)
@JvmStatic
public external fun jni_YGNodeSetStyleInputsJNI(
nativePointer: Long,
styleInputsArray: FloatArray,
size: Int
)
@JvmStatic public external fun jni_YGNodeCloneJNI(nativePointer: Long): Long
@JvmStatic
public external fun jni_YGNodeSetAlwaysFormsContainingBlockJNI(
nativePointer: Long,
alwaysFormContainingBlock: Boolean
)
}

View File

@@ -88,6 +88,10 @@ public abstract class YogaNode implements YogaProps {
public abstract void setPositionType(YogaPositionType positionType);
public abstract YogaBoxSizing getBoxSizing();
public abstract void setBoxSizing(YogaBoxSizing boxSizing);
public abstract YogaWrap getWrap();
public abstract void setWrap(YogaWrap flexWrap);
@@ -120,6 +124,12 @@ public abstract class YogaNode implements YogaProps {
public abstract void setFlexBasisAuto();
public abstract void setFlexBasisMaxContent();
public abstract void setFlexBasisFitContent();
public abstract void setFlexBasisStretch();
public abstract YogaValue getMargin(YogaEdge edge);
public abstract void setMargin(YogaEdge edge, float margin);
@@ -144,6 +154,8 @@ public abstract class YogaNode implements YogaProps {
public abstract void setPositionPercent(YogaEdge edge, float percent);
public abstract void setPositionAuto(YogaEdge edge);
public abstract YogaValue getWidth();
public abstract void setWidth(float width);
@@ -152,6 +164,12 @@ public abstract class YogaNode implements YogaProps {
public abstract void setWidthAuto();
public abstract void setWidthMaxContent();
public abstract void setWidthFitContent();
public abstract void setWidthStretch();
public abstract YogaValue getHeight();
public abstract void setHeight(float height);
@@ -160,35 +178,65 @@ public abstract class YogaNode implements YogaProps {
public abstract void setHeightAuto();
public abstract void setHeightMaxContent();
public abstract void setHeightFitContent();
public abstract void setHeightStretch();
public abstract YogaValue getMinWidth();
public abstract void setMinWidth(float minWidth);
public abstract void setMinWidthPercent(float percent);
public abstract void setMinWidthMaxContent();
public abstract void setMinWidthFitContent();
public abstract void setMinWidthStretch();
public abstract YogaValue getMinHeight();
public abstract void setMinHeight(float minHeight);
public abstract void setMinHeightPercent(float percent);
public abstract void setMinHeightMaxContent();
public abstract void setMinHeightFitContent();
public abstract void setMinHeightStretch();
public abstract YogaValue getMaxWidth();
public abstract void setMaxWidth(float maxWidth);
public abstract void setMaxWidthPercent(float percent);
public abstract void setMaxWidthMaxContent();
public abstract void setMaxWidthFitContent();
public abstract void setMaxWidthStretch();
public abstract YogaValue getMaxHeight();
public abstract void setMaxHeight(float maxheight);
public abstract void setMaxHeightPercent(float percent);
public abstract void setMaxHeightMaxContent();
public abstract void setMaxHeightFitContent();
public abstract void setMaxHeightStretch();
public abstract float getAspectRatio();
public abstract void setAspectRatio(float aspectRatio);
public abstract float getGap(YogaGutter gutter);
public abstract YogaValue getGap(YogaGutter gutter);
public abstract void setGap(YogaGutter gutter, float gapLength);

View File

@@ -1,18 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
public abstract class YogaNodeFactory {
public static YogaNode create() {
return new YogaNodeJNIFinalizer();
}
public static YogaNode create(YogaConfig config) {
return new YogaNodeJNIFinalizer(config);
}
}

View File

@@ -0,0 +1,14 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
public object YogaNodeFactory {
@JvmStatic public fun create(): YogaNode = YogaNodeJNIFinalizer()
@JvmStatic public fun create(config: YogaConfig): YogaNode = YogaNodeJNIFinalizer(config)
}

View File

@@ -32,6 +32,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
private static final byte LAYOUT_BORDER_START_INDEX = 14;
@Nullable private YogaNodeJNIBase mOwner;
@Nullable private YogaConfig mConfig;
@Nullable private List<YogaNodeJNIBase> mChildren;
@Nullable private YogaMeasureFunction mMeasureFunction;
@Nullable private YogaBaselineFunction mBaselineFunction;
@@ -57,6 +58,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNodeJNIBase(YogaConfig config) {
this(YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase) config).mNativePointer));
mConfig = config; // makes sure the YogaConfig is not garbage collected
}
public void reset() {
@@ -299,6 +301,14 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
}
public YogaBoxSizing getBoxSizing() {
return YogaBoxSizing.fromInt(YogaNative.jni_YGNodeStyleGetBoxSizingJNI(mNativePointer));
}
public void setBoxSizing(YogaBoxSizing boxSizing) {
YogaNative.jni_YGNodeStyleSetBoxSizingJNI(mNativePointer, boxSizing.intValue());
}
public YogaWrap getWrap() {
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer));
}
@@ -363,6 +373,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
}
public void setFlexBasisMaxContent() {
YogaNative.jni_YGNodeStyleSetFlexBasisMaxContentJNI(mNativePointer);
}
public void setFlexBasisFitContent() {
YogaNative.jni_YGNodeStyleSetFlexBasisFitContentJNI(mNativePointer);
}
public void setFlexBasisStretch() {
YogaNative.jni_YGNodeStyleSetFlexBasisStretchJNI(mNativePointer);
}
public YogaValue getMargin(YogaEdge edge) {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()));
}
@@ -411,6 +433,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
}
public void setPositionAuto(YogaEdge edge) {
YogaNative.jni_YGNodeStyleSetPositionAutoJNI(mNativePointer, edge.intValue());
}
public YogaValue getWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
}
@@ -427,6 +453,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
}
public void setWidthMaxContent() {
YogaNative.jni_YGNodeStyleSetWidthMaxContentJNI(mNativePointer);
}
public void setWidthFitContent() {
YogaNative.jni_YGNodeStyleSetWidthFitContentJNI(mNativePointer);
}
public void setWidthStretch() {
YogaNative.jni_YGNodeStyleSetWidthStretchJNI(mNativePointer);
}
public YogaValue getHeight() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer));
}
@@ -443,6 +481,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
}
public void setHeightMaxContent() {
YogaNative.jni_YGNodeStyleSetHeightMaxContentJNI(mNativePointer);
}
public void setHeightFitContent() {
YogaNative.jni_YGNodeStyleSetHeightFitContentJNI(mNativePointer);
}
public void setHeightStretch() {
YogaNative.jni_YGNodeStyleSetHeightStretchJNI(mNativePointer);
}
public YogaValue getMinWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer));
}
@@ -455,6 +505,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
}
public void setMinWidthMaxContent() {
YogaNative.jni_YGNodeStyleSetMinWidthMaxContentJNI(mNativePointer);
}
public void setMinWidthFitContent() {
YogaNative.jni_YGNodeStyleSetMinWidthFitContentJNI(mNativePointer);
}
public void setMinWidthStretch() {
YogaNative.jni_YGNodeStyleSetMinWidthStretchJNI(mNativePointer);
}
public YogaValue getMinHeight() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer));
}
@@ -467,6 +529,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
}
public void setMinHeightMaxContent() {
YogaNative.jni_YGNodeStyleSetMinHeightMaxContentJNI(mNativePointer);
}
public void setMinHeightFitContent() {
YogaNative.jni_YGNodeStyleSetMinHeightFitContentJNI(mNativePointer);
}
public void setMinHeightStretch() {
YogaNative.jni_YGNodeStyleSetMinHeightStretchJNI(mNativePointer);
}
public YogaValue getMaxWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer));
}
@@ -479,6 +553,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
}
public void setMaxWidthMaxContent() {
YogaNative.jni_YGNodeStyleSetMaxWidthMaxContentJNI(mNativePointer);
}
public void setMaxWidthFitContent() {
YogaNative.jni_YGNodeStyleSetMaxWidthFitContentJNI(mNativePointer);
}
public void setMaxWidthStretch() {
YogaNative.jni_YGNodeStyleSetMaxWidthStretchJNI(mNativePointer);
}
public YogaValue getMaxHeight() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer));
}
@@ -491,6 +577,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
}
public void setMaxHeightMaxContent() {
YogaNative.jni_YGNodeStyleSetMaxHeightMaxContentJNI(mNativePointer);
}
public void setMaxHeightFitContent() {
YogaNative.jni_YGNodeStyleSetMaxHeightFitContentJNI(mNativePointer);
}
public void setMaxHeightStretch() {
YogaNative.jni_YGNodeStyleSetMaxHeightStretchJNI(mNativePointer);
}
public float getAspectRatio() {
return YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer);
}
@@ -713,8 +811,8 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
}
@Override
public float getGap(YogaGutter gutter) {
return YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue());
public YogaValue getGap(YogaGutter gutter) {
return valueFromLong(YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue()));
}
@Override

View File

@@ -15,15 +15,33 @@ public interface YogaProps {
void setWidthPercent(float percent);
void setWidthAuto();
void setWidthMaxContent();
void setWidthFitContent();
void setWidthStretch();
void setMinWidth(float minWidth);
void setMinWidthPercent(float percent);
void setMinWidthMaxContent();
void setMinWidthFitContent();
void setMinWidthStretch();
void setMaxWidth(float maxWidth);
void setMaxWidthPercent(float percent);
void setWidthAuto();
void setMaxWidthMaxContent();
void setMaxWidthFitContent();
void setMaxWidthStretch();
/* Height properties */
@@ -31,15 +49,33 @@ public interface YogaProps {
void setHeightPercent(float percent);
void setHeightAuto();
void setHeightMaxContent();
void setHeightFitContent();
void setHeightStretch();
void setMinHeight(float minHeight);
void setMinHeightPercent(float percent);
void setMinHeightMaxContent();
void setMinHeightFitContent();
void setMinHeightStretch();
void setMaxHeight(float maxHeight);
void setMaxHeightPercent(float percent);
void setHeightAuto();
void setMaxHeightMaxContent();
void setMaxHeightFitContent();
void setMaxHeightStretch();
/* Margin properties */
@@ -81,6 +117,12 @@ public interface YogaProps {
void setFlexBasis(float flexBasis);
void setFlexBasisMaxContent();
void setFlexBasisFitContent();
void setFlexBasisStretch();
void setFlexDirection(YogaFlexDirection direction);
void setFlexGrow(float flexGrow);
@@ -105,6 +147,8 @@ public interface YogaProps {
void setBaselineFunction(YogaBaselineFunction yogaBaselineFunction);
void setBoxSizing(YogaBoxSizing boxSizing);
/* Getters */
YogaValue getWidth();
@@ -148,4 +192,6 @@ public interface YogaProps {
YogaValue getPosition(YogaEdge edge);
float getBorder(YogaEdge edge);
YogaBoxSizing getBoxSizing();
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga;
public class YogaStyleInputs {
public static final short LAYOUT_DIRECTION = 0;
public static final short FLEX_DIRECTION = 1;
public static final short FLEX = 2;
public static final short FLEX_GROW = 3;
public static final short FLEX_SHRINK = 4;
public static final short FLEX_BASIS = 5;
public static final short FLEX_BASIS_PERCENT = 6;
public static final short FLEX_BASIS_AUTO = 7;
public static final short FLEX_WRAP = 8;
public static final short WIDTH = 9;
public static final short WIDTH_PERCENT = 10;
public static final short WIDTH_AUTO = 11;
public static final short MIN_WIDTH = 12;
public static final short MIN_WIDTH_PERCENT = 13;
public static final short MAX_WIDTH = 14;
public static final short MAX_WIDTH_PERCENT = 15;
public static final short HEIGHT = 16;
public static final short HEIGHT_PERCENT = 17;
public static final short HEIGHT_AUTO = 18;
public static final short MIN_HEIGHT = 19;
public static final short MIN_HEIGHT_PERCENT = 20;
public static final short MAX_HEIGHT = 21;
public static final short MAX_HEIGHT_PERCENT = 22;
public static final short JUSTIFY_CONTENT = 23;
public static final short ALIGN_ITEMS = 24;
public static final short ALIGN_SELF = 25;
public static final short ALIGN_CONTENT = 26;
public static final short POSITION_TYPE = 27;
public static final short ASPECT_RATIO = 28;
public static final short OVERFLOW = 29;
public static final short DISPLAY = 30;
public static final short MARGIN = 31;
public static final short MARGIN_PERCENT = 32;
public static final short MARGIN_AUTO = 33;
public static final short PADDING = 34;
public static final short PADDING_PERCENT = 35;
public static final short BORDER = 36;
public static final short POSITION = 37;
public static final short POSITION_PERCENT = 38;
public static final short IS_REFERENCE_BASELINE = 39;
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga
public object YogaStyleInputs {
public const val LAYOUT_DIRECTION: Short = 0
public const val FLEX_DIRECTION: Short = 1
public const val FLEX: Short = 2
public const val FLEX_GROW: Short = 3
public const val FLEX_SHRINK: Short = 4
public const val FLEX_BASIS: Short = 5
public const val FLEX_BASIS_PERCENT: Short = 6
public const val FLEX_BASIS_AUTO: Short = 7
public const val FLEX_WRAP: Short = 8
public const val WIDTH: Short = 9
public const val WIDTH_PERCENT: Short = 10
public const val WIDTH_AUTO: Short = 11
public const val MIN_WIDTH: Short = 12
public const val MIN_WIDTH_PERCENT: Short = 13
public const val MAX_WIDTH: Short = 14
public const val MAX_WIDTH_PERCENT: Short = 15
public const val HEIGHT: Short = 16
public const val HEIGHT_PERCENT: Short = 17
public const val HEIGHT_AUTO: Short = 18
public const val MIN_HEIGHT: Short = 19
public const val MIN_HEIGHT_PERCENT: Short = 20
public const val MAX_HEIGHT: Short = 21
public const val MAX_HEIGHT_PERCENT: Short = 22
public const val JUSTIFY_CONTENT: Short = 23
public const val ALIGN_ITEMS: Short = 24
public const val ALIGN_SELF: Short = 25
public const val ALIGN_CONTENT: Short = 26
public const val POSITION_TYPE: Short = 27
public const val ASPECT_RATIO: Short = 28
public const val OVERFLOW: Short = 29
public const val DISPLAY: Short = 30
public const val MARGIN: Short = 31
public const val MARGIN_PERCENT: Short = 32
public const val MARGIN_AUTO: Short = 33
public const val PADDING: Short = 34
public const val PADDING_PERCENT: Short = 35
public const val BORDER: Short = 36
public const val POSITION: Short = 37
public const val POSITION_PERCENT: Short = 38
public const val IS_REFERENCE_BASELINE: Short = 39
}

View File

@@ -13,7 +13,10 @@ public enum YogaUnit {
UNDEFINED(0),
POINT(1),
PERCENT(2),
AUTO(3);
AUTO(3),
MAX_CONTENT(4),
FIT_CONTENT(5),
STRETCH(6);
private final int mIntValue;
@@ -31,6 +34,9 @@ public enum YogaUnit {
case 1: return POINT;
case 2: return PERCENT;
case 3: return AUTO;
case 4: return MAX_CONTENT;
case 5: return FIT_CONTENT;
case 6: return STRETCH;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

View File

@@ -1,18 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.CLASS;
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
@Retention(CLASS)
public @interface DoNotStrip { }

View File

@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga.annotations
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.FIELD,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER,
AnnotationTarget.CONSTRUCTOR,
)
@Retention(AnnotationRetention.BINARY)
public annotation class DoNotStrip

View File

@@ -429,6 +429,28 @@ static void jni_YGNodeCopyStyleJNI(
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
}
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(name) \
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name)
#define YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(name) \
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name)
#define YG_NODE_JNI_STYLE_UNIT_INTRINSIC(name) \
static void jni_YGNodeStyleSet##name##MaxContentJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
YGNodeStyleSet##name##MaxContent(_jlong2YGNodeRef(nativePointer)); \
} \
static void jni_YGNodeStyleSet##name##FitContentJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
YGNodeStyleSet##name##FitContent(_jlong2YGNodeRef(nativePointer)); \
} \
static void jni_YGNodeStyleSet##name##StretchJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { \
YGNodeStyleSet##name##Stretch(_jlong2YGNodeRef(nativePointer)); \
}
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static jlong jni_YGNodeStyleGet##name##JNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
@@ -460,6 +482,14 @@ static void jni_YGNodeCopyStyleJNI(
static_cast<float>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static void jni_YGNodeStyleSet##name##AutoJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
YGNodeStyleSet##name##Auto( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
@@ -467,6 +497,7 @@ YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGBoxSizing, BoxSizing);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
@@ -474,15 +505,15 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, Flex);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(FlexBasis);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Width);
YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(FlexBasis);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(Width);
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MinWidth);
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MaxWidth);
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO_INTRINSIC(Height);
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MinHeight);
YG_NODE_JNI_STYLE_UNIT_PROP_INTRINSIC(MaxHeight);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(Position);
static jlong jni_YGNodeStyleGetMarginJNI(
JNIEnv* /*env*/,
@@ -694,13 +725,13 @@ jni_YGNodeCloneJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
return reinterpret_cast<jlong>(clonedYogaNode);
}
static jfloat jni_YGNodeStyleGetGapJNI(
static jlong jni_YGNodeStyleGetGapJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer,
jint gutter) {
return (jfloat)YGNodeStyleGetGap(
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter));
return YogaValue::asJavaLong(YGNodeStyleGetGap(
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter)));
}
static void jni_YGNodeStyleSetGapJNI(
@@ -811,6 +842,12 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetPositionTypeJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetPositionTypeJNI},
{"jni_YGNodeStyleGetBoxSizingJNI",
"(J)I",
(void*)jni_YGNodeStyleGetBoxSizingJNI},
{"jni_YGNodeStyleSetBoxSizingJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetBoxSizingJNI},
{"jni_YGNodeStyleGetFlexWrapJNI",
"(J)I",
(void*)jni_YGNodeStyleGetFlexWrapJNI},
@@ -855,6 +892,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetFlexBasisAutoJNI",
"(J)V",
(void*)jni_YGNodeStyleSetFlexBasisAutoJNI},
{"jni_YGNodeStyleSetFlexBasisMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetFlexBasisMaxContentJNI},
{"jni_YGNodeStyleSetFlexBasisFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetFlexBasisFitContentJNI},
{"jni_YGNodeStyleSetFlexBasisStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetFlexBasisStretchJNI},
{"jni_YGNodeStyleGetMarginJNI",
"(JI)J",
(void*)jni_YGNodeStyleGetMarginJNI},
@@ -891,6 +937,9 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetPositionPercentJNI",
"(JIF)V",
(void*)jni_YGNodeStyleSetPositionPercentJNI},
{"jni_YGNodeStyleSetPositionAutoJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetPositionAutoJNI},
{"jni_YGNodeStyleGetWidthJNI", "(J)J", (void*)jni_YGNodeStyleGetWidthJNI},
{"jni_YGNodeStyleSetWidthJNI", "(JF)V", (void*)jni_YGNodeStyleSetWidthJNI},
{"jni_YGNodeStyleSetWidthPercentJNI",
@@ -899,6 +948,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetWidthAutoJNI",
"(J)V",
(void*)jni_YGNodeStyleSetWidthAutoJNI},
{"jni_YGNodeStyleSetWidthMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetWidthMaxContentJNI},
{"jni_YGNodeStyleSetWidthFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetWidthFitContentJNI},
{"jni_YGNodeStyleSetWidthStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetWidthStretchJNI},
{"jni_YGNodeStyleGetHeightJNI", "(J)J", (void*)jni_YGNodeStyleGetHeightJNI},
{"jni_YGNodeStyleSetHeightJNI",
"(JF)V",
@@ -909,6 +967,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetHeightAutoJNI",
"(J)V",
(void*)jni_YGNodeStyleSetHeightAutoJNI},
{"jni_YGNodeStyleSetHeightMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetHeightMaxContentJNI},
{"jni_YGNodeStyleSetHeightFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetHeightFitContentJNI},
{"jni_YGNodeStyleSetHeightStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetHeightStretchJNI},
{"jni_YGNodeStyleGetMinWidthJNI",
"(J)J",
(void*)jni_YGNodeStyleGetMinWidthJNI},
@@ -918,6 +985,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetMinWidthPercentJNI",
"(JF)V",
(void*)jni_YGNodeStyleSetMinWidthPercentJNI},
{"jni_YGNodeStyleSetMinWidthMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMinWidthMaxContentJNI},
{"jni_YGNodeStyleSetMinWidthFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMinWidthFitContentJNI},
{"jni_YGNodeStyleSetMinWidthStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMinWidthStretchJNI},
{"jni_YGNodeStyleGetMinHeightJNI",
"(J)J",
(void*)jni_YGNodeStyleGetMinHeightJNI},
@@ -927,6 +1003,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetMinHeightPercentJNI",
"(JF)V",
(void*)jni_YGNodeStyleSetMinHeightPercentJNI},
{"jni_YGNodeStyleSetMinHeightMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMinHeightMaxContentJNI},
{"jni_YGNodeStyleSetMinHeightFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMinHeightFitContentJNI},
{"jni_YGNodeStyleSetMinHeightStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMinHeightStretchJNI},
{"jni_YGNodeStyleGetMaxWidthJNI",
"(J)J",
(void*)jni_YGNodeStyleGetMaxWidthJNI},
@@ -936,6 +1021,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetMaxWidthPercentJNI",
"(JF)V",
(void*)jni_YGNodeStyleSetMaxWidthPercentJNI},
{"jni_YGNodeStyleSetMaxWidthMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMaxWidthMaxContentJNI},
{"jni_YGNodeStyleSetMaxWidthFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMaxWidthFitContentJNI},
{"jni_YGNodeStyleSetMaxWidthStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMaxWidthStretchJNI},
{"jni_YGNodeStyleGetMaxHeightJNI",
"(J)J",
(void*)jni_YGNodeStyleGetMaxHeightJNI},
@@ -945,6 +1039,15 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetMaxHeightPercentJNI",
"(JF)V",
(void*)jni_YGNodeStyleSetMaxHeightPercentJNI},
{"jni_YGNodeStyleSetMaxHeightMaxContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMaxHeightMaxContentJNI},
{"jni_YGNodeStyleSetMaxHeightFitContentJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMaxHeightFitContentJNI},
{"jni_YGNodeStyleSetMaxHeightStretchJNI",
"(J)V",
(void*)jni_YGNodeStyleSetMaxHeightStretchJNI},
{"jni_YGNodeStyleGetAspectRatioJNI",
"(J)F",
(void*)jni_YGNodeStyleGetAspectRatioJNI},
@@ -954,7 +1057,7 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeSetHasMeasureFuncJNI",
"(JZ)V",
(void*)jni_YGNodeSetHasMeasureFuncJNI},
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*)jni_YGNodeStyleGetGapJNI},
{"jni_YGNodeStyleGetGapJNI", "(JI)J", (void*)jni_YGNodeStyleGetGapJNI},
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
{"jni_YGNodeStyleSetGapPercentJNI",
"(JIF)V",

View File

@@ -1,393 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<b1b955741beb678b9f3f72a74ad0ae50>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class YGDisplayTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_display_none() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_fixed_size() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(20f);
root_child1.setHeight(20f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root_child0.setWidth(20f);
root_child0.setHeight(20f);
root_child0.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_child() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasisPercent(0f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = createNode(config);
root_child1_child0.setFlexGrow(1f);
root_child1_child0.setFlexShrink(1f);
root_child1_child0.setFlexBasisPercent(0f);
root_child1_child0.setWidth(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setFlexGrow(1f);
root_child2.setFlexShrink(1f);
root_child2.setFlexBasisPercent(0f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_position() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setPosition(YogaEdge.TOP, 10f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_position_absolute() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root_child0.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.yoga.utils;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaFlexDirection;
public class TestUtils {
public static class intrinsicMeasureFunction implements YogaMeasureFunction {
private static float widthPerChar = 10;
private static float heightPerChar = 10;
@Override
public long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
String text = (String) node.getData();
float measuredWidth;
float measuredHeight;
if (widthMode == YogaMeasureMode.EXACTLY) {
measuredWidth = width;
} else if (widthMode == YogaMeasureMode.AT_MOST) {
measuredWidth = Math.min(text.length() * widthPerChar, width);
} else {
measuredWidth = text.length() * widthPerChar;
}
if (heightMode == YogaMeasureMode.EXACTLY) {
measuredHeight = height;
} else if (heightMode == YogaMeasureMode.AT_MOST) {
measuredHeight =
Math.min(
caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
? measuredWidth
: Math.max(measuredWidth, getWidestWordWidth(text))), height);
} else {
measuredHeight = caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
? measuredWidth
: Math.max(measuredWidth, getWidestWordWidth(text)));
}
return YogaMeasureOutput.make(measuredWidth, measuredHeight);
}
static float getWidestWordWidth(String text) {
int widestWordLength = 0;
String[] words = text.split(" ");
for (String word : words) {
int wordLength = word.length();
if (widestWordLength < wordLength) {
widestWordLength = wordLength;
}
}
return (float) widestWordLength * widthPerChar;
}
static float caclulateHeight(String text, float measuredWidth) {
if (text.length() * widthPerChar <= measuredWidth) {
return heightPerChar;
}
String[] words = text.split(" ");
float lines = 1;
float currentLineLength = 0;
for (String word : words) {
float wordWidth = word.length() * widthPerChar;
if (wordWidth > measuredWidth) {
if (currentLineLength > 0) {
lines++;
}
lines++;
currentLineLength = 0;
} else if (currentLineLength + wordWidth <= measuredWidth) {
currentLineLength += wordWidth + widthPerChar;
} else {
lines++;
currentLineLength = wordWidth + widthPerChar;
}
}
return (currentLineLength == 0 ? lines - 1 : lines) * heightPerChar;
}
}
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3ccb0b2604c647cde1c76fc2629a3113>>
* @generated SignedSource<<c4a613bef526a87ca88e3b28e1abc215>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAbsolutePositionTest {
@@ -69,6 +70,135 @@ public class YGAbsolutePositionTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_auto_right() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionAuto(YogaEdge.LEFT);
root_child0.setPosition(YogaEdge.RIGHT, 10f);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_right_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.LEFT, 10f);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_auto_right_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionAuto(YogaEdge.LEFT);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_end_bottom() {
YogaConfig config = YogaConfigFactory.create();

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bd8a962cdd17e27c9a61363c7e25044c>>
* @generated SignedSource<<cafd5a49032616243a68af66ae440904>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAlignContentTest {
@@ -5206,6 +5207,305 @@ public class YGAlignContentTest {
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_flex_end_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setAlignItems(YogaAlign.FLEX_END);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_START);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(75f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(250f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(75f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(250f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_flex_start_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_center_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setAlignItems(YogaAlign.CENTER);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(38f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(213f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(38f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(213f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_stretch_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<17eb6adbebe0409ff047a82dc3257d91>>
* @generated SignedSource<<84597dd8b2c4f3aac1f21abe68f25308>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAlignItemsTest {
@@ -2292,6 +2293,86 @@ public class YGAlignItemsTest {
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_items_non_stretch_s526008() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(400f);
root.setHeight(400f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setAlignItems(YogaAlign.FLEX_START);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child0_child0_child0_child0 = createNode(config);
root_child0_child0_child0_child0.setHeight(10f);
root_child0_child0_child0.addChildAt(root_child0_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(400f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<473604215dcf5ee686799fe2c2dc2004>>
* @generated SignedSource<<90c29809153285d8773124e93961ba55>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAlignSelfTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<a6047e80a41c4f9d4de130eaba8f57c0>>
* @generated SignedSource<<245b1ad71f126cebcb48b66239bbc759>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAndroidNewsFeed {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<474f52d92a8fc32c66d5b5c1cc446124>>
* @generated SignedSource<<37a01c67158df025b1b43b8378071746>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAspectRatioTest {
@@ -178,6 +179,46 @@ public class YGAspectRatioTest {
assertEquals(197f, root_child0_child0_child2_child0_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_zero_aspect_ratio_behaves_like_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setAspectRatio(0 / 1f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(250f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -0,0 +1,325 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<30103b31d09984d8443cf1ba544adeb7>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAutoTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAutoTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_auto_width() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidthAuto();
root.setHeight(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(150f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(150f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
root.setHeightAuto();
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_flex_basis() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_position() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
root.setHeight(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(25f);
root_child0.setHeight(25f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
root.setHeight(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setWidth(25f);
root_child0.setHeight(25f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c313aae6965f21b021d2dae0af1173bf>>
* @generated SignedSource<<d4e5fb968cdc2a3a64ddc14d21e8f867>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGBorderTest {

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0f79d7debf11777b10de09656cb38147>>
* @generated SignedSource<<6a430747c0b764e9fb683f023b45391a>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGDimensionTest {

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<be0d102e74e15f15050520f21afcaee1>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayContentsTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGDisplayContentsTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_test1() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setDisplay(YogaDisplay.CONTENTS);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0_child0.setFlexBasisPercent(0f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setFlexGrow(1f);
root_child0_child1.setFlexShrink(1f);
root_child0_child1.setFlexBasisPercent(0f);
root_child0_child1.setHeight(20f);
root_child0.addChildAt(root_child0_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5bb2b698f40c9c95737a77fff84f7700>>
* @generated SignedSource<<5e698842feb033db77ff508df3f33b4a>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGFlexDirectionTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<744d504e2ab572337ace7a2589bc3570>>
* @generated SignedSource<<a33d3aa3ed335ded287fa37f788c321c>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGFlexTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ef62c060fc074248a6d6db6c619f38d4>>
* @generated SignedSource<<f977e27ada480c9023d16368fae4fab2>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGFlexWrapTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bb0dd2eb7bd992caee5efdd08b65a756>>
* @generated SignedSource<<feba5f3f4c830be8a570d3a4c9deb8eb>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGGapTest {

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<a4f2e216ee29aa4a703244d1e18e5c3b>>
* @generated SignedSource<<ebd50ee9980922e7e6f3beabff5375ea>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGJustifyContentTest {
@@ -1789,6 +1790,7 @@ public class YGJustifyContentTest {
}
@Test
@Ignore
public void test_justify_content_overflow_row_reverse_space_around() {
YogaConfig config = YogaConfigFactory.create();
@@ -1818,17 +1820,17 @@ public class YGJustifyContentTest {
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
@@ -1841,23 +1843,24 @@ public class YGJustifyContentTest {
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(-18f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(62f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
@Ignore
public void test_justify_content_overflow_row_reverse_space_evenly() {
YogaConfig config = YogaConfigFactory.create();
@@ -1887,17 +1890,17 @@ public class YGJustifyContentTest {
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
@@ -1910,17 +1913,17 @@ public class YGJustifyContentTest {
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(-18f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(62f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<be80692a6b8a8fee76e2060f62f9ae36>>
* @generated SignedSource<<f9410af3e2849999ef3aec09cebbeef1>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGMarginTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<857e5626695bb6b524eb6b609a6c7b55>>
* @generated SignedSource<<19cdc4fc9425af726b656ef628bab8af>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGMinMaxDimensionTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<e7b2dc11dc748322103e0c8d1196dc64>>
* @generated SignedSource<<6116c0f130b77b635a6551b3204c3cf8>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGPaddingTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<baefd1632c2e9c66e4c42114856aa74f>>
* @generated SignedSource<<27e18496d4ee880d9ba95ad0b2648071>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGPercentageTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<40959004b04825e4f8f58e8a6d796047>>
* @generated SignedSource<<06c18c6b3b9735644daf5b5bd0777eb8>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGRoundingTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<debde6a37b3a2ad5892a15611a2fa8ec>>
* @generated SignedSource<<26e773ec772f84370bc0f3f53d8221ed>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGSizeOverflowTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3bbbf27ae54f7b245d6adad352761339>>
* @generated SignedSource<<997d12880828a3c2881898b769618b43>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
*/
@@ -16,6 +16,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGStaticPositionTest {
@@ -5886,6 +5887,144 @@ public class YGStaticPositionTest {
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_static_position_absolute_child_multiple() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
final YogaNode root_child0 = createNode(config);
root_child0.setPadding(YogaEdge.LEFT, 100);
root_child0.setPadding(YogaEdge.TOP, 100);
root_child0.setPadding(YogaEdge.RIGHT, 100);
root_child0.setPadding(YogaEdge.BOTTOM, 100);
root_child0.setWidth(400f);
root_child0.setHeight(400f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setPositionType(YogaPositionType.STATIC);
root_child0_child0.setWidth(100f);
root_child0_child0.setHeight(100f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child0_child0.setWidthPercent(10f);
root_child0_child0_child0.setHeight(50f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setPositionType(YogaPositionType.STATIC);
root_child0_child1.setWidth(100f);
root_child0_child1.setHeight(100f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child1_child0 = createNode(config);
root_child0_child1_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child1_child0.setWidthPercent(50f);
root_child0_child1_child0.setHeight(50f);
root_child0_child1.addChildAt(root_child0_child1_child0, 0);
final YogaNode root_child0_child1_child1 = createNode(config);
root_child0_child1_child1.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child1_child1.setWidthPercent(50f);
root_child0_child1_child1.setHeight(50f);
root_child0_child1.addChildAt(root_child0_child1_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child2.setWidth(25f);
root_child0_child2.setHeight(50f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(400f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(400f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(275f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -23,7 +23,7 @@ const {
const {existsSync} = require('fs');
const {readFile, writeFile, rm} = require('fs/promises');
const glob = require('glob');
const {glob} = require('glob');
const path = require('path');
const which = require('which');

View File

@@ -38,14 +38,13 @@
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.23.0",
"@babel/preset-typescript": "^7.23.0",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.1",
"@types/node": "^16.18.25",
"@types/which": "^3.0.0",
"@yogalayout/cmake-bin": "3.28.0-1",
"babel-register-esm": "^1.2.5",
"clang-format": "^1.8.0",
"glob": "^8.0.3",
"glob": "^10.4.2",
"jest": "^29.3.1",
"just-scripts": "^2.1.0",
"ninja-binaries": "^1.11.1",

View File

@@ -75,6 +75,10 @@ void Node::copyStyle(Node const& other) {
YGNodeCopyStyle(m_node, other.m_node);
}
void Node::setBoxSizing(int boxSizing) {
YGNodeStyleSetBoxSizing(m_node, static_cast<YGBoxSizing>(boxSizing));
}
void Node::setPositionType(int positionType) {
YGNodeStyleSetPositionType(m_node, static_cast<YGPositionType>(positionType));
}
@@ -87,6 +91,10 @@ void Node::setPositionPercent(int edge, double position) {
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position);
}
void Node::setPositionAuto(int edge) {
YGNodeStyleSetPositionAuto(m_node, static_cast<YGEdge>(edge));
}
void Node::setAlignContent(int alignContent) {
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
}
@@ -152,6 +160,18 @@ void Node::setFlexBasisAuto() {
YGNodeStyleSetFlexBasisAuto(m_node);
}
void Node::setFlexBasisMaxContent() {
YGNodeStyleSetFlexBasisMaxContent(m_node);
}
void Node::setFlexBasisFitContent() {
YGNodeStyleSetFlexBasisFitContent(m_node);
}
void Node::setFlexBasisStretch() {
YGNodeStyleSetFlexBasisStretch(m_node);
}
void Node::setFlexGrow(double flexGrow) {
YGNodeStyleSetFlexGrow(m_node, flexGrow);
}
@@ -172,6 +192,18 @@ void Node::setWidthAuto() {
YGNodeStyleSetWidthAuto(m_node);
}
void Node::setWidthMaxContent() {
YGNodeStyleSetWidthMaxContent(m_node);
}
void Node::setWidthFitContent() {
YGNodeStyleSetWidthFitContent(m_node);
}
void Node::setWidthStretch() {
YGNodeStyleSetWidthStretch(m_node);
}
void Node::setHeight(double height) {
YGNodeStyleSetHeight(m_node, height);
}
@@ -184,6 +216,18 @@ void Node::setHeightAuto() {
YGNodeStyleSetHeightAuto(m_node);
}
void Node::setHeightMaxContent() {
YGNodeStyleSetHeightMaxContent(m_node);
}
void Node::setHeightFitContent() {
YGNodeStyleSetHeightFitContent(m_node);
}
void Node::setHeightStretch() {
YGNodeStyleSetHeightStretch(m_node);
}
void Node::setMinWidth(double minWidth) {
YGNodeStyleSetMinWidth(m_node, minWidth);
}
@@ -192,6 +236,18 @@ void Node::setMinWidthPercent(double minWidth) {
YGNodeStyleSetMinWidthPercent(m_node, minWidth);
}
void Node::setMinWidthMaxContent() {
YGNodeStyleSetMinWidthMaxContent(m_node);
}
void Node::setMinWidthFitContent() {
YGNodeStyleSetMinWidthFitContent(m_node);
}
void Node::setMinWidthStretch() {
YGNodeStyleSetMinWidthStretch(m_node);
}
void Node::setMinHeight(double minHeight) {
YGNodeStyleSetMinHeight(m_node, minHeight);
}
@@ -200,6 +256,18 @@ void Node::setMinHeightPercent(double minHeight) {
YGNodeStyleSetMinHeightPercent(m_node, minHeight);
}
void Node::setMinHeightMaxContent() {
YGNodeStyleSetMinHeightMaxContent(m_node);
}
void Node::setMinHeightFitContent() {
YGNodeStyleSetMinHeightFitContent(m_node);
}
void Node::setMinHeightStretch() {
YGNodeStyleSetMinHeightStretch(m_node);
}
void Node::setMaxWidth(double maxWidth) {
YGNodeStyleSetMaxWidth(m_node, maxWidth);
}
@@ -208,6 +276,18 @@ void Node::setMaxWidthPercent(double maxWidth) {
YGNodeStyleSetMaxWidthPercent(m_node, maxWidth);
}
void Node::setMaxWidthMaxContent() {
YGNodeStyleSetMaxWidthMaxContent(m_node);
}
void Node::setMaxWidthFitContent() {
YGNodeStyleSetMaxWidthFitContent(m_node);
}
void Node::setMaxWidthStretch() {
YGNodeStyleSetMaxWidthStretch(m_node);
}
void Node::setMaxHeight(double maxHeight) {
YGNodeStyleSetMaxHeight(m_node, maxHeight);
}
@@ -216,6 +296,18 @@ void Node::setMaxHeightPercent(double maxHeight) {
YGNodeStyleSetMaxHeightPercent(m_node, maxHeight);
}
void Node::setMaxHeightMaxContent() {
YGNodeStyleSetMaxHeightMaxContent(m_node);
}
void Node::setMaxHeightFitContent() {
YGNodeStyleSetMaxHeightFitContent(m_node);
}
void Node::setMaxHeightStretch() {
YGNodeStyleSetMaxHeightStretch(m_node);
}
void Node::setAspectRatio(double aspectRatio) {
YGNodeStyleSetAspectRatio(m_node, aspectRatio);
}
@@ -244,6 +336,10 @@ void Node::setGapPercent(int gutter, double gapLength) {
YGNodeStyleSetGapPercent(m_node, static_cast<YGGutter>(gutter), gapLength);
}
int Node::getBoxSizing(void) const {
return YGNodeStyleGetBoxSizing(m_node);
}
int Node::getPositionType(void) const {
return YGNodeStyleGetPositionType(m_node);
}
@@ -343,8 +439,9 @@ Value Node::getPadding(int edge) const {
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
}
float Node::getGap(int gutter) {
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
Value Node::getGap(int gutter) const {
return Value::fromYGValue(
YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)));
}
bool Node::isReferenceBaseline() {

View File

@@ -76,6 +76,7 @@ class Node {
void setPositionType(int positionType);
void setPosition(int edge, double position);
void setPositionPercent(int edge, double position);
void setPositionAuto(int edge);
void setAlignContent(int alignContent);
void setAlignItems(int alignItems);
@@ -96,25 +97,46 @@ class Node {
void setFlexBasis(double flexBasis);
void setFlexBasisPercent(double flexBasis);
void setFlexBasisAuto();
void setFlexBasisMaxContent();
void setFlexBasisFitContent();
void setFlexBasisStretch();
void setFlexGrow(double flexGrow);
void setFlexShrink(double flexShrink);
void setWidth(double width);
void setWidthPercent(double width);
void setWidthAuto();
void setWidthMaxContent();
void setWidthFitContent();
void setWidthStretch();
void setHeight(double height);
void setHeightPercent(double height);
void setHeightAuto();
void setHeightMaxContent();
void setHeightFitContent();
void setHeightStretch();
void setMinWidth(double minWidth);
void setMinWidthPercent(double minWidth);
void setMinWidthMaxContent();
void setMinWidthFitContent();
void setMinWidthStretch();
void setMinHeight(double minHeight);
void setMinHeightPercent(double minHeight);
void setMinHeightMaxContent();
void setMinHeightFitContent();
void setMinHeightStretch();
void setMaxWidth(double maxWidth);
void setMaxWidthPercent(double maxWidth);
void setMaxWidthMaxContent();
void setMaxWidthFitContent();
void setMaxWidthStretch();
void setMaxHeight(double maxHeight);
void setMaxHeightPercent(double maxHeight);
void setMaxHeightMaxContent();
void setMaxHeightFitContent();
void setMaxHeightStretch();
void setAspectRatio(double aspectRatio);
@@ -126,6 +148,8 @@ class Node {
void setGap(int gutter, double gapLength);
void setGapPercent(int gutter, double gapLength);
void setBoxSizing(int boxSizing);
public: // Style getters
int getPositionType(void) const;
Value getPosition(int edge) const;
@@ -162,7 +186,9 @@ class Node {
Value getPadding(int edge) const;
float getGap(int gutter);
Value getGap(int gutter) const;
int getBoxSizing(void) const;
public: // Tree hierarchy mutators
void insertChild(Node* child, unsigned index);

View File

@@ -70,6 +70,7 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setPositionType", &Node::setPositionType)
.function("setPosition", &Node::setPosition)
.function("setPositionPercent", &Node::setPositionPercent)
.function("setPositionAuto", &Node::setPositionAuto)
.function("setAlignContent", &Node::setAlignContent)
.function("setAlignItems", &Node::setAlignItems)
@@ -89,25 +90,48 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setFlexBasis", &Node::setFlexBasis)
.function("setFlexBasisPercent", &Node::setFlexBasisPercent)
.function("setFlexBasisAuto", &Node::setFlexBasisAuto)
.function("setFlexBasisMaxContent", &Node::setFlexBasisMaxContent)
.function("setFlexBasisFitContent", &Node::setFlexBasisFitContent)
.function("setFlexBasisStretch", &Node::setFlexBasisStretch)
.function("setFlexGrow", &Node::setFlexGrow)
.function("setFlexShrink", &Node::setFlexShrink)
.function("setWidth", &Node::setWidth)
.function("setWidthPercent", &Node::setWidthPercent)
.function("setWidthAuto", &Node::setWidthAuto)
.function("setWidthMaxContent", &Node::setWidthMaxContent)
.function("setWidthFitContent", &Node::setWidthFitContent)
.function("setWidthStretch", &Node::setWidthStretch)
.function("setHeight", &Node::setHeight)
.function("setHeightPercent", &Node::setHeightPercent)
.function("setHeightAuto", &Node::setHeightAuto)
.function("setHeightMaxContent", &Node::setHeightMaxContent)
.function("setHeightFitContent", &Node::setHeightFitContent)
.function("setHeightStretch", &Node::setHeightStretch)
.function("setMinWidth", &Node::setMinWidth)
.function("setMinWidthPercent", &Node::setMinWidthPercent)
.function("setMinWidthMaxContent", &Node::setMinWidthMaxContent)
.function("setMinWidthFitContent", &Node::setMinWidthFitContent)
.function("setMinWidthStretch", &Node::setMinWidthStretch)
.function("setMinHeight", &Node::setMinHeight)
.function("setMinHeightPercent", &Node::setMinHeightPercent)
.function("setMinHeightMaxContent", &Node::setMinHeightMaxContent)
.function("setMinHeightFitContent", &Node::setMinHeightFitContent)
.function("setMinHeightStretch", &Node::setMinHeightStretch)
.function("setMaxWidth", &Node::setMaxWidth)
.function("setMaxWidthPercent", &Node::setMaxWidthPercent)
.function("setMaxWidthMaxContent", &Node::setMaxWidthMaxContent)
.function("setMaxWidthFitContent", &Node::setMaxWidthFitContent)
.function("setMaxWidthStretch", &Node::setMaxWidthStretch)
.function("setMaxHeight", &Node::setMaxHeight)
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
.function("setMaxHeightMaxContent", &Node::setMaxHeightMaxContent)
.function("setMaxHeightFitContent", &Node::setMaxHeightFitContent)
.function("setMaxHeightStretch", &Node::setMaxHeightStretch)
.function("setBoxSizing", &Node::setBoxSizing)
.function("setAspectRatio", &Node::setAspectRatio)
@@ -145,6 +169,8 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("getMaxWidth", &Node::getMaxWidth)
.function("getMaxHeight", &Node::getMaxHeight)
.function("getBoxSizing", &Node::getBoxSizing)
.function("getAspectRatio", &Node::getAspectRatio)
.function("getBorder", &Node::getBorder)

Some files were not shown because too many files have changed in this diff Show More