Compare commits

..

808 Commits

Author SHA1 Message Date
dependabot[bot]
e8121df8e0 Bump express from 4.19.2 to 4.21.0
Bumps [express](https://github.com/expressjs/express) from 4.19.2 to 4.21.0.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.0/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.19.2...4.21.0)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-21 11:06:14 +00: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
Richard Howell
baf670e261 make yogaApple modular
Summary:
X-link: https://github.com/facebook/react-native/pull/44938

Yoga is transitively included in Swift targets and needs to be modular.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D58469454

fbshipit-source-id: 72bc6b5d3e5ee0710d9334a626e4e7297ce26b09
2024-06-13 14:18:45 -07:00
Joe Vilches
289b62732b Fix issue with alternating flex direction and percent postions (#1663)
Summary:
X-link: https://github.com/facebook/react-native/pull/44792

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

Fixing https://github.com/facebook/yoga/issues/1658. We had a problem where if a child had a different flex direction than its parent, and it also set a position as a percent, it would look at the wrong axis to evaluate the percent. What was happening was we were passing in the container's mainAxis size and crossAxis size to use to evaluate the position size if it was a percent. However, we matched these sizes with the main/cross axis of the child - which is wrong if the flex direction is different.

I changed it so that the function just takes in ownerWidth and ownerHeight then calls isRow to determine which one to use for the main/cross axis position. This reduces the ambiguity quite a bit imo.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D58172416

fbshipit-source-id: eafd8069e03493fc56c41a76879d1ad9b7e9236d
2024-06-10 18:25:19 -07:00
Joe Vilches
72b7e5b5cf Fix issue where % width would be wrong if physical and relative padding defined on parent (#1662)
Summary:
X-link: https://github.com/facebook/react-native/pull/44791

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

This should fix https://github.com/facebook/yoga/issues/1657. Rather insidious bug but we had code like

```
  // The total padding/border for a given axis does not depend on the direction
  // so hardcoding LTR here to avoid piping direction to this function
  return node->style().computeInlineStartPaddingAndBorder(
             axis, Direction::LTR, widthSize) +
      node->style().computeInlineEndPaddingAndBorder(
          axis, Direction::LTR, widthSize);
```

That comment is NOT true if someone sets both the physical edge and relative edge. So like paddingLeft and paddingEnd for RTL. This diff simply pipes the direction to that spot to use instead of hardcoding LTR. Every file changed is just to pipe `direction`.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D58169843

fbshipit-source-id: 5b4854dddc019285076bd06955557edf73ef7ec5
2024-06-10 18:25:19 -07:00
Nick Gerleman
fb53cb7443 Reland: Sanitize measure function results
Summary:
D57285584 was reverted because we have service code with a faulty measure function, and adding logging to Yoga when invalid measurements were received was enough to spike error rate to elevated levels and block release.

This is a reland of the below change, with a couple modifications:
1. We log warnings instead of errors, which from what I heard, shouldn't block release, but should still make signal
2. We only zero the dimension which was NaN, to preserve exact behavior

## Original

We've started seeing assertion failures in Yoga where a `NaN` value makes its way to an `availableHeight` constraint when measuring Litho tree.

Because it's only happening on Litho, I have some suspicion this might be originating from a Litho-specific measure function. This adds sanitization in Yoga to measure function results, where we will log an error, and set size to zero, if either dimension ends up being negative of `NaN`.

This doesn't really help track down where the error was happening, but Yoga doesn't have great context to show this to begin with. If we see this is issue, next steps would be Litho internal intrumentation to find culprit.

Changelog: [Internal]

Reviewed By: sbuggay

Differential Revision: D57473295

fbshipit-source-id: 979f1b9a51f5550a8d3ca534276ec191a3cb7b9e
2024-05-17 19:12:13 -07:00
Gilad Bar
24f0c56cce Revert D57285584: Sanitize measure function results
Differential Revision:
D57285584

Original commit changeset: 935fcdd28c05

Original Phabricator Diff: D57285584

fbshipit-source-id: 3c5d7ccefd608885af4d6f08c0d1cd00553f1f34
2024-05-14 07:13:21 -07:00
Nick Gerleman
eb1ca8ec7a Sanitize measure function results
Summary:
X-link: https://github.com/facebook/react-native/pull/44557

We've started seeing assertion failures in Yoga where a `NaN` value makes its way to an `availableHeight` constraint when measuring Litho tree.

Because it's only happening on Litho, I have some suspicion this might be originating from a Litho-specific measure function. This adds sanitization in Yoga to measure function results, where we will log an error, and set size to zero, if either dimension ends up being negative of `NaN`.

This doesn't really help track down where the error was happening, but Yoga doesn't have great context to show this to begin with. If we see this is issue, next steps would be Litho internal intrumentation to find culprit.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D57285584

fbshipit-source-id: 935fcdd28c05bbac0d73e1c7654ae11a74898537
2024-05-13 17:12:49 -07:00
Joe Vilches
dc23284cf7 Add some tests for padding and border for absolute positioning (#1650)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1650

See https://github.com/facebook/yoga/issues/1436#issuecomment-2070877918

Reviewed By: NickGerleman

Differential Revision: D56478788

fbshipit-source-id: 94a552ed55eb4127eddc6c2018706661fff64093
2024-04-23 21:02:36 -07:00
Nick Gerleman
932361cdbf Fixup margin: auto and justification behavior for overflowed containers (#1646)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1646

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

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

1. Don't allow auto margin spaces to become a negative length
2. Replicate fallback alignment behavior specified by box-alignment spec that we are using for align-content.

Reviewed By: joevilches

Differential Revision: D56091577

fbshipit-source-id: 3c02f81f969bb947cdc5c80b15faaa0b0d39c0c2
2024-04-17 21:50:55 -07:00
Nick Gerleman
c0239e338f Fix JS build on Windows (#1648)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1648

Node made a breaking change in a security release for 18/20 where `spawn()` no longer loads `.bat` files by default. 69ffc6d50d. Execute command in shell.

Reviewed By: javache

Differential Revision: D56230965

fbshipit-source-id: 52e9bd8a76664bd07ea25b6355ac54fcb24cbb9a
2024-04-17 03:03:02 -07:00
Soe Lynn
cd4a1b8cf6 Implement Percentage support for gap styles (#1643)
Summary:
X-link: https://github.com/facebook/react-native/pull/44067

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

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

Changelog [Internal]:
- Added percentage value for flex layout gap
- Wired up to pass proper available width and height to implement this feature

Reviewed By: NickGerleman

Differential Revision: D56002340

fbshipit-source-id: c0bc86ac70a1391f115c87da99c2ef411535f68b
2024-04-15 16:44:16 -07:00
Nick Gerleman
d4247d65c0 Don't run test validation off main branch (#1644)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1644

Because Chrome behaviors can change

Reviewed By: cortinico

Differential Revision: D56088135

fbshipit-source-id: 7f760786dde061df9af034368e2184117e6e6846
2024-04-15 10:43:25 -07:00
Nick Gerleman
617fd3a6b7 Isolate Distributed JavaScript (#1645)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1645

Right now we publish Yoga by transforming in-place, and rewriting the entrypoint to point to the generated vanilla JavaScript.

It is nice to include the original source, e.g. so that users can use sourcemaps when debugging, but putting these files on top of each other has been causing problems, like https://github.com/facebook/yoga/issues/1637#issuecomment-2049099690

This changes the packaging step to instead put all the outputs into a "dist" folder, and point the package entrypoints there. We still include original source for sourcemap usage.

Reviewed By: yungsters

Differential Revision: D56093470

fbshipit-source-id: ecd52dddd9040294aae66747cf1fdf48c7f602e7
2024-04-15 09:28:23 -07:00
Nick Gerleman
70de2da05f Make new nodes dirty by default (#1641)
Summary:
X-link: https://github.com/facebook/react-native/pull/44010

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

Yoga has quirk where newly constructed nodes are clean, which isn't really correct. Normally never shows in in real code because setting a style or children  will dirty. Fabric doesn't use the public APIs that do this dirtying, so it ends up getting creative instead.

We should fix so that newly constructed nodes are dirty. Copy-constructed Nodes (also only a Fabric thing, will retain original dirty flag.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D55855328

fbshipit-source-id: be49efaf8ac29351f8e5ec509bd9912546944332
2024-04-10 22:15:25 -07:00
Bela Bohlender
bbdd1afe59 Entry point without TLA for js package (#1638)
Summary:
Follow up on https://github.com/facebook/yoga/issues/1637

TLDR: tooling for TLA is not there yet; An additional entry point without top-level-await is appropriate

- adds ./load entry to js package
- uses .js file extensions to prevent requiring [allowImportingTsExtensions](https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions)

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

Reviewed By: joevilches

Differential Revision: D55614636

Pulled By: NickGerleman

fbshipit-source-id: 126a94aa68d22d32b938282cfa1a5059bb9df337
2024-04-08 12:04:08 -07:00
Joe Vilches
194f83dea5 Add mobile yoga tree captures (#1640)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1640

Added two captures that were captured from a mobile device.

**profile-ios**: A profile-like view with a central picture and some text information underneath. Captured on iOS device
**feed-android** A feed-like view with a scrollable list of images and text. Captured on Android device.

Fixed a bug that would not deserialize undefined values

Reviewed By: NickGerleman

Differential Revision: D55712235

fbshipit-source-id: ed32b393c088c695d8191149c729e51008df4e7e
2024-04-05 14:01:54 -07:00
Nick Gerleman
6f10656868 Update align-content handling of overflow
Summary:
X-link: https://github.com/facebook/react-native/pull/43752

Gentest tests started failing because Chrome changed behavior of overflowed align-content container. Spec says should fallback to "safe center", which is really just "start", instead of previous "center" behavior. This changes behavior accordingly.

There is one bit where I think we are doing the wrong thing wrt alignment of flex start vs start (which we don't support yet), but couldn't repro a failing chrome test.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D55617689

fbshipit-source-id: 08f23d198c75f2c2f51ccaa8795289e6e4a92cb8
2024-04-02 04:47:09 -07:00
Nick Gerleman
f12d436314 Yoga Docs: Fix Yoga 3.0 Release Data (#1635)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1635

Accidentally set to May instead of March.

Differential Revision: D55286740

fbshipit-source-id: 260f15258b265a79a2017a57152f41e4d67b6a68
2024-03-24 00:20:09 -07:00
Willson Haw
5cbc7b4f1c Add JavaScript bindings for YGHasNewLayout (#1631)
Summary:
Adds JavaScript bindings for YGHasNewLayout which introduces
two new node methods: `hasNewLayout()` and `markLayoutSeen()`.

Closes https://github.com/facebook/yoga/issues/681

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

Reviewed By: joevilches

Differential Revision: D55213296

Pulled By: NickGerleman

fbshipit-source-id: 161288c3f54c2b82a6b2b842387916fe8713c2c9
2024-03-21 17:36:36 -07:00
Bruce Mitchener
9dcd8ba9dc Fix typos. (#1629)
Summary:
This fixes a variety of spelling mistakes in file names, identifiers, and comments.

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

Reviewed By: NickGerleman

Differential Revision: D54987359

Pulled By: yungsters

fbshipit-source-id: 6b7ca20f4855f5f654036672bc10f8b079288acd
2024-03-19 02:52:40 -07:00
Nick Gerleman
6ef7be293a Fix some dependency warnings (#1628)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1628

Fixes https://github.com/facebook/yoga/pull/1627

Fixes https://github.com/facebook/yoga/pull/1584

Reviewed By: yungsters

Differential Revision: D54924246

fbshipit-source-id: 4fa9f3b5b03d4277f1ec48f6d4d97a0cca5c6d7e
2024-03-15 01:52:20 -07:00
Nick Gerleman
c54e0e7fed Yoga Docs: Remove Footer Links (#1623)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1623

I copied these over from the default Docusaurus template but they don't add much value, and it is too heavy/irrelevant right now.

Before:
{F1468497789}

After:
{F1468497977}

Reviewed By: joevilches

Differential Revision: D54886187

fbshipit-source-id: c9ad11c59c7809d14c7a110e0ee2dd735505e28a
2024-03-14 11:10:50 -07:00
Nick Gerleman
3c7ac064ad Yoga Docs: Label All JS/TS examples as JavaScript (#1620)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1620

A couple of these are labeled as TypeScript. We expose TypeScript types, but this also works as plain-old JavaScript, and is the label we use in most of the documentaion.

Reviewed By: joevilches

Differential Revision: D54884484

fbshipit-source-id: 763c56843a797db0a4f78776c55397eaa9b4a966
2024-03-14 11:10:50 -07:00
Nick Gerleman
522a2bfbef Yoga Docs: Fix a couple files missed in rename (#1621)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1621

These changes accidentally got removed when rebasing.

Reviewed By: joevilches

Differential Revision: D54884103

fbshipit-source-id: d2b6562be1a05934b5f19e3dd6f9e8e451377560
2024-03-14 11:10:50 -07:00
Nick Gerleman
4d3f323fa5 Yoga Docs: tweak Yoga 3.0 Relase Notes (#1622)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1622

Update the date, link to some documentation we added, small other tweaks for consistency.

Reviewed By: joevilches

Differential Revision: D54883806

fbshipit-source-id: f20a8f1aa51c1dfe1b205aa0a3b530ef5632ffd2
2024-03-14 11:10:50 -07:00
Nick Gerleman
206b95aba5 Yoga Docs: Rename website-next to website (#1613)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1613

So that GitHub links to edit a page point to the right place.

This will fail in OSS build until I switch the directory used by Vercel instance, but I am waiting to do that until ready to land, since that would cause other in progress changes to fail when exported.

Reviewed By: joevilches

Differential Revision: D54837857

fbshipit-source-id: 9bec90232dbe3ec8638568685671185d597fcf2d
2024-03-13 17:25:39 -07:00
Nick Gerleman
108c2f30a2 Yoga Docs: Delete the Old website (#1612)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1612

Moving new website to `/website` before publishing, so that edit links point to the right eventual place in the GitHub repo.

Reviewed By: joevilches

Differential Revision: D54837808

fbshipit-source-id: 46de8a638ad9bce18558fd768ed8c080892b828e
2024-03-13 15:53:21 -07:00
Nick Gerleman
d7faf2c101 Yoga Docs: Remove background color from playground section (#1611)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1611

Make it consistent everywhere

Before:
 {F1468059137}

After:
{F1468058347}

Reviewed By: joevilches

Differential Revision: D54835823

fbshipit-source-id: 87a7df758dc335861a3611d79aa6c8aef79ae9fa
2024-03-13 15:53:21 -07:00
Nick Gerleman
dfedfacd27 Yoga Docs: Fill out information about config, measure functions, incremental layout, box sizing, invalidation (#1610)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1610

Filling out a bunch more content.

 {F1468059666}

 {F1468059812}

 {F1468059886}

Reviewed By: joevilches

Differential Revision: D54831358

fbshipit-source-id: 0a988bcb7f32d4af8cc1803235ef529864176ddf
2024-03-13 15:53:21 -07:00
Joe Vilches
cafffebbe3 Add gap documentation (#1619)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1619

Reviewed By: NickGerleman

Differential Revision: D54859536

fbshipit-source-id: 8d351379bf6da936678bee22b208f7b6f5d161b8
2024-03-13 14:07:44 -07:00
Joe Vilches
281563501f Add documentation for space evenly in align content (#1617)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1617

tsia, this was added recently and did not exist in the old docs

Reviewed By: yungsters

Differential Revision: D54830687

fbshipit-source-id: bbc7c833fdabe281367edeb0fbdc85960fe982fb
2024-03-13 14:07:44 -07:00
Joe Vilches
20e05881a8 Add insets documentation (#1618)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1618

tsia

Reviewed By: NickGerleman

Differential Revision: D54830359

fbshipit-source-id: 999a7fa3659b41ae532dd00e5df739e91f23905b
2024-03-13 14:07:44 -07:00
Joe Vilches
609a9a7a30 Add containing block documentation (#1615)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1615

tsia

Reviewed By: yungsters

Differential Revision: D54822992

fbshipit-source-id: b98cd32bb2a753ff7088533fda4b4e9d4ad5a6e4
2024-03-13 10:19:30 -07:00
Joe Vilches
1db7a3ff61 Clean up certain style choices on website's example documentation (#1616)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1616

This is based on a few comments earlier in the stack and my own discretion on what should change. But I went through all of the examples and changed the following:

* Only add code tick marks in a few cases where it would make sense. Things like `start` and `end`, `undefined` as a value, etc. There ends up not being that many after this. Previously, any property or value was tick marked even if it was more of a concept than actual code. **I replaced those cases with a link to their respective documentation as I feel like this keeps the indication that this is a keyword without labeling it as code**.
* Any reference to "element" was changed to "node"
* Capitalize words that follow a colon
* Run code examples through prettier for consistent style

Reviewed By: yungsters

Differential Revision: D54816609

fbshipit-source-id: 20ee925cf46bd1c519cc88bab9327321e926ac56
2024-03-13 10:19:30 -07:00
Nick Gerleman
f4facf8990 Fixup npm package README
Summary: Remove some outdated information and make sure that npmjs shows the builtin TypeScript typings (now that we no longer have clever resolution schemes).

Reviewed By: javache

Differential Revision: D54788636

fbshipit-source-id: 76e7663924189fd68ac62b27730f44213b13ad85
2024-03-12 16:35:42 -07:00
Nick Gerleman
d1c6b9af78 Yoga Website: Tweak Playground visuals for embedding (#1608)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1608

Fixes up layout when embedded into document, and removes the copy button taking more horizontal real estate than it is worth, when we want to show a horizontal playground at 75% width.

Before:

{F1467611957}

{F1467613069}

{F1467613795}

After:

{F1467611817}

{F1467612896}

{F1467613557}

Reviewed By: javache

Differential Revision: D54787261

fbshipit-source-id: 2177d896baf81971d1b979c060eecf51535de4c5
2024-03-12 15:17:57 -07:00
Nick Gerleman
066e366246 Fill out "About Yoga", "Laying out a Yoga tree" , and "Styling" (#1591)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1591

Adds initial documentation to these sections.

Reviewed By: joevilches

Differential Revision: D54708141

fbshipit-source-id: b2c1ac20573840833a3e5fde8c7b53f2770cecbd
2024-03-12 15:17:57 -07:00
Joe Vilches
a0a09b4570 Add flex basis grow shrink documentation (#1607)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1607

tsia

Reviewed By: yungsters

Differential Revision: D54783674

fbshipit-source-id: 95530db0b129d8f0fb3e677430b9bfbf0662f590
2024-03-12 11:31:46 -07:00
Joe Vilches
25f94f8bfb Add align items self documentation (#1606)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1606

tsia

Reviewed By: yungsters

Differential Revision: D54783193

fbshipit-source-id: 66d5d58eefec827024b2e029be7cbee637c5484e
2024-03-12 11:31:46 -07:00
Joe Vilches
389e715257 Add align content documentation (#1605)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1605

tsia

Reviewed By: yungsters

Differential Revision: D54782553

fbshipit-source-id: a65aaa754ea98a8dfe3b581a7cdb06dddf35f64a
2024-03-12 11:31:46 -07:00
Joe Vilches
35fb3b2c49 Add flex wrap documentation (#1604)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1604

tsia

Reviewed By: yungsters

Differential Revision: D54782530

fbshipit-source-id: ae613b070557050646a28392e4cadebdb06f9b11
2024-03-12 11:31:46 -07:00
Joe Vilches
bb9d080d04 Add width/height documentation (#1603)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1603

tsia

Reviewed By: yungsters

Differential Revision: D54781571

fbshipit-source-id: 136ac9a89296bc5110b01d96243944ad716fa5e4
2024-03-12 11:31:46 -07:00
Joe Vilches
be59f394c4 Add position documentation (#1602)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1602

tsia

Reviewed By: yungsters

Differential Revision: D54781220

fbshipit-source-id: 1141c0f6cdc9840b7afabbd25e344fe9e5042d4e
2024-03-12 11:31:46 -07:00
Joe Vilches
6205338c34 Add min max width height documentation (#1601)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1601

tsia

Reviewed By: NickGerleman

Differential Revision: D54780258

fbshipit-source-id: 6690e4d776b948ae0f8ae3e331f395bdada68089
2024-03-12 11:31:46 -07:00
Joe Vilches
b4b6d3a43d Add margin padding border documentation (#1600)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1600

tsia

Reviewed By: NickGerleman

Differential Revision: D54779378

fbshipit-source-id: f20c428034b38d5dcb0220f8e411df22fa9078f1
2024-03-12 11:31:46 -07:00
Joe Vilches
bd3e3edc75 Add layout direction documentation (#1599)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1599

tsia. Had to add JS api support for set/get direction

Reviewed By: yungsters

Differential Revision: D54778992

fbshipit-source-id: 346152e1d61c80aa524b515e8b30a96fe32fe7c3
2024-03-12 11:31:46 -07:00
Joe Vilches
aed6f015bf Add justify content documentation (#1598)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1598

tisa

Reviewed By: NickGerleman

Differential Revision: D54778011

fbshipit-source-id: d1a38a88da3e8534577f87ea410bd8d8b3ecc6be
2024-03-12 11:31:46 -07:00
Joe Vilches
654a7753df Add flex direction documentation (#1597)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1597

tsia

Reviewed By: yungsters

Differential Revision: D54777588

fbshipit-source-id: a4e9ffa4684b152a5e8e76b061bcd24d3d91a252
2024-03-12 11:31:46 -07:00
Joe Vilches
7d537eff41 Add display documentation (#1596)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1596

tsia

Reviewed By: yungsters

Differential Revision: D54775960

fbshipit-source-id: 0d9e782cd9badb3071112038ff6ce40c2ae2c6e4
2024-03-12 11:31:46 -07:00
Joe Vilches
8a6c092693 Add aspect ratio documentation (#1595)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1595

tsia, copied markdown from https://yogalayout.dev/docs/aspect-ratio

Reviewed By: yungsters

Differential Revision: D54774755

fbshipit-source-id: 8b93c35c4efa69f942daa09458a315fc33578094
2024-03-12 11:31:46 -07:00
Joe Vilches
543f36d5b4 Fix bug where absolute nodes were not insetted correctly in certain cases (#1593)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1593

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

There was a bug where we did not position absolute nodes correctly if the static node had a different main/cross axis from the containing node. This fixes that. The change is somewhat complicated unfortunately but I tried to add sufficient comments to explain what is happening

Reviewed By: NickGerleman

Differential Revision: D54703955

fbshipit-source-id: 096c643f61d4f9bb3ee6278d675ebd69b57350d7
2024-03-12 11:08:43 -07:00
Jamon Holmgren
d591885e29 Fix TypeScript link (#1594)
Summary:
Link was wrong, fixed it.

* [Old link](https://github.com/facebook/yoga/blob/main/javascript/src/wrapAssembly.d.ts)
* [New link](https://github.com/facebook/yoga/blob/main/javascript/src/wrapAssembly.ts)

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

Reviewed By: joevilches

Differential Revision: D54763374

Pulled By: arushikesarwani94

fbshipit-source-id: c82589617efb07809fb0b5bd3f6d745936dcc545
2024-03-11 13:37:55 -07:00
Nick Gerleman
0d23e07202 Reduce warning level of distributed Yoga builds (#1592)
Summary:
X-link: https://github.com/facebook/react-native/pull/43405
Pull Request resolved: https://github.com/facebook/yoga/pull/1592

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

Yoga may be built with a high warning level. This is helpful in letting Yoga be used in more places, and finding defects. We currently set these in the internal BUCK build, the CMake reference build, and the Yoga Standalone (not RN) CocoaPods build.

Yoga's reference CMake build and spec are consumed today by users of Yoga, instead of just Yoga developers. Here, it makes more sense to avoid anything that could break compiler-to-compiler compatibility.

We default these to a less intense (`-Wall -Werror`). I kept `/W4`, for pragmatic reasons, and since it is relatively standard for MSVC.

We continue to build with strict flags on Buck build on Clang.

Reviewed By: cortinico

Differential Revision: D54735661

fbshipit-source-id: 130e35ac9dcffa2f7e70e48d18770f1275864e2a
2024-03-11 10:38:55 -07:00
Nick Gerleman
cc2a87d4f9 Add skeleton for documentation (#1589)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1589

Adds a skeleton to the new website of documentation and such for us to fill out.

Reviewed By: joevilches

Differential Revision: D54567186

fbshipit-source-id: 700dfe0787fcb9806c3daa0675e838540119bbc0
2024-03-08 14:13:55 -08:00
Nick Gerleman
367643faa5 Add Yoga 3.0 Relase Notes (#1587)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1587

Adds release notes for Yoga 3.0. Tentatively going to try to polish up the rest of the website bits, to be able to put this out on Monday.

If we get the website bits finished, I will add some bits about the new documentation.

Reviewed By: joevilches

Differential Revision: D54560841

fbshipit-source-id: 237f94985d2b804cf5a1e1737a23dc8a7a03695a
2024-03-08 12:44:44 -08:00
Nick Gerleman
a5c49ebd7b Run CocoaPods Trunk Publish Job on macOS (#1588)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1588

This was previously running on Ubuntu, but just happened to work until the setup job assumed macOS. Run the job on macOS.

Reviewed By: cipolleschi

Differential Revision: D54563775

fbshipit-source-id: 2311029cf9b56527608e9cb000d5c09320607a99
2024-03-06 01:24:01 -08:00
Riccardo Cipolleschi
363016eb5c Fix MacCatalyst archiving for stand-alone pod (#1585)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1585

When used alone, yoga has no visibility over the USE_FRAMEWORKS variable set by React Native.

In this case, there is no other way to know whether the current target that will install the spec is using use_framewors or not. As a failsafe, condition, let's always add the `"$(PODS_TARGET_SRCROOT)"` to the search paths to make sure that archiving won't fail.

Whe used in other context, that should not be a problem: search paths are just directory Xcode uses to find headers that are needed.

Reviewed By: NickGerleman

Differential Revision: D54417386

fbshipit-source-id: aa2ae41c077e4346c0417c73291a37c992a06b58
2024-03-04 03:44:10 -08:00
Nick Gerleman
b959c79a2a Enable Clang Tidy (#1586)
Summary:
X-link: https://github.com/facebook/litho/pull/976

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

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

Add the React Clang Tidy config to Yoga, run the auto fixes, and make some manual mechanical tweaks.

Notably, the automatic changes to the infra for generating a Yoga tree from JSON capture make it 70% faster.

Before:
{F1463947076}

After:
{F1463946802}

This also cleans up all the no-op shallow const parameters in headers.

{F1463943386}

Not all checks are available in all environments, but that is okay, as Clang Tidy will gracefully skip them.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D54461054

fbshipit-source-id: dbd2d9ce51afd3174d1f2c6d439fa7d08baff46f
2024-03-04 02:28:02 -08:00
Kesha Antonov
47a56db5f6 Update Yoga.podspec: fixes archiving for Mac Catalyst
Summary:
Hi

When I tried to archive macos catalyst app in Xcode I got errors:

<img width="977" alt="Screenshot 2024-02-05 at 00 03 32" src="https://github.com/kesha-antonov/react-native/assets/11584712/b83f75a5-b42f-42e4-9afa-1e2527501baa">

This PR fixes archiving by linking PrivateHeaders in yoga.framework

<img width="399" alt="Screenshot 2024-02-05 at 01 03 48" src="https://github.com/kesha-antonov/react-native/assets/11584712/089080ad-b1dc-4703-9273-d8aa3253205e">

<img width="1404" alt="Screenshot 2024-02-05 at 01 05 18" src="https://github.com/kesha-antonov/react-native/assets/11584712/5263cb80-8a53-4a51-bcfc-9d3a2ba739b4">

Prev PR here https://github.com/facebook/react-native/pull/42159

## Changelog:

[IOS] [FIXED] - fixed archiving for Mac Catalyst

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

Reviewed By: NickGerleman

Differential Revision: D53920474

Pulled By: cipolleschi

fbshipit-source-id: 0534d9aa9d249e4e0c35ada0464c38c291be7f84
2024-02-22 06:00:12 -08:00
Joe Vilches
c278713eb5 Node -> Measure func map instead of vec (#1581)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1581

This is better than just trusting the order of the measure func call. Now each measure function I/O is associated with a node in the JSON.

Reviewed By: NickGerleman

Differential Revision: D53776790

fbshipit-source-id: 793cf2d9cbf6f663d24848af0af30aa297614eea
2024-02-21 18:02:58 -08:00
Joe Vilches
b35456b93c Error message when measure functions mismatch
Summary:
To sanity check that a capture is working as expected when running benchmark

We could maybe even throw here as a bad measure function will throw off the rest of the benchmark.

Reviewed By: NickGerleman

Differential Revision: D53681506

fbshipit-source-id: f5ab7e00e76df0ac899d62c3f6b4535b3780d45d
2024-02-13 17:22:08 -08:00
Joe Vilches
e679327904 Add small desktop capture
Summary: A much smaller tree than the previous one. It only has 100 or so nodes

Reviewed By: NickGerleman

Differential Revision: D53632451

fbshipit-source-id: 1268499fa768f3b6673ff8bcedac23cf6d9395ac
2024-02-13 17:22:08 -08:00
Joe Vilches
cae7ef924a Convience script to run benchmark
Summary: You need to provide the benchmark binary with a path to the captures. This is annoying and there is not a great way to do this in c++ that is cross-plat. So I just made this bash script to ease it. It can do buck and cmake.

Reviewed By: NickGerleman

Differential Revision: D53632438

fbshipit-source-id: 98b0ad52f91f2581e09f787da24f2ec2fff58bf4
2024-02-13 17:22:08 -08:00
Joe Vilches
e2ed3f031d Support for (de)serializing measure funcs
Summary:
In addition to all the state that gets set on the node that is easy to serialize - like floats, enums, bools, etc - we also need to serialize measure functions. This is because these functions take a nontrivial amount of time up during layout and we should capture that. Also, they are important to the ability to truly replay layout as it was captured as the results of the measure functions determine many of the steps the layout algorithm takes.

Capturing this is rather tricky however, but I think I found a solution that is relatively simple and non-error prone. Essentially, since we are capturing the entire tree and virtually every input that goes into the flexbox algorithm, we *should* be able to replay layout exactly as it was captured. This means that the order in which measure functions are called *should* be the same. If this is the case, then all we need to do to capture the measure functions is store their input, output, and duration in a big array. During deserialization we just keep track of an index and use that to determine which measure function we should call. That is the premise behind what happens in this diff. In theory the algorithm could change and the capture would be wrong but it is easy enough to recapture again. Additionally we need to dirty the tree so that we get rid of caching which might omit some measure func calls

In order to capture you need to insert a method exposed by CaptureTree.h into the client measure func, which is kind of annoying but not that bad. In future diffs I will put a macro in place to make this even easier.

I also add our first capture! Which is of a large react native desktop app

Reviewed By: NickGerleman

Differential Revision: D53581121

fbshipit-source-id: 876a230208d67f0ecf76844a4f1b80048353aae2
2024-02-13 17:22:08 -08:00
Joe Vilches
cc66362a28 Expose replacement wrapper of CalculateLayout + (de)serialize layout inputs (#1575)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1575

If we want to replay layouts for benchmark, we should also capture the inputs. This diff does that as well as changing the API in CaptureTree.h. We now expose YGCalculateLayoutWithCapture designed to be a drop-in replacement for YGCalculateLayout. This allows us to have a bit more control on the order of everything and lets us capture measure functions in the next diff much easier.

Reviewed By: NickGerleman

Differential Revision: D53444261

fbshipit-source-id: 616e39153c21e7b472911502b6a717e92c88a4d1
2024-02-09 16:44:32 -08:00
Joe Vilches
753b319977 Support for (de)serializing node state (#1570)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1570

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

tsia. Need node state

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D53206323

fbshipit-source-id: eb48c3873536eb52c8ffcce8005725da274e5373
2024-02-09 16:44:32 -08:00
Joe Vilches
f90ad378ff Support for (de)serializing config values (#1571)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1571

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

tsia. This is state we need to capture as it can drastically affect the benchmark times

Reviewed By: NickGerleman

Differential Revision: D53203385

fbshipit-source-id: 47178458d039df90fb15d8a420f9e0f17e4fe6ca
2024-02-09 16:44:32 -08:00
Joe Vilches
a37565f70d Fix failing MVSC benchmark builds (#1573)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1573

Noticed a recent stack of commits cause the MVSC builds of benchmark to fail. This was due to forgetting to call `.string()` of a path and trying to escape a character that cannot be escaped.

Reviewed By: philIip

Differential Revision: D53461723

fbshipit-source-id: b6cc034d53b3a61929012965e257a3984c3bff47
2024-02-06 11:16:21 -08:00
Joe Vilches
94960f123e main() function to run a benchmark (#1564)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1564

tsia

Reviewed By: NickGerleman

Differential Revision: D53028962

fbshipit-source-id: dee2670eaa4fe0ab8b6e2b9e1bbe4356bb2c0735
2024-02-05 11:48:07 -08:00
Joe Vilches
8dbf55f230 Add ability to time captured benchmarks (#1569)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1569

Added a `benchmark` function that takes a path representing a directory to read captures from. This is supplied by the caller due to annoyance with filesystem access in C++. This calls into timing code with <chrono> and prints it out to the console.

Reviewed By: NickGerleman

Differential Revision: D53104632

fbshipit-source-id: fe8bcb0a87198701865fb04193894591d2eff821
2024-02-05 11:48:07 -08:00
Joe Vilches
0ca15bdaaa Ability to recreate yoga trees from JSON captures (#1566)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1566

In the previous diffs we serialized the in-memory representation of a node into json. This diff exposes a `generateBenchmark` method that reads from that json executes the proper public Yoga API functions to recreate the same tree. It then calls calculate layout so that we can time that in the next diff.

This diff is really only focusing on the core aspects of a yoga tree like style, children, and calculating layout; there are still more things to add coming up:

* Support for configs, experiments, and errata
* Support for measure functions
* Support for general node state that is not style (like always forming a containing block)
* Actually running all of these benchmarks together
* Tests

Reviewed By: NickGerleman

Differential Revision: D52987588

fbshipit-source-id: 7f7c9ca9956f693be62bc5e3cebdf1aed6f58aec
2024-02-05 11:48:07 -08:00
Joe Vilches
efd27efd70 Ability to capture trees as JSON files (#1565)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1565

This adds a `captureTree` method intended to be injected in somewhere where you would like a JSON representation of a yoga tree. Right now it is very simple and just calls on `nodeToString` to serialize a node into JSON, and then saves that into a file in the given path. Some buck file changes needed to be done as well to use this in other files.

Reviewed By: NickGerleman

Differential Revision: D52972995

fbshipit-source-id: f4e09a815edef92ab959cfc76bacccbce225d940
2024-02-02 15:44:23 -08:00
Joe Vilches
bb83f45872 Change NodeToString.cpp to output JSON not html (#1563)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1563

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

We want to be able to capture Yoga trees in production. To do this we need to serialize and deserialize the in-memory representation of a tree. We have a way to turn a tree into html using NodeToString.cpp but that outputs html, which is going to be hard to deserialize. So, I added the [nlohmann json library](https://github.com/nlohmann/json/tree/develop?tab=readme-ov-file) so that we can serialize into JSON instead. Then we need to change the inner workings of NodeToString.cpp to use this library instead of its html.

One of the bigger structural changes I made was standardizing the checks need to append something to the string. What we want is to only add something if it is not the default style. The existing logic does that but bears the burden of knowing what the default of certain styles actually is. This just calls the getter on a new node to obtain that value, which should simplify things a bit.

Reviewed By: NickGerleman

Differential Revision: D52929268

fbshipit-source-id: 06eff1e10061bcb55fcdeb6f3ebe7e95155b4c86
2024-02-02 15:44:23 -08:00
Joe Vilches
19af9e6450 Move NodeToString.cpp to benchmark and remove interal usages (#1568)
Summary:
X-link: https://github.com/facebook/react-native/pull/42710

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

This is no longer going to be built with normal yoga so we are going to switch to a public API

Reviewed By: NickGerleman

Differential Revision: D53141235

fbshipit-source-id: 259270a4cd91ef0dab91cefba9c41953b6340d78
2024-02-02 15:44:23 -08:00
Joe Vilches
28975a6053 Remove public APIs for YGNodePrint and YGConfigSetPrintTreeFlag (#1567)
Summary:
X-link: https://github.com/facebook/react-native/pull/42688

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

We are planning on overhauling NodeToString to output JSON instead of HTML for the purposes of better benchmarking and capturing trees in JSON format to benchmark later. This gives us a bit of a headache as we have to revise several build files to ensure this new library works, ensure that it is only included in certain debug builds, and deal with the benchmark <-> internal cross boundary that arises as the benchmark code (which is a separate binary) tries to interact with it.

On top of it all this is really not used at all.

The plan is to rip out this functionality and just put it in a separate binary that one can include if they really want to debug. That means that it cannot exist in the public API, so I am removing it here.

Private internals come next

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D53137544

fbshipit-source-id: 7571d243b914cd9bf09ac2418d9a1b86d1bee64a
2024-02-02 15:44:23 -08:00
Nick Gerleman
58aa090774 Fix flooring of border (#1562)
Summary:
X-link: https://github.com/facebook/react-native/pull/42411

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

I added a small regression D52605596, where negative border would not be correctly floored. This fixes that, and starts adding tests specifically targeting the computed style API, now decoupled from the yoga node.

Reviewed By: joevilches

Differential Revision: D52930827

fbshipit-source-id: e165dade705a8de54c92d65f3664c9081137788c
2024-01-22 22:07:49 -08:00
Joe Vilches
8fe38fc7a8 Fix mismatched cases of inlineStart/End and flexStart/End (#1561)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1561

Back when I introduced the inline functions that would get the edge according to the writing direction I swapped some instances of `setLayoutPosition` which wrote to the flexStart edge erroneously. We should basically never read from some inline style and write to the flex edge. This changes them all to use the flex values.

Reviewed By: NickGerleman

Differential Revision: D52921401

fbshipit-source-id: 92b74d652018596134c91827806272ed7418ef6c
2024-01-22 15:41:09 -08:00
Nick Gerleman
67154d47a3 Replace CompactValue with StyleValueHandle and StyleValuePool (#1534)
Summary:
X-link: https://github.com/facebook/react-native/pull/42131

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

Now that the storage method is a hidden implementation detail, this changes the underlying data structure used to store styles, from `CompactValue` (a customized 32-bit float with tag bits), to `StyleValuePool`.

This new structure operates on 16-bit handles, and a shared small buffer. The vast majority of real-world values can be stored directly in the handle, but we allow arbitrary 32 bit (and soon 64-bit) values to be stored, where the handle then becomes an index into the styles buffer.

This results in a real-world memory usage win, while also letting us store the 64-bit values we are wanting to use for math function support (compared to doubling the storage requirements).

This does seem to make style reads slower, which due to their heavy frequency, does have a performance impact observable by synthetics. In an example laying out a tree of 10,000 nodes, we originally read from `StyleValuePool` 2.4 million times.

This originally resulted in a ~10% regression, but when combined with the changes in the last diff, most style reads become simple bitwise operations on the handle, and we are actually 14% faster than before.

| | Before | After | Δ |
| `sizeof(yoga::Style)` | 208B  | 144B | -64B/-31% |
| `sizeof(yoga::Node)` | 640B  | 576B | -64B/-10% |
| `sizeof(YogaLayoutableShadowNode) ` |  920B | 856B | -64B/-7% |
| `sizeof(YogaLayoutableShadowNode) + sizeof(YogaStylableProps)` | 1296B  | 1168B | -128B/-10% |
| `sizeof(ViewShadowNode)`  |  920B | 856B | -64B/-7% |
| `sizeof(ViewShadowNode) + sizeof(ViewShadowNodeProps)` | 2000B  | 1872B | -128B/-6% |
| "Huge nested layout" microbenchmark (M1 Ultra) | 11.5ms | 9.9ms | -1.6ms/-14% |
| Quest Store C++ heap usage (avg over 10 runs) | 86.2MB | 84.9MB | -1.3MB/-1.5% |

Reviewed By: joevilches

Differential Revision: D52223122

fbshipit-source-id: 990f4b7e991e8e22d198ce20f7da66d9c6ba637b
2024-01-19 18:22:29 -08:00
Nick Gerleman
395c596695 Add some tests for justification under row-reverse (#1560)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1560

I added these when I was trying to debug the Facepile break removing the row-reverse errata caused. Yoga is doing the right thing, and the tests pass. We didn't have this specific coverage before, so add it.

Reviewed By: joevilches

Differential Revision: D52909633

fbshipit-source-id: d1e8f55bb534d76bd7dfdc46a1e1cc6f0a3ca211
2024-01-19 16:21:59 -08:00
Nick Gerleman
8744792f41 Simplify Edge Resolution (#1550)
Summary:
X-link: https://github.com/facebook/react-native/pull/42254

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

This change aims to simplify how we resolve edges. This operation happens many, many times, and has gotten complex and slow when paired with StyleValuePool.

This starts reshaping so that `yoga::Style` can resolve a style prop for a given edge. This is closer to the ideal computed style API to avoid recalcing this so many times, but doesn't address that.

This relies on removing the errata related to row-reverse, and cleans up the removal started in the last change.

This has no measurable perf effect under CompactValue, but has a >10% uplift in perf when using StyleValueHandle, where we can trivially check if a handle points to a defined value without resolving it, but only within `yoga::Style` since we don't expose the handle outside of it.

More quantifiably, we go from 2.35 million StyleValuePool reads to 993k. The rest are checks on the handle.

Reviewed By: joevilches

Differential Revision: D52605596

fbshipit-source-id: 0b366963a899e376f99ce3d75cd5f14a25d60cec
2024-01-19 11:28:06 -08:00
Nick Gerleman
35b9b5223e yoga::Node::getStyle() to yoga::Node::style() (#1555)
Summary:
X-link: https://github.com/facebook/react-native/pull/42314

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

The next diff moves a bunch of methods to `yoga::Style`. This renames the function to be a tad bit shorter, for more readable callsites. It also makes it more consistent with style property getters.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D52803393

fbshipit-source-id: 557df34a9f0fb0ee42ad23b1fda99c1e0eb1d4e3
2024-01-19 11:28:06 -08:00
Nick Gerleman
d6a3b71085 Fix missing assignment in Node move constructor (#1554)
Summary:
X-link: https://github.com/facebook/react-native/pull/42275

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

Adds recently added field missing from move constructor

Reviewed By: joevilches

Differential Revision: D52767525

fbshipit-source-id: ec68452b058178967650bbef736562caafbf4a36
2024-01-19 09:46:08 -08:00
Nathaniel Brough
1a8b80a3d5 Add simple fuzz-harness (#1537)
Summary:
> This PR is based on the proposal in https://github.com/facebook/yoga/issues/1538 inlined below, to integrate yoga with `oss-fuzz`

Hey yoga team,

I've recently become interested in yoga. I'd like to suggest and champion an effort to set up some basic fuzz-testing and combine it with google/oss-fuzz for continuous fuzzing. I'm fully aware that you are very busy people and I don't want to overload your review/maintenance capacity. Is this a bad time to discuss potential security/reliability improvements?

If you're not familiar with fuzzing or oss-fuzz I've included a few brief notes below.

#### **Benefits of Fuzz-Testing**

- **Dynamic Code Testing**: Fuzz-testing challenges systems with unexpected data, aiming to identify vulnerabilities or bugs. It’s akin to an exhaustive stress-test for the code.
- **Detecting Hidden Vulnerabilities**: It can uncover potential weaknesses that may not be evident in routine tests.
- **Continuous and Automated Testing**: With tools like Google’s OSS-Fuzz, fuzz-testing can be automated, running continuously on distributed systems, ensuring daily resilience checks.

#### **Google/oss-fuzz for Continuous Fuzzing**

- **Automated Fuzzing**: OSS-Fuzz undertakes comprehensive fuzz-testing daily on a distributed cluster.
- **Detailed Reporting**: OSS-Fuzz offers exhaustive reports in case of detected anomalies, enabling effective action.

I’d be more than happy to lead the effort in integrating fuzz testing with the yoga and assist in any way required.

#### Prior integrations
There have been a number of previous integrations completed with facebook repositories and google/oss-fuzz including;
- facebook/time
- facebook/zstd
- facebookexperimental/starlark-rust (this was me)
- facebook/proxygen
- facebook/hermes
- facebook/rocksdb

As a proof of concept I created a couple of super simple fuzz harnesses in https://github.com/facebook/yoga/issues/1537.

NOTE: Adding fuzz-testing and integrating with google/oss-fuzz was previously suggested here https://github.com/facebook/yoga/pull/1055 and was rejected. I think I've addressed the concerns raised in the first PR. While the original PR contained what was probably a higher performance fuzzer, the new fuzzer should be easier to integrate and doesn't introduce multiple sources of truth.

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

Reviewed By: yungsters

Differential Revision: D52800366

Pulled By: NickGerleman

fbshipit-source-id: 4957282456f3263e600d13ae6f3e983681bebda6
2024-01-19 09:00:35 -08:00
Joe Vilches
1541f9d528 Rename AbsolutePositioning errata (#1558)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1558

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

AbsolutePositioning -> AbsolutePositioningCatchAll

A bit more clear. This errata is for various issues with positioning absolute nodes. There really isn't a clear description as to what specifically this enables/disables, so I just opted to say "catch all" to indicate that this controls various bugs

Reviewed By: NickGerleman

Differential Revision: D52820117

fbshipit-source-id: 80b77832baf65e68e57ca523c418422dd346ef0f
2024-01-18 21:22:05 -08:00
Joe Vilches
06c26d7d46 Remove static-behaves-like-relative errata (#1556)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1556

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

Since we aim to ship static to all users of yoga (not just XPR), we need to remove the errata that is gating most of the features. This should be a non breaking change. To ensure that, I added a new errata which, if on, will use the inner size of the containing node as the containing block. This is how it has been for a while and resolving this is risky and time consuming so for the time being we will stick with that.

Reviewed By: NickGerleman

Differential Revision: D52706161

fbshipit-source-id: 30a93f29cb0d97b20b2947eaa21f36cdc78c4961
2024-01-18 21:22:05 -08:00
Joe Vilches
f69a1a43e5 Hardcode AbsolutePercentageAgainstPaddingEdge experimental feature to false (#1549)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1549

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

This experimental feature is always false, and with the next diff I will be deleting the branch that actually calls into this. Separating this diff out to simplify the review process.

Reviewed By: NickGerleman

Differential Revision: D52705765

fbshipit-source-id: 705f4aa297eae730af9b44753eb01c9dec385dcf
2024-01-18 21:22:05 -08:00
Nick Gerleman
0bbfe4503d Remove YGNodeSetPrintFunc and related (#1553)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1553

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

Separate from `YGConfigSetPrintTreeFlag` we have a public API `YGNodeSetPrintFunc` which sets a function called, if you manually change a constant in source code during debugging.

This is not debug-only, is exposed as part of the public API (without a way to turn it on from the public API), and takes up a pointer per node doing nothing.

I'm not aware of anyone recently using the capability, and the tracing/event related work done since then would be more powerful for this anyway.

Remove the API.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D52767445

fbshipit-source-id: f72927b47cffa4fe6fe886b42f07cc1ba55f141e
2024-01-16 10:07:19 -08:00
Nick Gerleman
508df05f0d Android Gradle Plugin 8.2.1 (#1548)
Summary:
We technically didn't need to be on the Beta before for NDK 26, but this bumps to the latest, non-prerelease version.

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

Reviewed By: christophpurrer

Differential Revision: D52749378

Pulled By: NickGerleman

fbshipit-source-id: c1940976e6b240aba2af5a2863f189280701ebd3
2024-01-12 22:49:14 -08:00
Nick Gerleman
8c3e01166b Remove row-reverse errata (#1547)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1547

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

Yoga has an odd behavior, where `start`/`end` edges under row-reverse are relative to flex-direction, instead of writing direction.

While Yoga doesn't actually document what this behavior is supposed to be, it goes against CK documentation, historic RN documentation, and the behavior valid on the web. It is also applied inconsistently (e.g. sometimes only on container, sometimes on child). It really is a bug, instead of an intended behavior.

We changed the default behavior for Yoga, but left the existing one behind an errata (so existing fbsource users got old behavior). We have previously seen this behavior show up in product code, including CK when running on FlexLayout.

`row-reverse` is surprisingly uncommon though:
1. Litho has <40 usages
2. RN has ~40 usages in `RKJSModules`,~30 in `arvr/js`, ~6 in `xplat/archon`
3. CK has ~80 usages
4. NT has ~40 usages

There are few enough, mostly simple components, that we can inspect through each of them, looking for signs they will hit the issue (at the potential chance of missing some).

CK accounts for 10/14 usages that I could tell would trigger the issue, since it only exposes start/end edge, and not left/right. It might make sense to make it preserve behavior instead, to reduce risk a bit.

FlexLayout is now separately powering Bloks, which wasn't surveyed, so I didn't touch CK behavior under Bloks.

There could also be other usages in other frameworks/bespoke usages, and this has implications for OSS users. But based on our own usage, of many, many components, this seems rare.

Changelog:
[General][Breaking] - Make `start/end` in styles always refer to writing direction

Reviewed By: pentiumao, joevilches

Differential Revision: D52698130

fbshipit-source-id: 2a9ac47e177469f30dc988d916b6c0ad95d53461
2024-01-12 13:49:53 -08:00
dependabot[bot]
7e70656e46 Bump follow-redirects from 1.15.3 to 1.15.4 (#1546)
Summary:
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
<details>
<summary>Commits</summary>
<ul>
<li><a href="65858205e5"><code>6585820</code></a> Release version 1.15.4 of the npm package.</li>
<li><a href="7a6567e16d"><code>7a6567e</code></a> Disallow bracketed hostnames.</li>
<li><a href="05629af696"><code>05629af</code></a> Prefer native URL instead of deprecated url.parse.</li>
<li><a href="1cba8e85fa"><code>1cba8e8</code></a> Prefer native URL instead of legacy url.resolve.</li>
<li><a href="72bc2a4229"><code>72bc2a4</code></a> Simplify _processResponse error handling.</li>
<li><a href="3d42aecdca"><code>3d42aec</code></a> Add bracket tests.</li>
<li><a href="bcbb096b32"><code>bcbb096</code></a> Do not directly set Error properties.</li>
<li>See full diff in <a href="https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=follow-redirects&package-manager=npm_and_yarn&previous-version=1.15.3&new-version=1.15.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: cortinico

Differential Revision: D52689011

Pulled By: NickGerleman

fbshipit-source-id: 3a8b1d0802a03d262660bafd5998bedd8487c5b0
2024-01-11 04:28:37 -08:00
Joe Vilches
93b6c09eeb Fix error from misspelled function name (#1542)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1542

`YGNodeSetAlwaysFormContainingBlock` -> `YGNodeSetAlwaysFormsContainingBlock`

Started getting tasks telling me github CI was broken. Turns out I was just mispelling this.

Its not a big deal but we really should ensure that stuff will not land if it break github CI...not in our wheelhouse but it seems quite silly that this happens.

Also, a lot of the random files do not have auto complete or code checking which is why I didn't notice this to begin with.

Reviewed By: NickGerleman

Differential Revision: D52632257

fbshipit-source-id: 367ae5766ef9baecf55f7c227ff9fc8dece43af6
2024-01-09 11:46:05 -08:00
Joe Vilches
e4ab593686 JS bindings for setAlwaysFormsContainingBlock (#1541)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1541

tsia

Reviewed By: NickGerleman

Differential Revision: D52608426

fbshipit-source-id: 19fa01d87cbae3457adb9cdb9e0cb602b7afa619
2024-01-08 20:28:49 -08:00
Joe Vilches
47e9f33eb4 Java bindings for setAlwaysFormsContainingBlock (#1540)
Summary:
X-link: https://github.com/facebook/react-native/pull/42192

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

tsia

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52608259

fbshipit-source-id: 647ec4e2fe180ace8d6b641e17cd610fa53fe845
2024-01-08 20:28:49 -08:00
Joe Vilches
5425107246 Support transforms forming containing blocks (#1539)
Summary:
X-link: https://github.com/facebook/react-native/pull/42191

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

React native supports transforms and if a node has a transform it will [form a containing block for absolute descendants regardless of position type](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block). So we need to pass that information into Yoga to ensure this happens.

The verbiage for the field "alwaysFormsContainingBlock" is very specific. In a vacuum a node cannot simply "form a containing block". It only forms a containing block in reference to a different node. This can be illustrated in a scenario where we have a static node that is a flex container which has 1 absolute child and 1 relative child. This static node will form a containing block for the relative child but not the absolute one. We could just pass the information on rather something has a transform or not but Yoga is not supposed to know about transforms in general. As a result we have a notion of "always" forming a containing block. Since Yoga is a flexbox spec, non-absolute nodes' containing blocks will ways be their parent. If we add something like a transform to a node then that will also apply to absolute nodes - hence we can say the node will **always** form a CB, no matter who is the descendant.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52521160

fbshipit-source-id: bab9319ffddec617f5281823930f2a00cc2967f2
2024-01-08 20:28:49 -08:00
Nick Gerleman
94e7336394 Move trailing position functions (#1533)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1533

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

I have some reservations about  some of the conditional setting of trailing position in general, and some of the repeated transformations that neccesitates this, but these functions don't belong in `CalculateLayout.h`. For now, just move these to their own header.

Reviewed By: joevilches

Differential Revision: D52292121

fbshipit-source-id: 4a998a4390a8d045af45f5424adaf049ed635e7a
2023-12-21 13:48:11 -08:00
Nick Gerleman
c319c36b0d Remove duplicate declaration of calculateLayoutInternal (#1532)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1532

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

as per title

Reviewed By: joevilches

Differential Revision: D52289613

fbshipit-source-id: 51a810dda32e6fe44be05a42fe21d78aede52d30
2023-12-21 13:48:11 -08:00
Nick Gerleman
3b0545b15d Add tests for cycles with percentage dimensions (#1530)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1530

Yoga has a shortcut where if a min dimension and max dimension are the same, the value acts as a definite length.

I was curious how browsers handled this.

CSS 2.1 said:
> If the containing block's width depends on this element's width, then the resulting layout is undefined

This is superceded in the CSS box sizing spec. https://www.w3.org/TR/css-sizing-3/#sizing-values

> If, in a particular axis, the containing block’s size depends on the box’s size, see the relevant layout module for special rules on how to resolve percentages. Negative values are invalid.

And later:
https://www.w3.org/TR/css-sizing-3/#cyclic-percentage-contribution

> Sometimes the size of a percentage-sized box’s containing block depends on the intrinsic size contribution of the box itself, creating a cyclic dependency. When calculating the intrinsic size contribution of such a box (including any calculations for a content-based automatic minimum size), a percentage value that resolves against a size in the same axis as the intrinsic size contribution (a cyclic percentage size) is resolved specially:

> If the box is non-replaced, then the entire value of any max size property or preferred size property (width/max-width/height/max-height) specified as an expression containing a percentage (such as 10% or calc(10px + 0%)) that is cyclic is treated for the purpose of calculating the box’s intrinsic size contributions only as that property’s initial value. For example, given a box with width: calc(20px + 50%), its max-content contribution is calculated as if its width were auto. (The percentage is honored as usual, however, during the actual sizing of the box itself; see below.)

> Otherwise, the percentage is resolved against the containing block’s size. (The containing block’s size is not re-resolved based on the resulting size of the box; the contents might thus overflow or underflow the containing block).

So, for the purpose of sizing the parent, the child sized using a percentage does not contribute, but we should be sizing children based on that size.

Yoga does not really work like this right now, but gets the answer right answer for half of these tests.

Reviewed By: yungsters

Differential Revision: D52251601

fbshipit-source-id: 4978b90723130283b00e87bbf49795a4d209174c
2023-12-19 13:38:40 -08:00
Nick Gerleman
c5edcb3d3a Reorder members in Node.h (#1529)
Summary:
X-link: https://github.com/facebook/react-native/pull/41994

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

Reorganizes the header according to common C++ convnetions. Public first, then private. Constructors, then functions, then member variables.

Reviewed By: joevilches

Differential Revision: D52106056

fbshipit-source-id: 0095cf7caa58dc79c1803b3b231911e4fc66ddaf
2023-12-19 13:38:40 -08:00
Nick Gerleman
1f391dfc50 Node::styleDefinesDimension() -> Node::hasDefiniteLength() (#1526)
Summary:
X-link: https://github.com/facebook/react-native/pull/41995

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

This function has made quite the journey from something that originally made more sense. This renames, refactors, and adds documentation for what it actually does.

This should eventually make its way into `yoga::Style` once computed style is moved into that structure.

bypass-github-export-checks

Reviewed By: joevilches

Differential Revision: D52105718

fbshipit-source-id: 6492224dd2e10cef3c5fc6a139323ad189a0925c
2023-12-19 13:38:40 -08:00
Nick Gerleman
ca4ecc044d yoga::resolveValue -> Length::resolve (#1520)
Summary:
X-link: https://github.com/facebook/react-native/pull/41939

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

This code originates as `YGValueResolve`, used to compute a YGValue to a length in points, using a reference for 100%.

This moves it to `Style::Length`, so we can encapsulate parts of it (for style value functions), and make the API more cohesive now that we can do C++ style OOP with it.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D51796973

fbshipit-source-id: a7c359c7544f4bd2066a80d976dde67a0d16f1dd
2023-12-19 13:38:40 -08:00
Nick Gerleman
192016a0a8 Make CompactValue internal detail of yoga::Style (#1492)
Summary:
X-link: https://github.com/facebook/react-native/pull/41776
Pull Request resolved: https://github.com/facebook/yoga/pull/1492

# Summary

In preparation to replace `CompactValue`, this fully encapsulates it as an implementation detail of `yoga::Style`.

The internal API now always operates on `Style::Length`, converted to `YGValue` at the public API boundary.

In the next step, we can plug in a new representation within `Style`, which should enable 64 bit values, and lower memory usage.

# Test Plan

1. Existing tests (inc for style, invalidation, CompactValue) pass
2. Check that constexpr `yoga::isinf()` produces same assembly under Clang as `std::isinf()`
3. Fabric Android builds
4. Yoga benchmark does style reads

# Performance

Checking whether a style is defined, then reading after, is a hot path, and we are doubling any space style lengths take in the stack (but not long-term on the node). After a naive move, on one system, the Yoga benchmark creating, laying out, and destroying a tree, ran about 8-10%  slower in the "Huge nested flex" example. We are converting in many more cases instead of doing undefined check, but operating on accessed style values no longer needs to do the conversion multiple times.

I changed the `CompactValue` conversion to YGValue/StyleLength path to check for undefined as the common case (since we always convert, instead of calling `isUndefined` directly on CompactValue. That seemed to get the difference down to ~5-6% when I was playing with it then. We can optimistically make some of this up with ValuePool giving better locality, and fix this more holistically if we reduce edge and value resolution.

On another machine where I tested this, the new revision went the opposite direction, and was about 5% faster, so this isn't really a cut and dry regression, but we see different characteristics than before.

# Changelog
[Internal]

Reviewed By: rozele

Differential Revision: D51775346

fbshipit-source-id: c618af41b4882b4a227c917fcad07375806faf78
2023-12-19 13:38:40 -08:00
Nick Gerleman
2caa8ac8cb Workaround Docusaurus prism highlighting hydration bug (#1519)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1519

See https://github.com/facebook/docusaurus/issues/9629

We use prism to render the code for the inline editor. Prism renders colors to style directly, and the color chosen is dependent on a setting that may not be available at SSR time.

This adds an SSR-specific representation of the code, missing some of the nuances in token colorization (similar to https://github.com/facebook/docusaurus/pull/7373). This adds a little bit of jank compared to perfect SSR, but fixes cases where the mode is incorrect, and is a lot less jank then the more generic solution used by theme-live-codeblock of keeping the rendering of the opposite color until rehydration.

Preview: https://yoga-website-next-git-fork-nickgerleman-exp-2f8171-fbopensource.vercel.app/

Reviewed By: yungsters

Differential Revision: D52163722

fbshipit-source-id: 312dc52134f0084d40f78147190151700ee10ff7
2023-12-19 12:46:26 -08:00
Nick Gerleman
3f6f04cb92 Don't include code in SSR generation of Playground endpoint (#1518)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1518

We allow arbitrary code in the query param, that static site generation doesn't know about. Current experience in production build is confusing, since you can see a flash of one set of code (playground default), quickly change to another. It is less confusing to have it go from blank to code showing.

Reviewed By: yungsters

Differential Revision: D52162928

fbshipit-source-id: fc7b51455682351a0616be8b9ecf557122d3a8db
2023-12-19 12:46:26 -08:00
Nick Gerleman
eeeb2cae49 Make playground links shorter (#1516)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1516

Right now playground links are URL encoded base64 of the code content. This leads to some pretty long links.

Running a service, or needing to auth to some other service, seems like a lot more headache than it is worth, so this change instead tries to make the URLs a bit more reasonable.

One minor saving is that we're URL encoding base64, instead of just representing using the url-safe variant of base64. But we can get more savings, even in small examples, using compression. This adds a popular, small, library to do that.

Reviewed By: yungsters

Differential Revision: D52161884

fbshipit-source-id: 9f5d131f27e25a611501c2e3bf3907e83c2e3da1
2023-12-19 12:46:26 -08:00
Nick Gerleman
7697be57a8 Consistent bracket spacing in main example (#1517)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1517

Accidentally using a combination of prettier default vs with `--no-bracket-spacing`

Reviewed By: yungsters

Differential Revision: D52162274

fbshipit-source-id: a0e629717060c17b63fa6144d775a590258580ac
2023-12-18 09:38:00 -08:00
Nick Gerleman
3f3b909086 Change Style::resolveColumnGap() return from Length to Style::Length (#1525)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1525

Accidentally left this inconsistent with some of the refactoring. Rename the lone usage of `Length` within Style class to `Style::Length` to match the rest of the code.

This is functionally identical as before.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: yungsters

Differential Revision: D52096820

fbshipit-source-id: d6c569a02fb27a6e7548a9c12ff764afb823a282
2023-12-17 02:58:54 -08:00
Nick Gerleman
a1751127ef Fix align-content of cross-stretched container (#1524)
Summary:
X-link: https://github.com/facebook/react-native/pull/41964

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

D52087013 (#1513) fixed some issues, including where measuring under max-content or fit-content, align-content stretch would consume the entire available cross-dimensions, instead of only sizing to definite dimension, like the spec dicates.

I missed a case, where flexbox considers a container as having a definite cross-size if it is being stretched, even if it doesn't have a definite length.

https://www.w3.org/TR/css-flexbox-1/#definite-sizes

> 3. Once the cross size of a flex line has been determined, items in auto-sized flex containers are also considered definite for the purpose of layout;

> 1. If a single-line flex container has a definite cross size, the outer cross size of any stretched flex items is the flex container’s inner cross size (clamped to the flex item’s min and max cross size) and is considered definite.

We handle `align-items: stretch` of a flex container after cross-size determination by laying out the child under stretch-fit (previously YGMeasureModeExactly) constraint. This checks that case, and sizing the line container to specified cross-dim if we are told to stretch to it.

We could probably afford to merge this a bit with later with what is currently step 9, where we end up redoing some of this same math.

Reviewed By: yungsters

Differential Revision: D52234980

fbshipit-source-id: 475773a352fd01f63a4b21e93a55519726dc0da7
2023-12-17 01:13:36 -08:00
Cheng Zhao
2a8c7a4223 std::terminate belongs to <exception> header (#1511)
Summary:
X-link: https://github.com/facebook/react-native/pull/41917

See also https://en.cppreference.com/w/cpp/error/terminate.

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

Reviewed By: christophpurrer

Differential Revision: D52072882

Pulled By: NickGerleman

fbshipit-source-id: 4d4d442b82d108d1d2ff5d241fbdc8df89045fed
2023-12-17 00:47:44 -08:00
Nick Gerleman
464d1668ba Fix sizing and alignment issues with multi-line containers (#1513)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1513

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

Fixes https://github.com/facebook/yoga/issues/1300
Fixes https://github.com/facebook/yoga/issues/1008

This fixes a smattering of issues related to both sizing and aligment of multi-line-containers:

1. We were previously incorrectly bounding the size of each flex line to the min/max of the entire container.
2. Per-line leads were sometimes incorrectly contributing to alignment within the line
3. The cross dim size used for multi-line alignment is not correct, or correctly clamped. If the available size comes from a max constraint, that was incorrectly used instead of a definite size, or size of content. Leads were entirely skipped for min constraint.

Need to test how breaking this is, to see if it might need to go behind an errata.

See related PRs:
1. https://github.com/facebook/yoga/pull/1491
2. https://github.com/facebook/yoga/pull/1493
3. https://github.com/facebook/yoga/pull/1013

Changelog:
[General][Fixed] - Fix Yoga sizing and alignment issues with multi-line containers

Reviewed By: joevilches

Differential Revision: D52087013

fbshipit-source-id: 8d95ad17e58c1fec1cceab9756413d0b3bd4cd8f
2023-12-16 01:12:30 -08:00
Nick Gerleman
baf95897cb Enable lints for React Components (#1515)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1515

The out-of-the-box docusaurus template doesn't enable linting for React components. This enables those, fixes the errors, and does dome cleanup around the area (e.g. autofocus is a lot more sane).

Reviewed By: vincentriemer

Differential Revision: D52156109

fbshipit-source-id: f32fede3ec4f8a42ecb7f9d77caa2a30581f35ee
2023-12-15 22:46:58 -08:00
Joe Vilches
bac80cafba Add minimist dep to package.json (#1522)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1522

I have the types but not the core

Reviewed By: NickGerleman

Differential Revision: D52216588

fbshipit-source-id: ec348537655213f6d8a3b35402fec03998744c78
2023-12-15 16:26:31 -08:00
Joe Vilches
7aee99567a Change readme yarn link (#1521)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1521

I linked the forked version of yarn when in reality it should be yarn classic

Reviewed By: NickGerleman

Differential Revision: D52215925

fbshipit-source-id: 5d5800d162f2cc250fcf54151de0de87a427abc2
2023-12-15 16:26:31 -08:00
Joe Vilches
43d09a3a94 GitHub workflow to ensure tests are up to date (#1505)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1505

This will ensure that all tests are not modified by hand and that gentest was run if needed (i.e. someone edited those files and forgot to update the tests). Not sure if this works right now, need to export to github and see what happens :)

Reviewed By: NickGerleman

Differential Revision: D52002920

fbshipit-source-id: 1ee033eda04eeba5d01885488bfe8078e7b2f386
2023-12-14 11:48:22 -08:00
Joe Vilches
06c792a407 Create gentest-validate script to validate test signatures (#1504)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1504

I aim to consume this via a github action or workflow. Separating out the CI configuration from the actual script. We could and should maybe change this script to take in arguments for the test dirs so it is more configurable, but getting the barebones down right now.

Reviewed By: NickGerleman

Differential Revision: D51999865

fbshipit-source-id: 5792c6eec5692943518fecefc6226d784c6f0ad8
2023-12-14 11:48:22 -08:00
Joe Vilches
4743040d62 Sign generated tests (#1503)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1503

This diff makes it so that our driver will sign all of the generated files to help ensure that they are not edited by hand. Next I will add CI to actually verify the signature

Reviewed By: NickGerleman

Differential Revision: D51966201

fbshipit-source-id: f7e3f4fde1c98832212a448b2dcc8e21be0560c4
2023-12-14 11:48:22 -08:00
Joe Vilches
e1b59d63a7 Update README with new instructions on how to run the gentest script (#1502)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1502

We should change this if we are moving away from using Ruby

Reviewed By: yungsters, NickGerleman

Differential Revision: D51957351

fbshipit-source-id: fddb0b3348db2b93c661c919a61150c81906a61a
2023-12-14 11:48:22 -08:00
Joe Vilches
e61eb0178c Remove ruby files and regen tests (#1501)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1501

Now that we have `gentest-driver.ts` we can delete the ruby gentest. I also regened all of the tests that have a comment with the wrong file name for where it was generated.

Reviewed By: yungsters, NickGerleman

Differential Revision: D51956567

fbshipit-source-id: d389492e54711cf161dff9e649396cc40f1e5073
2023-12-14 11:48:22 -08:00
Joe Vilches
fba32ebf14 Add command line options to new node-based gentest (#1499)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1499

This uses the minimist library to parse the command line easily for flags and options. I added over the same ones in the ruby script (-f and -s).

Reviewed By: yungsters, NickGerleman

Differential Revision: D51877810

fbshipit-source-id: 643606cad25609ed2567bb63470818b81ebef531
2023-12-14 11:48:22 -08:00
Joe Vilches
98552078b1 Create node version of gentest script (#1498)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1498

The only instance of ruby in this repository is `gentest.rb` used to generate test cases from html fixtures. This is quite annoying as ruby is not the most popular compared to something like Node and it does not integrate into the rest of our stack. I changed this to use Node.js instead. Instead of `watir` we now use `selenium-webdriver`. `watir` is backed by Selenium so I do not expect anything to change.

Next commits will add command line options, clean up gentest.rb and its references, and change the README

allow-large-files

Reviewed By: yungsters, NickGerleman

Differential Revision: D51874433

fbshipit-source-id: ef8588d48aa7f8b720b57df08738bbd01e9e74a3
2023-12-14 11:48:22 -08:00
Nick Gerleman
43cb24fdce Fix playground handling of visible scrollbars (#1514)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1514

On machines with scrollbars, we shouldn't show them unconditionally, and the toolbar should be in the area within them.

This also fixes a couple bugs:
1. Preview not rendering based on correct code when light/dark mode changes
2. Crash on start on mobile safari
3. Incorrect rendering of preview on mobile safari

This also fixes a bug where the playground re-rendering (e.g. on theme change) makes the preview snap back to the initial code passes.

https://yoga-website-next-git-fork-nickgerleman-exp-194d90-fbopensource.vercel.app/

Reviewed By: shwanton

Differential Revision: D52145666

fbshipit-source-id: 50184305987aab4cbcd066f37582997dfdc78c02
2023-12-13 20:05:29 -08:00
Nick Gerleman
738d04fcb0 Fix OSS JS Build (#1512)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1512

Latest revision either never got exported, or didn't block land? Fix the typo.

Reviewed By: joevilches

Differential Revision: D52087122

fbshipit-source-id: 2dfcff4925902bdd1dd210a219a78707186fd28e
2023-12-12 13:11:01 -08:00
Nick Gerleman
c01c4cbb82 Backfil Yoga 2.0 Release notes to blog (#1508)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1508

Backfilling the release notes already on GitHub before the next time we want to do a release, and use the Docusaurus blog.

Reviewed By: yungsters

Differential Revision: D52012362

fbshipit-source-id: 35de017017943ed21263a4a9aeaa0fd1418c2bc7
2023-12-12 09:06:58 -08:00
Nick Gerleman
77742af676 Replace Playground with JSX Editor (#1500)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1500

Inspired by the frequent usage of Expo snacks to run RN, to repro Yoga issues, this replaces the Playground port with a new ground up Playground UI. This UI right now is pretty simple, with a JSX editor which creates a Yoga tree, which is then rendered using the WebAssembly variant of Yoga.

There are a lot of ways we can continue to improve this, but this merges the foundation. Subjectively, I find this more useful as a tool to play with Yoga behavior than the GUI.

This also replaces some of the bits of the homepage, and adds a playground entrypoint (though it's pretty identical to the one I've been testing on the home page).

Reviewed By: yungsters

Differential Revision: D51963201

fbshipit-source-id: 1265cb1784151b685686e189d47ecd42cbacdf8f
2023-12-12 09:06:58 -08:00
Nick Gerleman
0d03d8a06d Manage native build toolchain (#1506)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1506

In order to build the website, you must build a Yoga binary. This usually requires installing native toolchains.

We have warning messages for these right now, but an even better solution is to just manage the dependencies ourselves. This does that, bringing in specific CMake and Ninja binaries from NPM, and caching a local copy of Emscripten during the build.

A downside is that the CMake packages are chunky, so we add 130MB to node_modules (for a repo total around 350MB). This also delays acquiring Emscripten (which is even chunkier) in CI builds until it is needed, and I added some caching for it as well.

The upside of JS users being able to run and test (inc the website) without installing and managing their own versions of toolchains is a real time-saver though, and is probably worth it.

allow-large-files

Reviewed By: yungsters

Differential Revision: D52013026

fbshipit-source-id: 3d307f751463a21c5e5d5b98b8e9e63db9d3d52e
2023-12-12 09:06:58 -08:00
Nick Gerleman
a43754266a <bit> and <concepts> (#1497)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1497

The lowest common denominator we have had for Yoga has been Clang 12 + MSVC 2017 stdlib. This has allowed Yoga to use C++ 20 language features, but not library features. React Native for mobile has not been bound to this restriction.

Builds using that toolchain are being updated to latest MSVC 2019 stdlib (which has good C++ 20 library support), along with Clang 17 (or maybe a stop at 15) pending projects using `-fcoroutines-ts` being migrated to C++ 20.

This tests out some C++ 20 standard library usages against the current Clang 12 + MSVC 2019 stdlib toolchain that didn't work before, and adds a couple concepts for better constraints/compiler error messages if misused.

This bumps min-tested XCode (and minimum required) version to 14.3, matching a similar change for React Native. This should probably be bumped to 15 sometime before Apple starts requiring 15+ to go out to the iOS app store.

We are approaching a practical support range of:
1. XCode >= 14.3
2. NDK >= 26
3. Clang/libc++ >= 14
4. GCC/libstdc++ >= 11
5. MSVC >= 16.11 (VS 2019)

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D51604487

fbshipit-source-id: d394d0d86672b69781b8ae071d87adcf944ddc72
2023-12-12 08:52:11 -08:00
Nick Gerleman
ab37ed70ae Add concurrency group for website publish (#1510)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1510

Make each workflow acquire a shared mutex so that if two commits happen close to each other, the publish order must correspond to commit order.

Reviewed By: cortinico

Differential Revision: D52031970

fbshipit-source-id: 960cd8e8f79b26ab3d9c131e0637b795618d898e
2023-12-12 07:07:56 -08:00
Joe Vilches
1ea575684d Enable previously broken absolute positioning tests (#1488)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1488

These were disabled when they were written because they were broken. The recent changes made them pass now so lets enable them. I also added another test that is already passing

Reviewed By: NickGerleman

Differential Revision: D51404875

fbshipit-source-id: ed10004968b871c1d033640d75138f00afc15968
2023-12-07 21:25:45 -08:00
Joe Vilches
bc5dc2d6bf Fix issues with aligning absolute nodes (#1490)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1490

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

In the previous diffs I fixed problems with justifying absolute nodes. The same issues plague aligning so I fixed them in the same way. Added tests that were failing before but now passing

Reviewed By: NickGerleman

Differential Revision: D51404489

fbshipit-source-id: 604495d651eb67cfdcca40df9d8d3a125c5741a8
2023-12-07 21:25:45 -08:00
Joe Vilches
b573f91a38 Fix issue where we were not applying flex end correctly when justifying (#1487)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1487

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

The code here was just wrong. I changed it to be the same logic as the Justify:FlexStart case, but with the flex end sides. Then I get the position for the opposite edge since we need to write to flex start side.

Reviewed By: NickGerleman

Differential Revision: D51383792

fbshipit-source-id: 372835a44edff361dbd84dd92ff9f2ec844b9f9c
2023-12-07 21:25:45 -08:00
Joe Vilches
897f9b7423 Fix issue where we were not centering absolute nodes correctly when justifying (#1489)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1489

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

Centering involves centering the margin box in the content box of the parent, and then getting the distance from the flex start edge of the parent to the child

Reviewed By: NickGerleman

Differential Revision: D51383625

fbshipit-source-id: 6bbbace95689ef39c35303bea4b99505952df457
2023-12-07 21:25:45 -08:00
Joe Vilches
f8d048bb1a Fix bug where we used border box for size of containing block in a certain case (#1486)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1486

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

Somehow missed this case. We never want to measure the CB as that gets border box but we want padding box

Reviewed By: NickGerleman

Differential Revision: D51376309

fbshipit-source-id: 2b5119c421ef92fadb28a70254cb7fe02aeb8c28
2023-12-07 21:25:45 -08:00
Joe Vilches
d1dda2185e Fix bug with align start not taking into account parent padding (#1484)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1484

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

Tsia. Added test and accounted for parent padding

Reviewed By: NickGerleman

Differential Revision: D51374086

fbshipit-source-id: ed9d79887aa1613ea93c10c639cd1465271d23d8
2023-12-07 21:25:45 -08:00
Joe Vilches
a5c955a579 Relayout test for containing block changing size (#1483)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1483

This test is for ensuring caching does not break layout when a CB changes. No changes were needed to get this passing it just works this way with the implementation we chose earlier.

Reviewed By: NickGerleman

Differential Revision: D51333812

fbshipit-source-id: b3b603fc641d470cb61e63c44c71f7544f3c7727
2023-12-07 21:25:45 -08:00
Joe Vilches
9b87d8b3f3 Fix issue where percentages were off of the border box, not padding box (#1485)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1485

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

The size of the containing block is the size of the padding box of the containing node for absolute nodes. We were looking at  `containingNode->getLayout().measuredDimension(Dimension::Width)` which is the border box. So we need to subtract the border from this.

Added a test that was failing before this change as well

Reviewed By: NickGerleman

Differential Revision: D51330526

fbshipit-source-id: adc448dfb71b54f1bbed0d9d61c5553bda4b106c
2023-12-07 21:25:45 -08:00
Joe Vilches
f6c4a8e8e4 Make position static behave like position static (#1482)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1482

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

This is the final step (that I know of) to get the core features of static working. Here we turn on all of the tests and pass down the correct owner size for the call to `calculateLayoutInternal` that is in `layoutAbsoluteChild`

Reviewed By: NickGerleman

Differential Revision: D51293606

fbshipit-source-id: 972259e7ebecb19b55aef2ef866bd7cb57aaf0ca
2023-12-07 21:25:45 -08:00
Joe Vilches
1b146cd8a8 Make positionAbsoluteChild the sole place that matters when determining absolute node's position (#1481)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1481

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

Absolute nodes can be laid out by themselves and do not have to care about what is happening to their siblings. Because of this we can make `positionAbsoluteChild` the sole place where we handle this logic. Right now that is scattered around algorithm with many `if (child is absolute)` cases everywhere. This makes implementing position static a lot harder since we are relying on the CB to do all this work, not the parent.

With this change the only time we set position for an absolute node and it matter (i.e. not overwritten) is in `positionAbsoluteChild`

Reviewed By: NickGerleman

Differential Revision: D51290723

fbshipit-source-id: 405d81b1d28826cbb0323dc117c406a44d381dff
2023-12-07 21:25:45 -08:00
Joe Vilches
c93734f579 Fix issue in gentest where border-<edge> would add a border to test (#1496)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1496

Gentest code has a problem where we try to apply a border in our test when the web browser is not actually adding one. This happens when we do something like `border-top: 10px`. This will actually set the style of the border to `initial` which is just `none`, so nothing renders. This is causing at least 1 test to pass when it actually fails.

I changed it so we ignore setting this value if the style is one of these values. I then re-ran the gentest code and excluded the now failing test (which gets fixed in my static stack).

Reviewed By: NickGerleman

Differential Revision: D51831754

fbshipit-source-id: a325e4a42b2d7cd6f19efc6cd5a2445574467fb7
2023-12-05 13:30:03 -08:00
Nicola Corti
7b3b66d288 Re-enabled disabled tests ReactPropForShadowNodeSpecTest and ReactPropForShadowNodeSetterTest (#1494)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1494

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

Those tests are currently disabled due to Yoga attempting to do JNI calls.
I've added infra to bypass .so loading during tests, and we should be good to re-enable those tests by now.

Changelog:
[Internal] [Changed] - Re-enabled disabled tests ReactPropForShadowNodeSpecTest and ReactPropForShadowNodeSetterTest

Reviewed By: NickGerleman

Differential Revision: D51814491

fbshipit-source-id: adbbace19c94a0c6d8947f61221fafafd7797ac8
2023-12-05 07:14:20 -08:00
Joe Vilches
dde0fda9f5 New file for layout methods related to absolute children (#1495)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1495

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

This is a copy of D51369722 to make it so that it preserves the file history

CalculateLayout.cpp is massive and approaching 3k lines. I added a few large functions dealing with layout of absolute nodes and was thinking it would be nice if that logic was just in its own file so it was more isolated and easier to reason about. So I made AbsoluteLayout.cpp and AbsoluteLayout.h to house this logic. In order for this to work I had to expose calculateLayoutInternal in CalculateLayout.h as layoutAbsoluteChild calls it. This is unideal and I would like to find a better way...

I also make LayoutUtils.h to house misc small helper methods as they are called in AbsoluteLayout.cpp and CalculateLayout.cpp

Reviewed By: NickGerleman

Differential Revision: D51824115

fbshipit-source-id: 9b27449e3c1516492c01e6167a6b2c4568a33807
2023-12-04 19:35:30 -08:00
Joe Vilches
7893c4bd85 Fix issue where start/end would not be respected in flex edge getters (#1479)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1479

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

There are two ways to get the value of a style for a specific edge right now:

1) From the inline start/end edge which is determined via the writing direction (ltr or rtl), assuming you do not have errata on
2) From the flex start/end edge which is determined via the flex direction (row, row-reverse, column, column-reverse)

There is a weird curiosity in the second case: you can define a style to be on the "start" or "end" edge when writing the stylex/css. The physical edge that this refers to is dependent on the writing direction. So `start` would be `left` in `ltr` and `right` in `rtl`, with `end` the opposite. It is **never** determined via the flex direction. Additionally, `start`/`end` takes precedence over the physical edge it corresponds to in the case both are defined.

So, all of this means that to actually get the value of a style from the flex start/end edges, we need to account for the case that one of these relative edges was defined and would overwrite any physical edge. Since this mapping is solely determined by the writing direction, we need to pass that in to all the flex start/end getters and do that logic. This is done in  `flexStartRelativeEdge`/`flexEndRelativeEdge` which was added earlier but for some reason only being used on border.

Reviewed By: NickGerleman

Differential Revision: D51293315

fbshipit-source-id: 26fafff54827134e7c5b10354ff9bfdf67096f5b
2023-12-04 19:35:30 -08:00
Joe Vilches
4ad9330fb9 Introduce positionAbsoluteChild (#1473)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1473

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

To simplify the logic a bit I introduce a new function called `positionAbsoluteChild`. This function will, eventually, be the **sole function that matters** when determining the layout position of an absolute node. Because [absolute nodes do not participate in flex layout](https://drafts.csswg.org/css-flexbox/#abspos-items), we can determine the position of said node independently of its siblings. The only information we need are the node itself, its parent, and its containing block - which we have all of in `layoutAbsoluteChild`.

Right now, however, this is purely a BE change with no functionality different. There was a big set of if statements at the end of `layoutAbsoluteChild` that would position the node on the main and cross axis for certain cases. The old code had it so that the main and cross axis had basically the same logic but the code was repeated. This puts that logic, as is, in `positionAbsoluteChild` and calls that from `layoutAbsoluteChild`.

I will soon edit this function to actually do what it is envisioned to do (i.e. be the sole place that position is set for absolute nodes).

Reviewed By: NickGerleman

Differential Revision: D51272855

fbshipit-source-id: 68fa1f0e0f4d595faf2af1d9eaceb467382ca406
2023-12-04 19:35:30 -08:00
Joe Vilches
e042cb102c Use containing block to adjust absolute child position (#1472)
Summary:
X-link: https://github.com/facebook/react-native/pull/41490

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

This change has most of the logic needed for supporting `position: static`. We do two things here that fix a lot of the broken static test:

1) We pass in the containing node to `layoutAbsoluteChild` and use it to properly position the child in the case that insets are defined.
2) We rewrite the absolute child's position to be relative to it's parent in the event that insets are defined for that child (and thus it is positioned relative to its CB). Yoga's layout position has always be relative to parent, so I feel it is easier to just adjust the coordinates of a node to adhere to that design rather than change the consumers of yoga.

The "hard" part of this algorithm is determining how to iterate the offset from the containing block needed to do this translation described above. That is handled in `layoutAbsoluteDescendants`.

Reviewed By: NickGerleman

Differential Revision: D51224327

fbshipit-source-id: ae6dc54fe2a71bebb4090ba21a0afb0125264cbc
2023-12-04 19:35:30 -08:00
Joe Vilches
2222c2c475 Allow the containing block to set trailing position of absolute descendants (#1471)
Summary:
X-link: https://github.com/facebook/react-native/pull/41489

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

If we are going to allow the containing block to layout its absolute descendants and NOT the direct parent then we need to change step 11 which is concerned with setting the trailing position in the case we are row or column reverse. This is the very last step in the function and is positioned that way because it operates on the assumption that all children have their position set by this time. That is no longer a valid assumption if CBs layout their absolute children. In that case the CB also needs to take care of setting the position here.

Because of this problem I moved some things around. It now works like:

* If errata is set, the direct parent will set trailing position for all non absolute children in step 11
* If errata is set the CB will set trailing position of absolute descendants after they are laid out inside of layoutAbsoluteDescendants

Reviewed By: NickGerleman

Differential Revision: D51217291

fbshipit-source-id: a7eea0d3623f9041b73d609a1de2bfb0f0343a26
2023-12-04 19:35:30 -08:00
Joe Vilches
5a24c81672 Let containing blocks layout their absolute descendants, not parents (#1470)
Summary:
X-link: https://github.com/facebook/react-native/pull/41488

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

The way we plan on implementing `position: static` is by changing how we lay out absolutely positioned nodes. Instead of letting their direct parent lay them out we are going to let their containing block handle it. This is useful because by the time the containing block gets to this step it will already know its size, which is needed to ensure that absolute nodes can get the right value with percentage units. Additionally, it means that we can "translate" the position of the absolute nodes to be relative to their parent fairly easily, instead of some second pass that would not be possible with a different design.

This change just gets the core pieces of this process going. It makes it so that containing blocks will layout out absolute descendants that they contain. We also pass in the containing block size to the owner size args for `layoutAbsoluteChild`. This new path will only happen if we have the errata turned off. If there is no positioned ancestor for a given node we just assume the root is. This is not exactly how it works on the web - there is a notion of an initial containing block - but we are not implementing that as of right now.

Reviewed By: NickGerleman

Differential Revision: D51182593

fbshipit-source-id: 88b5730f7f4fec4f33ec64288618e23363091857
2023-12-04 19:35:30 -08:00
Joe Vilches
59bf902a17 Insets no longer apply to statically positioned nodes (#1454)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1454

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

One of the most basic aspects of statically positioned nodes is that [insets do not apply to them](https://developer.mozilla.org/en-US/docs/Web/CSS/position#static). So I put a guard inside `Node::relativePosition` where we take that into account when setting the position.

Reviewed By: NickGerleman

Differential Revision: D50507808

fbshipit-source-id: 7aab4138b06e60936db0ddb6019a9a30f1ded2db
2023-12-04 19:35:30 -08:00
Nick Gerleman
382faa3f44 Change default back to position: "relative" (#1469)
Summary:
X-link: https://github.com/facebook/react-native/pull/41480

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

The previous version of static didn't do anything inside of Yoga. Now that we're making it do something, this changes the default back to relative so that users with no errata set don't see their deafult styles changing.

Reviewed By: joevilches

Differential Revision: D51182955

fbshipit-source-id: c0ea357694e1367fb6786f1907dfff784b19a4bc
2023-11-28 18:51:34 -08:00
Nick Gerleman
bb8fd593ff Remove NumericBitfield (#1463)
Summary:
X-link: https://github.com/facebook/react-native/pull/41394

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

Now that are enums are unsigned, and we don't have BitfieldRef, we can convert the last remaining user of NumericBitfield to a plain old bitfield,  for better readability (e.g. the default values), debugability, and less complexity. We also break a cycle which lets us properly group public vs private members.

Reviewed By: joevilches

Differential Revision: D51159415

fbshipit-source-id: 7842a8330eed6061b863de3f175c761dcf4aa2be
2023-11-27 21:20:20 -08:00
Nick Gerleman
9b0fd09ec6 Remove yoga::Style::BitfieldRef (#1459)
Summary:
X-link: https://github.com/facebook/react-native/pull/41393

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

Removes the last of the non setter-style style setters.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D51155925

fbshipit-source-id: 2921c87d95ad36495b7013e592d5169015321545
2023-11-27 21:20:20 -08:00
Nick Gerleman
ed6e91479c Remove yoga::Style::Ref (#1462)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1462

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

Moves the last usages of `yoga::Style::Ref` to setters.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D51154501

fbshipit-source-id: 52dbca7a76de500a8841387eb59fded463864de7
2023-11-27 21:20:20 -08:00
Nick Gerleman
325ccea068 YGEdge -> yoga::Edge (#1461)
Summary:
X-link: https://github.com/facebook/react-native/pull/41391

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

Converts usages of `YGEdge` within internal APIs to `yoga::Edge` scoped enum.

With the exception of YGUnit which is in its own state of transition, this is the last public yoga enum to need to be moved to scoped enum form for usages internal to the Yoga public API.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51152779

fbshipit-source-id: 06554f67bfd7709cbc24fdd9a5474e897e9e95d8
2023-11-25 20:41:22 -08:00
Nick Gerleman
a121483e81 Use CSS terminology for sizing rules (#1460)
Summary:
X-link: https://github.com/facebook/react-native/pull/41390

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

Yoga passes `MeasureMode`/`YGMeasureMode` to express constraints in how a box should be measured, given definite or indefinite available space.

This is modeled after Android [MeasureSpec](https://developer.android.com/reference/android/view/View.MeasureSpec), with a table above `calculateLayoutImpl()` explaining the CSS terms they map to. This can be confusing when flipping between the spec, and code.

This switches internal usages to the CSS terms, but leaves around `YGMeasureMode` since it is the public API passed to measure functions.

Reviewed By: joevilches

Differential Revision: D51068417

fbshipit-source-id: 0a76266a4e7e0cc39996164607229c3c41de2818
2023-11-25 20:41:22 -08:00
Nick Gerleman
aca02406ef CompactValue -> Style::Length (#1458)
Summary:
X-link: https://github.com/facebook/react-native/pull/41392

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

We're moving `CompactValue` to be an internal detail of `yoga::Style`, where users outside of the style will be dealing with a resolved/non-compact representation.

This change renames usages of `CompactValue` to `Style::Length`, which will be Yoga's representation for CSS input lengths. Right now one is just a type alias of the other, but this will let us change the internals of CompactValue with the rest of the world looking the same.

A few factory functions are added to `yoga::value` for creating CSS values. There are some shenanigans around how we want to represent CSS pixels (one YGUnitPoint), when we also end up adding CSS points (slightly larger than one YGUnitPoint). For now, I reused `point` until making other changes.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D51000389

fbshipit-source-id: 00f55e72bfb8aa291b53308f8a62ac8797be490f
2023-11-25 20:41:22 -08:00
Nick Gerleman
a822f2635e Do not expose aggregate style edges (#1477)
Summary:
X-link: https://github.com/facebook/react-native/pull/41610

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

A reland of the main change in D50998164, moving away from exposing compound edge arrays directly.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D51512611

fbshipit-source-id: 2d4ceb89c9d76317feb9074aa271358a3abc0ee1
2023-11-22 22:43:41 -08:00
Nick Gerleman
0ebac779aa Remove YGStyleAccessorsTest (#1476)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1476

Up the stack, Style uses just plain getters and setters. These tests aren't particularly useful enough to update.

Previously landed as part of D50998164

Reviewed By: joevilches

Differential Revision: D51481328

fbshipit-source-id: b0413270fd5951c7c8d783269b08cca9f939ce25
2023-11-22 22:43:41 -08:00
Nick Gerleman
0eb861b459 Don't enable ordinalCount() or bitCount() for bitset enums
Summary:
Bitfield enums are not sequential, so use of these functions on these enums would be invalid.

I looked at whether we could trivially move `bitCount` to template based on `ordinalCount`. `bitCount` must be constexpr, since we use it directly as a bit-field size constant. `log2` and `ceil` to be constexpr, which isn't here until C++ 26.

Reviewed By: javache

Differential Revision: D51518899

fbshipit-source-id: 256f15bbed517be6f90bf43baa43ce96e9259a71
2023-11-22 11:06:31 -08:00
Nick Gerleman
c7c81e3c89 Remove composite border comparisons (#1475)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1475

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

Removes cases where we rely on comparing composite of Yoga edges, since we are removing that internal API (public API is already one at a time). Extracted from D50998164, with more sound facility for looping through edges.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D51478403

fbshipit-source-id: 162170b91345ff86db44a49a04a2345f0fbd0911
2023-11-21 23:17:32 -08:00
Nick Gerleman
a713a598c8 Fix modulemap typo (#1474)
Summary:
X-link: https://github.com/facebook/react-native/pull/41564

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

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

We build with Swift, but don't build something consuming Yoga module, and don't use modulemap and CocoaPods. This is a gap in validation we should figure out, but in the meantime, we should fix the typo.

Reviewed By: christophpurrer

Differential Revision: D51472493

fbshipit-source-id: 60e05cc49969f51d5fc4856cf25ce2afede72f36
2023-11-20 14:10:56 -08:00
Nick Gerleman
27af596359 Revert D50998164: Allow lazy resolution of edge dimension values
Differential Revision:
D50998164

Original commit changeset: 248396f9587e

Original Phabricator Diff: D50998164

fbshipit-source-id: 4f592158324d758bb9e3731ced36b8e3587c459c
2023-11-15 18:34:47 -08:00
Nick Gerleman
f2c8acad2c Allow lazy resolution of edge dimension values (#1453)
Summary:
X-link: https://github.com/facebook/react-native/pull/41347

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

This follows the previous patterns used for `Gutters` and `Dimension`, where we hide CompactValue array implementation from `yoga::Style` callers.

This allows a single read of a style to only need access to the resolved values of a single edge, vs all edges. This is cheap now because the interface is the representation, but gets expensive if `StyleValuePool` is the actual implementation.

This prevents us from needing to resolve nine dimensions, in order to read a single value like `marginLeft`. Doing this, in the new style, also lets us remove `IdxRef` from the API.

We unroll the structure dependent parts in the props parsing code, for something more verbose, but also a bit clearer.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50998164

fbshipit-source-id: 248396f9587e29d62cde05ae7512d8194f60c809
2023-11-14 09:12:35 -08:00
Nick Gerleman
bb892af3a4 Make trunk builds "0.0.0" (#1466)
Summary:
X-link: https://github.com/facebook/react-native/pull/41423

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

Right now Yoga's main branch says it's 2.0.0, and RN's dirsync says its 1.14.0, but the code is really closer to what will be Yoga 3.0.0.

This changes trunk builds to "0.0.0" for clarity, which will be assigned a real version number the first time publishing a new Yoga branch.

This is separately a good practice to prevent the chance of accidental publishes causing damage.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51236778

fbshipit-source-id: 06cac89bcca1c707ce5c00f9c346f627eef6b4bc
2023-11-13 22:09:35 -08:00
Nick Gerleman
8c1a672f92 GitHub Actions Cleanup (#1467)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1467

1. Avoid reusing workflow names between validation and publish jobs, since they show up with the same UI when wanting to adhoc trigger a publish.
2. Merge SwiftPM checks into Validate Apple job
3. Merge remnants of website-next workflow into website workflow (and remove a redundant explicit build step already removed in one workflow)
4. Run more validation on push to release branch
5. Do not run website validation off of main, since it is only ever deployed from main branch

Reviewed By: cipolleschi

Differential Revision: D51236885

fbshipit-source-id: dd8165aa9871f173d8914f345569c6cde1edda72
2023-11-13 03:57:52 -08:00
Nick Gerleman
6f41a27e31 "yogalayout.com" to "yogalayout.dev" (#1465)
Summary:
X-link: https://github.com/facebook/react-native/pull/41420

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

https://yogalayout.com now redirects to https://yogalayout.dev

This replaces references to "yogalayout.com" with "yogalayout.dev", the same website, with a new domain. This includes:
1. Code comments
2. Yoga website config (publish action CNAME, Docusaurus config)
3. Documentation URLs in Yoga packages

Changelog:
[General][Fixed] - "yogalayout.com" to "yogalayout.dev"

Reviewed By: christophpurrer

Differential Revision: D51229587

fbshipit-source-id: b1c336a52aab5e02565071b61430d5435381dc0a
2023-11-13 02:48:29 -08:00
Nick Gerleman
1b1df3a87e Simplify YGConfigSetPointScaleFactor (#1451)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1451

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

The special meaning of `0.0` is now explained in the function header, and we aren't doing any sort of insensitive compare here, so the code after should be equivalent and a bit simpler.

Reviewed By: yungsters

Differential Revision: D51014264

fbshipit-source-id: 60f4a2df039f74089d5c7fabd4b7d8ac6234ba72
2023-11-10 16:31:46 -08:00
Nick Gerleman
c46ea9c6f5 Modularize and document public API (#1449)
Summary:
X-link: https://github.com/facebook/react-native/pull/41317

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

This aims to clean up the public Yoga C API, by:
1. Documenting public YGNode, YGValue, YGConfig APIs
2. Splitting APIs for specific objects into different header files (because Yoga.h was big enough without documentation)
3. Reordering headers and definitions for consistent grouping

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50963424

fbshipit-source-id: 45124b7370256fc63aefd6d5b7641466e9a79d3b
2023-11-10 16:31:46 -08:00
Nick Gerleman
12a8d16b62 Remove Yoga-internal.h (#1452)
Summary:
X-link: https://github.com/facebook/react-native/pull/41346

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

This removes the last remnant from `Yoga-interna.h`, `YGNodeDellocate()`. The API is renamed to `YGNodeFinalize` to give it the explicit purpose of freeing the node from a garbage collector, and made public with that documented contract.

With that, every top-level header is now a public API, and Yoga's JNI bindings do not need to rely on private headers anymore.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D51014340

fbshipit-source-id: 553f04b62c78b76f9102cd6197146650955aeec5
2023-11-07 21:27:59 -08:00
Nick Gerleman
9eb8a62739 Remove YGNodeMarkDirtyAndPropagateToDescendants (#1448)
Summary:
X-link: https://github.com/facebook/react-native/pull/41305

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

This should not be part of Yoga's API. If benchmarks want to do this, they still can (though I don't know the ones we have for it are super valuable).

Reviewed By: javache

Differential Revision: D50963933

fbshipit-source-id: 6482bd269928188b6469a358ffde5c4f9f5f9527
2023-11-07 21:27:59 -08:00
Joe Vilches
283e3203f6 Fix issue where absolute children of row-reverse containers would inset on the wrong side (#1446)
Summary:
X-link: https://github.com/facebook/react-native/pull/41293

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

NickGerleman pointed out that my recent changes to fix the slew of row-reverse problems in Yoga actually ended up regressing some parts. Specifically, absolute children of row-reverse containers would have their insets set to the wrong side. So if you set left: 10 it would apply it to the right.

Turns out, in `layoutAbsoluteChild` there were cases where we were applying inlineStart/End values to the flexStart/End edge, which can never be right. So I changed the values to also be flexStart/End as the fix here.

Reviewed By: NickGerleman

Differential Revision: D50945475

fbshipit-source-id: 290de06dcc04e8e644a3a32c127af12fdabb2f75
2023-11-07 11:02:20 -08:00
Joe Vilches
c09554056d Introduce isDefined() and remove cases of !isUndefined() (#1439)
Summary:
X-link: https://github.com/facebook/react-native/pull/41209

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

There are so many instances in this code base where we use the double negative of `!yoga::isUndefined(<something>)`. This is not as easy to read since because of this double negative imo. Additionally, sometimes we have really long chains like `!longVariableName.longFunctionName(longArgumentName).isUndefined()` and it is hard to see that this undefined is inverted.

This just replaces all instances of inverted `isUndefined()` with `isDefined()` so its easier to read.

Reviewed By: NickGerleman

Differential Revision: D50705523

fbshipit-source-id: edc7d3f2cbbae38ddaeb2030a419320caf73feff
2023-11-07 11:02:20 -08:00
Joe Vilches
e90f2a8e2c Simplify getting padding + border for cross axis in algorithm (#1437)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1437

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

Reading through the sizing logic and this seemed a bit redundant/confusing. Lets use the same function we just used for the main axis for the cross axis as well so people do not think its special. Also we will need one less variable. The reason this was done it seems is because we need the leading padding + border elsewhere so this is technically a few less steps but this is cleaner

Reviewed By: NickGerleman

Differential Revision: D50704177

fbshipit-source-id: 1a091edbfee6482a2bf472aca2980702bd75ad94
2023-11-07 11:02:20 -08:00
Joe Vilches
484118c89b Change gentest to only write position relative to parent
Summary:
`child.offsetLeft/Top` calculates the offset from child to its nearest positioned ancestor, not its direct parent. These are often the same and have not mattered in the past since we have not supported position static. Since are are in the process of supporting that, we would like our tests to be usable so this adjusts the gentest methodology to only speak the same language as Yoga - that is left/top are always relative to direct parents.

It works by using `getBoundingClientRect().left/top` instead. Then we pass that down to children and subtract it from the childs `getBoundingClientRect()` to get the position relative to the parent. Note we have to round the final result as `child.offsetLeft/Top` is rounded.

Reviewed By: NickGerleman

Differential Revision: D51053629

fbshipit-source-id: 8809588d12953565228ae50fdf38197213c46182
2023-11-07 09:57:04 -08:00
Joe Vilches
301ed20296 Remove unused arg in calculateTree in gentest.js
Summary: tsia

Reviewed By: NickGerleman

Differential Revision: D51050456

fbshipit-source-id: bd3ef113bd612f6d257b9adce5501f8e8bb32d26
2023-11-07 09:57:04 -08:00
Nick Gerleman
92860077f9 Port more content to website-next (#1435)
Summary:
This builds upon https://github.com/facebook/yoga/pull/1433 and starts porting over and fixing some of the code in website-next.

1. Create a hero similar to current https://yogalayout.com hero
2. Start moving from `antd` and harcoded colors to [Infima](https://infima.dev/docs/getting-started/introduction/) primitives provided by Docusaurus
3. Replaced some more stock docusaurus assets, links, and text with the ones for Yoga.

There is still a lot to do here (not the least, adding real content), but it's beginning to look like a website, and is already pretty snappy. Eventually I want to get SSR working correctly with Playground, which is still a little broken in the port.

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

Test Plan:
**Gatsby Original**
<img width="1795" alt="image" src="https://github.com/facebook/yoga/assets/835219/7670d53a-00a8-4146-a100-e4a05dd77488">

**New (light mode)**
<img width="800" alt="image" src="https://github.com/facebook/yoga/assets/835219/ebe11d15-5f6f-445f-bcc8-9ec51ecfac62">

**New (dark mode)**
<img width="800" alt="image" src="https://github.com/facebook/yoga/assets/835219/ca44a492-46df-410a-8303-baec3029ec49">

Reviewed By: yungsters

Differential Revision: D50523462

Pulled By: NickGerleman

fbshipit-source-id: 61b4610104f695a4e38a7d4bb6a0c2488bd6f89e
2023-11-03 05:23:56 -07:00
Joe Vilches
a20559063e Regenerate YGStaticPositionTest.test.ts that was failing github CI checks (#1447)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1447

Just ran

```
ruby xplat/yoga/gentest/gentest.rb
```

It seems that D50453324 changed a bunch of the import directories in these test files but for some reason it did not get picked up for this test. As a result we are seeing failing github checks like https://github.com/facebook/yoga/actions/runs/6738747977/job/18318958442. Should be good now.

Reviewed By: yungsters

Differential Revision: D50951161

fbshipit-source-id: a2472022782f64f840a64ed991f5f35c3ef556dc
2023-11-02 16:52:18 -07:00
Nick Gerleman
ef1d772447 Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417

This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.

This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.

As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).

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

Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes

Reviewed By: yungsters

Differential Revision: D50453324

Pulled By: NickGerleman

fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
Nick Gerleman
b19a07cff9 Use libc++ in Ubuntu Clang Build (#1440)
Summary:
An ubuntu-latest image update caused build failures, where GTest importing chrono headers caused an error inside of stdlib++ when being compiled by Clang.

This switches to explicitly asking for libc++ (LLVM stdlib) in the reference Ubuntu Clang build instead of stdlibc++ (GCC stdlib).

We don’t force this in CMake logic, to not force a specific stdlib for users compiling Yoga alongside other libraries. E.g. https://github.com/facebookexperimental/libunifex/issues/86

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

Reviewed By: joevilches

Differential Revision: D50790965

Pulled By: NickGerleman

fbshipit-source-id: fe525cfb4385a9a5ae6a02fcbc6decad0e07ff6e
2023-10-30 14:52:45 -07:00
Joe Vilches
4f98bfe40a Add tests for absolute positioning of children with padding in the parent
Summary:
I was playing around with absolute children and padding and noticed an issue so adding tests to track.

Made a github issue: https://github.com/facebook/yoga/issues/1436

Reviewed By: yungsters

Differential Revision: D50670457

fbshipit-source-id: 4672d1e8b831a0a42509d95e91178944fc0f5c06
2023-10-26 10:12:04 -07:00
Joe Vilches
52ae53a7c8 Add errata supporting changes to position: static (#1434)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1434

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

I will use this errata to gate my changes that actually make position: static behave like the web. We have future plans to make position: relative the default again but users could still have declared certain nodes as position: static, so I think this is needed regardless.

Reviewed By: NickGerleman

Differential Revision: D50506915

fbshipit-source-id: b0d9e6883167de6ff002352c9288053324464cb9
2023-10-23 18:20:24 -07:00
Joe Vilches
6cc9e58246 Add more tests to eventually test position: static
Summary:
Doing some test-driven-development to support this feature, so I will start by adding a ton of tests to ensure the nuance of position: static is captured in Yoga. Specifically I have a slew of tests to capture:

* Insets have no effect on static elements
* Insets are relative to the nearest non-static ancestor
* Percentage values for insets, padding, and margin of absolute children respect the correct dimension of the nearest non-static ancestor
  * Also added similar ones for static and relative children which should just respect their ancestor (static only because it is a flexbox by default)
  * This rule does NOT apply to border
* The containing block for absolute children is the padding box of their nearest non-static ancestor
* The containing block for static children is the content box of their parent (because all elements are flex containers in yoga, at least right now)

Reviewed By: NickGerleman

Differential Revision: D50475939

fbshipit-source-id: 7988ffc9bea3317875128dd1908d787b9b714a45
2023-10-23 18:20:24 -07:00
Joe Vilches
2ea4c043fd gentest support for position: static + initial test
Summary:
I am about to embark on supporting `position: static` in Yoga. The enum exists already (and is the default position type, lol) but does not actually do anything and just behaves like `position: relative`.

My approach here is to write a bunch of tests to test for the various behaviors of static positions and then develop on Yoga afterwards to get those tests passing. To do this, we need to make a few changes to the gentest files as there is not support for adding `position: static` at the moment:

* Make it so that the gentest code can physically write `YGPositionTypeStatic` if it encounters `position: static` in the style
* Make it so that gentest.js knows that Yoga's default is actually static. This way the code generated in the tests will actually label nodes for non default values
* Explicitly label the position type even when it is not declared in the style prop (with the exception of the default)
* Regenerate all the tests

Additionally I added the first, basic test: making sure insets do nothing on a statically positioned element.

Reviewed By: NickGerleman

Differential Revision: D50437855

fbshipit-source-id: 0e8bbf1c224d477ea4592b7563d0b70d2ffa79c8
2023-10-23 18:20:24 -07:00
Joe Vilches
7e91004b90 Remove skips on passing position tests and add errata tests
Summary: Now that the tests are passing let's not skip it anymore. Also adding errata tests to make sure most prod builds are still protected.

Reviewed By: NickGerleman

Differential Revision: D50390993

fbshipit-source-id: cb91a7a377e919eaca24fb25e3d73d3c92eb8931
2023-10-18 17:30:18 -07:00
Joe Vilches
b6f85a1c76 Fix issue where position insets were not working with row reverse (#1431)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1431

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

The last of the row-reverse issues hurray!

The position insets were broken with row-reverse since we were using the main-start/main-end edges to inset from and NOT the inline-start/inline-end edges as we should. This made it so that inset in left and right were swapped and same with top and bottom (with column-reverse). The solution here is the same as the previous ones were we are migrating to using inline-start/end as the leading/trailing edge now.

Reviewed By: NickGerleman

Differential Revision: D50390543

fbshipit-source-id: b714deab8489fbe11f7f6db21e4aad3b3aa314b3
2023-10-18 17:30:18 -07:00
Joe Vilches
2668e8e70c Fix row-reverse flex direction fixtures
Summary:
These tests were a bit weird for testing something with position. The gentest setup makes it so that the fixtures are wrapped in a absolutely positioned container with height and width bot 0. However, the generated yoga tests do NOT do this and instead have the root node as the fixture itself with no wrapping container.

This causes a problem when testing left/right/top/bottom position insets. Because left/right/top/bottom will position the element relative to its containing block when position is absolute, we will get different values on yoga and chrome even if the implementation is correct: https://developer.mozilla.org/en-US/docs/Web/CSS/right#description

To fix this, we just wrap the fixture in a set size div that is also absolutely positioned.

The file was also formatted.

Reviewed By: NickGerleman

Differential Revision: D50389229

fbshipit-source-id: ecd23939b973225cfb0611dc87f30c262952c5fc
2023-10-18 17:30:18 -07:00
Nick Gerleman
f1f869b955 Build with MSVC /W4 (#1432)
Summary:
X-link: https://github.com/facebook/react-native/pull/41044

The reference Clang/GCC build has a pretty strict set of warnings enabled. The reference MSVC build has less strict warnings, which can be a problem for MSVC users building at higher warning levels (e.g. React Native for Windows in OSS uses `/W4` as its baseline warning level).

This bumps up the MSVC warning level to `/W4`, since we are nearly clean already.

There are some limitations. E.g. we don't test binary with MSVC (some issues I didn't work out), and only test building statically linked. But but we do have a minimal C benchmark we compile with MSVC.

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

Test Plan: GitHub Actions running benchmark MSVC build.

Reviewed By: yungsters

Differential Revision: D50398443

Pulled By: NickGerleman

fbshipit-source-id: 6616034d79b1a308b32d5d3387bae70f40b7b5ab
2023-10-18 17:24:52 -07:00
Nico Burns
0d28b283e2 Support "align-content: space-evenly" (#1422)
Summary:
X-link: https://github.com/facebook/react-native/pull/41019

### Changes made
- Regenerated tests (as some aspect ratio tests seem to be out of date compared to the fixtures)
- Added SpaceEvenly variant to the "Align" enums (via enums.py)
- Implemented `align-content: space-evenly` alignment in CalculateLayout.cpp
- Added generated tests `align-content: space-evenly`
- Updated NumericBitfield test to account for the fact that the Align enum now requires more bits (this bit could do with being reviewed as I am not 100% certain that it's valid to just update the test like this).

### Changes not made
- Any attempt to improve the spec-compliance of content alignment in general (e.g. I think https://github.com/facebook/yoga/pull/1013 probably still needs to happen)

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

Reviewed By: yungsters

Differential Revision: D50305438

Pulled By: NickGerleman

fbshipit-source-id: ef9f6f14220a0db066bc30db8dd690a4a82a0b00
2023-10-17 20:59:51 -07:00
Joe Vilches
2e2c124c28 Revamp tests for row reverse + padding after fix
Summary: no longer skip passing tests + add errata tests

Reviewed By: NickGerleman

Differential Revision: D50282417

fbshipit-source-id: 515600111c1ad7b15e40cfe5a3894e40c241c559
2023-10-17 20:30:16 -07:00
Joe Vilches
7502595bef Fix issue where paddingStart and paddingEnd were swapped with row reverse (#1426)
Summary:
X-link: https://github.com/facebook/react-native/pull/41023

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

Just like D50140503 where marginStart and marginEnd were not working with row reverse, paddingStart and paddingEnd are not working either with row reverse either. The solution is similar - we were checking the flex item layout starting/ending edges and not the general layout starting/ending edges. This change makes it so that we look at the proper edge according to what direction is set.

One caveat is that in the case of padding (and also border) there is a callsite that actually wants to get the flex item layout's leading/trailing padding and not the one dictated by direction. So, I made a new function to accommodate this and just swapped that callsite out.

Reviewed By: NickGerleman

Differential Revision: D50348995

fbshipit-source-id: 85717df23de7cf5f66b38d3ff28435b053a4e68e
2023-10-17 20:30:16 -07:00
Joe Vilches
b558059b74 Revamp tests for row reverse + border after fix
Summary: this is fixed now so we can turn it on

Reviewed By: NickGerleman

Differential Revision: D50348206

fbshipit-source-id: 61c2a72164c6f0ee91b1b5b576d3f129e8cfbe40
2023-10-17 20:30:16 -07:00
Joe Vilches
b52d6ce7f2 Fix issue where borderStart and borderEnd were swapped with row reverse (#1425)
Summary:
X-link: https://github.com/facebook/react-native/pull/41022

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

Just like D50140503 where marginStart and marginEnd were not working with row reverse, borderStart and borderEnd are not working either with row reverse either. The solution is similar - we were checking the flex item layout starting/ending edges and not the general layout starting/ending edges. This change makes it so that we look at the proper edge according to what direction is set.

One caveat is that in the case of border (and also padding) there is a callsite that actually wants to get the flex item layout's leading/trailing border and not the one dictated by direction. So, I made a new function to accommodate this and just swapped that callsite out.

Reviewed By: NickGerleman

Differential Revision: D50348085

fbshipit-source-id: eca2702c1753dbebb503034e2f0732684ad6c56e
2023-10-17 20:30:16 -07:00
Joe Vilches
e17005960f Rename ambiguous getLeading/Trailing... functions in Node.cpp (#1424)
Summary:
X-link: https://github.com/facebook/react-native/pull/41018

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

See D50344874

Reviewed By: NickGerleman

Differential Revision: D50344874

fbshipit-source-id: 32fc35df674eb854c682a5e387c031a94c1c4f68
2023-10-17 20:30:16 -07:00
Joe Vilches
bab6b43683 Rename ambiguous leading/trailingEdge functions (#1423)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1423

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

Before resolving https://github.com/facebook/yoga/issues/1208 yoga was in a state where "leading" and "trailing" only referred to the main-start and main-end directions ([definition in spec](https://drafts.csswg.org/css-flexbox/#box-model)). That is, the start/end of the layout of flex items in a container. This is distinct from something like inline-start/inline-end which is the [start of text layout as defined by direction](https://drafts.csswg.org/css-writing-modes-3/#inline-start).

The bug linked above happened because "leading" and "trailing" functions are referring to the wrong directions in certain cases. So in order to fix this we added a new set of functions to get the "leading" and "trailing" edges according to what inline-start/inline-end would refer to - i.e. those defined by the direction (ltr | rtl). In this state I think it is confusing to understand which function refers to which direction and more specific names could help that.

This diff just renames the following 4 FlexDirection.h functions:

* **leadingEdge** -> **flexStartEdge**
* **trailingEdge** -> **flexEndEdge**
* **leadingLayoutEdge** -> **inlineStartEdge**
* **trailingLayoutEdge** -> **inlineEndEdge**

The spec calls the start/end directions as dictated by the flex-direction attribute "main-start" and "main-end" respectively, but mainStartEdge might be a bit confusing given it will be compared to a non-flexbox-specific name in inlineStartEdge. As a result I landed on flexStart/flexEnd similar to what values are used with alignment attributes (justify-content, align-content).

I chose to get rid of the "leading" and "trailing" descriptors to be more in line with what terminology the spec uses.

Next diff will be to rename the functions in Node.cpp to adhere to the above patterns.

Reviewed By: NickGerleman

Differential Revision: D50342254

fbshipit-source-id: 1e83a885876af9cf363822ebdbb64537f4784520
2023-10-17 20:30:16 -07:00
dependabot[bot]
b40e44c1ab Bump @babel/traverse from 7.21.5 to 7.23.2 (#1428)
Summary:
Bumps [babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.21.5 to 7.23.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/babel/babel/releases"><code>@​babel/traverse</code>'s releases</a>.</em></p>
<blockquote>
<h2>v7.23.2 (2023-10-11)</h2>
<p><strong>NOTE</strong>: This release also re-publishes <code>babel/core</code>, even if it does not appear in the linked release commit.</p>
<p>Thanks <a href="https://github.com/jimmydief"><code>@​jimmydief</code></a> for your first PR!</p>
<h4>🐛 Bug Fix</h4>
<ul>
<li><code>babel-traverse</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16033">#16033</a> Only evaluate own String/Number/Math methods (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-preset-typescript</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16022">#16022</a> Rewrite <code>.tsx</code> extension when using <code>rewriteImportExtensions</code> (<a href="https://github.com/jimmydief"><code>@​jimmydief</code></a>)</li>
</ul>
</li>
<li><code>babel-helpers</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16017">#16017</a> Fix: fallback to typeof when toString is applied to incompatible object (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-helpers</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16025">#16025</a> Avoid override mistake in namespace imports (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
</ul>
<h4>Committers: 5</h4>
<ul>
<li>Babel Bot (<a href="https://github.com/babel-bot"><code>@​babel-bot</code></a>)</li>
<li>Huáng Jùnliàng (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
<li>James Diefenderfer (<a href="https://github.com/jimmydief"><code>@​jimmydief</code></a>)</li>
<li>Nicolò Ribaudo (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
<li><a href="https://github.com/liuxingbaoyu"><code>@​liuxingbaoyu</code></a></li>
</ul>
<h2>v7.23.1 (2023-09-25)</h2>
<p>Re-publishing <code>babel/helpers</code> due to a publishing error in 7.23.0.</p>
<h2>v7.23.0 (2023-09-25)</h2>
<p>Thanks <a href="https://github.com/lorenzoferre"><code>@​lorenzoferre</code></a> and <a href="https://github.com/RajShukla1"><code>@​RajShukla1</code></a> for your first PRs!</p>
<h4>🚀 New Feature</h4>
<ul>
<li><code>babel-plugin-proposal-import-wasm-source</code>, <code>babel-plugin-syntax-import-source</code>, <code>babel-plugin-transform-dynamic-import</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15870">#15870</a> Support transforming <code>import source</code> for wasm (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-helper-module-transforms</code>, <code>babel-helpers</code>, <code>babel-plugin-proposal-import-defer</code>, <code>babel-plugin-syntax-import-defer</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15878">#15878</a> Implement <code>import defer</code> proposal transform support (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-generator</code>, <code>babel-parser</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15845">#15845</a> Implement <code>import defer</code> parsing support (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
<li><a href="https://redirect.github.com/babel/babel/pull/15829">#15829</a> Add parsing support for the &quot;source phase imports&quot; proposal (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-generator</code>, <code>babel-helper-module-transforms</code>, <code>babel-parser</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-systemjs</code>, <code>babel-traverse</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15682">#15682</a> Add <code>createImportExpressions</code> parser option (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-standalone</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15671">#15671</a> Pass through nonce to the transformed script element (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-helper-function-name</code>, <code>babel-helper-member-expression-to-functions</code>, <code>babel-helpers</code>, <code>babel-parser</code>, <code>babel-plugin-proposal-destructuring-private</code>, <code>babel-plugin-proposal-optional-chaining-assign</code>, <code>babel-plugin-syntax-optional-chaining-assign</code>, <code>babel-plugin-transform-destructuring</code>, <code>babel-plugin-transform-optional-chaining</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15751">#15751</a> Add support for optional chain in assignments (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-helpers</code>, <code>babel-plugin-proposal-decorators</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15895">#15895</a> Implement the &quot;decorator metadata&quot; proposal (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-traverse</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15893">#15893</a> Add <code>t.buildUndefinedNode</code> (<a href="https://github.com/liuxingbaoyu"><code>@​liuxingbaoyu</code></a>)</li>
</ul>
</li>
<li><code>babel-preset-typescript</code></li>
</ul>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/babel/babel/blob/main/CHANGELOG.md"><code>@​babel/traverse</code>'s changelog</a>.</em></p>
<blockquote>
<h2>v7.23.2 (2023-10-11)</h2>
<h4>🐛 Bug Fix</h4>
<ul>
<li><code>babel-traverse</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16033">#16033</a> Only evaluate own String/Number/Math methods (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-preset-typescript</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16022">#16022</a> Rewrite <code>.tsx</code> extension when using <code>rewriteImportExtensions</code> (<a href="https://github.com/jimmydief"><code>@​jimmydief</code></a>)</li>
</ul>
</li>
<li><code>babel-helpers</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16017">#16017</a> Fix: fallback to typeof when toString is applied to incompatible object (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-helpers</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/16025">#16025</a> Avoid override mistake in namespace imports (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
</ul>
<h2>v7.23.0 (2023-09-25)</h2>
<h4>🚀 New Feature</h4>
<ul>
<li><code>babel-plugin-proposal-import-wasm-source</code>, <code>babel-plugin-syntax-import-source</code>, <code>babel-plugin-transform-dynamic-import</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15870">#15870</a> Support transforming <code>import source</code> for wasm (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-helper-module-transforms</code>, <code>babel-helpers</code>, <code>babel-plugin-proposal-import-defer</code>, <code>babel-plugin-syntax-import-defer</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15878">#15878</a> Implement <code>import defer</code> proposal transform support (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-generator</code>, <code>babel-parser</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15845">#15845</a> Implement <code>import defer</code> parsing support (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
<li><a href="https://redirect.github.com/babel/babel/pull/15829">#15829</a> Add parsing support for the &quot;source phase imports&quot; proposal (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-generator</code>, <code>babel-helper-module-transforms</code>, <code>babel-parser</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-systemjs</code>, <code>babel-traverse</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15682">#15682</a> Add <code>createImportExpressions</code> parser option (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-standalone</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15671">#15671</a> Pass through nonce to the transformed script element (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-helper-function-name</code>, <code>babel-helper-member-expression-to-functions</code>, <code>babel-helpers</code>, <code>babel-parser</code>, <code>babel-plugin-proposal-destructuring-private</code>, <code>babel-plugin-proposal-optional-chaining-assign</code>, <code>babel-plugin-syntax-optional-chaining-assign</code>, <code>babel-plugin-transform-destructuring</code>, <code>babel-plugin-transform-optional-chaining</code>, <code>babel-runtime-corejs2</code>, <code>babel-runtime-corejs3</code>, <code>babel-runtime</code>, <code>babel-standalone</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15751">#15751</a> Add support for optional chain in assignments (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-helpers</code>, <code>babel-plugin-proposal-decorators</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15895">#15895</a> Implement the &quot;decorator metadata&quot; proposal (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-traverse</code>, <code>babel-types</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15893">#15893</a> Add <code>t.buildUndefinedNode</code> (<a href="https://github.com/liuxingbaoyu"><code>@​liuxingbaoyu</code></a>)</li>
</ul>
</li>
<li><code>babel-preset-typescript</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15913">#15913</a> Add <code>rewriteImportExtensions</code> option to TS preset (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
<li><code>babel-parser</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15896">#15896</a> Allow TS tuples to have both labeled and unlabeled elements (<a href="https://github.com/yukukotani"><code>@​yukukotani</code></a>)</li>
</ul>
</li>
</ul>
<h4>🐛 Bug Fix</h4>
<ul>
<li><code>babel-plugin-transform-block-scoping</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15962">#15962</a> fix: <code>transform-block-scoping</code> captures the variables of the method in the loop (<a href="https://github.com/liuxingbaoyu"><code>@​liuxingbaoyu</code></a>)</li>
</ul>
</li>
</ul>
<h4>💅 Polish</h4>
<ul>
<li><code>babel-traverse</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15797">#15797</a> Expand evaluation of global built-ins in <code>babel/traverse</code> (<a href="https://github.com/lorenzoferre"><code>@​lorenzoferre</code></a>)</li>
</ul>
</li>
<li><code>babel-plugin-proposal-explicit-resource-management</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15985">#15985</a> Improve source maps for blocks with <code>using</code> declarations (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
</ul>
<h4>🔬 Output optimization</h4>
<ul>
<li><code>babel-core</code>, <code>babel-helper-module-transforms</code>, <code>babel-plugin-transform-async-to-generator</code>, <code>babel-plugin-transform-classes</code>, <code>babel-plugin-transform-dynamic-import</code>, <code>babel-plugin-transform-function-name</code>, <code>babel-plugin-transform-modules-amd</code>, <code>babel-plugin-transform-modules-commonjs</code>, <code>babel-plugin-transform-modules-umd</code>, <code>babel-plugin-transform-parameters</code>, <code>babel-plugin-transform-react-constant-elements</code>, <code>babel-plugin-transform-react-inline-elements</code>, <code>babel-plugin-transform-runtime</code>, <code>babel-plugin-transform-typescript</code>, <code>babel-preset-env</code>
<ul>
<li><a href="https://redirect.github.com/babel/babel/pull/15984">#15984</a> Inline <code>exports.XXX =</code> update in simple variable declarations (<a href="https://github.com/nicolo-ribaudo"><code>@​nicolo-ribaudo</code></a>)</li>
</ul>
</li>
</ul>
<h2>v7.22.20 (2023-09-16)</h2>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="b4b9942a6c"><code>b4b9942</code></a> v7.23.2</li>
<li><a href="b13376b346"><code>b13376b</code></a> Only evaluate own String/Number/Math methods (<a href="https://github.com/babel/babel/tree/HEAD/packages/babel-traverse/issues/16033">#16033</a>)</li>
<li><a href="ca58ec15cb"><code>ca58ec1</code></a> v7.23.0</li>
<li><a href="0f333dafcf"><code>0f333da</code></a> Add <code>createImportExpressions</code> parser option (<a href="https://github.com/babel/babel/tree/HEAD/packages/babel-traverse/issues/15682">#15682</a>)</li>
<li><a href="3744545649"><code>3744545</code></a> Fix linting</li>
<li><a href="c7e6806e21"><code>c7e6806</code></a> Add <code>t.buildUndefinedNode</code> (<a href="https://github.com/babel/babel/tree/HEAD/packages/babel-traverse/issues/15893">#15893</a>)</li>
<li><a href="38ee8b4dd6"><code>38ee8b4</code></a> Expand evaluation of global built-ins in <code>babel/traverse</code> (<a href="https://github.com/babel/babel/tree/HEAD/packages/babel-traverse/issues/15797">#15797</a>)</li>
<li><a href="9f3dfd9021"><code>9f3dfd9</code></a> v7.22.20</li>
<li><a href="3ed28b29c1"><code>3ed28b2</code></a> Fully support <code>||</code> and <code>&amp;&amp;</code> in <code>pluginToggleBooleanFlag</code> (<a href="https://github.com/babel/babel/tree/HEAD/packages/babel-traverse/issues/15961">#15961</a>)</li>
<li><a href="77b0d73599"><code>77b0d73</code></a> v7.22.19</li>
<li>Additional commits viewable in <a href="https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@babel/traverse&package-manager=npm_and_yarn&previous-version=7.21.5&new-version=7.23.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: yungsters

Differential Revision: D50373481

Pulled By: NickGerleman

fbshipit-source-id: 8ee1ef3f180c92e7858f4b748a96a30b7fea6317
2023-10-17 16:43:09 -07:00
Nick Gerleman
40279a8d4a Bump 'postcss' and 'word-wrap' (#1427)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1427

Fixes https://github.com/facebook/yoga/pull/1336
Fixes https://github.com/facebook/yoga/pull/1416

Reviewed By: yungsters

Differential Revision: D50349988

fbshipit-source-id: 6ab938b5914b26928ab627022e8a6e93310d65d5
2023-10-16 20:33:34 -07:00
Joe Vilches
656830e595 Add test for errata behavior for margin start/end
Summary: see D50200030

Reviewed By: NickGerleman

Differential Revision: D50231227

fbshipit-source-id: 5c1c51d8d885a36a0a51573f36a8ccc4c3b2e125
2023-10-12 17:51:24 -07:00
Joe Vilches
3fbd92bc3b No longer skip margin_start and margin_end row reverse tests
Summary: These are fixed now!

Reviewed By: NickGerleman

Differential Revision: D50200030

fbshipit-source-id: ac3e80e33d8c35440e342a10cfd3246161ee9018
2023-10-12 16:22:27 -07:00
Joe Vilches
f4337fbb07 Fix issue where marginStart and marginEnd were not working with rowReverse flex direction (#1420)
Summary:
X-link: https://github.com/facebook/litho/pull/962

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

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

This stack is ultimately aiming to solve https://github.com/facebook/yoga/issues/1208

**The problem**
Turns out that we do not even check direction when determining which edge is the leading (start) and trailing (end) edges. This is not how web does it as the start/end is based on the writing direction NOT the flex direction: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox#start_and_end_lines. While web does not have marginStart and marginEnd, they do have margin-inline-start/end which relies on the writing mode to determine the "start"/"end": https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-start.

This means that if you do something like
```
export default function Playground(props: Props): React.Node {
  return (
    <View style={styles.container}>
      <View style={styles.item} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    marginEnd: 100,
    flexDirection: 'row-reverse',
    backgroundColor: 'red',
    display: 'flex',
    width: 100,
    height: 100,
  },
  item: {
    backgroundColor: 'blue',
    width: 10,
  },
});
```

You get  {F1116264350}
As you can see the margin gets applied to the left edge even thought the direction is ltr and it should be applied to the right edge.

**The solution**
I ended up fixing this by creating a new `leadingLayoutEdge` and `trailingLayoutEdge` function that take the flex direction as well as the direction. Based on the errata, the a few functions will use these new functions to determine which `YGEdge` is the starting/ending.

You might be wondering why I did not put this logic inside of `leadingEdge(flexDirection)` / `trailingEdge(flexDirection)` since other areas could potentially have the same bug like `getLeadingPadding`. These functions are a bit overloaded and there are cases where we actually want to use the flexDirection to get the edge in question. For example, many of the calls to `setLayoutPosition` in `CalculateLayout.cpp` call `leadingEdge()` / `trailingEdge()` to set the proper position for cases like row-reverse where items need to line up in a different direction.

Reviewed By: NickGerleman

Differential Revision: D50140503

fbshipit-source-id: 5b580c7570f6ae1e2d031971926ac4e8f52dd362
2023-10-12 16:22:27 -07:00
Joe Vilches
50dc5ae2d1 Add errata for fix to marginStart/End for row-reverse flex direction (#1419)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1419

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

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

This stack is ultimately aiming to solve https://github.com/facebook/yoga/issues/1208

This adds an value to the Errata enum. I will use this to gate this fix as there is potential for users to rely on this bug or have a hack in place to fix it and this would be a breaking change.

Reviewed By: NickGerleman

Differential Revision: D50145273

fbshipit-source-id: 913d2103cd31c1fa94cb39fc15d05b0c0b255920
2023-10-12 16:22:27 -07:00
Eric Rozell
50ecd98141 Add test fixture to reproduce bug in aspect-ratio (#1421)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1421

Adds repro of inconsistent implementation of aspect-ratio behavior across Web and React Native.

Reviewed By: NickGerleman

Differential Revision: D50225804

fbshipit-source-id: 0494e0373dcdebc789715b2ec19c002a47d69ce0
2023-10-12 15:02:00 -07:00
Eric Rozell
a876372357 Add option to use aspect-ratio in test fixtures
Summary: Wires up codegen for aspect-ratio styles in JS, Java and CPP gentest fixtures.

Reviewed By: NickGerleman

Differential Revision: D50225805

fbshipit-source-id: 660a3999eab24611b7c2d2e073b1d55180a5d4f0
2023-10-12 15:02:00 -07:00
Eric Rozell
fad4d50b8e Add option to use overflow: scroll in text fixtures
Summary: Wires up the option to use overflow: scroll in JS, Java, and CPP gentest fixtures.

Reviewed By: NickGerleman

Differential Revision: D50225803

fbshipit-source-id: f71c000b7143ad9e0e34d99e2d5ba2c6186266d1
2023-10-12 15:02:00 -07:00
Joe Vilches
bac658b4f5 Add row reverse tests for position
Summary: after looking into the issue described in https://github.com/facebook/yoga/issues/1208 it seems to apply to position too, so adding tests to confirm

Reviewed By: NickGerleman

Differential Revision: D50154056

fbshipit-source-id: 64dd04ce3ad765526a547fe60b699b664f251c06
2023-10-11 14:02:39 -07:00
Joe Vilches
799624b9a5 Add row reverse tests for border
Summary: after looking into the issue described in https://github.com/facebook/yoga/issues/1208 it seems to apply to border too, so adding tests to confirm

Reviewed By: NickGerleman

Differential Revision: D50153472

fbshipit-source-id: a50f3e040153086b6a573924b513919dbb94f3c0
2023-10-11 14:02:39 -07:00
Joe Vilches
9d9b1f0874 Add row reverse tests for padding
Summary: after looking into the issue described in https://github.com/facebook/yoga/issues/1208 it seems to apply to padding too, so adding tests to confirm

Reviewed By: NickGerleman

Differential Revision: D50153085

fbshipit-source-id: bad0ef50389a71a45ec3a58d87c1dea0c2b26024
2023-10-11 14:02:39 -07:00
Chiara Mooney
81de77af8d Fix Type Casting Warnings in ReactCommon
Summary:
Casting warnings are treated as errors in React Native Windows. Adjusting casting to fix warnings.

## Changelog:
[GENERAL] [FIXED] - Fixes type casting warnings that are treated as errors downstream in React Native Windows.

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

Reviewed By: rshest

Differential Revision: D49940422

Pulled By: NickGerleman

fbshipit-source-id: e4d44326806a2b1974c7e50770e61807a007e39f
2023-10-09 11:07:46 -07:00
Nick Gerleman
7fe6e345a7 FloatOptional GCC build fix and more constexpr (#1411)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1411

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

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

GCC flags that `isUndefined()` is not declared `constexpr` but that `unwrapOrDefault()` is. `std::isnan` is not constexpr until C++ 23 (because we cannot have nice things), so I made `yoga::isUndefined()` constexpr, using the same code `std::isnan()` boils down to. I then made `FloatOptional` depend on `Comparison.h` (instead of the other way around), so we can use it.

Note that the use of the `std::floating_point` concept here requires the libc++ bump in the previous diff in the stack.

Reviewed By: yungsters

Differential Revision: D49896837

fbshipit-source-id: 61e2bbbfedecffd007a12d42d998e43d3cf5119c
2023-10-06 13:04:39 -07:00
Nick Gerleman
f700e1335c C++ style enums 17/N: Gutter (#1407)
Summary:
X-link: https://github.com/facebook/react-native/pull/39599

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

Replaces internal usages of YGGutter with Gutter.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49532100

fbshipit-source-id: 53c1d23e23a9db7294c66b6dc0eaff4e62ff278c
2023-10-04 20:34:42 -07:00
Nick Gerleman
98d2172e05 Use modern Android libc++ in Yoga and React Native OSS (#1412)
Summary:
X-link: https://github.com/facebook/react-native/pull/39795
Pull Request resolved: https://github.com/facebook/yoga/pull/1412

Android NDK 25 uses a version of libc++ that is more than three years old, missing a lot of basic features of C++ 20. This is rectified in NDK 26 (latest LTS NDK), which brings us up to date with latest Clang (17, released this year), and adds a new policy where future NDK versions will bump libc++ as part of bumping LLVM/Clang.

This requires an a beta AGP version (and corresponding Android Studio Preview). Based on how far we are historically, it wouldn't be a surprise if we see the stable release this month (well before the RN 0.74/Yoga 3.0 cut, even in the worse case).

Changelog:
[Android][Changed] - Use NDK 26

Reviewed By: yungsters

Differential Revision: D49895949

fbshipit-source-id: 37bb4d1fdf81137be7f14f6675b4e079c6f861e4
2023-10-04 19:57:14 -07:00
Nick Gerleman
2734784ddb Fix style resolution functions returning FloatOptional (#1404)
Summary:
X-link: https://github.com/facebook/react-native/pull/39595

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

These functions all ensure their returns are defined, but return FloatOptional anyway, making their callers have to deal with that possibility. Return `float` instead of `FloatOptional`, and do some additional cleanup.

Reviewed By: rshest

Differential Revision: D49531421

fbshipit-source-id: 95b21cade74e501dd54c7b6ca667c8c3859c5dae
2023-10-03 15:36:01 -07:00
Joe Vilches
ce8fe99bf9 Fix typo on aspect ratio page
Summary: Was reading https://yogalayout.com/docs/aspect-ratio and noticed a typo. "Flexbox does has" -> "Flexbox does have"

Reviewed By: NickGerleman

Differential Revision: D49885138

fbshipit-source-id: 847b40eda257bd0726c3992a7285ac6fa267d418
2023-10-03 14:44:00 -07:00
Joe Vilches
e099449c37 Adding optional QOL flags to gentest
Summary:
This diff adds the ability to add 2 flags to gentest.rb that can help with debugging that I found myself wanting to use:

* The ability to suspend the script. Meaning the chrome browser will pause after running each fixture so the user can inspect elements to see if their html is as expected. Normally, the browser just redirects to the next fixture
* The ability to run a specific fixture instead of all fixtures. I found myself wanting to do this as I was changing one in the previous diff. If the user input is incorrect it just ignores it.

Hopefully this will help make debugging this script a bit easier for noobs like me :P

Reviewed By: NickGerleman

Differential Revision: D49775228

fbshipit-source-id: 29933029119ee5afc0195213df70d4d2cf881a9e
2023-10-03 11:31:34 -07:00
Joe Vilches
e60ae290ea Add fixtures to test proper margins with reverse flex directions
Summary:
Yoga has a known bug where marginStart and marginEnd will swap with row-reverse flex direction. This is not the intended behavior. On Paper this is also an issue with marginLeft and marginRight (at least we think Paper is the culprit, not exactly clear yet).

margin-start (and end) is not actually valid css. The gentest.rb script will just turn this into margin-left, but the cpp generated will properly test marginStart. This seems a bit weird to be since marginStart != marginLeft AFAIK. Things like RTL and LTR modes might make this test not exactly right. But given how many other tests depend on this quirk I think it is fine to add as is - the end result is the same after all. If not, a followup would be to add support for mapping margin-inline-start (valid css) to marginStart.

Anyway, this diff is to add test coverage for this scenario. Next stop is to actually try to fix this problem, which may be a bit harder :P

See https://github.com/facebook/yoga/issues/1208 for more info.

Reviewed By: NickGerleman

Differential Revision: D49744271

fbshipit-source-id: 75b8dd0cc5c53b2f338476fb70b60006aaa89054
2023-10-03 11:31:34 -07:00
Nick Gerleman
4ef28bce24 Remove usage of Gutters arrays and YGGutter as index (#1406)
Summary:
X-link: https://github.com/facebook/react-native/pull/39597

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

Similar in vain to D49362819, we want to stop exposing pre-resolved CompactValue, and allow enum class usage without becoming annoying.

This also simplifies gap resolution a bit. I moved this to Style, to make it clear we aren't relying on any node state. I plan to do some similar cleanup for other resolution later.

Reviewed By: rshest

Differential Revision: D49530923

fbshipit-source-id: 47b06a7301fb283acc493dba159f496159d59580
2023-10-03 10:08:10 -07:00
jlmip
07cabca526 Fixed issue with first line element gap handling. (#1408)
Summary:
If the first element of a line is not contributing (e.g. position absolute), an additional gap will be added to the line, because the first gap element of the line is never identified (wrong start index).
Fix: raise the index of the first line element until we find an element that is contributing to the line.

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

Reviewed By: yungsters

Differential Revision: D49722065

Pulled By: NickGerleman

fbshipit-source-id: 1068cb0b11ae4b04ec8d063e70540cce06181d5a
2023-10-03 06:24:48 -07:00
Nick Gerleman
b03a821884 Fix handling of negative flex gap (#1405)
Summary:
X-link: https://github.com/facebook/react-native/pull/39596

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

I noticed that we weren't clamping negative flex gap values to zero. This fixes that bug.

Reviewed By: rshest

Differential Revision: D49530494

fbshipit-source-id: 069db7312f72a085c5c4b01ead7bc66a353a07e5
2023-09-30 21:09:13 -07:00
Nick Gerleman
a8566a0150 C++ style enums 16/N: Dimension (#1403)
Summary:
X-link: https://github.com/facebook/react-native/pull/39598

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

Replaces all usages of YGDimension with Dimension.

Adds `yoga::to_underlying` to act like `std::to_underlying`, added in C++ 23.

This enum is oddly only used internally, and is never an input to the public API, but it handled as any other public generated enum. Potentially some more cleanup to do there.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49475409

fbshipit-source-id: 7d4c31e8a84485baea0dab50b5cf16b86769fa07
2023-09-29 00:06:34 -07:00
Nick Gerleman
8d24fcd90f Remove FloatOptional related TODOs
Summary:
These were added quite a while ago, and the proprosed change doesn't really make sense to pursue, since FloatOptional is a C++ wrapper around a Float, and the public API is entirely C.

bypass-github-export-checks

Reviewed By: rshest

Differential Revision: D49476343

fbshipit-source-id: f83cc99adda75fc0dba96e063cca92510c3d2ef0
2023-09-21 18:14:46 -07:00
Nick Gerleman
83705c2942 Remove usage of Dimension arrays and YGDimension as index (#1402)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1402

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

This change hides away most usages of YGDimension as an index. We do this for a couple reasons:

1. Right now the style interface may return a full array of resolved edge or dimension values, as a CompactValue. As we abstract away from CompactValue, and move towards ValuePool, this will no longer be the internal interface, and cheap to return. We instead change the interface to return a single value at once, which lets us resolve values lazily.

2. As we move internal usage to scoped enums, enums are not implicitly convertible to intergers (broadly a good thing). Hiding the enum as index prevents the need for callers to cast or convert to underlying.

Instead of making a new version of `IdxRef` for this, I converted to a more traditional setter. I will be making similar changes later for other styles, when I hide CompactValue from the public interface.

To review I would recommend filtering to changes in `xplat`, or viewing this in a single one of the OSS PRs exported. Everything apart from the below 20 files is a mirror.

{F1096792573}

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D49362819

fbshipit-source-id: 30d730d78e62f36597d43f477120f65694e51ea3
2023-09-20 16:19:59 -07:00
hetan thakkar
81754d8cb2 Fixed minor syntax error (#1363)
Summary:
I've corrected the operator syntax error. This error disrupts the execution of command: 'npx react-native run-ios.'

<img width="1440" alt="Screenshot 2023-09-08 at 8 04 49 PM" src="https://github.com/facebook/yoga/assets/38756320/b6a51270-8ae3-4d3f-be22-1fd938af42f8">

bypass-github-export-checks

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

Reviewed By: yungsters

Differential Revision: D49118992

Pulled By: NickGerleman

fbshipit-source-id: 55c3ec7890a9682887d2d88e66400eb7f6613792
2023-09-20 08:34:18 -07:00
Nick Gerleman
6bc896e549 C++ style enums 15/N: Display (#1397)
Summary:
X-link: https://github.com/facebook/react-native/pull/39541

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

Moves internal usages of YGDisplay to Display

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49361952

fbshipit-source-id: a961efaa35a3fed01659d23783bf90e0b47656f0
2023-09-19 16:30:02 -07:00
Nick Gerleman
75bbfb0b71 C++ style enums 14/N: Overflow (#1398)
Summary:
X-link: https://github.com/facebook/react-native/pull/39537

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

Moves internal usages of YGOverflow to Overflow

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49361843

fbshipit-source-id: 42161aa8a26f64f052587b861120cdad0290ae46
2023-09-19 16:30:02 -07:00
Nick Gerleman
03d0523996 C++ style enums 13/N: Wrap (#1400)
Summary:
X-link: https://github.com/facebook/react-native/pull/39539

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

Moves internal usages of YGPositionType to PositionType

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49361746

fbshipit-source-id: ccc77b4c77753b5f41e11f1849d4c02153c190b7
2023-09-19 16:30:02 -07:00
Nick Gerleman
4ea6b4c4f9 C++ Style enums 12/N: PositionType (#1399)
Summary:
X-link: https://github.com/facebook/react-native/pull/39538

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

Moves internal usages of YGPositionType to PositionType

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49361677

fbshipit-source-id: 526222d6cf9f3dc26eddfbfb8a04de4ba28e14a9
2023-09-19 16:30:02 -07:00
Nick Gerleman
5bf81b1ef8 C++ style enums 11/N: Align (#1395)
Summary:
X-link: https://github.com/facebook/react-native/pull/39497

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

Moves internal usages of YGAlign to Align

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49337511

fbshipit-source-id: bb9906fcd22780d2cfd8d1360ef69f66b9701bb6
2023-09-19 16:30:02 -07:00
Nick Gerleman
61763e7d0a C++ style enums 10/N: Justify (#1396)
Summary:
X-link: https://github.com/facebook/react-native/pull/39498

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

Moves internal usages of YGJustify to Justify.

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49336538

fbshipit-source-id: 6deb2438e3cd2989c8212ee294fd0fe4819f40ab
2023-09-19 16:30:02 -07:00
Nick Gerleman
6ec790dd1b C++ style enums 9/N: FlexDirection (#1394)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1394

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

Moves internal usages of YGDirection to Direction.

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49336066

fbshipit-source-id: b49e1ffcd79a427e36ea8d2c26debaa98ef3e4c9
2023-09-19 16:30:02 -07:00
Nick Gerleman
9b99e4fc22 C++ style enums 8/N: Direction (#1392)
Summary:
X-link: https://github.com/facebook/react-native/pull/39483

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

Moves internal usages of YGDirection to Direction.

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49335231

fbshipit-source-id: 459fe820c91be88734cebaa8655cd3f0afda83bf
2023-09-19 16:30:02 -07:00
Nick Gerleman
ea3869fe9f Simplify bitfields (#1393)
Summary:
X-link: https://github.com/facebook/react-native/pull/39485

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

These were previously packed into structs to allow zero initializing all the flags at once without needing a ctor. C++ 20 has in-class member initializer support for bitfields, which makes these look more like normal member variables.

Setting enum values is a bit jank right now, due to relying on C enums which are effectively int32_t, along with GCC `-Wconversion` being a bit aggressive in needing to explicitly mask. I have some ideas to fix this later (e.g. using scoped enums internally).

bypass-github-export-checks

Changelog:
[General][Breaking] - Require C++ 20 when including renderer headers

Reviewed By: sammy-SC

Differential Revision: D49265967

fbshipit-source-id: 6ab935a866196df06e742c821f3af88eb4d18e1a
2023-09-19 01:28:35 -07:00
Nick Gerleman
557d2a76fe Breaking: Use C++ 20 (#1382)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1382

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

Have been running into places where C++ 20 makes life easier for use like `std::bit_cast` (that one is easy to polyfill), in-class member initializer support for bitfields, designated initializers, defaulted comparison operator, concepts instead of SFINAE, and probably more.

Our other infra is in the process of making this jump, or already has. This tests it out everywhere, across the various reference builds, to see if we have any issues.

This is a bit more aggressive than I had previously communicated, but n - 1 is going to be a better long term place than n - 2.

If we wanted to use `std::bit_cast` we would need one of:
1. GCC 11+ (~2.5 years old)
1. Clang 14 (~2.5 years old)
1. VS 16.11 (~2 years old)

For mobile this means:
1. NDK 26 (still in Beta 😭)
1. XCode 14.3.0 (~6 months old)

https://en.cppreference.com/w/cpp/compiler_support/20

That isn't quite doable yet, but we can start taking advantage of language features in the meantime. More of these will be supported in older toolchains.

Anyone needing support for older C++ versions can lag behind on more recent changes. E.g. Yoga 2.0 supports C++ 14.

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D49261607

fbshipit-source-id: ceb06eac20dfe93352d7b796d6847a7314069cf3
2023-09-19 01:28:35 -07:00
Nick Gerleman
ed406f0b55 C++ style enums 7/N: MeasureMode (#1389)
Summary:
X-link: https://github.com/facebook/react-native/pull/39452

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

This converts usages of YGMeasureMode to MeasureMode

Reviewed By: rozele

Differential Revision: D49271165

fbshipit-source-id: 273c9ed0a61c3965e469548d29d37e4566c974dc
2023-09-14 23:06:34 -07:00
Nick Gerleman
383b325d06 C++ style enums 6/N: PrintOptions (#1385)
Summary:
X-link: https://github.com/facebook/react-native/pull/39449

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

This converts usages of YGPrintOptions to PrintOptions

Reviewed By: rozele

Differential Revision: D49270929

fbshipit-source-id: ad98dd25865138808d25b48eff22fbe81ccdd352
2023-09-14 23:06:34 -07:00
Nick Gerleman
70954bbda5 C++ style enums 5/N: LogLevel (#1387)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1387

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

This converts usages of YGLogLevel to LogLevel

Reviewed By: rozele

Differential Revision: D49270695

fbshipit-source-id: 2ba5b4f2b0af93fef89dbbb2ce54c2f486670aac
2023-09-14 23:06:34 -07:00
Nick Gerleman
6f5eaefc51 C++ style enums 4/N: Errata (#1388)
Summary:
X-link: https://github.com/facebook/react-native/pull/39451

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

This converts usages of YGErrata to Errata

Reviewed By: rozele

Differential Revision: D49270354

fbshipit-source-id: 39c0d26a1609cca0a96da843796ab41c81e3af93
2023-09-14 23:06:34 -07:00
Nick Gerleman
42e1f2c737 C++ style enums 3/N: ExperimentalFeature (#1386)
Summary:
X-link: https://github.com/facebook/react-native/pull/39448

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

This converts usages of YGExperimentalFeature to ExperimentalFeature

Reviewed By: rozele

Differential Revision: D49269440

fbshipit-source-id: 0fcb4f380e214a6aadcac457df5a989789bb05d2
2023-09-14 23:06:34 -07:00
Nick Gerleman
9129a0af87 C++ style enums 2/N: NodeType (#1383)
Summary:
X-link: https://github.com/facebook/react-native/pull/39450

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

This converts usages of YGNodeType to NodeType

Reviewed By: rozele

Differential Revision: D49269117

fbshipit-source-id: 27318279fe555c28c605625a160d5be781b662b8
2023-09-14 23:06:34 -07:00
Nick Gerleman
4cd45ac5d5 C++ style enums 1/N: Generator (#1384)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1384

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

This adds logic to the enum generator to generate C++ style scoped enums.

This gives us a few nicities over C enums, even if both must exist:
1. We can add types and keep unsgined enums directly in bitfields
2. Style/readability
3. Avoiding implicit int conversion

Reviewed By: rozele

Differential Revision: D49267996

fbshipit-source-id: 1c41164c377b317c1fef97811c46cbc00b5a837e
2023-09-14 23:06:34 -07:00
Nick Gerleman
c60050d0cb Fixup hack for flex line size calculation (#1380)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1380

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

Back when rolling out flex gap, we encountered a bug where gap was added to the end of the main axis when a size was not specified.

During flex line justification/sizing, we calculate the amount of space that should be in between children. We erroneously add this, even after the last child element.

For `justify-content`, this space between children is derived from free space along the axis. The only time we have free space is if we had a dimension/dimension constraint already set on the parent. In this case, the extra space added to the end of the flex line is usually never noticed, because we bound `maxLineMainDim` to container dimension constraints at the end of layout, and the error doesn't effect how any children are positioned or sized.

There was at least one screenshot test where this issue showed up though, and I was able to add a slightly different repro where we may have free space without a definite dimension by enforcing a min dimension and not stretching.

{F1091401183}

The new reference is correct, and looking back at diffs, is what this seemed to originally look like when added three years ago. Seems like there may have been a potential regression, but I didn't spot anything suspicious when I looked around the code history.

`betweenMainDim` may still be set for `gap` even if we don't have a sized parent, which makes the extra space propagated to `maxLineMainDim` effect parent size.

Because we were in a code freeze, I opted to have us go with a solution just effecting flex gap, instead of the right one, in case there were any side effects. This cleans up the code to use the right calculation everywhere, and fixes a separate bug, where `endOfLineIndex` and `startOfLineIndex` may not be the last/first in the line if they are out of the layout flow (absolutely positioned, or display: none_

See the original conversation on https://github.com/facebook/yoga/pull/1188

Reviewed By: javache

Differential Revision: D49260049

fbshipit-source-id: 218552c5ff938668b9f257df7a1493e13ded4d0d
2023-09-14 20:26:31 -07:00
Nick Gerleman
f9c2c27d33 Use fbsource clang-format config
Summary:
This mirrors the clang-format config used by fbsource to Yoga.

They are pretty similar, except for an annoying habit where Yoga's previous forced small functions in headers to be a a single line, so you would get a combination of multiline and single line functions next to each other which are hard to read. That is what motivated this change.

It also enforces header ordering (yay). I don't think we have any side-effect causing headers, so this should be safe.

Reviewed By: yungsters

Differential Revision: D49248994

fbshipit-source-id: 66998395e7c0158ff9d9fb1bee44e8401bdd8f21
2023-09-13 20:12:55 -07:00
Nick Gerleman
9d21e3e300 Remove config drilling (#1378)
Summary:
X-link: https://github.com/facebook/react-native/pull/39404

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

We thread a config through the root node, to every function, that we don't actually use (with the exception of `canUseCachedMeasurement` in the previous diff which was passing root `pointScaleFactor`).

Since the model is currently per-node config, this only creates redundancy/confusion.

I do think we might want to make some more global/layout-pass scoped configuration in the future, but likely not with this sort of drilling.

Reviewed By: yungsters

Differential Revision: D49180385

fbshipit-source-id: 91248042df7d3cea1fc316b47b8137fcb790b521
2023-09-13 20:12:55 -07:00
Nick Gerleman
66cc95f932 Breaking: per-node pointScaleFactor (#1379)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1379

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

Right now we have a `pointScaleFactor` per-node, but only ever read the one off the root node. In most cases where config is global, these will be the same, but it is possible for these to differ.

This... doesn't make much sense from an API perspective, and there are edge cases where we may want to allow laying out a subtree with a different DPI then the rest of the tree (though I think there might be other solutions to that).

We should rethink some of what is currently on config being allowed per-node (do we really need each node to be able to have a separate logger?), but this makes the model consistent in the meantime.

This change is breaking to any users relying on setting `pointScaleFactor` on the config of the root node, but not other nodes.

Reviewed By: yungsters

Differential Revision: D49181131

fbshipit-source-id: f1363ca242094f04b995fd50c1e56834d5003425
2023-09-13 14:11:25 -07:00
Nick Gerleman
0a90b16ac6 Remove layoutContext Drilling (#1376)
Summary:
X-link: https://github.com/facebook/react-native/pull/39401

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

kill_with_fire_flamethrower

Reviewed By: rshest

Differential Revision: D49179244

fbshipit-source-id: 9a827e1bd29205254fee5725449191726d6bcf5a
2023-09-12 19:08:55 -07:00
Nick Gerleman
b1e0140aaa Remove JNI Binding usage of layoutContext (#1377)
Summary:
X-link: https://github.com/facebook/react-native/pull/39402

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

To avoid keeping a per-node mapping on native Yoga nodes to Java nodes, a per-layout context was added, to be able to pass information from the start of the layout, to measure functions, log functions, etc.

The way this was done was super invasive, and added quite a few private APIs used only by the JNI functions.

This change removes the context-using functions from the JNI bindings in favor of it managing its own context. Next diff removes all the cruft.

Reviewed By: javache

Differential Revision: D49179243

fbshipit-source-id: 7e4944bead864e6b73fd2208a47c5725c18ff2b0
2023-09-12 19:08:55 -07:00
Nick Gerleman
700be8c8ad Extract isBaselineLayout() (#1375)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1375

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

Moves `isBaselineLayout` out of `CalculateLayout` into `Baseline.h`. This function is called by flex line justification code, which I have been looking at extracting.

Reviewed By: yungsters

Differential Revision: D49177937

fbshipit-source-id: 02c13aa0b02b26cb60ef197473b90e06d53d5f8d
2023-09-12 19:08:55 -07:00
Nick Gerleman
62ba8ebb3d Replace dim and pos arrays (#1373)
Summary:
X-link: https://github.com/facebook/react-native/pull/39397

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

These are used to get the position origin edge from axis (same as leading edge), and dimension from axis.

Replace them with function usage, so that we can call into them from other files than `CalculateLayout.cpp`, and so that we can later use scoped enums not implicitly convertible to ints.

Reviewed By: rshest

Differential Revision: D49134566

fbshipit-source-id: cb806539ba0733a5773c594713720d465987e469
2023-09-11 19:51:40 -07:00
Nick Gerleman
a4f36bdb51 Separate FlexLine functionality (#1374)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1374

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

Yoga today has a struct `CollectFlexItemsRowValues`, and function `calculateFlexItemsRowValues()`. These names have evolved over time into something not making much sense.

The job of `calculateFlexItemsRowValues()` is a flex-wrap container into lines (i.e. line-breaking main-axis content, which may be row or column). It returns line-breaking results, but some other fields on `calculateFlexItemsRowValues()` are set much later in the process, and the struct is acting effectivelty as a holder for the line-specific values.

This change:
1. Does some renaming (mainly to FlexLine)
2. Reconciles the count `itemsOnLine` and list `relativeChildren` to list `itemsInFlow` (`relativeChildren` is a lie, as it can include elements with `YGPositionTypeStatic` and exclude relative elements which have `display: "none"`. It really just means children which are included in the layout flow for the line)
3. Makes non-changing algorithm outputs const for clarity of what is a running value, and what is a result of line-breaking values with flex basis.
4. Moves working layout values to a substructure `flexLine.layout`
5. Replaces some dishonest documentation about `endOfLineIndex`.
6. Extracts this logic out of `CalculateLayout()` to a separate file
7. Extracts `boundAxis` wholesale into a separate file, to be usable outside of `CalculateLayout.cpp`

Reviewed By: rshest

Differential Revision: D49133837

fbshipit-source-id: ec68c5a3d2f01e7c9bd8d26e28298331a3fe2475
2023-09-11 19:51:40 -07:00
Nick Gerleman
241c5e4baf Cleanup visibility macros (#1372)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1372

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

D18029030 added `-fvisibility-hidden`, and a corresponding `YOGA_EXPORT` macro for defining shared library visibility. This is used inline next to function and class definitions that should be exported out of the binary.

There was already a `WIN_EXPORT` macro doing the same thing when building a DLL, defined in the headers instead of CPP files, and it seems like sometimes folks forgot to add it to new public APIs after?

This reconciles the redundant macros into a single visibility macro, that we always place with declaration instead of definition. We also rename `YOGA_EXPORT` to `YG_EXPORT` to match the naming convention of other Yoga macros.

Reviewed By: rshest

Differential Revision: D49132643

fbshipit-source-id: cafa6de0c300788a72d9a446ce07c5ac89a20a8e
2023-09-11 19:51:40 -07:00
Nick Gerleman
0720e0b22a Breaking: YGConfigRef related const-correctness fixes (#1371)
Summary:
X-link: https://github.com/facebook/react-native/pull/39374

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

Right now `YGConfigGetDefault` and `YGNodeGetConfig` both return mutable, freeable, configs, which is bad, since the former points to a global singleton config, and the latter usually does too. Mutating this is not thread safe, and it should never be freed.

This change makes these functions return `YGConfigConstRef` to prevent mutation, and also lets us allow `YGConfigNewWithConfig` to accept a const config. If a caller does want to mutate a config (such as to free it), it must be tracked manually.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D49132476

fbshipit-source-id: ac9ce61149e69c6c25cadb99711435b0a5b9f38a
2023-09-11 19:51:40 -07:00
Nick Gerleman
a003c09a4c Cleanup Android logger code (#1367)
Summary:
X-link: https://github.com/facebook/react-native/pull/39373

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

Moves some messiness around conditionally using Android's logger to `Log.cpp`, isolated to within a single function.

Reviewed By: rshest

Differential Revision: D49131964

fbshipit-source-id: cdff8af1d4df6ae28f00eecfed1920c71eec24d0
2023-09-11 19:51:40 -07:00
Nick Gerleman
c35f8819ae Breaking: Remove "UseLegacyStretchBehaviour" functions (#1368)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1368

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

These were marked as deprecated as part of the public Yoga 2.0 release, and were alredy emitting deprecation warnings. Remove them.

Reviewed By: javache

Differential Revision: D49131250

fbshipit-source-id: cc1d4e8b179697b9a11a685f4fc4e9d36e1a26a0
2023-09-11 19:51:40 -07:00
Nick Gerleman
a2d3fc6a3c Breaking: Remove YGConfigGetInstanceCount (#1370)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1370

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

This was added in https://github.com/facebook/yoga/pull/497 specifically for tests related to memory leaks in the C# bindings to count how often YGConfigFree.

This is the wrong layer for this check, we don't have officially supported C# bindings anymore, and this API is not safe when Yoga runs on multiple threads. This removes it, similar to a global node instance count that was also previously removed.

Reviewed By: rshest

Differential Revision: D49131207

fbshipit-source-id: 58537ed635ed455ff065471bdf77061a4bf826f4
2023-09-11 19:51:40 -07:00
Nick Gerleman
776065d7c7 Breaking: size_t indices (#1366)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1366

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

Yoga's public API exposes indices most often as `uint32_t`, with exception of clone callbacks which are `int32_t`. Yoga internally represents these indices as `size_t` when dealing with the child vector, and this is the true index.

This changes the API to consistently be `size_t`. This should not be breaking for most users, but will cause breaks where:

1. Users set a clone node callback (I think this should be rare. RN uses it, but only because it relies on a separate private API).
2. Callers of `YGNodeGetChildCount()` are assigning to an int with less width than `size_t` and have strong warnings enabled.
3. Using a newer Yoga binary with older source, since we are not preserving ABI compatibility (Yoga in general does not aim to be ABI stable between major versions, only ABI safe for a given set of sources).

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49130914

fbshipit-source-id: 6a004c160c4c50f68047b108508fd437156f5fac
2023-09-11 19:51:40 -07:00
Nick Gerleman
26f2b28eca Breaking: Fix callback const-correctness (#1369)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1369

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

This fixes const-correctness of callbacks (e.g. not letting a logger function modify nodes during layout). This helps us to continue to fix const-correctness issues inside of Yoga.

This change is breaking to the public API, since it requires a change in signature passed to Yoga.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49130714

fbshipit-source-id: 4305f8882d89f296e45b78497a51716a0dbb3b2d
2023-09-11 19:51:40 -07:00
Nick Gerleman
b12a6a340c Non-breaking const-correctness fixes (#1365)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1365

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

This changes public Yoga API to in more places accept const structures where before they required mutable ones.

`resolveRef` is added as a quick way to resolve overloaded opaque refs for different types which is a bit easier to read than static_casting, and which will propagate const-ness. We also add `YGConfigConstRef`, similar to `YGNodeConstRef`. I was a bit iffy on whether we should add something to make it easier to convert to private interface,  but this doesn't seem any easier to misuse than someone who looks at the internals to find the `static_cast`.

This tries to avoid more breaking changes yet, e.g. changing callbacks to require clients do not modify nodes when they are passed for logging. We also don't have const variants for returning child structures which would allow mutation of dependencies of the const object. These would need new names under the public API, since we do not have operator overloading in C.

Reviewed By: rshest

Differential Revision: D49130412

fbshipit-source-id: ee6b31b47f4622031c63dd52d8ac133d21bf29b7
2023-09-11 19:51:40 -07:00
Nick Gerleman
3cb29e60a8 Fix Running Java UTs with CXX Platform
Reviewed By: rshest

Differential Revision: D49131492

fbshipit-source-id: 80b2f108b2a5d80b92c1a11c573a61520b345ac2
2023-09-11 16:15:46 -07:00
Nick Gerleman
26d2a2682f yoga::bit_cast
Summary:
X-link: https://github.com/facebook/react-native/pull/39358

This adds a function polyfilling C++ 20's `std::bit_cast`, using `memcpy()` to be safe with strict aliasing rules.

This replaces the conditional code in CompactValue for type punning, an unsafe place in YGJNI where we do it unsafely, and is used in ValuePool. The polyfill can be switched to `std::bit_cast` whenever we adopt C++ 20.

Note that this doesn't actually call into `memcpy()`, as verified by Godbolt. Compilers are aware of the memcpy type punning pattern and optimize it, but it's ugly and confusing to folks who haven't seen it before.

Reviewed By: javache

Differential Revision: D49082997

fbshipit-source-id: b848775a68286bdb11b2a3a95bef8069364ac9b5
2023-09-08 13:03:48 -07:00
Nick Gerleman
f8e2bc0875 Add copyright header to ld version script (#1360)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1360

Fixes a ShipIt warning about this.

Reviewed By: yungsters

Differential Revision: D48992315

fbshipit-source-id: 20b6ba86abc27599e5f7dc12471344295151db66
2023-09-06 09:50:43 -07:00
Nick Gerleman
aee43a53bc Enable -Wconversion (#1359)
Summary:
X-link: https://github.com/facebook/react-native/pull/39291

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

This enables clang warnings around potentially unsafe conversions, such as those with mismatched signedness, or ones which may lead to truncation.

This should catch issues in local development which create errors for MSVC (e.g. Dash), who's default `/W3` includes warnings akin to `-Wshorten-64-to-32`.

This full set of warnings here is a tad spammy, but probably more useful than not.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D48954777

fbshipit-source-id: 1ccc07b99d09d1c2d428158149698ffd04025605
2023-09-06 08:16:42 -07:00
Nick Gerleman
95a7b4497e Enable GitHub Actions Yarn Caching (#1332)
Summary:
We sometimes see workflows fail due to network flakiness, almost always being Windows agents doing a `yarn install`. This change enables storing and reusing Yarn's package cache, and makes `yarn install` more permissive when it does hit the network. https://stackoverflow.com/questions/51508364/yarn-there-appears-to-be-trouble-with-your-network-connection-retrying

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

Test Plan: Workflows succeed, and we see cache being restored before yarn install step.

Reviewed By: lunaleaps

Differential Revision: D48967590

Pulled By: NickGerleman

fbshipit-source-id: 55ce6f05496f014512e0153b6646a7ca0ab964d9
2023-09-05 10:27:27 -07:00
Nick Gerleman
65ae809d5d C++ Cleanup 10/N: YGNodeCalculateLayout (#1352)
Summary:
X-link: https://github.com/facebook/react-native/pull/39195

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

## This diff

This splits out all of the logic under `YGNodeCalculateLayout` to a couple of different files, does some mechanical renaming, and starts to split up the implementation a tiny bit. After this, core layout functions are all C++ convention and namespaced.

Each new file is marked as a move for the sake of blame history. It means Phabricator has a very inaccurate count of lines removed though.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48770478

fbshipit-source-id: 2a74b86441c3352de03ae193c98fc3a3573047ed
2023-09-05 05:24:54 -07:00
Nick Gerleman
7d8b9176fd C++ Cleanup 9/N: YGAssert (#1353)
Summary:
X-link: https://github.com/facebook/react-native/pull/39201

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

## This diff

This moves and renames `YGAssert`, and removes it from the public API, since external users should not need to call into internal Yoga assert functions, and the current API prevents us from making this a macro later to include the condition in the message.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48769809

fbshipit-source-id: b5480ac54781bc01b00c158b07d2d751fac87d37
2023-09-04 11:20:17 -07:00
Nick Gerleman
7be985d97c C++ Cleanup 8/N: Yoga-internal (#1355)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1355

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

## This diff

This splits up `Yoga-internal.h` which has become a grab bag. The actual header is left, with the purpose of being a private C ABI for bindings, but everything else is moved to a place more appropriate or removed.

A few notes:
1. `yoga::isUndefined` is replaced with `std::isnan` to avoid a layer of indirection (we will never be able to change its representation anyway). Internal usages of `YGFloatIsUndefined` are also replaced with `std::isnan` since the previous being at a library boundary means I'm not sure it can be inlined/.
2. `leading`, `trailing` arrays are factored into proper functions
3. `Values` is replaced entirely with `std::array`, since most of it was unused.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48769241

fbshipit-source-id: 5b8e2192309539e7c133c3b3b29b445b59dd5835
2023-09-04 11:20:17 -07:00
Nick Gerleman
31b6c0ddc9 C++ Cleanup 7/N: BitUtils (#1351)
Summary:
X-link: https://github.com/facebook/react-native/pull/39223

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

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

## This diff

This splits up `BitUtils.h`, does some minor renaming, and namespace consistency fixes.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847255

fbshipit-source-id: 4b9722303372f43e936118f8187c0127bceeb1d4
2023-08-31 01:17:39 -07:00
Nick Gerleman
989f352e03 C++ Cleanup 6/N: YGFloatOptional (#1356)
Summary:
X-link: https://github.com/facebook/react-native/pull/39224

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

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

## This diff

This renames YGFloatOptional to FloatOptional, adds it to a namespace, and moves it to a subdirectory. This needs Fabric updates because Fabric uses Yoga internals for props storage.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847256

fbshipit-source-id: ab9729a4a02ab90d974183425935f4d274db5732
2023-08-31 01:17:39 -07:00
Nick Gerleman
c029041707 C++ Cleanup 5/N: Reorganize Utils (#1357)
Summary:
X-link: https://github.com/facebook/react-native/pull/39222

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

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

## This diff

This splits `Utils.h` and `Utils.cpp`, and tweaks naming and namespaces.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847260

fbshipit-source-id: b99df3029cd66257a7ae64de28c13e8751ceb20c
2023-08-31 01:17:39 -07:00
Nick Gerleman
b959774af7 C++ Cleanup 4/N: Reorganize Log and YGNodePrint (#1354)
Summary:
X-link: https://github.com/facebook/react-native/pull/39220

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

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

## This diff

Moves these files to a `yoga/debug` subdirectory and does some mild renaming, namespace adjustment, and removes Yoga internal log function from list of library exports.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847259

fbshipit-source-id: c1607b1c6457d5a47039c735cdb7c365a301ebc0
2023-08-31 01:17:39 -07:00
Nick Gerleman
992f073746 C++ Cleanup 3/N: Reorganize YGNode (#1350)
Summary:
X-link: https://github.com/facebook/react-native/pull/39219

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

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

## This diff

This diff adds a top level `node` directory for code related to Yoga nodes and data structures on them (inc moving `YGLayout` to `LayoutResults`).

The public API for config handles is `YGNodeRef`, which is forward declared to be a pointer to a struct named `YGNode`. The existing `YGNode` is split into `yoga::Node`, as the private C++ implementation, inheriting from `YGNode`, a marker type represented as an empty struct. The public API continues to accept `YGNodeRef`, which continues to be `YGNode *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.

This change ends up needing to touch quite a bit, due to the amount of code that mixed and matched private and public APIs. Don't be scared though, because these changes are very mechanical, and Phabricator's line-count is 3x the actual amount due to mirrors and dirsyncs.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847258

fbshipit-source-id: fc560893533b55a5c2d52c37d8e9a59f7369f174
2023-08-30 19:57:16 -07:00
Nick Gerleman
f82babba8a C++ Cleanup 2/N: Reorganize YGConfig (#1348)
Summary:
X-link: https://github.com/facebook/react-native/pull/39218

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

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

## This diff

This diff adds a top level `config` directory for code related to configuring Yoga and Yoga Nodes.

The public API for config handles is `YGConfigRef`, which is forward declared to be a pointer to a struct named `YGConfig`. The existing `YGConfig` is split into `yoga::Config`, as the private C++ implementation, inheriting from `YGConfig`, a marker type represented as an empty struct. The public API continues to accept `YGConfigRef`, which continues to be `YGConfig *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D48847257

fbshipit-source-id: 7a2157d169ba80a6f79620693ae45bb10dfca5a3
2023-08-30 16:27:32 -07:00
Nick Gerleman
65d7f95901 C++ Cleanup 1/N: Reorganize YGStyle (#1349)
Summary:
X-link: https://github.com/facebook/react-native/pull/39221

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

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

## This diff

This diff adds a `style` directory for code related to storing and manipulating styles. `YGStyle`, which is not a public API, is renamed to `yoga::Style` and moved into this folder, alongside `CompactValue`. We will eventually add `ValuePool` alongside this for the next generation style representation.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D48847261

fbshipit-source-id: 0fc8c6991e19079f3f0d55d368574757e453fe93
2023-08-30 16:27:32 -07:00
Zhiyao Zhou
2a32637c56 Revert D48710084: C++ Cleanup 1/N: Reorganize YGStyle
Differential Revision:
D48710084

Original commit changeset: 20961aee30d5

Original Phabricator Diff: D48710084

fbshipit-source-id: 79cda4f13979b8d0cdf87dabbfc13cbd17abe488
2023-08-29 23:27:25 -07:00
Zhiyao Zhou
13c5ce2234 Revert D48710796: C++ Cleanup 2/N: Reorganize YGConfig
Differential Revision:
D48710796

Original commit changeset: d548553f7ce8

Original Phabricator Diff: D48710796

fbshipit-source-id: c8b2de245f3894f6a87c262ec70d313020aa228e
2023-08-29 23:27:25 -07:00
Zhiyao Zhou
ea7f61a3db Revert D48712710: C++ Cleanup 3/N: Reorganize YGNode
Differential Revision:
D48712710

Original commit changeset: d28eae38469a

Original Phabricator Diff: D48712710

fbshipit-source-id: 7a10b071edcf045ce98bbf8f9deca0d0e2e80a14
2023-08-29 23:27:25 -07:00
Zhiyao Zhou
6ca56e87ce Revert D48763820: C++ Cleanup 4/N: Reorganize Log and YGNodePrint
Differential Revision:
D48763820

Original commit changeset: 7e3ed7354497

Original Phabricator Diff: D48763820

fbshipit-source-id: 1bea996374f14481160aba8f87940c00e229aa69
2023-08-29 23:27:25 -07:00
Zhiyao Zhou
4c0e89e492 Revert D48767465: C++ Cleanup 5/N: Reorganize Utils
Differential Revision:
D48767465

Original commit changeset: da7157953292

Original Phabricator Diff: D48767465

fbshipit-source-id: 0dd948e2c4e6b3aaeb6e197b28b565c0b385d033
2023-08-29 23:27:25 -07:00
Zhiyao Zhou
7cf0483b17 Revert D48767992: C++ Cleanup 6/N: YGFloatOptional
Differential Revision:
D48767992

Original commit changeset: afaff0234359

Original Phabricator Diff: D48767992

fbshipit-source-id: 4666bdbb83aebbf2f7373b3a10a8c1dd0a03f92c
2023-08-29 23:27:25 -07:00
Zhiyao Zhou
8a95b785a8 Revert D48768374: C++ Cleanup 7/N: BitUtils
Differential Revision:
D48768374

Original commit changeset: 921a22ec88bd

Original Phabricator Diff: D48768374

fbshipit-source-id: 59106ab3d03619940023dac1c2af62fd88566773
2023-08-29 23:27:25 -07:00
Nick Gerleman
866b4f7d62 C++ Cleanup 7/N: BitUtils (#1351)
Summary:
X-link: https://github.com/facebook/react-native/pull/39200

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

## This diff

This splits up `BitUtils.h`, does some minor renaming, and namespace consistency fixes.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48768374

fbshipit-source-id: 921a22ec88bd470da1ef9b51f8954afc073d327d
2023-08-29 21:32:56 -07:00
Nick Gerleman
20fd7695e1 C++ Cleanup 6/N: YGFloatOptional (#1356)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1356

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

## This diff

This renames YGFloatOptional to FloatOptional, adds it to a namespace, and moves it to a subdirectory. This needs Fabric updates because Fabric uses Yoga internals for props storage.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48767992

fbshipit-source-id: afaff023435915dbd5e571fd1ee2e695e4f59a5c
2023-08-29 21:32:56 -07:00
Nick Gerleman
8fd4d290e6 C++ Cleanup 5/N: Reorganize Utils (#1357)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1357

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

## This diff

This splits `Utils.h` and `Utils.cpp`, and tweaks naming and namespaces.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48767465

fbshipit-source-id: da71579532924b3a912454163fe281c481770a77
2023-08-29 21:32:56 -07:00
Nick Gerleman
9ba8aa409c C++ Cleanup 4/N: Reorganize Log and YGNodePrint (#1354)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1354

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

## This diff

Moves these files to a `yoga/debug` subdirectory and does some mild renaming, namespace adjustment, and removes Yoga internal log function from list of library exports.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48763820

fbshipit-source-id: 7e3ed7354497a7e85b2a1f20ab50b0e2baeb4862
2023-08-29 21:32:56 -07:00
Nick Gerleman
59f75b0194 C++ Cleanup 3/N: Reorganize YGNode (#1350)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1350

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

## This diff

This diff adds a top level `node` directory for code related to Yoga nodes and data structures on them (inc moving `YGLayout` to `LayoutResults`).

The public API for config handles is `YGNodeRef`, which is forward declared to be a pointer to a struct named `YGNode`. The existing `YGNode` is split into `yoga::Node`, as the private C++ implementation, inheriting from `YGNode`, a marker type represented as an empty struct. The public API continues to accept `YGNodeRef`, which continues to be `YGNode *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.

This change ends up needing to touch quite a bit, due to the amount of code that mixed and matched private and public APIs. Don't be scared though, because these changes are very mechanical, and Phabricator's line-count is 3x the actual amount due to mirrors and dirsyncs.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48712710

fbshipit-source-id: d28eae38469afa24a8cb03e4e75eeb8e431173c5
2023-08-29 21:32:56 -07:00
Nick Gerleman
5af3a5d1d9 C++ Cleanup 2/N: Reorganize YGConfig (#1348)
Summary:
X-link: https://github.com/facebook/react-native/pull/39169

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

## This diff

This diff adds a top level `config` directory for code related to configuring Yoga and Yoga Nodes.

The public API for config handles is `YGConfigRef`, which is forward declared to be a pointer to a struct named `YGConfig`. The existing `YGConfig` is split into `yoga::Config`, as the private C++ implementation, inheriting from `YGConfig`, a marker type represented as an empty struct. The public API continues to accept `YGConfigRef`, which continues to be `YGConfig *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48710796

fbshipit-source-id: d548553f7ce872488ebdd697e0aceaa9a625df62
2023-08-29 21:32:56 -07:00
Nick Gerleman
b289d12248 C++ Cleanup 1/N: Reorganize YGStyle (#1349)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1349

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

## This diff

This diff adds a `style` directory for code related to storing and manipulating styles. `YGStyle`, which is not a public API, is renamed to `yoga::Style` and moved into this folder, alongside `CompactValue`. We will eventually add `ValuePool` alongside this for the next generation style representation.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48710084

fbshipit-source-id: 20961aee30d54a6b0d8c1cc2976df09b9b6d486a
2023-08-29 21:32:56 -07:00
Andrew Wang
49fbd406b6 Ship the fix for local reference overflow in Yoga (#1347)
Summary:
X-link: https://github.com/facebook/litho/pull/954

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

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

# Context

Reviewed By: NickGerleman, astreet

Differential Revision: D48607502

fbshipit-source-id: 79552bc76879d1fc15341423ae6fbadeab2fb7af
2023-08-24 12:48:56 -07:00
Nick Gerleman
38ad93c87b Fix segfault calling YGJNILogFunc (#1344)
Summary:
X-link: https://github.com/facebook/react-native/pull/39051

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

`YGJNILogFunc` has a bug where it uses a `va_list` to determine the length of a printf string, then reuses the same `va_list` later after it has already been iterated through. Even if no arguments are present, this may cause a crash looking something like:

```
C  [libsystem_platform.dylib+0xf12]  _platform_strlen+0x12
C  [libsystem_c.dylib+0x31bf]  __vfprintf+0x1339
C  [libsystem_c.dylib+0x307ce]  _vsnprintf+0x100
C  [libsystem_c.dylib+0x6965]  vsnprintf+0x44
C  [libyoga.dylib+0x5161]  YGJNILogFunc(YGConfig*, YGNode*, YGLogLevel, void*, char const*, __va_list_tag*)+0x59
```

Fixing this fixes crashing unit tests which are not explicitly disabled.

Reviewed By: yungsters

Differential Revision: D48388548

fbshipit-source-id: 492e7a89aeb5f9d15485ce31641875a295356bef
2023-08-18 00:07:51 -07:00
Roland Crosby
910adaa5dc Update standalone JS docs (#1342)
Summary:
Excited to see some activity around this project! The move from Flow to TypeScript broke one of the links in the documentation, which this PR fixes. I went ahead and updated the example code as well, since it looks like some things moved around since the switch to the async loader.

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

Reviewed By: yungsters

Differential Revision: D48337554

Pulled By: NickGerleman

fbshipit-source-id: 8397cab60cf2104e271029a235f287a179ece2f4
2023-08-14 21:20:59 -07:00
Lvv.me
ef5784aca6 Add SwiftPM support (#1339)
Summary:
Using yoga in Swift

```swift
import UIKit
import yoga

let YGUndefined = Float.nan

UIGraphicsBeginImageContextWithOptions(CGSize(width: 1, height: 1), true, 0)
let scale = UIGraphicsGetCurrentContext()?.ctm.a ?? 1
UIGraphicsEndImageContext()

let config = YGConfigNew()
YGConfigSetUseWebDefaults(config, true)
YGConfigSetPointScaleFactor(config, Float(scale))

let root = YGNodeNewWithConfig(config)
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow)
YGNodeStyleSetFlexWrap(root, YGWrapWrap)
YGNodeStyleSetWidth(root, 200)

for i in 0..<4 {
    let leaf = YGNodeNewWithConfig(config)
    YGNodeStyleSetAspectRatio(leaf, 1)
    YGNodeStyleSetWidthPercent(leaf, 50)
    YGNodeInsertChild(root, leaf, UInt32(i))
}

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGNodeStyleGetDirection(root))

for i in 0..<4 {
    let leaf = YGNodeGetChild(root, UInt32(i))
    let left = YGNodeLayoutGetLeft(leaf)
    let top = YGNodeLayoutGetTop(leaf)
    let width = YGNodeLayoutGetWidth(leaf)
    let height = YGNodeLayoutGetHeight(leaf)

    print("leaf \(i): origin: \(left), \(top), size: \(width), \(height)")
}

let width = YGNodeLayoutGetWidth(root)
let height = YGNodeLayoutGetHeight(root)

print("root size: \(width), \(height)")

YGNodeFreeRecursive(root)
YGConfigFree(config)
```

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

Reviewed By: cipolleschi

Differential Revision: D48166958

Pulled By: NickGerleman

fbshipit-source-id: 72fef99729d01c7ba291b11f047cf75fd39f7630
2023-08-10 17:40:10 -07:00
Nick Gerleman
c18e2566a0 Fix set-version script corrupting files when new version is shorter than old one
Summary: We were leaving the last bits of the previous string around if writing a new file which is shorter. See 30b697d3fe for an example.

Reviewed By: cortinico

Differential Revision: D47824696

fbshipit-source-id: 82ebafd9cd1720752cbc62ea93c5b9362395d5c8
2023-07-28 09:48:07 -07:00
Nick Gerleman
44507ec62e Unify ESLint and Prettier across xplat/yoga (#1335)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1335

Reviewed By: christophpurrer

Differential Revision: D47459866

fbshipit-source-id: fd6b4e4e2518d91968ac7180b32129b3f70edf88
2023-07-17 14:27:32 -07:00
Nick Gerleman
05b2edfb85 Explicit C++ toolchain on ubuntu-latest (#1334)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1334

Last change made me discover CMake on Ubuntu defaults to GCC. This change makes it so that we explicitly configure whether to use Clang/LLVM or GCC when building on machines with the `ubuntu-latest` image.

Reviewed By: christophpurrer

Differential Revision: D47462132

fbshipit-source-id: e81fb6d4b1740ab2913d39b6e90c52d674e5a4f2
2023-07-14 20:54:41 -07:00
Nick Gerleman
61bf4d15ab Fixup Yoga UT compilation on non-clang compilers (#1333)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1333

Yoga is compiled on more than clang, both internally, and in OSS. D47345669 added unguarded usage of `
#pragma clang diagnostic push` to Yoga UTs which will cause unrecognized pragma errors if building the tests on other platforms.

The code here is flagged for implicitly converting enum to float. This is test code which is using the enum as an arbitrary differentiating input, so I just changed this to an explicit cast, which I assume should silence the warning.

Reviewed By: NuriAmari

Differential Revision: D47460301

fbshipit-source-id: 952ff61e0c26deb8bbff8b860faf30896753a3bd
2023-07-14 09:49:50 -07:00
dependabot[bot]
45b0697960 Bump semver from 5.7.1 to 5.7.2 (#1328)
Summary:
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/npm/node-semver/releases">semver's releases</a>.</em></p>
<blockquote>
<h2>v5.7.2</h2>
<h2><a href="https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2">5.7.2</a> (2023-07-10)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><a href="2f8fd41487"><code>2f8fd41</code></a> <a href="https://redirect.github.com/npm/node-semver/pull/585">https://github.com/facebook/yoga/issues/585</a> better handling of whitespace (<a href="https://redirect.github.com/npm/node-semver/issues/585">https://github.com/facebook/yoga/issues/585</a>) (<a href="https://github.com/joaomoreno"><code>@​joaomoreno</code></a>, <a href="https://github.com/lukekarrys"><code>@​lukekarrys</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md">semver's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2">5.7.2</a> (2023-07-10)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><a href="2f8fd41487"><code>2f8fd41</code></a> <a href="https://redirect.github.com/npm/node-semver/pull/585">https://github.com/facebook/yoga/issues/585</a> better handling of whitespace (<a href="https://redirect.github.com/npm/node-semver/issues/585">https://github.com/facebook/yoga/issues/585</a>) (<a href="https://github.com/joaomoreno"><code>@​joaomoreno</code></a>, <a href="https://github.com/lukekarrys"><code>@​lukekarrys</code></a>)</li>
</ul>
<h2>5.7</h2>
<ul>
<li>Add <code>minVersion</code> method</li>
</ul>
<h2>5.6</h2>
<ul>
<li>Move boolean <code>loose</code> param to an options object, with
backwards-compatibility protection.</li>
<li>Add ability to opt out of special prerelease version handling with
the <code>includePrerelease</code> option flag.</li>
</ul>
<h2>5.5</h2>
<ul>
<li>Add version coercion capabilities</li>
</ul>
<h2>5.4</h2>
<ul>
<li>Add intersection checking</li>
</ul>
<h2>5.3</h2>
<ul>
<li>Add <code>minSatisfying</code> method</li>
</ul>
<h2>5.2</h2>
<ul>
<li>Add <code>prerelease(v)</code> that returns prerelease components</li>
</ul>
<h2>5.1</h2>
<ul>
<li>Add Backus-Naur for ranges</li>
<li>Remove excessively cute inspection methods</li>
</ul>
<h2>5.0</h2>
<ul>
<li>Remove AMD/Browserified build artifacts</li>
<li>Fix ltr and gtr when using the <code>*</code> range</li>
<li>Fix for range <code>*</code> with a prerelease identifier</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="f8cc313550"><code>f8cc313</code></a> chore: release 5.7.2</li>
<li><a href="2f8fd41487"><code>2f8fd41</code></a> fix: better handling of whitespace (<a href="https://redirect.github.com/npm/node-semver/issues/585">https://github.com/facebook/yoga/issues/585</a>)</li>
<li><a href="deb5ad51bf"><code>deb5ad5</code></a> chore: <code>@​npmcli/template-oss</code><a href="https://github.com/4"><code>@​4</code></a>.16.0</li>
<li>See full diff in <a href="https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2">compare view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a href="https://www.npmjs.com/~lukekarrys">lukekarrys</a>, a new releaser for semver since your current version.</p>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=semver&package-manager=npm_and_yarn&previous-version=5.7.1&new-version=5.7.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: yungsters

Differential Revision: D47414316

Pulled By: NickGerleman

fbshipit-source-id: 9a38149c18cfc0fef714ffc9ce73f92a463224a1
2023-07-13 18:13:35 -07:00
Nick Gerleman
aa6a5d8888 Docusarus: Build validation (#1329)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1329

Add build validation for `website-next`, also adding validation that `yoga-layout/sync` may be bundled by Webpack out-of-the-box.

Reviewed By: christophpurrer

Differential Revision: D47414176

fbshipit-source-id: 9adc4f9673333f4f79c91352f445489d6da05a07
2023-07-13 14:08:07 -07:00
Nick Gerleman
45088187a7 Docusaurus: Replant Playground (#1331)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1331

This lifts and copies code from the Yoga Playground component of the old website, to the new one, using a live workspace version of JS Yoga. This may eventually be used if the new website is fleshed out, but this also gives us real-world validation of the Yoga bindings in a web scenario, compared to the Node test runner. There is still some cleanup here needed, but we are able to bundle, typecheck, and render the playground now.

The code here is mostly the same as before, but I removed some of the cruftier bits (e.g. URL shortener that goes to some private Heroku instance), and needed to do some tweaks for the new Yoga package, and TypeScript.

This is currently using `yoga-layout/sync`, the asmjs bindings. But I had previously checked bundling against the wasm ones.

Reviewed By: cortinico

Differential Revision: D46884439

fbshipit-source-id: f53f0855c131cd2b81975bf05f71c43713600616
2023-07-13 14:08:07 -07:00
Nuri Amari
6ae890dccd Pragma guard remaining -Wenum-conversion failures
Summary:
These incorrect enum conversions constitute compile errors
with Pika / Xcode 15. Pragma guard the current offenders so
we can make the warning fatal again.

Reviewed By: drodriguez

Differential Revision: D47345669

fbshipit-source-id: bb85a93e9f48236c9f8c54d59d55a86648c1c6fd
2023-07-13 09:53:47 -07:00
Nick Gerleman
5bbaadfa54 Add blurb about configuring TypeScript for ESM resolution (#1330)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1330

This has been tripping folks up a bit. Add a blurb to the package README to call it out.

Reviewed By: cortinico

Differential Revision: D47370333

fbshipit-source-id: f07b2e4d0e23865e3554c7aaf6ec77dff71a7423
2023-07-12 15:43:10 -07:00
Nick Gerleman
5310eb3cf7 Separate Node and Web Binaries (#1325)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1325

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

Reviewed By: cortinico

Differential Revision: D47368830

fbshipit-source-id: 570a45ad7fd182ef82e6edda4037ae2f6faa0c75
2023-07-12 15:43:10 -07:00
Nick Gerleman
7097b12b92 Remove YogaKit
Summary: We deprecated this as part of the Yoga 2.0 release. The last version is still present as part of the release-v2.0 branch, and was still published, but we are not carrying the code forward. This removes it.

Reviewed By: mdvacca

Differential Revision: D47136781

fbshipit-source-id: ac60939efb2372db04e33ed26456bad2f3b5852b
2023-07-12 12:19:27 -07:00
Nick Gerleman
660edcec20 C++ 17 style nested namespaces (#1326)
Summary:
X-link: https://github.com/facebook/react-native/pull/38304

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

For better readability

Reviewed By: christophpurrer

Differential Revision: D47384926

fbshipit-source-id: 2f60d50a185331b3624d45d1fc45f98d504b3034
2023-07-12 09:38:40 -07:00
Nick Gerleman
423dc155d8 Target C++ 17 (#1327)
Summary:
X-link: https://github.com/facebook/react-native/pull/38303

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

This bumps Yoga to C++ 17 for a few reasons:
1. New versions of C++ may introduce behavior changes (e.g. evaluation order) and deprecations. Keeping the version closer to the version of large users helps avoid that.
2. C++ 17 unblocks some new bits I have wanted to use at times, like `std::optional`, `std::variant`, `if constexpr`, `[[nodiscard]]`.
3. There are already changes in C++ 20 that would be directly useful to Yoga, like `std::bit_cast` to avoid `memcpy` style type punning.

There has been some contention around C++ versions before, but by the time the next stable version of Yoga is out, it will have been more than 6 years (~2 C++ versions) since a stable version of Clang/LLVM with C++ 17 support. I would not like to go back further than n-2.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D47383922

fbshipit-source-id: eb95d4853f2168b68d6df5fddb797236eac55870
2023-07-12 09:38:40 -07:00
Nicola Corti
dbd8e915d5 Remove the build-logic module
Summary:
As now we have a single module to publish, I'm removing the build-logic folder and moving everything inside the java/build.gradle file.
I've also converted it to Kotlin,

Reviewed By: NickGerleman

Differential Revision: D47259204

fbshipit-source-id: 2378d9e9598d7816f230db5f763f2b0f4cdf01d0
2023-07-11 04:30:02 -07:00
Nick Gerleman
f7324fb71e Remove YogaLayout ViewGroup (#1318)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1318

We deprecated this as part of the Yoga 2.0 release. The last version is still present as part of the `release-v2.0` branch, and was still published, but we are not carrying the code forward. This removes it.

There are a couple followups here:
1. The top-level organization (e.g. a gradle-specific directory called `build-logic` in a multi-language repo) can and should be cleaned up. Yoga Java bindings should be condensed to the `java` folder.
2. We no longer have a sample app excersizing the bindings. We should resolve this by getting the JNI binding UTs working in OSS again.

Reviewed By: cortinico

Differential Revision: D47136243

fbshipit-source-id: 72f74914effde2c895934ac1100adfd305044d46
2023-07-05 22:00:16 -07:00
Nick Gerleman
1b40f05b8c Fixes for publish workflows (#1319)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1319

This fixes a few issues encountered during publishing Yoga `2.0.0-beta.1`.

1. The tag trigger was missing quotes needed to be valid syntax
2. `pod trunk publish` must be run with `--synchronous` if we are publishing a package that relies on another just published package. There does not seem to be a way to just publish evertything at once.
3. `yarn publish` was not reading the NPM auth token from the environment, so we write it to a `.npmrc` before publishing.
4. The root `.gitignore` was not updated when moving to yarn workspaces to ignore `node_modules`, so the OSS Yoga repo (not internal) will, try to add its contents after `yarn install`.

Reviewed By: cortinico

Differential Revision: D47135994

fbshipit-source-id: d8c9b05176a98443be1ebc7cf74996f22520d20d
2023-06-30 11:44:15 -07:00
Nicola Corti
cdc3328ca5 Actually hit Maven Central when publishing tags
Summary:
Due to a copypasta error, the tags will keep on publishing to the snapshot repo.
I've updated the config to actually hit Maven Central.

Reviewed By: NickGerleman

Differential Revision: D47150549

fbshipit-source-id: 314b931c1c9203ef53e1433a88bcc00609abd3d0
2023-06-30 11:39:09 -07:00
Nick Gerleman
0aec0a1ac4 Remove YGExperimentalFeatureFixAbsoluteTrailingColumnMargin (#1317)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1317

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

This is edge-casey enough, and I actually broke this in D42282358 without us noticing (I changed height to width of the bottom usage, instead, copy/pasting the value of the top one).

Reviewed By: yungsters

Differential Revision: D45766764

fbshipit-source-id: b600b79b8436534fe48ef2acbfde8ba64068e593
2023-06-29 11:04:01 -07:00
Nick Gerleman
506027925d Add publish workflows for npmjs and CocoaPods (#1316)
Summary:
This adds workflows which run on tag, or manually, to publish packages to npmjs and cocoapods. These secrets should be set, but this is untested. We can fix manually and re-run though.

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

Test Plan: no parse errors when adding to GitHub

Reviewed By: cortinico

Differential Revision: D47069617

Pulled By: NickGerleman

fbshipit-source-id: efe0664be7cd287c598515c9572daff1655cfc14
2023-06-28 13:54:03 -07:00
Nick Gerleman
0294373929 Add yarn pack validation (#1315)
Summary:
Adds a step to validate the prepublish steps, and upload the resulting tarball.

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

Test Plan: A tarball is uploaded as part of validation and looks decent.

Reviewed By: cortinico

Differential Revision: D47068368

Pulled By: NickGerleman

fbshipit-source-id: 62c8946a1bb542310634c8a7384a0e4890b35bdf
2023-06-28 02:21:05 -07:00
Nick Gerleman
23e58ebaf5 Docusaurus: Replace config basics (#1314)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1314

Replace some of the basic parts of the config with values for Yoga

Reviewed By: yungsters

Differential Revision: D46884432

fbshipit-source-id: ff729d93b4378925c9b526b50dd06f95f5e27b51
2023-06-23 17:56:41 -07:00
Nick Gerleman
3e3c4f09f9 Docusaurus: Use yarn workspaces (#1313)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1313

Use yarn workspaces to consolidate the lockfile, and to let the website use our local Yoga package. This was not possible with the old version of Gatsby we were previously using.

This does not yet sync the versions of different packages, or move config files to the root of the repo. That will happen later after removing the original website package.

Reviewed By: yungsters

Differential Revision: D46884433

fbshipit-source-id: dfa43bdaaad66bb4365922287a39d6a34fa9f464
2023-06-23 17:56:41 -07:00
Nick Gerleman
cd7390e093 Include CMmake configuration stdio
Summary: Include error messages or other output for CMake generating the build for ninja

Reviewed By: yungsters

Differential Revision: D46884396

fbshipit-source-id: a31ae4dbdecd8833e62d8e3b8bf8dcaae9ba67e2
2023-06-23 14:08:12 -07:00
Nick Gerleman
d63f078fd4 Docusarus: Init Project (#1312)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1312

This starts us transitioning the Yoga website off of an ancient version of Gatsby by initializing a new Docusaurus project. This commit adds a new stock project, to be filled in later, then fixes license lint errors.

Note that this seems to have init'd using npm, but in the next diff I convert this to yarn workspaces anyway.

Reviewed By: yungsters

Differential Revision: D46884434

fbshipit-source-id: 7a0a4dddc144ad2d22cd18a02e8dcb9ff2184489
2023-06-22 13:46:57 -07:00
Nick Gerleman
75322f2bcb Add more ignore patterns (#1311)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1311

Adds some more output files to be ignored by prettier, eslint, tsconfig

Reviewed By: rozele

Differential Revision: D46884397

fbshipit-source-id: 69329f924cb3e949152a07d93514dc8cf8b3253a
2023-06-21 17:18:26 -07:00
Nick Gerleman
b8a0240aaf Build WebAssembly with SINGLE_FILE=1 (#1310)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1310

Emscripten normally compiles a binary into a `.js` file and a `.wasm` file. The `.js` file contains a shim to load the WebAssembly file for the target platform, along with passing some environment information to the underlying assembly.

Under Node this would use APIs like `fs.readFile` and its WebAssembly APIs to load the binary. In a browser, APIs like `instantiateStreaming` are used to start downloading and compiling the binary at the same time.

This format creates many, many, headaches, and manual bundler configuration. E.g. we must tell Webpack to treat WASM files as auxilary files instead of WebAssembly, cannot use Emscripten's loader directly, and would need to add more variants of the binary, since (or Node polyfills in the browser) `-s ENVIRONMENT='web,node'` emits code that looks like `if (isNode) {require('fs')}`.

This change makes us instead pack the WebAssembly as base64 inline with the JS loader. This adds a size penalty, and means we cannot start async compilation until the entire file is present, but should work out of the box when using different bundlers and configurations, and the size is small enough where it likely makes sense to inline into the bundle anyway.

There is a [proposal for integration of WebAssembly and ES Modules](https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration) that Node has experimental support for, and bundlers are veering towards supporting. It is the eventual solution we should target, but does not seem mature enough yet. E.g. WebPack [does not support](https://github.com/webpack/webpack/issues/11893) WebAssembly import objects, and will instead try to import each of the named imports as modules.

Reviewed By: rozele

Differential Revision: D46884398

fbshipit-source-id: a1c93c122c255b913f426bfb6bdb38fd9f9dfd41
2023-06-21 17:18:26 -07:00
Nick Gerleman
8c8235cfcf Use ES Module Export in wrapAssembly.js
Summary: This is needed to make Webpack happy when bundling Yoga. Webpack assumes this is an ESModule after following it from the package.json export map. We are already importing this via default import.

Reviewed By: GijsWeterings

Differential Revision: D46811190

fbshipit-source-id: 7a074e5d2aa9c0cb4b59e506a0d910762a62dd58
2023-06-20 14:53:03 -07:00
Andrew Wang
f3e9b6bfb0 Fix the issue that local reference overflows in Yoga 1 (#1308)
Summary:
X-link: https://github.com/facebook/react-native/pull/37929

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

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

Long story in short, we're trying to fix an issue with Yoga that could potentially lead to an overflow in the JNI local reference table.

Reviewed By: NickGerleman, astreet

Differential Revision: D46653732

fbshipit-source-id: 0bc34bd5a819037c046c62b651e414b249cbdcb8
2023-06-16 06:15:07 -07:00
Eric Rozell
ca4cf852aa Update watir to 7.2.0
Summary: I was not able to run `ruby gentest.rb` from Yoga. Updating watir seems to fix the issue.

Reviewed By: shwanton, NickGerleman

Differential Revision: D46687292

fbshipit-source-id: 9922996144aa23fc7fa2f0dcb372367121689598
2023-06-13 12:40:09 -07:00
Nick Gerleman
2d19f45c86 Sync up package descriptions (#1307)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1307

This syncs up some of the descriptions, author names, etc between the different Yoga packages we are going to soon publish.

Reviewed By: cortinico

Differential Revision: D46664187

fbshipit-source-id: b15974efee31f349650e5d23f9fcaebaef6d6dd3
2023-06-13 11:33:58 -07:00
Nick Gerleman
2d408acbab Mark YogaKit Podspec as Deprecated (#1306)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1306

We are deprecating YogaKit as part of Yoga 2.0, with that version planned as the last release. Mark the podspec as deprecated.

We are also deprecating the Android ViewGroup in a similar way but from the googling I did there is not an equivalent way to do that for Maven artifacts.

Reviewed By: cortinico

Differential Revision: D46663201

fbshipit-source-id: 14e89df8f20470996b5c4b25f098d27cd3f49c7f
2023-06-13 11:33:58 -07:00
Nick Gerleman
3792d72462 Quick and dirty versioning script (#1305)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1305

Made a quick script to set versions in manifests that currently exist. This should probably be stamped in more places, like the binary as well, but we don't do that right now. This does not update lockfiles for CocoaPods or JS, so those will need to be updated via an install after running this script.

A note on language: This repo already has too many toolchains, but I chose Python for this since it corresponds with the enum script, and we  can run it with no dependencies on macOS/Linux distros.

Reviewed By: cortinico

Differential Revision: D46662378

fbshipit-source-id: 74ab99eef137511f8ed2fd7d81335a0fa633caf5
2023-06-12 15:53:16 -07:00
Nicola Corti
36e491754f Setup publishing for Yoga stables
Summary:
This sets up publishing for stable of Yoga whenever a git tag gets published.
I also re-enabled Javadoc publishing as this is a requirement to hit Maven Central.

Reviewed By: NickGerleman

Differential Revision: D46522898

fbshipit-source-id: dc4b9139aed7aff27dce966bcee7b9b0cc4c6fe9
2023-06-08 02:23:48 -07:00
Nicola Corti
a2832f4d55 Use the correct secrets for snapshot publishing
Summary:
I accidentally mixed the secret name for publishing to sonatype.
The correct values are `SONATYPE_USERNAME` and `SONATYPE_PASSWORD`.

After this snapshot publishing should be green.

Reviewed By: NickGerleman

Differential Revision: D46522897

fbshipit-source-id: 3ebb5bf5be32a7bbac1fefc9ed46c49be15bd56c
2023-06-08 01:51:30 -07:00
Pieter Vanderwerff
8a07ffe6c8 Update prettier to v2.8.8
Summary:
X-link: https://github.com/facebook/react-native/pull/37738

Upgrade Prettier to the latest stable version, 2.8.8.

Reviewed By: SamChou19815

Differential Revision: D46403769

fbshipit-source-id: 551d64db0b701a8d3f275900dd8f6324c115a3e6
2023-06-06 20:06:25 -07:00
Nick Gerleman
4fc1657f2c Basic CocoaPods Validation (#1303)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1303

This gets `pod lib lint` and building the sample app with xcbuild passing (using https://github.com/facebook/yoga/pull/1105 as a template).

Reviewed By: cipolleschi

Differential Revision: D46470738

fbshipit-source-id: f66f6c6efc1b7cf1443fbca0815a24801c16a626
2023-06-06 14:56:44 -07:00
Nick Gerleman
5e74e20a4d Remove In-tree C# Bindings (#1302)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1302

These C# bindings were contributed as part of ff8f17ac99. They have occasionally been refreshed, but has never really had validation it built continuously, or dedicated maintenance.

There has been a surge of work with https://github.com/facebook/yoga/pull/1207 to try to modernize the build for these, but checking with jkoritzinsky I'm not sure either of us have the time to commit to supporting these at the same level as other bindings.

Some well-known projects like Unity had already abandoned this set of bindings for their own. 016297e35c (diff-c85198aaac9095a5446ed00b0fba8025072d235b2b69dea8aad85abc64a83e1e)

So, as part of the work for an official OSS release, and really trying to define what is deprecated, and what we will try to support, I am removing the in-tree C# bindings from Yoga.

In the past, gaps in Yoga bindings we haven't supported have led to new bindings with dedicated maintainers e.g. [FlexLayout](https://github.com/layoutBox/FlexLayout), [yoga-rs](https://github.com/bschwind/yoga-rs), [yoga-wasm-web](https://github.com/shuding/yoga-wasm-web). My hope is that by removing the C# bindings that we are not supporting, we free up the opportunity for a new version to become the defacto.

Reviewed By: javache

Differential Revision: D46425886

fbshipit-source-id: df964c4d55adf93c4d1e82c104e74ca5ad181612
2023-06-05 10:48:10 -07:00
Nicola Corti
1ab0c7b493 Add a Github Action to publish SNAPSHOTS after every commit.
Summary: I'm adding this action which will setup publishing of `-SNAPSHOT` version after every commit to main.

Reviewed By: mdvacca

Differential Revision: D46330012

fbshipit-source-id: 8d9f32a357f157a8f2e05c88074befd8dd871c94
2023-05-31 15:22:21 -07:00
Nicola Corti
9a0ba05d13 Setup publishing of snapshots using io.github.gradle-nexus.publish-plugin
Summary:
This sets up publishing of -SNAPSHOT verison of Yoga using the
Gradle plugin `io.github.gradle-nexus.publish-plugin`

This plugin will take care of setting up the credentials for Sonatype and hitting the Maven repository.
I've cleaned up the setup and centralized it inside a script plugin in the `build-logic` folder so we can easily add more module and just use `id("publish")` to publish them as well.

Reviewed By: mdvacca

Differential Revision: D46330013

fbshipit-source-id: 7221b296b9955a257fc290a2d1ac1d9fedfb787d
2023-05-31 15:22:21 -07:00
Nicola Corti
186f4d318d Update project to use Gradle's plugins{} block
Summary:
This project was still using the legacy Gradle's "apply:" syntax
to apply Gradle Plugins. I'm changing it here to use instead the
`plugins{}` block as it make easier to apply other plugins for publishing later.

Reviewed By: mdvacca

Differential Revision: D46330014

fbshipit-source-id: 5483a717a62d5ab76749026c5203dc96a35d73e7
2023-05-31 14:48:05 -07:00
Nick Gerleman
f2b4e42ca2 Change how we set cmake policy (#1288)
Summary:
X-link: https://github.com/facebook/react-native/pull/37349

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

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

New versions of CMake add "policies" which control how the build system acts wrt breaking changes. By default, CMake will emulate the behavior of the version specified in `cmake_minimum_required`.

Setting a policy to true (to opt into new behavior where `cmake_minimum_required` is lower than the current version) seems actually just error out on the old versions.

Googling around, apparently the way I should be doing this is to specify `<policy_max>` as part of `cmake_minimum_required `. https://gitlab.kitware.com/cmake/cmake/-/issues/20392

This should I think use new policies introduced up to 3.26 (what we test on right now), while letting 3.13 be the minimum.

Reviewed By: cortinico

Differential Revision: D45724864

fbshipit-source-id: 120cc2015a043605e7c07ef0459667643a4284b7
2023-05-15 15:21:56 -07:00
Nick Gerleman
3fb698c08b Remove pinned CMake version from Gradle build (#1292)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1292

AGP 8.0 will now bring in a new enough CMake version to avoid internal warnings without extra configuration.

Reviewed By: cortinico

Differential Revision: D45766980

fbshipit-source-id: 7834f723c87ec76c450a94958cd36b4930a8961a
2023-05-15 14:03:00 -07:00
Patryk Ozga
6f31ea8e03 remove extra semis from arfx/atlas/modules and deps attempt 2 (#1299)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1299

X-link: https://github.com/facebook/igl/pull/22

deletes semicolons and adds whitespace sometimes

moved the runtime ipc chages int a seperate diff

Reviewed By: KSRandom

Differential Revision: D45835378

fbshipit-source-id: 2890e93620af4cadd33b9c8c9149157d9078fa32
2023-05-15 13:15:29 -07:00
Junfeng Li
974473aa99 Revert D45722118: remove extra semis from arfx/atlas/modules and deps
Differential Revision:
D45722118

Original commit changeset: a749ca9e979d

Original Phabricator Diff: D45722118

fbshipit-source-id: 9316f2946966e001f0884af17bf733a1a48e75cc
2023-05-12 15:57:47 -07:00
Patryk Ozga
13e2b5ee73 remove extra semis from arfx/atlas/modules and deps (#1289)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1289

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

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

X-link: https://github.com/facebook/igl/pull/21

Reviewed By: nlutsenko, NickGerleman

Differential Revision: D45722118

fbshipit-source-id: a749ca9e979d4447e65d075493c251169f81c289
2023-05-12 12:44:37 -07:00
Nick Gerleman
6db81656ac Make jni_YGNodeDeallocateJNI call YGNodeDeallocate
Summary:
X-link: https://github.com/facebook/react-native/pull/37388

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

Updating this glue was missed in D45556206 when moving from one revision to the other...

Reviewed By: yungsters

Differential Revision: D45780647

fbshipit-source-id: 4ca64bc9971d3e4697990e73b618a3dc91df259b
2023-05-11 13:30:49 -07:00
Nick Gerleman
e53d1ee28a Enable -Wextra in C++ builds (#1294)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1294

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

Add -Wextra to the build, and fixup some more instances of -Wunused-parameter that it sufaces which were not automatically fixable.

Reviewed By: javache

Differential Revision: D45772846

fbshipit-source-id: 29bf71006f63161521fe5869c3a7d8bf7aae9c81
2023-05-11 09:43:36 -07:00
Nick Gerleman
a97dbecb49 Apply fixes from clag-tidy misc-unused-parameters (#1293)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1293

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

Gets the project mostly clean of `-Wunused-parameter`, part of `-Wextra`.

Reviewed By: yungsters

Differential Revision: D45772554

fbshipit-source-id: db4c4d2bd222debef178c4c16f7b60fb6c8db2a2
2023-05-11 09:43:36 -07:00
Nick Gerleman
9e1b14cd9e Add hasErrata(), addErrata(), removeErrata()
Summary:
X-link: https://github.com/facebook/react-native/pull/37375

Adds internal helpers to YGConfig to make bit manipulation more readable. We also expose `hasErrata()` to YGNode beacuse checking that will be a common pattern. We intentionally don't add mutating functions to the node, since current model is to inval a node on commiting whole config.

This is not exposed via the C ABI.

Reviewed By: yungsters

Differential Revision: D45765971

fbshipit-source-id: eadaee4b9cf5204ac4984ecc52cc08650d144a30
2023-05-11 05:30:57 -07:00
Nick Gerleman
3b088c3383 Fix use-after-free if JNI Yoga nodes are garbage collected using multiple threads (#1279)
Summary:
X-link: https://github.com/facebook/react-native/pull/37243

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

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

Java bindings for Yoga rely solely on garbage collection for memory management. Each Java `YogaNode` has references to its children and parent Java Nodes. This means, for a node to be garbage collected, it cannot be reachable from any user accessible node. Each node then has single ownership of a `YGNodeRef`. When the `YogaNode` is garbage collected, a finalizer is run to call `YGNodeFree` and free the underlying native Yoga Node.

This may cause a use-after-free if finalizers are run from multiple threads. This is because `YGNodeFree` does more than just freeing, but instead also interacts with its parent and children nodes to detach itself, and remove any dangling pointers. If multiple threads run finalizers at once, one may traverse and try to mutate a node which another is freeing.

Because we know the entire connected tree is dead, there is no need to remove dangling pointers, so I want to expose a way to just free a Yoga Node, without it mutating the tree as a side effect.

This adds a currently private `YGNodeDeallocate` that frees without traversal. Ideally from naming this is what `YGNodeFree` would do, but we think changing the behavior of that might be too disruptive to OSS. At the same time there may be other memory safety related API changes we would like to eventually make, so this isn't made public beyond the JNI bindings to prevent needing to transition more APIs.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45556206

fbshipit-source-id: 62a1394c6f6bdc2b437b388098ea362a0fbcd0f7
2023-05-10 22:52:48 -07:00
Nick Gerleman
149849d22b Move generated Jest tests to TypeScript (#1287)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1287

Outputs tests as TypeScript, along with using/testing the new form of enums imported directly from the package.

We need to change how we are telling Jest which variant to run, so that tests can import enums from "yoga-layout" and have it resolve to the entrypoint which has a binary which has already been built.

Reviewed By: yungsters

Differential Revision: D45723545

fbshipit-source-id: 887d929344a78cadec159a07c643b74b76b87c6c
2023-05-10 22:46:39 -07:00
Nick Gerleman
e769dd97d8 Add data-disabled to test fixtures (#1286)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1286

This can be marked in fixtures to skip a test without commenting it out. We add one more usage of this.

The same functionality existed (unused) before for `experiments`, which I changed to `data-experiments`.

Formatting of JS tests changed to be closer to what Prettier would output, and to remove usage of `Yoga.UNDEFINED` which doesn't existi and just resolves to `undefined` (this is converted to NaN by the wrapper layer).

Reviewed By: yungsters

Differential Revision: D45723003

fbshipit-source-id: 337af319ab1c1c12047d6579da8c7e63b4f1537a
2023-05-10 22:46:39 -07:00
Nick Gerleman
e409bfb43a Use babel-node instead of ts-node when running benchmark script
Summary:
`ts-node` does transformation using tsc. Do transformation with Babel instead so that the generation is consistent with Jest and the packed output.

We still need `ts-node` around since various systems rely on it being present to enable `.ts` config files.

This also enables transformation of any JS files.

Reviewed By: yungsters

Differential Revision: D45722106

fbshipit-source-id: 51b7a4f6a1532bea1133d59e626297d3b40f1762
2023-05-10 17:12:10 -07:00
generatedunixname89002005325679
82096a1465 Daily arc lint --take PRETTIERJAVASCRIPT
Reviewed By: adamjernst

Differential Revision: D45725703

fbshipit-source-id: efab6e4a84888178066be723ebb7915830792791
2023-05-10 07:04:59 -07:00
Nick Gerleman
af89315fd4 Fixup TypeScript with export maps (#1284)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1284

This makes TypeScript resolution play nicely with export maps, and converts the entrypoints to TypeScript.

We remove the non-export-map fallbacks as well, so the export maps are always followed.

Tests are moved to load yoga from its external export, testing the entrypoints.

This moves the only untyped bit to the binary wrapper, which another diff will move.

Reviewed By: yungsters

Differential Revision: D45713689

fbshipit-source-id: 228e6f2c9d53520230707a81e76c3c35fcd46de5
2023-05-09 22:21:01 -07:00
Nick Gerleman
104646d8ca Namespaced and TypeScript Enums (#1285)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1285

Enums are currently exposed to the JS package as constants (e.g. `import {ERRATA_NONE} from 'yoga-layout'`).

This exports enums in the form of `import {Errata} from 'yoga-layout'` then `Errata.None`.

It would be more ergonomic for these to be string union based enums instead, but right now it is a pretty thin wrapper around the native API, we need ordinal values to do things with bit masks, and folks have wanted to serialize them before.

Reviewed By: yungsters

Differential Revision: D45570417

fbshipit-source-id: dbfd330e939051d0c16460a4d2a996f88f98875c
2023-05-09 22:21:01 -07:00
Nick Gerleman
aa812d0e48 In-place JS environment
Summary:
This change restructures the package to try to remove the JS build step from the inner loop. Instead, we have a single `src` directory that we babel transform when using, then apply the same transform inline during prepublish.

At the end, we will be publishing a source directory with Babel transformed TS, JS, and TS declarations.

We do a little spring cleaning when doing this. Fixing up some of the folder/file conventions, and removing the non-export-map fallbacks.

We cannot remove the need for a native build.

Reviewed By: yungsters

Differential Revision: D45682153

fbshipit-source-id: ea2dd75c2dd6e3529b1ef6cf6ac6a64a270049a4
2023-05-09 15:35:42 -07:00
Nick Gerleman
0a6a581936 Match xplat/yoga/javascript prettier conventions
Summary:
Match Prettier config to match other Meta OSS projects

Didn't update the test generator to use this form yet.

Reviewed By: yungsters

Differential Revision: D45570415

fbshipit-source-id: d5fd791b047debf41c28aecac75fb8dde16da3e3
2023-05-09 15:35:42 -07:00
Nick Gerleman
0cb4a49d38 Convert manually authored tests to TypeScript
Summary: Converts the manually authored tests against the JavaScript bindings to TypeScript. This should make authoring UTs a bit more pleasent, but more importantly lets us run typechecking on sample usage of all of the various APIs.

Reviewed By: yungsters

Differential Revision: D45570416

fbshipit-source-id: 44586b4d31fbeae406b388ed336a8305c788b5dd
2023-05-09 15:35:42 -07:00
Nicola Corti
172bd0a88e Let the Yoga sample app compile
Summary:
The sample app is really old and has a lot of legacy code. Here I'm refreshing it a bit.
Will do another pass later (perhaps rewrite it in Kotlin?).

Reviewed By: mdvacca

Differential Revision: D45694414

fbshipit-source-id: 36a84609b0dcf5b4a5237da900f665e4eb7895a5
2023-05-09 10:43:02 -07:00
Nicola Corti
420f0016c6 Hook Yoga's Gradle build into Gradle Enterprise
Summary: This adds the setup necessary to hook Yoga into a Gradle Enterprise instance

Reviewed By: mdvacca

Differential Revision: D45694413

fbshipit-source-id: 766ea7e05f99ae347853dbe3817521379b4e44ba
2023-05-09 09:48:55 -07:00
Nick Gerleman
a1fbbc6070 Fix YGNodeSetConfig causing excessive dirtying
Summary:
X-link: https://github.com/facebook/react-native/pull/37316

In Fabric, a ShadowNode may re-initialize YGConfig several times throughout the lifetime of a perpetually cloned Yoga Node.

RN sets `pointScaleFactor` lazily, when laying out the rootview. So right now it initializes a config to `pointScaleFactor` of 1.0, sets it, sets a new `pointScaleFactor` on the config, then repeats. This cycles the config between two `pointScaleFactor` values and will excessively dirty the node now that `YGNodeSetConfig` dirties on config change (D45505089)

This change makes it so that we retain previously used `pointScaleFactor` when cloning the Yoga nodes.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D45669878

fbshipit-source-id: bfd2e185d9264a1cda64e59132960060385e16f1
2023-05-08 16:30:06 -07:00
Nick Gerleman
b8126cdc6c Dirty nodes when dynamically setting config (#37207)
Summary:
X-link: https://github.com/facebook/react-native/pull/37207

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

Yoga exposes public APIs for dirtying Nodes, but will itself perform dirty marking when changing bits which invalidate layout. E.g. changing the style of a Node will invalidate it along with every parent Node.

Because config setting is newly public to the C ABI, this makes a similar change so that replacing a Node's config will dirty the tree above the node if there is a layout impacting config change (I don't think children need to be invalidated since child output shouldn't change given the same owner dimensions).

One quirk of this is that configs may be changed independently of the node. So someone could attach a config to a Node, then change the live config after the fact. The config does not currently have a back pointer to the Node, so we do not invalidate in that case of live config edits. The future work to rectify this would be to make configs immutable once created.

There are also currently some experimental features here which should maybe be compared, but these should be moved to YGErrata anyway.

Reviewed By: javache

Differential Revision: D45505089

fbshipit-source-id: 72b2b84ba758679af081d92e7403750c9cc53cb5
2023-05-07 00:34:02 -07:00
Nicola Corti
54d78926ce AGP to 8.0.1 (#1280)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1280

I'm refreshing some of the dependencies of the project,
here doing AGP to 8.0.1.
I'm also removing the older publishing plugin as we're most likely going to use
Gradle's default publishing + another plugin to manage the nexus interactions (the same we use on React Native).

I'm also doing some changes on the JDK side:
- Bumps the JDK version to 17 as that's required by AGP
- Bumps the source/target version to JDK 8. JDK 7 is long deprecated and we're getting a lot of warnings for it on console. Users should be on JDK 11 already by now, but 8 is also good enough.

Reviewed By: passy

Differential Revision: D45564575

fbshipit-source-id: ffe1cc15892659923177a2cad609d5d30f8249ac
2023-05-05 04:07:40 -07:00
Nicola Corti
3a69a040c4 local.properties to gitignore
Summary:
When trying to open Yoga on Android studio, the local.properties file gets created and added
to the untracked files. This file should not be committed so I'm .gitignoring it.

Reviewed By: mdvacca

Differential Revision: D45564577

fbshipit-source-id: 62c8c8798b539cd6db6e341ee321e27239c25b87
2023-05-04 11:30:01 -07:00
Nicola Corti
1712b38282 Gradle to 8.1
Summary:
I'm refreshing some of the dependencies of the project,
starting with Gradle to 8.1

Reviewed By: mdvacca

Differential Revision: D45564578

fbshipit-source-id: 9570d0026a1c5c4e15921a411b80471f5c5e8ebd
2023-05-04 11:30:01 -07:00
Nick Gerleman
44ea3c1555 Add types to scripts and config files (#1277)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1277

Now that we have some TypeScript infra set up, move scripts (mainly the benchmarking one) and config files to TypeScript.

Starts to move away a bit from the magic globals used in the JS environment.

Reviewed By: yungsters

Differential Revision: D45511176

fbshipit-source-id: 09bb1117a1b331758ed9d210e82d5b250577df81
2023-05-04 08:11:04 -07:00
Nick Gerleman
19aed1d63e Lint and typecheck TypeScript (#1276)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1276

This change starts to enlighten linting and other repo configuration to TypeScript. This was previously special-cased out of linting, and meant we were not linting everything. It is also a precondition to do real typechecking and linting our definitions with type information.

1. Add TypeScript dependencies
1. Configure ESLint, Babel, tsc for TypeScript
1. Run tsc as part of linting (OSS only for now)

This is continued in another change with adding types to scripts and config files, but more importantly converting hand-written tests and test generation to TypeScript, so we get real-world usage to typecheck against for testing.

Reviewed By: yungsters

Differential Revision: D45508576

fbshipit-source-id: 6d2e48b9d25bb6b1788440ea3515ea5f5c64d346
2023-05-04 08:11:04 -07:00
Nick Gerleman
70153cc16c Try to fix MSVC Buck Build (#37242)
Summary:
X-link: https://github.com/facebook/react-native/pull/37242

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

Reviewed By: yungsters

Differential Revision: D45552325

fbshipit-source-id: 5687e8ec27a7a70df66e2f89e800210e3ce21ba3
2023-05-04 00:41:12 -07:00
Nick Gerleman
f3633a256b TypeScript fixes (#1275)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1275

A pending change revamps a lot of how ESLint, Prettier, and Jest are configured in the repo, along with moving the world to TypeScript (and adding tsc usage).

That still needs some work to split up, but this change adds types used in our unit tests that I found were missing.

Reviewed By: yungsters

Differential Revision: D45506781

fbshipit-source-id: c4c5cb3aeff95f16bd54121e2ca0e042b6429ba0
2023-05-03 16:11:20 -07:00
Nick Gerleman
d8dec0f85a Don't export private headers from Buck target (#1269)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1269

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

This prevents targets which include Yoga from using its private APIs.

Instances of this have been mostly cleaned up in the past diffs, with the major exception of RN Fabric. To stage this without blocking on that, I added a `yoga-private-api` target for now to keep using these headers while making it unlikely new usages will show up.

Reviewed By: javache

Differential Revision: D45339425

fbshipit-source-id: eb7ef151ad2467d7c3370cd7c10d47e8db9496a0
2023-05-02 18:08:58 -07:00
Nick Gerleman
080d16cabf Cleanup YGValue.h header (#37179)
Summary:
X-link: https://github.com/facebook/react-native/pull/37179

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

1. Simplify nan handling a bit
2. Remove string literal operators which seem dead enough to remove. These are public, so anyone could be using them, but it seems like almost nobody is.
    1. FB has no usages of `using namespace facebook::yoga::literals` (exposing the literal operators) outside of Yoga tests.
    1. There is only [a single usage](6dfba905ea/SDLTest/UIKit.hpp (L19)) on GitHub.

Reviewed By: yungsters

Differential Revision: D45419970

fbshipit-source-id: 8121303e5ae66596132a848a711802081728f4fb
2023-05-02 17:08:24 -07:00
Nick Gerleman
3156cb207f Fix YG_DEPRECATED in MSVC C Build (#37178)
Summary:
X-link: https://github.com/facebook/react-native/pull/37178

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

Forgot to export this one to the Yoga repo to test the MSVC bits...

Reviewed By: yungsters

Differential Revision: D45432859

fbshipit-source-id: 8d5f2daacb00daab67de111410329f8db80475e0
2023-04-30 11:06:02 -07:00
Nick Gerleman
f32d37a3d5 Deprecate YGConfigSetUseLegacyStretchBehaviour (#37117)
Summary:
X-link: https://github.com/facebook/react-native/pull/37117

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

This deprecates `YGConfigSetUseLegacyStretchBehaviour` and `YGConfigGetUseLegacyStretchBehaviour`and points users to errata APIs instead. Using the C API will fire deprecation warnings, which should create errors in builds with `-Werror`, though they can be ignored if truly needed (like we do with the language bindings which need to expose their own deprecated interface).

Reviewed By: rshest

Differential Revision: D45337198

fbshipit-source-id: 7f069623e38834171f5702382bbf47c37a556a22
2023-04-30 08:20:05 -07:00
Nick Gerleman
893b3e3957 Add JavaScript bindings for Errata API (#1260)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1260

Wire C ABI to embind to expose to JS

Reviewed By: yungsters

Differential Revision: D45297215

fbshipit-source-id: ef832ad423703496a550b864ebee70525a858b50
2023-04-27 13:53:45 -07:00
Nick Gerleman
215f0a9d6d Add C# bindings for Errata API (#1259)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1259

Wires C ABI to C# bindings using `System.Runtime.InteropServices`. Note that we don't have a working C# build right now, but there is [effort to address that](https://github.com/facebook/yoga/pull/1207) which may get some more effort before the Yoga release, so this keeps the bindings up to date.

Reviewed By: yungsters

Differential Revision: D45297676

fbshipit-source-id: 408f84d74ebbc7698407e951e831627117cbc2ed
2023-04-27 13:53:45 -07:00
Nick Gerleman
c1a5219b03 Move YogaKit to YGErrataClassic (#1261)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1261

YogaKit integrates Yoga with UIKit as a higher level framework. It does not expose config setting to users.

We set YGErrataClassic for now to prioritize compatibility instead of conformance (YogaKit is relatively used in fbsource as well).

I'm also tempted to remove the usage of ExperimentalWebFlexBasis since last I heard rozelle thought it was generally broken, but I am a bit afraid to if it has been enabled so long, and is used in many cases in Meta.

Reviewed By: yungsters

Differential Revision: D45298803

fbshipit-source-id: 92f72148fafbdaffba4589c18c8b46591ca7c364
2023-04-27 13:53:45 -07:00
Nick Gerleman
26a7f72124 Deprecate Java YogaConfig.setUseLegacyStretchBehaviour() (#37095)
Summary:
X-link: https://github.com/facebook/react-native/pull/37095

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

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

Now that our own usages are removed, mark this as deprecated to encourage users to move to the errata API. The same will be done to variants of this function on other platforms before releasing, and the functions will be removed after releasing.

Reviewed By: yungsters

Differential Revision: D45300343

fbshipit-source-id: 1ecb2b25021f43a0c97ae6e7976317d28551abea
2023-04-27 12:32:28 -07:00
Nick Gerleman
4692e97ba0 Add Java bindings for Errata API (#37096)
Summary:
X-link: https://github.com/facebook/react-native/pull/37096

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

JNI glue to expose `YogaConfig.setErrata()` and `YogaConfig.getErrata()`.

Reviewed By: yungsters

Differential Revision: D45296538

fbshipit-source-id: 8d743d278b7df43f7843a79d8f4542bfb03fc08d
2023-04-27 06:48:04 -07:00
Nick Gerleman
fc6485b8cd Add YGErrata integration within C ABI (#37075)
Summary:
X-link: https://github.com/facebook/react-native/pull/37075

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

This diff wires up YGErrata to a public API, along with existing functions to set UseLegacyStretchBehaviour.

The `UseLegacyStretchBehaviour` functions will be removed after the world internally is transitioned to `YGConfigSetErrata`. This is intentionally breaking, since most users previously enabling `UseLegacyStretchBehaviour` will want to pick a new appropriate errata setting. Internally, users of the API will be moved to`YGErrataAll`.

The overall change looks like:
1. Clean up YGConfig to use accessors/setters
2. Change up YGconfig internal storage
    1. Fabric has a config per ShadowNode, so it makes sense to do some size optimization before adding more (free-form bools to bitfield, `std::array<bool,>` to `std::bitset` since not specialized)
3. Wire accessor/setter of UseLegacyStretchBehaviour to errata while both APIs exist
4. Add errata APIs to C ABI

After this we will need to expose the ABI to more language projections, and (more involved), add usages of the API to internal consumption of Yoga before adding more errata and removing `UseLegacyStretchBehaviour`.

Note that this API representation is similar, but distinct to `YGExperimentalFeature`. I think that API may also have made sense as an enum bitset, like we explicitly want for the new API, but it's not really worth changing the existing API to make that happen.

Reviewed By: rshest

Differential Revision: D45254097

fbshipit-source-id: 5c725ce5a77b25c1356f753d11c468587dbd8ded
2023-04-27 06:48:04 -07:00
Nick Gerleman
36406ce17c Remove config variant copy ctor from YGNode (#37091)
Summary:
X-link: https://github.com/facebook/react-native/pull/37091

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

This private constructor was added specifically for Fabric when config setting was deprecated, but that is undeprecated now. Fbsource fabric was moved off of it, and the RN desktop for was in the last diff in the stack, so we can remove it now.

Reviewed By: yungsters

Differential Revision: D45292729

fbshipit-source-id: 87b2a1adaafaf817befe44dbc3ac178af59a6e68
2023-04-27 06:48:04 -07:00
Nick Gerleman
c878ceeabd Define Flag operators for YGPrintOptions (#37115)
Summary:
X-link: https://github.com/facebook/react-native/pull/37115

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

This is an existing bitset enum in the API. Use the facility added in the last diff to add flag operators to it, to avoid the need for casting, and to make it clearer in the generated YGEnums.h that it is a bitset.

Reviewed By: rshest

Differential Revision: D45341504

fbshipit-source-id: 0b80588f3e2e167d4c1c722c6d6608408dd617ba
2023-04-27 03:15:14 -07:00
Nick Gerleman
01c0c4ed3b Add YGErrata Enum (#1256)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1256

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

This adds a `YGErrata` bitset enum matching the API and guarantees described in https://github.com/facebook/yoga/issues/1247.

It is hooked up in later diffs. There are a couple of `YGExperimentalFeature` values that belong here, but keeping the current options means that the default `YGErrataNone` corresponds to existing default behavior, letting us stage the series of changes as:
1. Implement errata API
2. Update internal Yoga users we want to de-risk to `YGErrataClassic` or `YGErrataAll` (if setting `UseLegacyStretchBehaviour`)
3. Add new errata, changing Yoga defaults to be conformant, while letting internal apps opt into compatibility modes pending experimentation.

I also added a macro to let C++ users of Yoga perform bitwise operations on the enum without casting (already available for C users).

Reviewed By: rshest

Differential Revision: D45254098

fbshipit-source-id: d4b61271a8018f548f2d9d8c953db4b121a502d1
2023-04-27 03:15:14 -07:00
Nick Gerleman
fc68765314 Remove private headers exposed by podspecs (#940)
Summary:
X-link: https://github.com/facebook/litho/pull/940

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

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

Fabric relies on the private C++ internals of Yoga. This creates a conundrum in the open source build due to how header creation in Cocoapods works.

1. The default mechanism of specifying public headers needs to include the private headers for them to be made usable by fabric (by default)
2. Cocoapods will roll up all of the public headers when importing a module

https://github.com/facebook/react-native/pull/33381 fixed the Fabric Cocoapods build which ran into this. React Native relies on FlipperKit which relies on YogaKit, which in turn finally imports the Yoga podspec. Because YogaKit may use Swift, we can only expose the public Yoga C ABI.

The first solution in that PR was to allow RN to access Yoga private headers, but this was changed to instead make all Yoga headers public, and to add ifdefs to all of them to no-op when included outside of a C++ environment.

Talking to Kudo, we should be able to change back to the earlier approach in the PR, to instead expose the private headers to only RN. This lets us avoid exposing headers that we ideally wouldn't be, and lets us avoid the messy ifdefs in every Yoga header.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45139075

fbshipit-source-id: 99152986a578f7aac8324dffe0e18c42a38cc6a5
2023-04-26 17:27:29 -07:00
Nick Gerleman
292bbc43d6 Disable broken YogaKit test
Summary: This test fails locally and testx shows it always failing in continuous, disable it for now.

Reviewed By: yungsters

Differential Revision: D45298519

fbshipit-source-id: dc1d654bc4ecf5b32b733a6b5ae40255f35acafc
2023-04-26 07:01:36 -07:00
Nick Gerleman
b15894b70a Cleanup YGNode for explicit per-node config
Summary:
Cleans up some of the changes to UseWebDefaults that were made in the interest of moving it outside of YGConfig. It still exists in YGConfig, but also exists on the node.

We also assert on null config, or when someone tries to change UseWebDefaults after creating a node (since right now YGStyle does not know the difference between unset vs set explicitly to what would normally be default).

Removes a peculiar constructor which was added to avoid config setting.

Reviewed By: rshest

Differential Revision: D45133644

fbshipit-source-id: 2b5e2baeb826653133df9b1175cf5c194e342e3e
2023-04-24 18:48:48 -07:00
Nick Gerleman
85ff2f06c2 Remove C++ form of YGNodeSetChildren (#37013)
Summary:
X-link: https://github.com/facebook/react-native/pull/37013

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

Brings Yoga public interface back to a nice pure C ABI.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45138827

fbshipit-source-id: 8df7e4fd03afcda9a714d193b0430c122a7a7574
2023-04-21 15:36:17 -07:00
Nick Gerleman
7afddfd204 Remove YGNode "reserved_" field (#36991)
Summary:
X-link: https://github.com/facebook/react-native/pull/36991

D15296732 added a byte to each YGNode exposed via private API, to stash random junk in. At the time, not adding to node size because of how fields ended up aligning. I'm not sure if this is still the case, but this is subject to change (e.g. adding a single extra flag).

There is a per-node "context" already that can store arbitrary data, and this reserved space isn't public, so this API is already a bit suspect.

The only place it is used is in instrumentation in fbandroid, enabled only in benchmarks, to store an enum to forward to QPL for what framework it thinks created the Yoga Node.

This is already broken for React Native (worked for Paper only), and afaict isn't used anywhere. But it also has little reason to be caching more information on the node (beyond maybe saving a couple memory accesses) since it derives this information from the node config already.

This removes the field.

Changelog:
[Internal]

Reviewed By: rshest

Differential Revision: D45137133

fbshipit-source-id: 75755b21102f7928b3ad947051c35b1a6566ef40
2023-04-21 13:54:50 -07:00
Nick Gerleman
3138a438af Remove YGTraversePreOrder (#37014)
Summary:
X-link: https://github.com/facebook/react-native/pull/37014

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

This is unused, and kinda missed the intent of Yoga.h and YG* functions being a C ABI.

Reviewed By: rshest

Differential Revision: D45138646

fbshipit-source-id: 743e7d0f43c122932c3a6f43ce564c0f209b4771
2023-04-21 09:58:07 -07:00
Nick Gerleman
88f1f3cab9 Remove BitUtils Usage in YGNode (#1250)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1250

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

BitUtils functions in Yoga are like bit fields, with more steps, and more error prone (you need to work with explicit offsets which can be tricky for anything variable length). Replace usage with a bitfield struct. Eventually I'd like to remove the BitUtils functions in general.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45133645

fbshipit-source-id: aa1430df5e2fb71ed9d2a5f5b1a35429b71c7069
2023-04-20 17:38:55 -07:00
Nick Gerleman
19e15a4455 Undeprecate Config setting APIs (#1251)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1251

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

YGNode::setConfig was deprecated as part of D15416474 in an apparent goal to remove config pointers per-Node.

While I don't know the history of the motivation here, these config pointers were never removed, and we will be doubling down on per-node configs for StrictLayout, so we will want to undeprecate this.

This also exposes functions to the public C ABI, but I didn't spend the effort to create language projections for it.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45133646

fbshipit-source-id: 2bb15c4825717793529cdad8542447d11e723e35
2023-04-20 14:01:14 -07:00
dependabot[bot]
5fd3240f85 Bump nokogiri from 1.13.10 to 1.14.3 in /gentest (#1245)
Summary:
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.10 to 1.14.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/sparklemotion/nokogiri/releases">nokogiri's releases</a>.</em></p>
<blockquote>
<h2>1.14.3 / 2023-04-11</h2>
<h3>Security</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to address CVE-2023-29469, CVE-2023-28484, and one other security-related issue. See <a href="https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-pxvg-2qj5-37jq">GHSA-pxvg-2qj5-37jqGHSA-pxvg-2qj5-37jq</a> for more information.</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to <a href="https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.10.4">v2.10.4</a> from v2.10.3.</li>
</ul>
<hr />
<p>sha256 checksums:</p>
<pre><code>9cc53dd8d92868a0f5bcee44396357a19f95e32d8b9754092622a25bc954c60c  nokogiri-1.14.3-aarch64-linux.gem
320fa1836b8e59e86a804baee534893bcf3b901cc255bbec6d87f3dd3e431610  nokogiri-1.14.3-arm-linux.gem
67dd4ac33a8cf0967c521fa57e5a5422db39da8a9d131aaa2cd53deaa12be4cd  nokogiri-1.14.3-arm64-darwin.gem
13969ec7f41d9cff46fc7707224c55490a519feef7cfea727c6945c5b444caa2  nokogiri-1.14.3-java.gem
9885085249303461ee08f9a9b161d0a570391b8f5be0316b3ac5a6d9a947e1e2  nokogiri-1.14.3-x64-mingw-ucrt.gem
997943d7582a23ad6e7a0abe081d0d40d2c1319a6b2749f9b30fd18037f0c38a  nokogiri-1.14.3-x64-mingw32.gem
58c30b763aebd62dc4222385509d7f83ac398ee520490fadc4b6d7877e29895a  nokogiri-1.14.3-x86-linux.gem
e1d58a5c56c34aab71b00901a969e19bf9f7322ee459b4e9380f433213887c04  nokogiri-1.14.3-x86-mingw32.gem
f0a1ed1460a91fd2daf558357f4c0ceac6d994899da1bf98431aeda301e4dc74  nokogiri-1.14.3-x86_64-darwin.gem
e323a7c654ef846e64582fb6e26f6fed869a96753f8e048ff723e74d8005cb11  nokogiri-1.14.3-x86_64-linux.gem
3b1cee0eb8879e9e25b6dd431be597ca68f20283b0d4f4ca986521fad107dc3a  nokogiri-1.14.3.gem
</code></pre>
<h2>1.14.2 / 2023-02-13</h2>
<h3>Fixed</h3>
<ul>
<li>Calling <code>NodeSet#to_html</code> on an empty node set no longer raises an encoding-related exception. This bug was introduced in v1.14.0 while fixing <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2649">#2649</a>. [<a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2784">#2784</a>]</li>
</ul>
<hr />
<p>sha256 checksums:</p>
<pre lang="text"><code>966acf4f6c1fba10518f86498141cf44265564ac5a65dcc8496b65f8c354f776  nokogiri-1.14.2-aarch64-linux.gem
8a3a35cadae4a800ddc0b967394257343d62196d9d059b54e38cf067981db428  nokogiri-1.14.2-arm-linux.gem
81404cd014ecb597725c3847523c2ee365191a968d0b5f7d857e03f388c57631  nokogiri-1.14.2-arm64-darwin.gem
0a39222af14e75eb0243e8d969345e03b90c0e02b0f33c61f1ebb6ae53538bb5  nokogiri-1.14.2-java.gem
62a18f9213a0ceeaf563d1bc7ccfd93273323c4356ded58a5617c59bc4635bc5  nokogiri-1.14.2-x64-mingw-ucrt.gem
54f6ac2c15a7a88f431bb5e23f4616aa8fc97a92eb63336bcf65b7050f2d3be0  nokogiri-1.14.2-x64-mingw32.gem
c42fa0856f01f901954898e28c3c2b4dce0e843056b1b126f441d06e887e1b77  nokogiri-1.14.2-x86-linux.gem
f940d9c8e47b0f19875465376f2d1c8911bc9489ac9a48c124579819dc4a7f19  nokogiri-1.14.2-x86-mingw32.gem
2508978f5ca28944919973f6300f0a7355fbe72604ab6a6913f1630be1030265  nokogiri-1.14.2-x86_64-darwin.gem
bc6405e1f3ddac6e401f82d775f1c0c24c6e58c371b3fadaca0596d5d511e476  nokogiri-1.14.2-x86_64-linux.gem
&lt;/tr&gt;&lt;/table&gt;
</code></pre>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md">nokogiri's changelog</a>.</em></p>
<blockquote>
<h2>1.14.3 / 2023-04-11</h2>
<h3>Security</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to address CVE-2023-29469, CVE-2023-28484, and one other security-related issue. See <a href="https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-pxvg-2qj5-37jq">GHSA-pxvg-2qj5-37jqGHSA-pxvg-2qj5-37jq</a> for more information.</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to <a href="https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.10.4">v2.10.4</a> from v2.10.3.</li>
</ul>
<h2>1.14.2 / 2023-02-13</h2>
<h3>Fixed</h3>
<ul>
<li>Calling <code>NodeSet#to_html</code> on an empty node set no longer raises an encoding-related exception. This bug was introduced in v1.14.0 while fixing <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2649">#2649</a>. [<a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2784">#2784</a>]</li>
</ul>
<h2>1.14.1 / 2023-01-30</h2>
<h3>Fixed</h3>
<ul>
<li>Serializing documents now works again with pseudo-IO objects that don't support IO's encoding API (like rubyzip's <code>Zip::OutputStream</code>). This was a regression in v1.14.0 due to the fix for <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/752">https://github.com/facebook/yoga/issues/752</a> in <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2434">#2434</a>, and was not completely fixed by <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2753">#2753</a>. [<a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2773">#2773</a>]</li>
<li>[CRuby] Address compiler warnings about <code>void*</code> casting and old-style C function definitions.</li>
</ul>
<h2>1.14.0 / 2023-01-12</h2>
<h3>Notable Changes</h3>
<h4>Ruby</h4>
<p>This release introduces native gem support for Ruby 3.2. (Also see &quot;Technical note&quot; under &quot;Changed&quot; below.)</p>
<p>This release ends support for:</p>
<ul>
<li>Ruby 2.6, for which <a href="https://www.ruby-lang.org/en/downloads/branches/">upstream support ended 2022-04-12</a>.</li>
<li>JRuby 9.3, which is not fully compatible with Ruby 2.7+</li>
</ul>
<h4>Faster, more reliable installation: Native Gem for <code>aarch64-linux</code> (aka <code>linux/arm64/v8</code>)</h4>
<p>This version of Nokogiri ships <em>official</em> native gem support for the <code>aarch64-linux</code> platform, which should support AWS Graviton and other ARM64 Linux platforms. Please note that glibc &gt;= 2.29 is required for aarch64-linux systems, see <a href="https://nokogiri.org/#supported-platforms">Supported Platforms</a> for more information.</p>
<h4>Faster, more reliable installation: Native Gem for <code>arm-linux</code> (aka <code>linux/arm/v7</code>)</h4>
<p>This version of Nokogiri ships <em>experimental</em> native gem support for the <code>arm-linux</code> platform. Please note that glibc &gt;= 2.29 is required for arm-linux systems, see <a href="https://nokogiri.org/#supported-platforms">Supported Platforms</a> for more information.</p>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="e8d2f4a829"><code>e8d2f4a</code></a> version bump to v1.14.3</li>
<li><a href="59fbc7b6d5"><code>59fbc7b</code></a> doc: update CHANGELOG for v1.14.3</li>
<li><a href="347eacbeea"><code>347eacb</code></a> Merge pull request <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2852">#2852</a> from sparklemotion/flavorjones-libxml2-2.10.4-backport</li>
<li><a href="36b0b3355d"><code>36b0b33</code></a> dep: update libxml2 to 2.10.4 from 2.10.3</li>
<li><a href="ac83e6ee70"><code>ac83e6e</code></a> test: update behavior of namespaces in HTML4</li>
<li><a href="2cf4996c52"><code>2cf4996</code></a> test: make default GC behavior &quot;normal&quot;</li>
<li><a href="1580121eea"><code>1580121</code></a> version bump to v1.14.2</li>
<li><a href="530947753e"><code>5309477</code></a> Merge pull request <a href="https://redirect.github.com/sparklemotion/nokogiri/issues/2791">#2791</a> from sparklemotion/2784-encoding-empty-strings-v1.14.x</li>
<li><a href="975ae491c4"><code>975ae49</code></a> doc: update CHANGELOG</li>
<li><a href="f13cdb4640"><code>f13cdb4</code></a> fix: empty node set serialization when document encoding is nil</li>
<li>Additional commits viewable in <a href="https://github.com/sparklemotion/nokogiri/compare/v1.13.10...v1.14.3">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=nokogiri&package-manager=bundler&previous-version=1.13.10&new-version=1.14.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: cortinico, mdvacca

Differential Revision: D45068426

Pulled By: NickGerleman

fbshipit-source-id: 7b8b5397c1fee8b7c9838770746c6e4f47c6e555
2023-04-18 03:50:37 -07:00
Yurii Nakonechnyi
e255cdd562 Minor: removed extra semicolon (#937)
Summary:
X-link: https://github.com/facebook/litho/pull/937

Latest `emscripten` compiler shows the next warning:
```
yoga/event/event.h:83:6: warning: extra ‘;’ [-Wpedantic]
   83 |     };
      |      ^
```

This small PR fixes it

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

Test Plan: landcastle

Reviewed By: cortinico, mdvacca

Differential Revision: D44775620

Pulled By: philIip

fbshipit-source-id: 79b7ca5df2a31ac9a6ef24ef55d4acb6117a8acb
2023-04-14 13:23:44 -07:00
Yurii Nakonechnyi
d06f7b989e Minor formatting: added space in YGNodeMarkDirty assert message (#1243)
Summary:
Currently `YGNodeMarkDirty()` assert message displayed **without** space between 2 lines:
```
"Only leaf nodes with custom measure functionsshould manually mark themselves as dirty"
                                     ^^^^^^^^^^^^^^^
```
This minor PR fixes it :)

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

Reviewed By: jacdebug

Differential Revision: D44870410

Pulled By: javache

fbshipit-source-id: 58db50106e8e2980ec84c99976f569b94b739d9b
2023-04-11 08:28:00 -07:00
Ruslan Shestopalyuk
3782644b32 Find and fix typos in yoga code (#36560)
Summary:
X-link: https://github.com/facebook/react-native/pull/36560

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

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

Changelog:
[Internal] -

A follow-up to D44172494, I've run a pass of [typos](https://github.com/crate-ci/typos) on the Yoga code to detect/fix typos in comments and identifiers (with a manual review afterwards).

Reviewed By: javache

Differential Revision: D44254911

fbshipit-source-id: 6e8bfe83ec2f963108450cdcb8c79dfc8d1a7375
2023-03-21 16:29:09 -07:00
Dmitry Ivakhnenko
b17f08ed49 fix: types tweaks (#1236)
Summary:
- format types with `prettier`
- apply suggestion from https://github.com/facebook/yoga/pull/1233#discussion_r1120807560

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

Reviewed By: javache

Differential Revision: D44052580

Pulled By: NickGerleman

fbshipit-source-id: 0d9810da460cf4290e15308acdbb705c71f8d8a1
2023-03-14 04:15:36 -07:00
Bela Bohlender
c09405d58c Typescript: improve enum types and setMargin type (#1233)
Summary:
Currently, it is impossible to write `node.setPositionType(2)` instead of `node.setPositionType(POSITION_TYPE_ABSOLUTE)`. I understand that the idea is to force explicit usage of the enums. However, declaring `type POSITION_TYPE_ABSOLUTE = 2 & ['POSITION_TYPE']` artificially limits use cases, where, for example, the state should be serialized typesafe.

Additionally, this PR fixes the incorrect typing of `setMargin(edge: Edge, margin: number)` by extending the type to `margin: number | string`

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

Reviewed By: javache

Differential Revision: D43695520

Pulled By: NickGerleman

fbshipit-source-id: aac5f1de71817cc268fb003454ba29d31be10e0b
2023-03-01 07:40:03 -08:00
acton393
3f9f0f3ceb Add print yoga node AllEdge value when debug mode (#948)
Summary:
add print yoga node AllEdge value when debug mode, the old logic just print four edgeValue including top left bottom and right

but when we set the same value to these edge, we use YGAllEdge, this will be more convenient debug code

so I open this pull request to add it

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

Reviewed By: cortinico

Differential Revision: D43525328

Pulled By: NickGerleman

fbshipit-source-id: 59dde363e6ee8433d10ecf27e440ea7d54000bc1
2023-02-27 08:20:29 -08:00
Bela Bohlender
92e83193c4 Typescript: Fix typo in type defintions (#1231)
Summary:
Extracted the typo fix from https://github.com/facebook/yoga/pull/1228

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

Reviewed By: NickGerleman

Differential Revision: D43495158

Pulled By: cortinico

fbshipit-source-id: a455eb231169d53b8d4ced9a783b94d2ee46ca0c
2023-02-22 13:09:05 -08:00
Dmitry Ivakhnenko
13eacf8858 es6 compatable enums (#1229)
Summary:
I wanna repeat the constants export in `yoga-wasm-web`, to achieve

```js
import { ALIGN_CENTER } from "yoga-layout";
```

And I failed. it is impossible because `rollup` and other tools can't transform commonjs `module.exports = { WHATEVER: 1 }` into ECMAScript modules. however, they can work with separate exports like `exports.WHATEVER = 1` and this PR transforms yoga constants into this convertible format

This doesn't change anything for the yoga package, but it makes it possible to reexport constants without any modification and hacks, like this

```js
export * from "./javascript/src_js/generated/YGEnums.js";
```

[discussion in yoga-layout-wasm](https://github.com/shuding/yoga-wasm-web/pull/15)

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

Reviewed By: NickGerleman

Differential Revision: D43437177

Pulled By: rshest

fbshipit-source-id: bfe1404d1b48779f404e6510f2aafadd7fd4e774
2023-02-20 19:54:03 -08:00
Nick Gerleman
220d2582c9 Remove config null check
Summary:
This removes the null-check on Yoga config added (we think we root-caused the issue), and adds an assertion to the public API accepting a config that it is non-null.

There are more changes to config setting that will come later.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D43273456

fbshipit-source-id: cba498352d114a3fa2694f3a144f5f01a83d3190
2023-02-14 09:42:43 -08:00
Nick Gerleman
ed6223c0c0 Add config null-check as remediation
Summary:
See code comment. D42282358 (7e96b65790) added usage of `YGConfigIsExperimentalFeatureEnabled` during layout, in a place where we sometimes encounter a Yoga node from RN which has an unexpectedly null config.

This is a hack to stop the bleed while we add logging to figure out where the null config is coming from in RN.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D43203521

fbshipit-source-id: 2a21143a45c712ca00d16172f734fb116d165926
2023-02-10 17:51:46 -08:00
Dmitry Ivakhnenko
ba38a2c784 Flex basis auto is mysteriously missed again (#1225)
Summary:
- adds a test to check that `setFlexBasisAuto` is here

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

Reviewed By: javache

Differential Revision: D43150473

Pulled By: NickGerleman

fbshipit-source-id: b5b82fe4a5db069d3ed5672990c9b8ade9141296
2023-02-09 02:15:43 -08:00
Eric Rozell
996267dbcb Revert D13866122: Fix negative value rounding issue for nodes across an axis
Differential Revision:
D13866122 (4266409934)

Original commit changeset: 4faf8a9efc86

Original Phabricator Diff: D13866122 (4266409934)

fbshipit-source-id: c11919fdd585f09b0422e8db55a8a3d66027676f
2023-02-02 14:04:12 -08:00
Jonathan Maurice
4266409934 Fix negative value rounding issue for nodes across an axis (#688)
Summary:
This fix issue https://github.com/facebook/yoga/issues/683 the rounding calculation is incorrect if a node is crossing an axis and it will shrink it's width/height on layout calculation.

The following test reproduce the issue :

```
TEST(YogaTest, node_shrink_on_axis)
{
  const YGConfigRef config = YGConfigNew();
  const YGNodeRef root = YGNodeNewWithConfig(config);
  const YGNodeRef child = YGNodeNewWithConfig(config);

  YGNodeInsertChild(root, child, 0);

  YGNodeStyleSetWidth(child, 10);
  YGNodeStyleSetHeight(child, 10);
  YGNodeStyleSetPosition(root, YGEdgeLeft, -0.75f);
  YGNodeStyleSetPosition(root, YGEdgeTop, -0.75f);

  YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

  ASSERT_FLOAT_EQ(YGNodeLayoutGetWidth(child), 10);
  ASSERT_FLOAT_EQ(YGNodeLayoutGetHeight(child), 10);

  YGNodeFreeRecursive(root);

  YGConfigFree(config);
}
```

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

Reviewed By: NickGerleman

Differential Revision: D13866122

Pulled By: rozele

fbshipit-source-id: 4faf8a9efc86723c303f600d730660a2e13d8a73
2023-02-02 07:50:12 -08:00
Dmitry Ivakhnenko
483e399158 fix type for getFlexBasis (#1222)
Summary:
`getFlexBasis` returns `Value` not a `number`

source:
https://github.com/facebook/yoga/blob/main/javascript/src_native/Node.hh#L145

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

Reviewed By: rozele, cipolleschi

Differential Revision: D42818313

Pulled By: NickGerleman

fbshipit-source-id: cbcfe1b5d353ed86303a4de987e66f86b77ced1b
2023-01-30 13:57:23 -08:00
Dmitry Ivakhnenko
5496554cbf fix breaking change in setMeasureFunc after emscripten migration (#1219)
Summary:
current `MeasureFunc` is stricter than the previous one and when it returns only one dimension object yoga throw `TypeError: Missing field:  "height"` or `TypeError: Missing field:  "width"`

this is a breaking change and `react-pdf` use this feature a lot, so i wanna return the previous behavior back

codesandbox with reproduction on `yoga-layout-prebuilt`: https://codesandbox.io/s/yoga-layout-measure-callback-wrong-data-1l9133

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

Reviewed By: NickGerleman

Differential Revision: D42778696

Pulled By: jacdebug

fbshipit-source-id: 2fb87be74f456ee34273655f2c47f62360001895
2023-01-26 16:09:23 -08:00
Nick Gerleman
9e1bcd8557 Remove legacy layout diffing
Summary:
This removes some unused flags which will cause Yoga to layout every tree twice, then diffing the tree, reporting whether the whole tree is different. This is too expensive to run outside of local experimentation, but we have more nuanced ways to implement the `YGNodeLayoutAffectedByQuirk` I am wanting to add.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D42406917

fbshipit-source-id: b415ed02768f6b59de3a6fa90c60c750d56fd4b0
2023-01-19 06:38:45 -08:00
Nick Gerleman
cac197f5a6 Colorize GTest Output in GitHub Actions (#1218)
Summary:
GitHub actions supports terminal colors, but most programs won't output color to a non-interactive terminal. We can control this via env variable, so that GTest output in GitHub actions is colorized.

Before:
{F847577544}

After:
{F847577610}

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

Reviewed By: christophpurrer

Differential Revision: D42537630

Pulled By: NickGerleman

fbshipit-source-id: 28b22c061200026bf167c1a31d6a58445ba70214
2023-01-16 13:06:45 -08:00
Nick Gerleman
65c57d6a01 Replace "facebook.proguard.annotations" with "facebook.yoga.annotations" (#35841)
Summary:
X-link: https://github.com/facebook/react-native/pull/35841

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

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

The Yoga JNI bindings use Reflection, so we need to let ProGuard know not to strip certain annotated fields.

This is done internally using a single copy of `com.facebook.proguard.annotations` from fbandroid (sometimes), which is then repackaged externally, and published as its own whole Yoga specific package. We never actually inform the stock Gradle project of the rules for the annotations though, so apps must add these manually.

This simplifies the setup, where Yoga has its own self-contained annotations/rules. The rules are exposed for Gradle/Buck dependencies, but RN and Litho both consume Yoga via dirsync + custom Gradle logic, so we need to duplicate the proguard rules to them instead of them being propagated automatically.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D42406641

fbshipit-source-id: c2b12fd498f93f144e5651917ca878d2a5050e08
2023-01-16 11:25:59 -08:00
Nick Gerleman
83c6997f29 Add Global CMake Build and OSS Tests (#1217)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1217

This updates the CMake build present for being able to share options, fixing up flags, etc. A GTest build is added as well, along with a script and VSCode debug target so that OSS contributors can very easily run and debug tests on any OS.

Note that this isn't completely done (need to revise Windows, Mac, documentation), but should be finished enough otherwise for review.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D42406686

fbshipit-source-id: 95e7ba5e4751c496a171785490e85cf0097fa839
2023-01-16 07:56:11 -08:00
Nick Gerleman
53872e2521 Update Gradle Setup (#1215)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1215

This updates:
1. The Gradle Wrapper and Gradle Version
2. AGP Version
3. Android SDK and NDK Versions
4. Java Version (to support newer AGP)
5. Required CMake Version

Versions are loosely aligned to RN. CMake 3.18.1 is the latest provided by the NDK but the Android build itself creates warnings on CMake < 3.19, so we add the "+" to prefer something newer if available (but we set an old required version to CMake policy will keep compatible).

This also removes the "yogacore" project, which packages libyoga.so without the jni bindings. Afaik it was never published, and we don't rely on it ourselves.

Reviewed By: cortinico

Differential Revision: D42406551

fbshipit-source-id: 5e127dffde69352269ecbddadbc2bdd82f7d50fa
2023-01-16 04:16:07 -08:00
Nick Gerleman
53a8842abb Set C++ version consistently to C++ 14 (#1203)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1203

~~This sets the C++ standard to C++ 17 in the working builds and Apple. GTest will stop supporting C++ 11 soon, so we need to update. C++ 14 is more embeddable, but C++ 17 support and usage should be relatively common now and the language version adds quite a bit.~~

This bumps from C++ 11 to C++ 14 in existing places where it is specified. C++ 17 allows more, and is better aligned to infra (semantics can change in std versions in suprising ways), but C++ 14 still has broader ecosystem compatibility.

Changelog: [Internal]

Reviewed By: cortinico, dmytrorykun

Differential Revision: D42285391

fbshipit-source-id: 88d7b6b8783a80b9b2e48781a2fd3d326ecd87d0
2023-01-10 09:44:00 -08:00
Nick Gerleman
83cef5b12f Fixup UTs for MSVC and Release Mode
Summary: This fixes incompatibility with MSVC in /W3 (designated initializers, precision loss) along with guarding tests which will only pass in DEBUG builds

Reviewed By: cortinico

Differential Revision: D42406531

fbshipit-source-id: 2c0d59678f76decf9b9b4d91a7c9ec12136ca1b9
2023-01-09 13:59:19 -08:00
Nick Gerleman
9808358e08 Remove "YG_ENABLE_EVENTS" Preprocessor Definition
Summary:
This is always enabled internally, so we should just turn it on everywhere.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D42406509

fbshipit-source-id: c9cdd4fcf907d66cd276e0aec608a2e7db7ca5fb
2023-01-09 13:59:19 -08:00
Nick Gerleman
7e96b65790 Import "Fix percent absolute position and size calcuate different with web" behind experimental feature (#1028) (#1201)
Summary:
Fixes https://github.com/facebook/yoga/issues/850

https://github.com/facebook/yoga/issues/850 describes a conformance issue where positioning of an absolute child using percentages is not calculated against the correct box size.

This takes the fix for that in https://github.com/facebook/yoga/pull/1028, regenerates tests, and fixes tests so that the experimental feature can be enabled. Goal is to run this as an experiment internally to see if we can enable by default.

Changelog:
[Internal]

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

Reviewed By: yungsters

Differential Revision: D42282358

Pulled By: NickGerleman

fbshipit-source-id: 57c0dd9b0f1c47cb9335ff6e13d44b4646e5fa58
2023-01-08 13:41:27 -08:00
Nick Gerleman
627255c0e4 Enable ESLint for xplat/yoga/javascript
Summary: We enabled this in GitHub already, and this enables ESLint over the directory in Arcanist so changes made from internal will go through the same validation.

Reviewed By: yungsters

Differential Revision: D42321850

fbshipit-source-id: add4676f55977dbc1817a4e94cd4af6124509697
2023-01-03 20:00:05 -08:00
Nick Gerleman
c3291912b3 Make cmakeBuildTask accept opts instead of array (#1204)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1204

For expandability, consistency with other tasks, and added explicitness.

Reviewed By: huntie

Differential Revision: D42285129

fbshipit-source-id: 2b76a7dba7474bfae98509740c13c3e173fa9a27
2022-12-30 20:33:56 -08:00
Nick Gerleman
2359ccde78 Add "yarn clean" to JS bindings
Summary: The build is contained to `build` and `dist` folders we can just wipe.

Reviewed By: huntie

Differential Revision: D42285227

fbshipit-source-id: 18fa4a3e801415169e5b5b8cf212640199e627ba
2022-12-30 14:29:42 -08:00
Nick Gerleman
9fe1e77274 Use more specific enums types where previously using number (#1198)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1198

The Yoga JS bindings converted a previous Flow type directly to TypeScript. The enum types we expose are safer than accepting raw ordinal numbers, and we should replace the places in the typings where an ordinal was accepted instead of the specific type.

Reviewed By: cipolleschi

Differential Revision: D42265824

fbshipit-source-id: 6adcf24a612e79037fdceab0e9f6e4db09fe3ab2
2022-12-30 14:21:08 -08:00
Facebook Community Bot
cfc3696013 Re-sync with internal repository (#1202)
Co-authored-by: Facebook Community Bot <6422482+facebook-github-bot@users.noreply.github.com>
Co-authored-by: Nick Gerleman <ngerlem@meta.com>
2022-12-29 13:25:12 -08:00
Nick Gerleman
b0b255072c Fix typo "encmake" in emcmakeGenerateTask() (#1200)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1200

The task definitions in the (OSS-specific) build for Yoga's JS bindings expose `emcmakeGenerateTask()` to run Emscripten's `emcmake` wrapper over `cmake`'s project generator. This fixes a typo in its log output, where it will output "e*n*cmake" instead of "e*m*cmake".

Reviewed By: christophpurrer

Differential Revision: D42279467

fbshipit-source-id: e603bf381ef81e36da321bb73e6af9de6f85931d
2022-12-29 13:21:54 -08:00
Nick Gerleman
b842a9e1d9 Remove some easy yoga/libs
Summary:
This removes some of the libs in the libs folder that were only being used by the OSS Buck build (no longer supported), or the Buck build for samples (which we also no longer project, and ideally would convert to Gradle).

The OSS build doesn't use the remaining bits inside of libs, but D22037411 and D21429174 (ede65bbce4) added logic to co-opt them when building the Java version of Yoga outside of fbandroid. These should probably be moved to instead use `//third-party/java` or `//fbcode/third-party-java` (and something for SoLoader which isn't third party but lives in fbandroid). But that will take more effort to figure out the right steps.

Reviewed By: rshest

Differential Revision: D42248199

fbshipit-source-id: 29a886db14bd5ed9e20f67266be5ea5ac458ce4e
2022-12-29 10:27:00 -08:00
Nick Gerleman
98e25ea1ee Remove a couple config files from the JS bindings (#1197)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1197

Removes a couple config files from the last version of the JS bindings I accidentally left in https://github.com/facebook/yoga/pull/1177.
We can remove:
1. The .flowconfig because there isn't any more Flow
2. The .npmignore, because we use the package.json "files" field

Reviewed By: rshest

Differential Revision: D42265713

fbshipit-source-id: 9911416d36136d89cf7360180901673181238abe
2022-12-28 17:06:19 -08:00
Nick Gerleman
045e6bc16d Remove .hgignore
Summary: .hgignore doesn't do anything inside of Meta anymore. The JS bindings change removed a copy, and this removes the other copy.

Reviewed By: christophpurrer

Differential Revision: D42265530

fbshipit-source-id: 926d837f5245bed881ceb4e62f1b37893e4d0906
2022-12-28 17:03:37 -08:00
Nick Gerleman
fb4917c03c Move SingleWriterValueList to fbandroid (#1196)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1196

This is projected to the Yoga OSS repo as its own top-level directory, and its own static library, but we only ever use this in one specific place in fbandroid. Move this code there and to the same library.

Reviewed By: rshest

Differential Revision: D42240879

fbshipit-source-id: 97687310339fa05016d98b7c11574ea3e1c2b9a3
2022-12-28 01:43:58 -08:00
Nick Gerleman
287c48f7e3 Remove yoga/internal/experiments (#1195)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1195

These files are remnants of experimentation functions from D16687367 (dcfdb955b3). They do not seem to be included anywhere anymore, and we already have a YGExperimentalFeature setter in config we can use in the more common case.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D42241980

fbshipit-source-id: 482984b9a619dba8042e9166aee02a5e75e761ee
2022-12-28 01:29:36 -08:00
Dmitry Ivakhnenko
1813748eaa Revive JavaScript Bindings (#1177)
Summary:
Yoga's JavaScript bindings do not work past Node 10, or on recent versions of Ubuntu even using it. This is due to a reliance on `nbind`, a library which is no longer maintained. `nbind` itself abstracts over `embind` running Emscripten to generate an asm.js build, along with building Node native modules. In the meantime, [yoga-layout-prebuilt](https://www.npmjs.com/package/yoga-layout-prebuilt) has been used by the community instead of the official package.

https://github.com/facebook/yoga/pull/1177 was contributed as a conversion of bindings created using `nbind` to instead use `embind` directly.

I continued building on this to add more:
1. WebAssembly support (required to be async in browsers)
2. CMake + Ninja Build for the 4 flavors
3. TypeScript typings (partially generated)
4. yarn scripts to build (working on macOS, Ubuntu, Windows)
5. A README with some usage and contribution instructions
6. Updated tests to work with Jest, and updated general infra
7. ESLint and clang-format scripts
8. More GitHub actions (and now testing Windows)
9. Probably more I kinda got carried away here lol

The plan is to eventually publish this to NPM, but there is a little bit of work after this before that happens.

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

Test Plan: The bindings pass Jest tests (both manual and generated). GitHub actions added for the different yarn scripts. Did some manual checks on using the library as TS.

Reviewed By: christophpurrer

Differential Revision: D42207782

Pulled By: NickGerleman

fbshipit-source-id: 1dc5ce440f1c2b9705a005bbdcc86f952785d94e
2022-12-28 01:27:12 -08:00
Nick Gerleman
8035456330 Remove fbjni remnants
Summary: D42207782 moved Yoga to use vanilla JNI instead of fbjni, but there are some remnants left. One is a source copy being used to build lib/fb. The others are some targets/definitions left in Buck logic. This removes those, to prevent confusion.

Reviewed By: christophpurrer

Differential Revision: D42247773

fbshipit-source-id: ef9d831957948a183c39aac782ce869011e74fea
2022-12-28 01:21:52 -08:00
Nick Gerleman
08eaae7223 Reorgnaize C++ tests
Summary:
This does some preprataion for the Yoga CMake Build. The main change is removing the dedicated testutil top-level-directory and static library. This contains a method to count nodes using the event functions exposed to C++, along with a Java binding for the test utility (since the events don't have a Java binding). It is only used in a single place in a way that isn't very useful, so it simplifies things to treat is as source in the existing C++ test library.

This also separates the hand-written and generated UTs, like we are doing in the JS directory in D42207782.

Reviewed By: christophpurrer

Differential Revision: D42247762

fbshipit-source-id: f8a270e99d0315ba7fc608f2471333e7a7be9d79
2022-12-28 01:21:52 -08:00
Nick Gerleman
894142d589 Do not treat "yoga-playground" as package (#1192)
Summary:
"yoga-playground" contains the code for the playground used on the Yoga website. It lives inside the "website" package, but also has its own separate package.json and lockfile.

The package wasn't ever published, and does not share a workspace with the website or other JS packages. We can remove the package.json and related files to remove the lockfile, build steps, etc, while letting it still be used by the website (the only thing using the playground right now).

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

Test Plan: GitHub Actions will test that the website build still succeeds.

Reviewed By: christophpurrer

Differential Revision: D42240825

Pulled By: NickGerleman

fbshipit-source-id: fe0de2a25536d4e6b5a8531d0c0a2a51215fa38f
2022-12-26 14:57:03 -08:00
dependabot[bot]
2f9959da26 Bump nokogiri from 1.13.9 to 1.13.10 in /gentest (#1187)
Summary:
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.13.10.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/sparklemotion/nokogiri/releases">nokogiri's releases</a>.</em></p>
<blockquote>
<h2>1.13.10 / 2022-12-07</h2>
<h3>Security</h3>
<ul>
<li>[CRuby] Address CVE-2022-23476, unchecked return value from <code>xmlTextReaderExpand</code>. See <a href="https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-qv4q-mr5r-qprj">GHSA-qv4q-mr5r-qprj</a> for more information.</li>
</ul>
<h3>Improvements</h3>
<ul>
<li>[CRuby] <code>XML::Reader#attribute_hash</code> now returns <code>nil</code> on parse errors. This restores the behavior of <code>#attributes</code> from v1.13.7 and earlier. [<a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2715">#2715</a>]</li>
</ul>
<hr />
<p>sha256 checksums:</p>
<pre><code>777ce2e80f64772e91459b943e531dfef387e768f2255f9bc7a1655f254bbaa1  nokogiri-1.13.10-aarch64-linux.gem
b432ff47c51386e07f7e275374fe031c1349e37eaef2216759063bc5fa5624aa  nokogiri-1.13.10-arm64-darwin.gem
73ac581ddcb680a912e92da928ffdbac7b36afd3368418f2cee861b96e8c830b  nokogiri-1.13.10-java.gem
916aa17e624611dddbf2976ecce1b4a80633c6378f8465cff0efab022ebc2900  nokogiri-1.13.10-x64-mingw-ucrt.gem
0f85a1ad8c2b02c166a6637237133505b71a05f1bb41b91447005449769bced0  nokogiri-1.13.10-x64-mingw32.gem
91fa3a8724a1ce20fccbd718dafd9acbde099258183ac486992a61b00bb17020  nokogiri-1.13.10-x86-linux.gem
d6663f5900ccd8f72d43660d7f082565b7ffcaade0b9a59a74b3ef8791034168  nokogiri-1.13.10-x86-mingw32.gem
81755fc4b8130ef9678c76a2e5af3db7a0a6664b3cba7d9fe8ef75e7d979e91b  nokogiri-1.13.10-x86_64-darwin.gem
51d5246705dedad0a09b374d09cc193e7383a5dd32136a690a3cd56e95adf0a3  nokogiri-1.13.10-x86_64-linux.gem
d3ee00f26c151763da1691c7fc6871ddd03e532f74f85101f5acedc2d099e958  nokogiri-1.13.10.gem
</code></pre>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md">nokogiri's changelog</a>.</em></p>
<blockquote>
<h2>1.13.10 / 2022-12-07</h2>
<h3>Security</h3>
<ul>
<li>[CRuby] Address CVE-2022-23476, unchecked return value from <code>xmlTextReaderExpand</code>. See <a href="https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-qv4q-mr5r-qprj">GHSA-qv4q-mr5r-qprj</a> for more information.</li>
</ul>
<h3>Improvements</h3>
<ul>
<li>[CRuby] <code>XML::Reader#attribute_hash</code> now returns <code>nil</code> on parse errors. This restores the behavior of <code>#attributes</code> from v1.13.7 and earlier. [<a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2715">#2715</a>]</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="4c80121dc3"><code>4c80121</code></a> version bump to v1.13.10</li>
<li><a href="85410e3841"><code>85410e3</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2715">#2715</a> from sparklemotion/flavorjones-fix-reader-error-hand...</li>
<li><a href="9fe0761c47"><code>9fe0761</code></a> fix(cruby): XML::Reader#attribute_hash returns nil on error</li>
<li><a href="3b9c736bee"><code>3b9c736</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2717">#2717</a> from sparklemotion/flavorjones-lock-psych-to-fix-bui...</li>
<li><a href="2efa87b49a"><code>2efa87b</code></a> test: skip large cdata test on system libxml2</li>
<li><a href="3187d6739c"><code>3187d67</code></a> dep(dev): pin psych to v4 until v5 builds in CI</li>
<li><a href="a16b4bf14c"><code>a16b4bf</code></a> style(rubocop): disable Minitest/EmptyLineBeforeAssertionMethods</li>
<li>See full diff in <a href="https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.13.10">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=nokogiri&package-manager=bundler&previous-version=1.13.9&new-version=1.13.10)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: mdvacca

Differential Revision: D42114059

Pulled By: NickGerleman

fbshipit-source-id: 0c12b66ba4283d8dc39547edd97e26765e7e912b
2022-12-16 16:46:52 -08:00
Nishan
ba27f9d1ec fix: remove gap if its last element in line (fix flex gap extra spacing when children determine parents main axis size) (#1188)
Summary:
Fixes - https://github.com/facebook/react-native/issues/35553

## Approach
We're using `betweenMainDim` to add [gap between](bbeede82d3/yoga/Yoga.cpp (L2495)) items in main axis. This is resulting in increased [main axis](bbeede82d3/yoga/Yoga.cpp (L2598)) dimension of the container as it gets added even for the last element. One solution is to keep using it and subtract the gap when last element is reached.

## Aside
Mutating this value feels weird, but I think `betweenMainDim` gets initialized for every line so should be fine? I did some manual tests to verify. I tried running tests but I'll have to downgrade the java version. Let me know if anything fails. Thanks! 🙏

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

Test Plan: Added fixtures which previously failed but now pass.

Reviewed By: necolas

Differential Revision: D42078162

Pulled By: NickGerleman

fbshipit-source-id: 0e535618350422e001141a8786a83fc81651afe9
2022-12-15 16:30:37 -08:00
Nick Gerleman
35f3335efc Fix yg_positionType ordinals (#1183)
Summary:
Fixes https://github.com/facebook/yoga/issues/1179

fc88b2f774 shifted ordinals for the position enum, but only updated a limited set of code for the new values. Binding generation has since been fixed, but https://github.com/facebook/yoga/issues/1179 seems to be another case where the ordinal offsetting means that `yg_positionType` of a `YogaLayout` view does not work correctly.

Update the ordinals in accordance with the ordering in YogaPositionType which the integer value is converted to.

Using "static" (the new position type) directly gives a compilation error due to it being a reserved keyword, so I added it as "position_static" along with aliases to other properties with the same naming scheme for consistency.

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

Reviewed By: lunaleaps

Differential Revision: D41741955

Pulled By: NickGerleman

fbshipit-source-id: 2b035eb38d9efea19af652e5f05c02b0be402d54
2022-12-06 08:39:20 -08:00
Nick Gerleman
811b46ae63 Refine workflow push trigger (#1182)
Summary:
We run validation workflows on push, but we do this for every branch, so dependabot PRs run every validation twice. We only really want push validation for the main branch.

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

Test Plan: PRs still run

Reviewed By: cortinico

Differential Revision: D41741459

Pulled By: NickGerleman

fbshipit-source-id: 51abe2cc0c8c5b9c3fc8c8a20a585c9d5e868a5e
2022-12-06 07:51:12 -08:00
Nick Gerleman
5498d3ad61 Pin website workflows to ubuntu-20.04 (#1181)
Summary:
The website build started failing with what looks like an incompatibility between nbind and a new libc++ version. GithHub is rolling out a new Ubuntu image, which is the likely culprit.

Pin to an older version of Ubuntu since nbind will never be updated, and we haven't replaced it yet.

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

Test Plan: Website build works again in GitHub workflows

Reviewed By: cortinico

Differential Revision: D41741067

Pulled By: NickGerleman

fbshipit-source-id: 1171e3d7461568d1c76afab0c5a12899e3d5958e
2022-12-06 01:39:05 -08:00
Ian Petersen
707115ee7e Fix Yoga's conditional use of std::bit_cast<>()
Summary:
Yoga tries to use `std::bit_cast<>()` where it's available and falls back to
`std::memcpy()` everywhere else.  Unfortunately, the feature-test macro
(`__cpp_lib_bit_cast`) is only defined if the feature is available *and you have
already included either `<version>` or `<bit>`* (or something else that includes
one of those).  Since `CompactValue.h` checks `__cpp_lib_bit_cast` *first*, it's
not defined even if it *would be*  defined, leading the header not to
`#include <bit>`, leaving `std::bit_cast<>()` undefined; later, other headers
from the STL are included, leading to `__cpp_lib_bit_cast` *becoming* defined
and causing later code to choose to use the undefind `std::bit_cast<>()`.

This diff fixes the problem by `#include`ing either `<version>` or `<ciso646>`
(depending on availability) before checking any feature-test macros.

Changelog: [Internal]

Reviewed By: smeenai

Differential Revision: D41641205

fbshipit-source-id: 7d7bc5791c902a45302d3707e6cbf21fc0493f0c
2022-12-01 02:30:57 -08:00
dependabot[bot]
49af711502 Bump engine.io from 3.6.0 to 3.6.1 in /website (#1178)
Summary:
Bumps [engine.io](https://github.com/socketio/engine.io) from 3.6.0 to 3.6.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/socketio/engine.io/releases">engine.io's releases</a>.</em></p>
<blockquote>
<h2>3.6.1</h2>
<p>⚠️ This release contains an important security fix ⚠️</p>
<p>A malicious client could send a specially crafted HTTP request, triggering an uncaught exception and killing the Node.js process:</p>
<pre><code>Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
</code></pre>
<p>Please upgrade as soon as possible.</p>
<h3>Bug Fixes</h3>
<ul>
<li>catch errors when destroying invalid upgrades (<a href="83c4071af8">83c4071</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/socketio/engine.io/blob/main/CHANGELOG.md">engine.io's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/socketio/engine.io/compare/3.6.0...3.6.1">3.6.1</a> (2022-11-20)</h2>
<p>⚠️ This release contains an important security fix ⚠️</p>
<p>A malicious client could send a specially crafted HTTP request, triggering an uncaught exception and killing the Node.js process:</p>
<pre><code>Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
</code></pre>
<p>Please upgrade as soon as possible.</p>
<h3>Bug Fixes</h3>
<ul>
<li>catch errors when destroying invalid upgrades (<a href="83c4071af8">83c4071</a>)</li>
</ul>
<h2><a href="https://github.com/socketio/engine.io/compare/6.2.0...6.2.1">6.2.1</a> (2022-11-20)</h2>
<p>⚠️ This release contains an important security fix ⚠️</p>
<p>A malicious client could send a specially crafted HTTP request, triggering an uncaught exception and killing the Node.js process:</p>
<pre><code>Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
</code></pre>
<p>Please upgrade as soon as possible.</p>
<h3>Bug Fixes</h3>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="67a3a87859"><code>67a3a87</code></a> chore(release): 3.6.1</li>
<li><a href="83c4071af8"><code>83c4071</code></a> fix: catch errors when destroying invalid upgrades</li>
<li>See full diff in <a href="https://github.com/socketio/engine.io/compare/3.6.0...3.6.1">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=engine.io&package-manager=npm_and_yarn&previous-version=3.6.0&new-version=3.6.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: javache

Differential Revision: D41553525

Pulled By: NickGerleman

fbshipit-source-id: 78f520c4e102eebcf505f59f6beced5216e25ef1
2022-11-29 08:11:17 -08:00
Nick Gerleman
a1f4d2b8ed Add explicit defaulted copy ctor to Values (#1176)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1176

`Values` is a wrapper to story an array of YGValue's as CompactValues.

From https://github.com/facebook/yoga/issues/1174 we see a warning `Wdeprecated-copy` beacuse a user-defined copy constructor is not present, but a user-defined asignment operator is (the defaulted one). This adds an explicitly defaulted copy contructor which should silence the warning I think.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D41447490

fbshipit-source-id: 8cc8f291cf12014d87cc71c4598bb84fdd6cd930
2022-11-21 16:33:36 -08:00
dependabot[bot]
3614c8d82b Bump loader-utils from 1.4.1 to 1.4.2 in /website/src/components/Playground (#1175)
Summary:
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.1 to 1.4.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/webpack/loader-utils/releases">loader-utils's releases</a>.</em></p>
<blockquote>
<h2>v1.4.2</h2>
<h3><a href="https://github.com/webpack/loader-utils/compare/v1.4.1...v1.4.2">1.4.2</a> (2022-11-11)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>ReDoS problem (<a href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/226">https://github.com/facebook/yoga/issues/226</a>) (<a href="17cbf8fa89">17cbf8f</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/webpack/loader-utils/blob/v1.4.2/CHANGELOG.md">loader-utils's changelog</a>.</em></p>
<blockquote>
<h3><a href="https://github.com/webpack/loader-utils/compare/v1.4.1...v1.4.2">1.4.2</a> (2022-11-11)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>ReDoS problem (<a href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/226">https://github.com/facebook/yoga/issues/226</a>) (<a href="17cbf8fa89">17cbf8f</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="331ad5067d"><code>331ad50</code></a> chore(release): 1.4.2</li>
<li><a href="17cbf8fa89"><code>17cbf8f</code></a> fix: ReDoS problem (<a href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/226">https://github.com/facebook/yoga/issues/226</a>)</li>
<li>See full diff in <a href="https://github.com/webpack/loader-utils/compare/v1.4.1...v1.4.2">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=loader-utils&package-manager=npm_and_yarn&previous-version=1.4.1&new-version=1.4.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: NickGerleman

Differential Revision: D41394939

Pulled By: ryancat

fbshipit-source-id: 40034b0dc62431bccdc99611b8527422b74f15a3
2022-11-18 16:52:44 -08:00
Pieter De Baets
eea87c3abc Remove 'using namespace' from header files
Summary:
Fix linter warning when pulling in some code into AR

Changelog: [Internal]

Reviewed By: NickGerleman, mdvacca

Differential Revision: D41269423

fbshipit-source-id: 4305d6c362a51e62b19b4d3590fb0823073dff9a
2022-11-17 06:19:07 -08:00
Nick Gerleman
5a257aac85 Add tests for gap interaction with child margins
Summary:
Adds a couple test fixtures to validate the interaction of flex gap with children with margins. In both Yoga, and web browsers, these are additive vs collapsing.

Fixes a couple misspellings as well that weren't caught during review.

Changelog:
[Internal]

Reviewed By: lunaleaps

Differential Revision: D41343407

fbshipit-source-id: 427f94faf248901517feff24d334f17ccb85266b
2022-11-16 14:02:31 -08:00
Nick Gerleman
efefc1eb7f Use lowercase @generated in tests
Summary:
The presence of lowercase "generated" anywhere in a file means Phabricator and Meta's fork of VSCode will treat the file as generated. Change generated tests to use the exact string.

Changelog:
[Internal]

Reviewed By: yungsters

Differential Revision: D41312171

fbshipit-source-id: 2bc8ef450d8377ffbacf443043d115a418db4a2e
2022-11-15 19:51:48 -08:00
Nick Gerleman
8166c81135 Incorporate gap space into main axis overflow flag (#1173)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1173

In https://github.com/facebook/react-native/issues/35351 we see incorrect child item height when the flex-wrap is enabled, the cross-axis is to be stretched, and main-axis overflow is caused by gap.

In YGDistributeFreeSpaceSecondPass, if we do not have overflow (determined by flexBasisOverflows), we have stretch cross-alignment, and we reason that nothing can add to main axis dimensions, we know we're a single line and want to take full cross dimensions. and can set YGMeasureModeExactly which uses parent dimensions. Guessing an optimization?

If we do have overflow, then we set YGMeasureModeAtMost to find minimum possible cross-axis dimensions instead.

`flexBasisOverflows` incorporates both computed flex basis, and margin, so it is more generally a flag for whether we will wrap. So we should incorporate gap spacing into it. E.g. it is also used for whether we should the match main axis parent dimension of the overall container. This change does just that, and renames the flag to `mainAxisOverflows`.

We will want to cherry-pick the fix for this into RN 0.71 since we have not yet introduced the community to the incorrect behavior, and we expect a lot of usage of flex-gap.

Changelog:
[General][Fixed] - Fix incorrect height when gap causes main axis to overflow and cross-axis is stretched

Reviewed By: yungsters

Differential Revision: D41311424

fbshipit-source-id: bd0c3b5aac478a56878703b6da84fc3993cc14da
2022-11-15 19:51:48 -08:00
dependabot[bot]
40db73d1a8 Bump loader-utils from 1.4.0 to 1.4.1 in /website/src/components/Playground (#1171)
Summary:
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/webpack/loader-utils/releases">loader-utils's releases</a>.</em></p>
<blockquote>
<h2>v1.4.1</h2>
<h3><a href="https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.1">1.4.1</a> (2022-11-07)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>security problem (<a href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/220">https://github.com/facebook/yoga/issues/220</a>) (<a href="4504e34c47">4504e34</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/webpack/loader-utils/blob/v1.4.1/CHANGELOG.md">loader-utils's changelog</a>.</em></p>
<blockquote>
<h3><a href="https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.1">1.4.1</a> (2022-11-07)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>security problem (<a href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/220">https://github.com/facebook/yoga/issues/220</a>) (<a href="4504e34c47">4504e34</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="8f082b39f6"><code>8f082b3</code></a> chore(release): 1.4.1</li>
<li><a href="4504e34c47"><code>4504e34</code></a> fix: security problem (<a href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/220">https://github.com/facebook/yoga/issues/220</a>)</li>
<li>See full diff in <a href="https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.1">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=loader-utils&package-manager=npm_and_yarn&previous-version=1.4.0&new-version=1.4.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: yungsters

Differential Revision: D41165985

Pulled By: lunaleaps

fbshipit-source-id: 2061b7a4e793dded18050842d1d42ec32c9d9c8a
2022-11-10 13:48:27 -08:00
dependabot[bot]
ab6f3e1c60 Bump socket.io-parser from 3.3.2 to 3.3.3 in /website (#1172)
Summary:
Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 3.3.2 to 3.3.3.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md">socket.io-parser's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/Automattic/socket.io-parser/compare/3.3.2...3.3.3">3.3.3</a> (2022-11-09)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>check the format of the index of each attachment (<a href="fb21e422fc">fb21e42</a>)</li>
</ul>
<h2><a href="https://github.com/socketio/socket.io-parser/compare/3.4.1...3.4.2">3.4.2</a> (2022-11-09)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>check the format of the index of each attachment (<a href="04d23cecaf">04d23ce</a>)</li>
</ul>
<h2><a href="https://github.com/socketio/socket.io-parser/compare/4.2.0...4.2.1">4.2.1</a> (2022-06-27)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>check the format of the index of each attachment (<a href="b5d0cb7dc5">b5d0cb7</a>)</li>
</ul>
<h2><a href="https://github.com/socketio/socket.io-parser/compare/4.0.4...4.0.5">4.0.5</a> (2022-06-27)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>check the format of the index of each attachment (<a href="b559f050ee">b559f05</a>)</li>
</ul>
<h1><a href="https://github.com/socketio/socket.io-parser/compare/4.1.2...4.2.0">4.2.0</a> (2022-04-17)</h1>
<h3>Features</h3>
<ul>
<li>allow the usage of custom replacer and reviver (<a href="https://github-redirect.dependabot.com/socketio/socket.io-parser/issues/112">https://github.com/facebook/yoga/issues/112</a>) (<a href="b08bc1a93e">b08bc1a</a>)</li>
</ul>
<h2><a href="https://github.com/socketio/socket.io-parser/compare/4.1.1...4.1.2">4.1.2</a> (2022-02-17)</h2>
<h3>Bug Fixes</h3>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="cd11e38e1a"><code>cd11e38</code></a> chore(release): 3.3.3</li>
<li><a href="fb21e422fc"><code>fb21e42</code></a> fix: check the format of the index of each attachment</li>
<li>See full diff in <a href="https://github.com/socketio/socket.io-parser/compare/3.3.2...3.3.3">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=socket.io-parser&package-manager=npm_and_yarn&previous-version=3.3.2&new-version=3.3.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: christophpurrer

Differential Revision: D41177051

Pulled By: NickGerleman

fbshipit-source-id: 66ee5defdd185cffe52c0cc077efb979937293bb
2022-11-10 01:58:31 -08:00
dependabot[bot]
5dd33acc91 Bump nokogiri from 1.13.8 to 1.13.9 in /gentest (#1170)
Summary:
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.8 to 1.13.9.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/sparklemotion/nokogiri/releases">nokogiri's releases</a>.</em></p>
<blockquote>
<h2>1.13.9 / 2022-10-18</h2>
<h3>Security</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to address <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-2309">CVE-2022-2309</a>, <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-40304">CVE-2022-40304</a>, and <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-40303">CVE-2022-40303</a>. See <a href="https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-2qc6-mcvw-92cw">GHSA-2qc6-mcvw-92cw</a> for more information.</li>
<li>[CRuby] Vendored zlib is updated to address <a href="https://ubuntu.com/security/CVE-2022-37434">CVE-2022-37434</a>. Nokogiri was not affected by this vulnerability, but this version of zlib was being flagged up by some vulnerability scanners, see <a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2626">#2626</a> for more information.</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to <a href="https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.10.3">v2.10.3</a> from v2.9.14.</li>
<li>[CRuby] Vendored libxslt is updated to <a href="https://gitlab.gnome.org/GNOME/libxslt/-/releases/v1.1.37">v1.1.37</a> from v1.1.35.</li>
<li>[CRuby] Vendored zlib is updated from 1.2.12 to 1.2.13. (See <a href="https://github.com/sparklemotion/nokogiri/blob/v1.13.x/LICENSE-DEPENDENCIES.md#platform-releases">LICENSE-DEPENDENCIES.md</a> for details on which packages redistribute this library.)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>[CRuby] <code>Nokogiri::XML::Namespace</code> objects, when compacted, update their internal struct's reference to the Ruby object wrapper. Previously, with GC compaction enabled, a segmentation fault was possible after compaction was triggered. [<a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2658">#2658</a>] (Thanks, <a href="https://github.com/eightbitraptor"><code>@​eightbitraptor</code></a> and <a href="https://github.com/peterzhu2118"><code>@​peterzhu2118</code></a>!)</li>
<li>[CRuby] <code>Document#remove_namespaces!</code> now defers freeing the underlying <code>xmlNs</code> struct until the <code>Document</code> is GCed. Previously, maintaining a reference to a <code>Namespace</code> object that was removed in this way could lead to a segfault. [<a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2658">#2658</a>]</li>
</ul>
<hr />
<p>sha256 checksums:</p>
<pre><code>9b69829561d30c4461ea803baeaf3460e8b145cff7a26ce397119577a4083a02  nokogiri-1.13.9-aarch64-linux.gem
e76ebb4b7b2e02c72b2d1541289f8b0679fb5984867cf199d89b8ef485764956  nokogiri-1.13.9-arm64-darwin.gem
15bae7d08bddeaa898d8e3f558723300137c26a2dc2632a1f89c8574c4467165  nokogiri-1.13.9-java.gem
f6a1dbc7229184357f3129503530af73cc59ceba4932c700a458a561edbe04b9  nokogiri-1.13.9-x64-mingw-ucrt.gem
36d935d799baa4dc488024f71881ff0bc8b172cecdfc54781169c40ec02cbdb3  nokogiri-1.13.9-x64-mingw32.gem
ebaf82aa9a11b8fafb67873d19ee48efb565040f04c898cdce8ca0cd53ff1a12  nokogiri-1.13.9-x86-linux.gem
11789a2a11b28bc028ee111f23311461104d8c4468d5b901ab7536b282504154  nokogiri-1.13.9-x86-mingw32.gem
01830e1646803ff91c0fe94bc768ff40082c6de8cfa563dafd01b3f7d5f9d795  nokogiri-1.13.9-x86_64-darwin.gem
8e93b8adec22958013799c8690d81c2cdf8a90b6f6e8150ab22e11895844d781  nokogiri-1.13.9-x86_64-linux.gem
96f37c1baf0234d3ae54c2c89aef7220d4a8a1b03d2675ff7723565b0a095531  nokogiri-1.13.9.gem
</code></pre>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md">nokogiri's changelog</a>.</em></p>
<blockquote>
<h2>1.13.9 / 2022-10-18</h2>
<h3>Security</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to address <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-2309">CVE-2022-2309</a>, <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-40304">CVE-2022-40304</a>, and <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-40303">CVE-2022-40303</a>. See <a href="https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-2qc6-mcvw-92cw">GHSA-2qc6-mcvw-92cw</a> for more information.</li>
<li>[CRuby] Vendored zlib is updated to address <a href="https://ubuntu.com/security/CVE-2022-37434">CVE-2022-37434</a>. Nokogiri was not affected by this vulnerability, but this version of zlib was being flagged up by some vulnerability scanners, see <a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2626">#2626</a> for more information.</li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>[CRuby] Vendored libxml2 is updated to <a href="https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.10.3">v2.10.3</a> from v2.9.14.</li>
<li>[CRuby] Vendored libxslt is updated to <a href="https://gitlab.gnome.org/GNOME/libxslt/-/releases/v1.1.37">v1.1.37</a> from v1.1.35.</li>
<li>[CRuby] Vendored zlib is updated from 1.2.12 to 1.2.13. (See <a href="https://github.com/sparklemotion/nokogiri/blob/v1.13.x/LICENSE-DEPENDENCIES.md#platform-releases">LICENSE-DEPENDENCIES.md</a> for details on which packages redistribute this library.)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>[CRuby] <code>Nokogiri::XML::Namespace</code> objects, when compacted, update their internal struct's reference to the Ruby object wrapper. Previously, with GC compaction enabled, a segmentation fault was possible after compaction was triggered. [<a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2658">#2658</a>] (Thanks, <a href="https://github.com/eightbitraptor"><code>@​eightbitraptor</code></a> and <a href="https://github.com/peterzhu2118"><code>@​peterzhu2118</code></a>!)</li>
<li>[CRuby] <code>Document#remove_namespaces!</code> now defers freeing the underlying <code>xmlNs</code> struct until the <code>Document</code> is GCed. Previously, maintaining a reference to a <code>Namespace</code> object that was removed in this way could lead to a segfault. [<a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2658">#2658</a>]</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="897759cc25"><code>897759c</code></a> version bump to v1.13.9</li>
<li><a href="aeb1ac3283"><code>aeb1ac3</code></a> doc: update CHANGELOG</li>
<li><a href="c663e4905a"><code>c663e49</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2671">#2671</a> from sparklemotion/flavorjones-update-zlib-1.2.13_v1...</li>
<li><a href="212e07da28"><code>212e07d</code></a> ext: hack to cross-compile zlib v1.2.13 on darwin</li>
<li><a href="76dbc8c5be"><code>76dbc8c</code></a> dep: update zlib to v1.2.13</li>
<li><a href="24e3a9c414"><code>24e3a9c</code></a> doc: update CHANGELOG</li>
<li><a href="4db3b4daa9"><code>4db3b4d</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/sparklemotion/nokogiri/issues/2668">#2668</a> from sparklemotion/flavorjones-namespace-scopes-comp...</li>
<li><a href="73d73d6e43"><code>73d73d6</code></a> fix: Document#remove_namespaces! use-after-free bug</li>
<li><a href="5f58b34724"><code>5f58b34</code></a> fix: namespace nodes behave properly when compacted</li>
<li><a href="b08a8586c7"><code>b08a858</code></a> test: repro namespace_scopes compaction issue</li>
<li>Additional commits viewable in <a href="https://github.com/sparklemotion/nokogiri/compare/v1.13.8...v1.13.9">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=nokogiri&package-manager=bundler&previous-version=1.13.8&new-version=1.13.9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/yoga/network/alerts).

</details>

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

Reviewed By: cortinico

Differential Revision: D40581091

Pulled By: NickGerleman

fbshipit-source-id: 497668390996d0a1a4d39337e74cc01e8970118f
2022-10-21 14:56:45 -07:00
tangruiwen.mmh1103
e6a79d5c73 Add cmake install configurations (#1129)
Summary:
Add some cmake configurations to support cmake install command.

So other cmake based project can depends on yoga by using cmake `find_package` function as follow:

```
find_package(yoga CONFIG REQUIRED)
target_link_libraries(main PRIVATE yoga::yogacore)
```

Resolves https://github.com/facebook/yoga/issues/1057

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

Reviewed By: cortinico

Differential Revision: D40581194

Pulled By: NickGerleman

fbshipit-source-id: 1f67991b31713561cad766d695dae11c6fc78bbf
2022-10-21 14:46:07 -07:00
Nick Gerleman
e9184c793e Start Adding GitHub Actions (#1165)
Summary:
This change starts adding more coverage to GitHub Actions. Existing workflows are split up to be per-platform, and stale scripts, etc are removed.

We are currently limited a bit by issues with the build itself, but this still adds a good bit of coverage that readily works, and adds places to inject more.

Another option would have been to move these to CircleCI where we have more credits, or used docker images instead of manual setup steps. etc, The Yoga build and number of changes is very light though, so we don't really need the complexity yet.

Some TODOs:
1. Fix the Apple Builds (pod lint and pod install return errors seen by the community)
2. Add working Android UTs
3. Add C++ UTs
4. Add Apple Publish
5. Add version stamping

Changelog:
[Internal][Added] - Start Adding Yoga GitHub Actions

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

Reviewed By: cortinico

Differential Revision: D40386426

Pulled By: NickGerleman

fbshipit-source-id: c540dd25bfec6ac8c05e461c1236ef7fe6cb8598
2022-10-17 23:35:01 -07:00
Nick Gerleman
c2a0ccf0d4 Add tests for row-gap and column-gap
Summary:
This adds the fixtures from https://github.com/facebook/yoga/pull/1116 and generates tests.

This adds a good amount of coverage, but I plan to follow up with a diff adding a bit more, e.g. for interactions with flex direction of column when we should no-op, etc. I also discovered the current fixtures do not allow testing shorthand props like "gap" without changes.

This also updates the `webdrivers` gem to respond to a break with chromedriver on m1 macs from 4 days ago https://github.com/titusfortner/webdrivers/pull/239.

Reviewed By: yungsters

Differential Revision: D39922413

fbshipit-source-id: dfc7bda894be8dfcb24e25c19a4df0b09a72ce7e
2022-10-13 08:18:49 -07:00
Nick Gerleman
8e29e7c1e1 Teach test generator gap/row-gap/column-gap
Summary:
This adds mappings to the test generator to create the right language specific calls when an HTML fixture has gap properties.

Changelog:
[Internal][Added] - Teach yoga test generator gap/row-gap/column-gap

Reviewed By: javache

Differential Revision: D39922409

fbshipit-source-id: 5b905ed95ae64373d2c7d3bb1a03e94270bf209a
2022-10-13 08:18:49 -07:00
Nick Gerleman
f992e63ac5 Implement method bindings for gap/row-gap/column-gap
Summary:
This adds method bindings for `YGNodeStyleSetGap` and `YGNodeStyleGetGap`.

Changelog:
[Genral][Added] - Implement method bindings for yoga gap/row-gap/column-gap

Reviewed By: yungsters

Differential Revision: D39922411

fbshipit-source-id: 6cbb4d352203d2ec92df162c3f2f2efd02bd9568
2022-10-13 08:18:49 -07:00
Nick Gerleman
582533dbc6 Implement gap/row-gap/column-gap (within the C ABI)
Summary:
This extracts the core changes from https://github.com/facebook/yoga/pull/1116, to support gap/row-gap/column-gap, mostly identical, apart from the rename of gaps -> gutters.

The core functionality in this PR looks to be well tested from the fixtures added. I am not an expert in the internals of Yoga, but I am seeing everything that I would expect to. The space for the gap is accounted for in line-breaking, and the accumulated gaps limit the available line-length, before sizing flexible children, so items are sized correctly as to accommodate the gap. Then the gap is used for spacing during main axis and cross-axis justification.

Changelog:
[Genral][Added] - Implement gap/row-gap/column-gap (within the yoga C ABI)

Reviewed By: javache

Differential Revision: D39922410

fbshipit-source-id: 5850f22032169028bd8383b49dd240b335c11d3d
2022-10-13 08:18:49 -07:00
Dmitry Ivakhnenko
05dd228317 add setFlexBasisAuto (#1112)
Summary:
fix https://github.com/facebook/yoga/issues/766

is it possible to compile yoga and release the fix? Or javascript part of yoga is not maintained?

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

Reviewed By: yungsters

Differential Revision: D40026371

Pulled By: NickGerleman

fbshipit-source-id: c2f3b18e2d3951338ce37cd3a319249996dd8a2e
2022-10-13 00:35:44 -07:00
simonla
1daed063f3 Fix memory leak (#1167)
Summary:
<img width="1126" alt="image" src="https://user-images.githubusercontent.com/14934570/195335369-e3fccde7-ff6c-4437-a261-7bc7435143c2.png">

`root_child0` be removed by`YGNodeRemoveChild(root, root_child0);`
so `YGNodeFreeRecursive(root);` can not free `root_child0`

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

Reviewed By: NickGerleman, cipolleschi

Differential Revision: D40298891

Pulled By: motiz88

fbshipit-source-id: 251d3b3decfbd102372a7afeb2e95c907f96a980
2022-10-12 08:09:34 -07:00
Facebook Community Bot
260e60b4b1 Re-sync with internal repository (#1166)
Co-authored-by: Facebook Community Bot <6422482+facebook-github-bot@users.noreply.github.com>
2022-10-11 05:16:06 -07:00
Kinarobin
efdcfec88f Fix measure inner dimensions (#1114)
Summary:
`YGFloatIsUndefined(collectedFlexItemsValues.totalFlexGrowFactors) &&            collectedFlexItemsValues.totalFlexGrowFactors == 0`  is not reachable.

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

Reviewed By: NickGerleman

Differential Revision: D40203817

Pulled By: NickGerleman

fbshipit-source-id: 46a8c19dc0e097f4c28e7f48135f0382a557764a
2022-10-11 03:38:35 -07:00
Nick Gerleman
48cbf3802e Remove YogaDev Workspace
Summary:
D14600002 (74202aecff) added an XCode workspace for Yoga, but it hasn't been updated along with source changes, and is no longer functional.

For OSS build we should probably instead be relying on [YogaKitSample](https://github.com/facebook/yoga/tree/main/YogaKit/YogaKitSample), which is generated to consume Yoga via its podspec. This is also broken, but there are PRs open which fix this, and it refects real OSS usage of Yoga better.

Reviewed By: javache

Differential Revision: D40169978

fbshipit-source-id: 27c2b011721ba22f9453704c3ca857bf2459ba6a
2022-10-10 21:40:20 -07:00
Nick Gerleman
94885d41f1 Remove Generated NDK Artifacts
Summary: These files are generated by Android Gradle Plugin doing the CMake build. Remove the generated files and add to the .gitignore (this looks to also be used by hg).

Reviewed By: javache

Differential Revision: D40169828

fbshipit-source-id: e0b7d907474aab5fcdb1a2ab33d46fdee6feed45
2022-10-10 21:40:08 -07:00
Chaiwat Ekkaewnumchai
a1ce49534d Add New Plugin for Layout Preview
Summary:
cute-jumper suggested the layout preview move out of fbandroid4idea plugin because
1. Litho layout preview requires Yoga library and Yoga native library, which requires bundling. Bundling isn't supported by fbandroid4idea, and changing the plugin would be complicated.
2. We have more control in releasing our features for layout preview in a separate plugin as opposed to in fbandroid4idea.

As a result, this diff creates a new plugin for layout preview. Note that this diff creates only placeholder as moving the whole part might be too big for one diff

Reviewed By: cute-jumper

Differential Revision: D39974345

fbshipit-source-id: e3f579f700eafc9413562abed923da1ca3135fba
2022-10-06 05:01:08 -07:00
Nick Gerleman
c96564d23d Fix License Headers and Whitespace
Summary: This change applies all Arcanist recommended lint changes, which amounts to changing copyright headers and some cases of whitespace changes.

Reviewed By: yungsters

Differential Revision: D40060899

fbshipit-source-id: b62f9472e6ef58a3fc3d22eed661578a2635cb1f
2022-10-04 13:59:32 -07:00
Pearce Liang
276de5c122 Fix comment typo 'layed out' to 'laid out' (#1061)
Summary:
Just a simple typo fix.

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

Reviewed By: javache

Differential Revision: D40059940

Pulled By: javache

fbshipit-source-id: 052a4a8fe80ff49e059a3096500dbe5bddcb73db
2022-10-04 10:54:16 -07:00
Nick Gerleman
585df10ee8 strech -> stretch
Summary: This replicates https://github.com/facebook/yoga/pull/760, to fix a typo around align-items. It does not have an effect on the tests themselves, since align-items defaults to stretch, and the test generator omits CSS properties of a default value.

Reviewed By: yungsters

Differential Revision: D40060324

fbshipit-source-id: da0565f2ad17e3e4e0f541a1c7006cdeeb991ece
2022-10-04 08:51:51 -07:00
Jesse Katsumata
7a6f667bf1 docs: update url (#981)
Summary:
Updating url for react-native docs

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

Reviewed By: yungsters

Differential Revision: D40060061

Pulled By: yungsters

fbshipit-source-id: 7192b461cea007eb4c77789b92e911a62b21f0d3
2022-10-04 08:29:28 -07:00
licd
0a6a184fed YogaKit document does not exist any more (#873)
Summary:
document does not exist any more

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

Reviewed By: yungsters

Differential Revision: D40060142

Pulled By: yungsters

fbshipit-source-id: 51a5c2ba7d8b658fe30d2cdbb28aa6d544899caa
2022-10-04 08:14:04 -07:00
Joshua Yuan
68c038579c Fix broken absolute/relative link in Playground Editor (#1025)
Summary:
The correct link is https://yogalayout.com/docs/absolute-relative-layout
The current link leads to a broken page https://yogalayout.com/docs/absolute-position

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

Reviewed By: yungsters

Differential Revision: D23031145

Pulled By: yungsters

fbshipit-source-id: 7adaf4856d38546f2f75b47912edd7dcc23da294
2022-10-04 08:02:30 -07:00
Yannic Bonenberger
e1b401ca36 Re-add support for using Yoga without exceptions (#1006)
Summary:
This is a partial rollback of 07c0d539bd.

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

Reviewed By: yungsters

Differential Revision: D40032544

Pulled By: yungsters

fbshipit-source-id: 9ef9b80672eced86a98cfae66c81710bd3ee6f9b
2022-10-03 23:35:46 -07:00
Yurii Nakonechnyi
ec0a829110 Added suppression for warnings about unused parameters in 'publish<Type E>()' func (#1141)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1141

Reviewed By: yungsters

Differential Revision: D40025354

Pulled By: yungsters

fbshipit-source-id: 6eaaa77b71db95ab0dbc0a4f459c9d85f7e36c42
2022-10-03 22:04:06 -07:00
DaeWook, Kim
d16e918c52 Export YGInteropSetLogger method (#960)
Summary:
When building and using C # libraries,
EntryPointNotFoundException thrown from YGInteropSetLogger.

so, I added YOGA_EXPORT on YGInteropSetLogger.

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

Reviewed By: yungsters

Differential Revision: D40027238

Pulled By: yungsters

fbshipit-source-id: 6af584a16e66a31c91374a1bb64434888762e3c8
2022-10-03 21:26:05 -07:00
Jesse Katsumata
7f854ec13e Update README for android (#980)
Summary:
Install instruction and doc url seemed to be outdated.

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

Reviewed By: yungsters

Differential Revision: D40032063

Pulled By: yungsters

fbshipit-source-id: 540bf5fa87d343b3da9ccf8865ecc6ac646b77d7
2022-10-03 21:22:57 -07:00
Michael サイトー 中村 Bashurov
272eb940f1 Update standalone.md docs (#1110)
Summary:
Added set of row direction, otherwise it'll be column and numbers won't correspond to comments

https://codesandbox.io/s/yoga-standalone-docs-bug-izqwv?file=/src/index.js
![image](https://user-images.githubusercontent.com/1552189/142233513-8b21c77f-0a12-4c9d-9965-fe8c9e43c02f.png)

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

Reviewed By: yungsters

Differential Revision: D40026417

Pulled By: yungsters

fbshipit-source-id: 7e26406909268f85ee9b1ccf73aad50bab042ff9
2022-10-03 21:13:20 -07:00
Joe Gallegos
bc4c8f9fd9 Update React Native docs link (#1036)
Summary:
Updated link for new React Native docs site.

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

Reviewed By: yungsters

Differential Revision: D40026872

Pulled By: yungsters

fbshipit-source-id: e2d26b07b7b8785c0a2dee4543ec153fd69a8a3f
2022-10-03 21:11:52 -07:00
PhoebeHui
0faefad0c1 Add vcpkg installation instructions (#970)
Summary:
Yoga is available as a port in VCPKG , documenting the install process here will help users get started by providing a single set of commands to build yoga, ready to be included in their projects.

VCPKG is a C++ library manager that simplifies installation for yoga and other project dependencies, we also test whether our library ports build in various configurations (dynamic, static) on various platforms (OSX, Linux, Windows: x86, x64, UWP, ARM) to keep a wide coverage for users.

I'm a maintainer for vcpkg, and here is what the port script looks like. We try to keep the library maintained as close as possible to the original library.

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

Reviewed By: yungsters

Differential Revision: D40027569

Pulled By: yungsters

fbshipit-source-id: ca9a6aa481c7b46e96c5937fe3cc7b716e464e4d
2022-10-03 21:10:17 -07:00
迷渡
29c2151d8d fix missing dll exports (#1127)
Summary:
When I use libyogacore.so in other programming languages, it crash with message as

> Could not obtain symbol from the library: dlsym(0x20b84d220, YGConfigIsExperimentalFeatureEnabled): symbol not found

This function is defined as `WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled` in yoga.h, but is not defined using `YOGA_EXPORT` in yoga.cpp.

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

Reviewed By: yungsters

Differential Revision: D40024450

Pulled By: yungsters

fbshipit-source-id: f6f01eadccb13d593c68300059e96f4b0bbc9fb6
2022-10-03 21:09:58 -07:00
Erfan Zekri Esfahani
572f525734 Update flex.md (#1118)
Summary:
correct sections' order in order to match header in alphabetical order

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

Reviewed By: yungsters

Differential Revision: D40026297

Pulled By: yungsters

fbshipit-source-id: d28d41d69eb3a99fab9536cc79057c617cf0e2df
2022-10-03 18:48:30 -07:00
Nick Gerleman
80c89a48a1 Move GitHub Actions from Node 8 to Node 12 (#1164)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1164

Yoga CI in GitHub is currently running using Node 8, released in 2017. It has long been out of support, and is not able to install many of the packages in the updated lockfile due to version restrictions in the new packages.

Node 12 is able to install the current lockfile. Although it is old enough that security support has ended for it 5 months ago, `yoga-layout` currently fails to install on Node 12+, because a dependency, `nbind`, was reliant on V8 internals that have changed between versions, and has not published a version supporting anything later than Node 10.

There are unpublished commits in the official repo which add Node 12 support. So, we use that version when developing against the website, to jump us to something more up to date, without rewriting or removing all of the JS bindings quite yet.

Reviewed By: yungsters

Differential Revision: D40036466

fbshipit-source-id: e1b775d87854250bd74fa17ca7ba939b32aa3bd8
2022-10-03 18:17:23 -07:00
Fabio Arnold
7986ca97a3 Fix typo in documentation (#1117)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1117

Reviewed By: yungsters

Differential Revision: D40026308

Pulled By: yungsters

fbshipit-source-id: e289f6461046f87a74947aff8e0aca5dc1db7ffc
2022-10-03 16:43:44 -07:00
Nick Gerleman
4ca1bfeff6 Update playground lockfile
Summary: Yoga playground within the website has a separate package.json from the website. Update that as well, which is responsible for 4 open dependabot PRs.

Reviewed By: yungsters

Differential Revision: D40026579

fbshipit-source-id: 2b82bdf2e90b8f433824f37b5e83750c338c9dfc
2022-10-03 15:50:39 -07:00
Damoness
40c600434e Update flex-direction.md (#1007)
Summary:
Spelling mistake

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

Reviewed By: yungsters

Differential Revision: D40027434

Pulled By: yungsters

fbshipit-source-id: 8d13e54e9cb9633282dadadad545d1b92ae3ba5c
2022-10-03 14:42:06 -07:00
Nick Gerleman
29bb669adf Rebuild yarn lockfiles
Summary:
Yoga has 35 open dependabot PRs targeting these two packages. This change generates fresh lockfiles for each version, which should close most of them I think.

For each lockfile:
1. Delete lockfile
2. Run `yarn --ignore-scripts`

Full-fat rebuilds of lockfiles are normally bit dangerous compared to more targeted dependency upgrades, but rebuilding the lockfile felt like a better option because of the duration since last update, number of pending updates, and the low risk due to neither package being installable on Node 12+ at the moment.

allow-large-files

Reviewed By: mdvacca

Differential Revision: D39987360

fbshipit-source-id: 86febac73b90b6c9f1fe2345325b59d14463d28b
2022-10-03 08:03:09 -07:00
Nick Gerleman
206bf414ec Add YGGutter Enum
Summary:
This adds the YGGutter enum, used to choose between row/column gap variants (row-gap, column-gap, gap).

This used later in changes from https://github.com/facebook/yoga/pull/1116, in the APIs which deal with setting gap on style on yoga node.

Note the original PR called this `YGGap`, but this ending up leading to a couple public method signatures that could appear ambiguous:
1. `SetGap(YGGap gap, float gapLength)`: Enums like `YGAlign` are the vaues for an `align` prop. `YGGap` controls the variant of the gap (like `YGEdge` does for left/right/top/bottom variants). So the enum reads as if it is the `gapValue`, and it looks like we have two of the same parameter.
2. `SetGap(YGGap gapDirection, float gap)`: This is misleading, because the direction gaps flow is the cross-axis of flex-direction.
3. `GetGap(YGGap gap)`: `gap` is the variant, but looks like an out param.

The [CSS Box Alignment](https://www.w3.org/TR/css-align-3/#column-row-gap) spec refers to these gaps as "Gutters", which removes the ambiguity.

Changelog:
[General][Added] - Add YGGutter Enum

Reviewed By: yungsters

Differential Revision: D39922412

fbshipit-source-id: 4b0baf800fecb3d03560a4267c7fb4c4330fd39e
2022-09-29 22:25:24 -07:00
Nick Gerleman
5a18ccdbe2 Fixup Enum Generator
Summary:
https://github.com/facebook/yoga/pull/1116 adds a new enum. The enum generator is out of date with copyright header, and some codemods, but it also looks like there were manual changes, types added, etc since generation. I fixed up the script to incorporate generating the changes folks made manually, and also added an enum that was previously only added manually to the C ABI.

Changelog:
[General][Fixed] - Fixup Yoga Enum Generator

Reviewed By: yungsters

Differential Revision: D39922252

fbshipit-source-id: b678fa9a43a896873d8c434745bdaf3f16fd991f
2022-09-29 22:25:24 -07:00
Nick Gerleman
fd180de774 Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.

I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.

This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).

The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.

Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066

Reviewed By: rozele, Andrey-Mishanin

Differential Revision: D39907416

fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
Shiping Yi
7d37b2e84b Merge TestTranscoder and TestUploader Activity into TargetedTesting Activity
Summary: move testTranscoder and TestUploader functions to TargetedTesting so that they can run batch testing for those as well, add listener for upload media composition

Differential Revision: D39299097

fbshipit-source-id: ed40a876875fdc6a0d1db8f283082da8d8dc20f7
2022-09-23 17:27:50 -07:00
Evan Charlton
97c8bbde12 fix: Correctly resolve classes with FindClass(..) (#34533)
Summary:
`JNIEnv`'s `FindClass(..)` function takes the classes in the standard
`foo/bar/Baz` class specification (unless they're special, like arrays).
Specifying them with `Lfoo/bar/Baz;` results in a
`ClassNotFoundException` being raised -- which is especially unhelpful
when intending to re-throw an exception.

The docs for `JNIEnv#FindClass(..)` can be found [here][jnienv].

[jnienv]:
  https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#:~:text=The%20name%20argument,java/lang/String%22

## Changelog

[Android] [Fixed] - Correctly resolve classes with FindClass(..)

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

Reviewed By: amir-shalem

Differential Revision: D39133326

Pulled By: jacdebug

fbshipit-source-id: 86283b7d21aed49ed0e9027b2aef85f0108cdf9a
2022-08-30 18:49:10 -07:00
Harold Pratt
fbf7a6feb5 Rewrite CompactValue to avoid undefined behavior from the use of a union for type-punning (#1154)
Summary:
C++ does not, pedantically, allow the use of unions for type-punning in the way that C does. Most compilers, in practice, do support it; however, recent versions of MSVC appear to have a bug that cause bad code to be generated due to this U.B. (see: https://developercommunity.visualstudio.com/t/Bad-code-generated-for-std::isnan-compil/10082631). This led to a series of issues in the react-native-windows project, see:
* https://github.com/microsoft/react-native-windows/issues/4122
* https://github.com/microsoft/react-native-windows/issues/8675

In C++20, the `<bit>` header and `bit_cast` function provide a pleasant API for type-punning. Since C++20 is not universally available, if the feature-test macro for `bit_cast` is not defined, memcpy is used instead.

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

Reviewed By: Andrey-Mishanin

Differential Revision: D38082048

Pulled By: rozele

fbshipit-source-id: a5da08cfb7d4296c725fb44871c55dbb12dc71e5
2022-07-25 15:35:25 -07:00
Michael Sokolnicki
64f865a639 Remove MaskedViewIOS from react-native-github
Summary:
Remove MaskedViewIOS from react-native-github, update deprecation warnings, rebuild CocoaPods.

Changelog:
[General][Removed] - Remove MaskedViewIOS

Reviewed By: lunaleaps

Differential Revision: D37860775

fbshipit-source-id: 963b4b9891eecf5610cfad1e93ac8bf83f29f521
2022-07-22 17:07:26 -07:00
Sim Sun
c5a8f447b1 Bump SoLoader version to 0.10.4
Differential Revision: D37988585

fbshipit-source-id: 586bf12c76ac6d44c5d46d3e2b5551e46dbc2112
2022-07-20 15:18:18 -07:00
Ron Edelstein
a9a21d0aa6 Explicitly set language to JAVA where it is missing [xplat] (round 1)
Reviewed By: IanChilds

Differential Revision: D37594044

fbshipit-source-id: 0bbcaaed951a212651d3cc0fc3371751ced13852
2022-07-06 09:07:07 -07:00
Privacy Ownership Team
88c9b046ed Asset Ownership Update For asset://code.third_party_library/fbsource/xplat%2Fyoga%2Flib%2Fappcompat
Reviewed By: SidharthGuglani

Differential Revision: D37225485

fbshipit-source-id: 2c565d2e373ec50f69a7b8c83e56702b89ea4b68
2022-06-17 07:58:15 -07:00
Privacy Ownership Team
22eb898e8c Asset Ownership Update For asset://code.third_party_library/fbsource/xplat%2Fyoga%2Flib%2Fjunit
Reviewed By: SidharthGuglani

Differential Revision: D37141168

fbshipit-source-id: 02c2f3b58819cc8f174e5c136e1ad2e40464bcc4
2022-06-14 09:12:55 -07:00
Janic Duplessis
bfcd15e4a9 Make all headers public and add #ifdef __cplusplus (#1150)
Summary:
This change is mostly needed to support the new react-native architecture with Swift. Some private yoga headers end up being included in the swift build and result in compilation failure since swift cannot compile c++ modules. See https://github.com/facebook/react-native/pull/33381.

The most reliable fix is to include all headers as public headers, and add `#ifdef __cplusplus` to those that include c++. This is already what we do for other headers, this applies this to all headers.

Tested in the YogaKitSample, and also in a react-native app.

Changelog:
[iOS] [Changed] - Make all Yoga headers public and add #ifdef __cplusplus

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

Reviewed By: dmitryrykun

Differential Revision: D36966687

Pulled By: cortinico

fbshipit-source-id: a34a54d56df43ab4934715070bab8e790b9abd39
2022-06-07 07:42:49 -07:00
Richard Howell
4d089ecc79 add missing sdk_modules
Summary: Add SDK modules that cannot be inferred from `frameworks`.

Reviewed By: jayhickey

Differential Revision: D35651890

fbshipit-source-id: 3e6dcdf3ff5db9ef9e1e05e3d4cbe3ff7e0189e3
2022-04-14 17:43:52 -07:00
Adam Ernst
2e1fa58ea5 Fix up more uses of Wno-error=
Summary: This results in compiler warnings. At the scale of our builds, warnings are useless; no one feels empowered to fix thousands of noisy warnings, so they are just noise. Turn them off.

Reviewed By: Daij-Djan, nlutsenko

Differential Revision: D35579825

fbshipit-source-id: cffb7b4ae94299b78aec057e43e87e756efd2d63
2022-04-13 10:04:19 -07:00
Hugo Cuvillier
f174de70af Use logical operator instead of bit operation
Summary:
I guess it's the same since we're working on a `bool` but... this causes some compilation error.

Changelog:
[General][iOS] - Fix compilation warning in yoga

Reviewed By: Andrey-Mishanin

Differential Revision: D35438992

fbshipit-source-id: 22bb848dfee435ede66af0a740605d4618585e18
2022-04-12 09:27:25 -07:00
caioagiani
44d8da2520 fix: typos (#33040)
Summary:
Fix typos in:

- `Libraries/Renderer/implementations/ReactFabric-dev.js`: transfered -> **transferred**
- `Libraries/Renderer/implementations/ReactNativeRenderer-dev.js`: transfered -> **transferred**
- `ReactAndroid/src/main/java/com/facebook/react/modules/network/ProgressiveStringDecoder.java`: remainderLenght -> **remainderLength**
- `ReactAndroid/src/main/jni/first-party/yogajni/jni/ScopedGlobalRef.h`: Transfering -> **Transferring**
- `ReactCommon/react/renderer/graphics/Transform.h`:  tranformation -> **transformation**
- `packages/rn-tester/js/examples/ToastAndroid/ToastAndroidExample.android.js`: occured -> **occurred**

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Fixed] - fix typos

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

Reviewed By: cortinico, pasqualeanatriello

Differential Revision: D34003812

Pulled By: dmitryrykun

fbshipit-source-id: 5c8699f8efcc4354854190a9aade30dbc5c90fdb
2022-03-08 03:58:58 -08:00
Dmitry Vinnik
b4d144a546 docs: add GH button in support of Ukraine (#1134)
Summary:
Our mission at Meta Open Source is to empower communities through open source, and we believe that it means building a welcoming and safe environment for all. As a part of this work, we are adding this banner in support for Ukraine during this crisis.

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

Reviewed By: cortinico

Differential Revision: D34635677

Pulled By: dmitryvinn-fb

fbshipit-source-id: 492fb66b9d4cb218f422564dcef24089c2847603
2022-03-04 11:41:41 -08:00
Keshav Kolur
fba952d5ec Remove platform specific behavior for fb_xplat_platform_specific_rule where rule = fb_prebuilt_jar
Summary: Same as title and added aliasing

Reviewed By: aniketmathur

Differential Revision: D34216617

fbshipit-source-id: 99de98d2c8264a02a8d6f7ff065adff924dd8060
2022-02-15 08:54:22 -08:00
Keshav Kolur
4d4918cdaf Replace fb_xplat_platform_specific_rule call in yoga_defs with fb_native.android_resource and add aliasing
Summary: Replace fb_xplat_platform_specific_rule call in yoga_defs with fb_native.android_resource and add aliasing

Reviewed By: alexmalyshev

Differential Revision: D34107731

fbshipit-source-id: c4d192e24cb3b86bedaa316b735c43387f6e36d4
2022-02-15 07:31:19 -08:00
Aniket Mathur
477fedd1b6 Rollout to xplat/{t..z}
Reviewed By: mzlee

Differential Revision: D33810211

fbshipit-source-id: c1a437a3834701d79461365ef503eee9fa4e75bd
2022-01-31 17:02:01 -08:00
Nolan O'Brien
bd95b3d243 Yoga: suppress warnings
Summary: There are two `yoga_defs.bzl` files... both need to be updated to suppress warnings

Differential Revision: D33393056

fbshipit-source-id: 752416af5386fc0d519689b554d2d6629d186d88
2022-01-04 10:51:28 -08:00
Andres Suarez
acbffc8485 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:00 -08:00
Nolan O'Brien
8123124c80 Suppress errors in xplat/yoga
Summary: Yoga (open source) has errors when `-Wconversion` is enabled.  Suppress those to be just warnings.

Differential Revision: D33330019

fbshipit-source-id: f5fad5581985942d469cb0689e706403d869323b
2021-12-29 09:24:00 -08:00
Richard Howell
b6c71ae58b disable submodules when exporting non-modular deps for ig deps
Summary:
This diff disables submodules for dependencies of IG that are not `ig_apple_library` and are exporting non-modular dependencies. This will allow for migration to using submodules as a default.

The list of targets was obtained with:
```
% buck query 'kind(apple_library, attrfilter(labels, skip_module_validation, deps(igios)) - attrfilter(labels, ig_apple_library, deps(igios)))'
```

Reviewed By: ebgraham

Differential Revision: D32399636

fbshipit-source-id: f3ba55def8001e8595fe3b1611d2de8ec38c8622
2021-11-16 09:07:39 -08:00
Jiaxi He
a6a2209902 Fix perf test path in CI job
Reviewed By: MarcioPorto

Differential Revision: D32287081

fbshipit-source-id: a856b266f986365cdb1f5006576555a28ad7a796
2021-11-09 19:04:10 -08:00
Hannes Friederich
ef490a9921 fixes to make Buck graph parse with arvr build modes
Reviewed By: javache

Differential Revision: D31990291

fbshipit-source-id: 14c7c6d16d2521f4d96b8271b371a0dd2f5ce159
2021-10-28 10:17:19 -07:00
Richard Howell
cfe21e1a60 add skip_module_validation label
Summary:
Add a label to modular libraries that are exporting non-modular deps. This will allow the upcoming tests to skip these targets for now.

#nocancel #retry_on_user_failure #notimeout #retry_on_timeout

Reviewed By: ebgraham

Differential Revision: D31320728

fbshipit-source-id: b1776d71168c282ff791030e530669a2341a9ac8
2021-10-06 14:19:15 -07:00
Athipat Pipatpinyopong
8a95fbe878 Add FBCODE specification to some targets in nonrecursive allowlist #4
Summary:
- Right now, it is only implied that fbcode can rely on these targets via the [fbcode_allowed_list_rules]((https://www.internalfb.com/code/fbsource/tools/build_defs/xplat/fbcode_allowed_list_rules.bzl))
- So, I'm making it explicit that fbcode can rely on these targets
- These targets aren't all related (just going in order of allowlist)

Reviewed By: aniketmathur

Differential Revision: D30405951

fbshipit-source-id: ad324c6d346d77d60fade9cabeae4b5622f0dab7
2021-08-24 16:30:56 -07:00
Pascal Hartig
5c3837f5f3 Default branch renames (#1102)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1102

Test Plan: _eyes

Reviewed By: timur-valiev

Differential Revision: D30302214

Pulled By: passy

fbshipit-source-id: 5b232136c20553883e148d10c99f9e73b8f36757
2021-08-13 08:24:14 -07:00
Lauren Bentley
578d197dd6 remove .buckversion files from fbsource/xplat
Summary: Buck has not relied on the .buckversion file for a while now. I am trying to clean up the number of configs at the root of the cell for buck. This diff attempts to remove .buckversion code referecnes from fbsource/xplat Instead of calling cat .buckversion to get the buckversion hash, you can call buck --fast-version which parses the buck-java11 file without downloading buck. Alternatively, you can also do something like cat .buck-java11 | grep -o -E -e "[0-9a-f]{40}" | head -1  to get the buckversion hash.

Reviewed By: stepancheg

Differential Revision: D28579639

fbshipit-source-id: 6231e16df41f3e403098576e4bfd5d5a2fd38a14
2021-06-18 12:20:32 -07:00
Amir Shalem
e5acf77eea Don't allocate large arrays on stack when copying native pointers, use heap based array
Summary:
Don't allocate large arrays on stack when copying native pointers, use heap based array.

Today the code copies the native pointers on the stack, since it may be too big, lets make sure to use heap based allocating using std::vector.

This array is afterwards converted into a reversed map from index to pointer, so it is heap based anyhow.

Changelog: [Internal] Don't allocate large arrays on stack when copying native pointers, use heap based array

Reviewed By: Andrey-Mishanin

Differential Revision: D28747213

fbshipit-source-id: da69b4b2d0960fdade9f07f44654b30d6dacc43a
2021-06-03 07:04:01 -07:00
Pascal Hartig
f03129728f Disable snapshot publishing (#1089)
Summary:
Currently broken. Will reenable this separately.

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

Reviewed By: mweststrate

Differential Revision: D28609885

Pulled By: passy

fbshipit-source-id: 380359d09ee96d321d49c6440bde358c3e791c1a
2021-05-23 11:38:27 -07:00
Pascal Hartig
8a65d8b6dc Release GitHub actions workflow (#1088)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1088

Reviewed By: mweststrate

Differential Revision: D28604872

Pulled By: passy

fbshipit-source-id: e77578d44557420be9b782dc90f047af697b7cb9
2021-05-21 11:41:13 -07:00
Pascal Hartig
0fcef77d7b Maven release docs (#1087)
Summary:
*Context: The Yoga OSS build has not been given a lot of attention over the past couple of years and is in serious disrepair. I'll try to get the release pipeline going again to publish to Maven Central as JCenter is shutting down. A bunch of intermediate commits may still have broken builds but will be inching closer to a working one.*

Adds some docs on how to use the release workflow.

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

Reviewed By: priteshrnandgaonkar

Differential Revision: D28604686

Pulled By: passy

fbshipit-source-id: 44cac2cd0593a4f71d80df1ec5324c3c27fbe888
2021-05-21 11:41:13 -07:00
Pascal Hartig
e3a59aa50e Maven central publish (#1086)
Summary:
Sets up the plugins necessary to publish to Maven Central.

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

Test Plan: ./gradlew publishToMavenLocal -PRELEASE_SIGNING_ENABLED=false

Reviewed By: mweststrate

Differential Revision: D28604529

Pulled By: passy

fbshipit-source-id: 2c35b94ce0e254bc7a8bc80e449ac5dadb5def38
2021-05-21 11:41:12 -07:00
Pascal Hartig
13e079e8f3 Upgrade Gradle setup (#1084)
Summary:
Trying to dust off the build setup and make it work again with a modern Android Studio / JVM.

Removing all JCenter setup, too, as this is no longer supported.

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

Test Plan:
`./gradlew :yoga-layout:assembleDebug` works already.
Looking if CI here likes this.

Reviewed By: mweststrate

Differential Revision: D28602272

Pulled By: passy

fbshipit-source-id: 0cb86f548cc6366ccefcc92c185d6e7772e75547
2021-05-21 11:15:18 -07:00
Pascal Hartig
508f4eacdf Fix env setting and Android setup (#1085)
Summary:
*Context: The Yoga OSS build has not been given a lot of attention over the past couple of years and is in serious disrepair. I'll try to get the release pipeline going again to publish to Maven Central as JCenter is shutting down. A bunch of intermediate commits may still have broken builds but will be inching closer to a working one.*

The current way env variables are set is no longer supported for security reasons: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/. The manual Android setup is also quite tricky to maintain and can mostly be done through GitHub Actions itself.

Please note that the actual build is still failing but that's because we're so far behind with the setup here that the Gradle version no longer works on a modern JVM. I'll fix that in subsequent diffs.

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

Test Plan: CI

Reviewed By: mweststrate

Differential Revision: D28602084

Pulled By: passy

fbshipit-source-id: e334ed92d16a9baa185a84b23bb62801399e5650
2021-05-21 10:11:37 -07:00
Andres Suarez
a999150c19 Apply clang-format
Reviewed By: igorsugak

Differential Revision: D28477074

fbshipit-source-id: f15dfc45b9fb30c661ebe2899cd882676d0fdf2a
2021-05-20 21:24:14 -07:00
Aditya Sharat
cbf6495d66 Refactor YogaNode.Inputs freeze API
Summary:
`InternalNode` will eventually not have a pointer to its parent. This diff removes one of the usages of the `InternalNode#getParent()` API. `InternalNode` will also not host the `YogaNode` eventually; so this diff also removes one of the usages of the `InternalNode#getYogaNode()` api.

Now the `Inputs#freeze` api will pass the parent's `YogaNode` and the `YogaNode` of the node (this) being measured.

Changelog: [Internal] Passes The YogaNode and parent YogaNode in the Inputs.freeze API

Reviewed By: SidharthGuglani

Differential Revision: D27240229

fbshipit-source-id: efc4ec3249a963c3181111f9b989d8ed9e17feb4
2021-03-30 05:42:09 -07:00
Aditya Sharat
07eaeea7a4 Create YogaProps Interface
Summary:
Create YogaProps Interface; this interface represents the inputs to YogaNode for layout calculation.

Changelog: [Internal] Create YogaProps Interface; this interface represents the inputs to YogaNode for layout calculation.

Reviewed By: mihaelao

Differential Revision: D27229274

fbshipit-source-id: 5205caf2384661369d7a2d7e7f3e49ff831a1c92
2021-03-26 10:05:14 -07:00
Altaibayar Tseveenbayar
638690255c Yoga set as a static library also for debug+release builds in x64
Summary: Yoga set as a static library also for debug+release builds in x64

Reviewed By: SidharthGuglani

Differential Revision: D27230019

fbshipit-source-id: d77e2c4130cd8303d1585723bfad927b9ddba23e
2021-03-22 07:43:09 -07:00
Altaibayar Tseveenbayar
6c2ba945be Making yoga by default a static library
Summary: We are linking yoga as a static library in most of the places

Reviewed By: SidharthGuglani

Differential Revision: D27228933

fbshipit-source-id: 725d6551198c96925ae80b3a62ef9737ee7e3052
2021-03-22 04:32:44 -07:00
Altaibayar Tseveenbayar
db6be5286e C4244 possible precision loss warning fix
Summary:
Fixing `warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data`

Changelog: [Internal]

Reviewed By: SidharthGuglani

Differential Revision: D27132355

fbshipit-source-id: 55ff35be368ef4f6093865eb88c17e753250d179
2021-03-19 19:23:54 -07:00
Altaibayar Tseveenbayar
67b6c24d7b Yoga Visual Studio project file fix
Summary: Yoga Visual Studio project file was outdated. Made it back working/compilable

Reviewed By: Andrey-Mishanin

Differential Revision: D27138942

fbshipit-source-id: 5d57e61dbb415db54e255e148739c2e670f3bd23
2021-03-18 03:44:00 -07:00
Pieter De Baets
b2095801ba Simplify YGNodeEmptyContainer / YGNodeWithMeasureFunc / YGNodeFixedSize
Summary:
These methods are only ever called just after setting the various YGStyle props. Therefore we can read any padding / margin / border state from there rather than recalculating it.

Changelog: [Internal]

Reviewed By: SidharthGuglani

Differential Revision: D27010098

fbshipit-source-id: a33f879b25c54cfdb0ffc724b6aa325858e97df5
2021-03-15 16:54:58 -07:00
Pieter De Baets
e87f429703 Simplify YGNodeCalculateAvailableInnerDim
Summary:
Avoid recalculating margin and padding by pre-subtracting the margin from `availableWidth` and inlining the calculation of `paddingAndBorderAxisCross`.

Changelog: [Internal]

Reviewed By: SidharthGuglani

Differential Revision: D27010094

fbshipit-source-id: afc3cf251a0306b9e5d7f0dc6856feee8d1dca6e
2021-03-15 16:54:58 -07:00
Pieter De Baets
41384fab7b Optimize edge value resolution
Summary:
Noticed in simpleperf this was a very hot method, showing 8ms spent in these methods in our sample application. By splitting the method out in a horizontal and vertical variant we can simplify cases enormously and check for begin/end in one go.

Changelog: [Internal]

Reviewed By: SidharthGuglani

Differential Revision: D27010008

fbshipit-source-id: 22fed58c7476e1d716b0191b55997c7a06e63223
2021-03-15 16:54:55 -07:00
Eric Rozell
342aebe1d7 Fixes layout of nodes with YGDisplayNone and YGPositionTypeAbsolute (#1068)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1068

There is an issue in react-native when the Yoga node position type is set to absolute and display: none is set where the node layout calculation gives the absolute dimensions, rather than the expected 0 x 0.

Here are some OSS issues tracking this:
https://github.com/facebook/react-native/issues/18415
https://github.com/microsoft/react-native-windows/issues/7289

## Changelog

[General] [Fix] - Fixes layout of nodes with YGDisplayNone and YGPositionTypeAbsolute

Reviewed By: Andrey-Mishanin

Differential Revision: D26849307

fbshipit-source-id: 197618aa3c4e1b3b7efeba7ea4efd30b2d1c982d
2021-03-10 13:10:32 -08:00
Andrew Coates
1745c23a12 Fix various C++ warnings (#31002)
Summary:
Fix warnings about implicit type truncation.

## Changelog

[Internal] [Fixed] - Fix various C++ warnings

Pull Request resolved: https://github.com/facebook/react-native/pull/31002

Test Plan:
Almost all the changes here are simply making explicit conversions which are already occurring.  With the exception of a couple of constants being changed from doubles to floats.

With these changes I am able to remove a bunch of warning suppressions in react-native-windows.

Reviewed By: shergin

Differential Revision: D26900502

Pulled By: rozele

fbshipit-source-id: d5e415282815c2212a840a863713287bbf118c10
2021-03-10 12:38:12 -08:00
Stiopa Koltsov
ccdea0f31b xplat: switch random files to Starlark
Summary:
We need to get rid of all `# BUILD FILE SYNTAX: PYTHON_DSL` to disable hybrid parser after we make Starlark default everywhere.

This is first bunch of changes.

Reviewed By: mzlee

Differential Revision: D26727784

fbshipit-source-id: 05c5f4d039feb4ce06169ac6d2fc5c49711125cd
2021-03-01 13:15:11 -08:00
Sidharth Guglani
c1a28f3f54 Add back snapshot in version for next release
Summary: Changelog: [Internal][Yoga] version bump

Reviewed By: pasqualeanatriello

Differential Revision: D26664063

fbshipit-source-id: ceb8d31a99f85db7d1fde20bd77584a537d356c6
2021-02-25 06:36:06 -08:00
Sidharth Guglani
0429704d5e version bump
Reviewed By: pasqualeanatriello

Differential Revision: D26664041

fbshipit-source-id: 5a4d0d176074c8831dd18681993463fe25e2642f
2021-02-25 06:36:05 -08:00
Sidharth Guglani
36e70c9ca0 Fix Yoga test
Summary: Changelog: [Internal][Yoga] Fixed unit test for default yoga style property

Reviewed By: pasqualeanatriello

Differential Revision: D26664040

fbshipit-source-id: 9c0af4e846ead3d90c75753e836570ccac760178
2021-02-25 06:36:02 -08:00
Aditya Sharat
de36e85004 Adds InternalNode#freeze() API
Summary:
Litho needs a new API which is called immediately before yoga begins layout calculations so that the InternalNode gets the opportunity to finalise itself; i.e. perform the last mutations and in effect avoid any more mutations to the hierarchy.

See D26373731 where the mutations from `Layout#collectResults` is moved back into the InternalNode.

Changelog: [Internal]  Adds new API to YogaNodeJNIBase

Reviewed By: SidharthGuglani

Differential Revision: D26373730

fbshipit-source-id: 471346d3444986ada91e86c95f5f9fb98bcd2fa6
2021-02-16 10:19:23 -08:00
Ruslan Serebriakov
651c527e94 CKDimension
Summary:
[rsrbk@devvm3461.lla0 /data/users/rsrbk/fbsource/fbobjc] fastmod --accept-all CKRelativeDimension RCRelativeDimension
[rsrbk@devvm3461.lla0 /data/users/rsrbk/fbsource/fbobjc] fastmod --accept-all CKRelativeSize RCRelativeSize
[rsrbk@devvm3461.lla0 /data/users/rsrbk/fbsource/fbobjc] fastmod --accept-all ComponentKit/RCDimension.h RenderCore/RCDimension.h

Reviewed By: kfirapps

Differential Revision: D26228615

fbshipit-source-id: 9c06128b324e1c6ece6fc21fbab1c041e5f5825a
2021-02-11 10:39:22 -08:00
Sidharth Guglani
2cb46cf3e2 instance of checks for YogaNodeJniBase
Summary:
Changelog:
[Internal][Yoga] - Added instance of checks in `YogaNodeJNIBase` class to prevent `ClassCastException`s. This was happening for some NT android tests - Mocked Yoga Node object was being passed in the `addChildAt` api

Stack Trace of exception
    java.lang.ClassCastException: com.facebook.yoga.YogaNode$MockitoMock$1408896622 cannot be cast to com.facebook.yoga.YogaNodeJNIBase
	at com.facebook.yoga.YogaNodeJNIBase.addChildAt(YogaNodeJNIBase.java:86)
	at com.facebook.litho.DefaultInternalNode.addChildAt(DefaultInternalNode.java:220)
	at com.facebook.litho.DefaultInternalNode.child(DefaultInternalNode.java:377)
	at com.facebook.litho.DefaultInternalNode.child(DefaultInternalNode.java:360)
	at com.facebook.litho.Column.resolve(Column.java:118)
	at com.facebook.litho.Layout.create(Layout.java:172)

Reviewed By: Andrey-Mishanin

Differential Revision: D26114992

fbshipit-source-id: 774a689609e67f9244b81c6788b62cd61cd96d14
2021-02-05 03:42:10 -08:00
Andres Suarez
584dfe961e Apply clang-format update fixes
Reviewed By: igorsugak

Differential Revision: D25861849

fbshipit-source-id: 840dc1061e557717c7f9ffcccbc09c24b96b78e0
2021-01-10 10:05:56 -08:00
Panagiotis Vekris
a38ec3d7a4 pin "classic" roots to v0.140
Summary:
In Flow v0.143 types-first will become the only supported mode in Flow.
As such the `types_first` configuration option will become invalid. To
prevent breaking roots that have `types_first=false` set and are **unversioned**,
this diff pins their version to v0.140, which is the last released version in fbsource.

## Repro

First compute the list of all `.flowconfig`s:
```
zbgf '.flowconfig$' | grep -v '^fbsource/fbcode/flow' | grep -v 'Binary file' | awk -F':' '{ print $1 }' | sort -u > all-flowconfigs.txt
```
Compute `.flowconfig`s that don’t have a version:
```
zbgs -f '\.flowconfig' '[version]' |  grep -v '^fbsource/fbcode/flow'  | grep -v 'Binary file' | awk -F':' '{ print $1 }' | sort -u > versioned-flowconfigs.txt
comm -23 all-flowconfigs.txt versioned-flowconfigs.txt > unversioned-flowconfigs.txt
```
Compute `.flowconfig`s that have `types_first=false`:
```
zbgr -f '\.flowconfig' '^types_first=false$' |  grep -v '^fbsource/fbcode/flow'  | grep -v 'Binary file' | awk -F':' '{ print $1 }' | sort -u > types_first-false-flowconfigs.txt
```
**and** no pinned version:
```
comm -12 unversioned-flowconfigs.txt types_first-false-flowconfigs.txt | grep 'fbsource' > pin-version-flowconfigs.txt
```
Update the `.flowconfig`s:
```
cat ~/scratch/flowconfigs/pin-version-flowconfigs-fbsource.txt | xargs -I{} bash -c 'printf "\n[version]\n^0.140.0\n" >> {}'
```

Reviewed By: mroch

Differential Revision: D25771452

fbshipit-source-id: 876d6310e4e1aafb81d3ef3051f4e9e9e838a633
2021-01-04 21:06:15 -08:00
Ron Edelstein
b043669972 Explicitly set autoglob (long tail)
Reviewed By: fbanurag, strulovich

Differential Revision: D25620908

fbshipit-source-id: 1dd737d451ddfd07baa427902bdf1c96d7e67e64
2020-12-17 19:34:48 -08:00
Kris Georges
e65b1ef654 Fix Yoga Playground website Litho codegen bugs
Summary:
Yoga Playground website

changing direction results in no change to Litho code because of this typo

Reviewed By: SidharthGuglani

Differential Revision: D24818769

fbshipit-source-id: 1633513d4a25aead2008b59d52f669293214c598
2020-11-10 08:22:42 -08:00
Pasquale Anatriello
07eac0c6e2 Fix clone issue in YogaNodeJNIBase
Summary:
Changelog:
Fix the cloneWithChildren implementation that was not copying the list of children on the java object.

We were missing on copying the list of children when cloning. This is pretty bad as it means that the clone operation was mutating the old node as well as the new. When multiple threads were involved this could cause crashes.

Reviewed By: SidharthGuglani

Differential Revision: D24565307

fbshipit-source-id: 4e2e111db389e25c315ce7603b4018ac695bb0f1
2020-10-29 09:25:03 -07:00
simek
64e2459427 remove most of tvOS remnants from the code (#29407)
Summary:
Refs: [0.62 release](https://reactnative.dev/blog/#moving-apple-tv-to-react-native-tvos), https://github.com/facebook/react-native/issues/28706, https://github.com/facebook/react-native/issues/28743, https://github.com/facebook/react-native/issues/29018

This PR removes most of the tvOS remnants in the code. Most of the changes are related to the tvOS platform removal from `.podspec` files, tvOS specific conditionals removal (Obj-C + JS) or tvOS CI/testing pipeline related code.

In addition to the changes listed above I have removed the deprecated `Platform.isTVOS` method. I'm not sure how `Platform.isTV` method is correlated with Android TV devices support which is technically not deprecated in the core so I left this method untouched for now.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

* **[Internal] [Removed]** - remove most of tvOS remnants from the code:
  * `TVEventHandler`, `TVTouchable`, `RCTTVView`, `RCTTVRemoteHandler` and `RCTTVNavigationEventEmitter`
* **[Internal] [Removed]** - remove `TARGET_TV_OS` flag and all the usages
* **[iOS] [Removed]** - remove deprecated `Platform.isTVOS` method
* **[iOS] [Removed]** - remove deprecated and TV related props from View:
  * `isTVSelectable`, `hasTVPreferredFocus` and `tvParallaxProperties`
* **[iOS] [Removed]** - remove `BackHandler` utility implementation

Pull Request resolved: https://github.com/facebook/react-native/pull/29407

Test Plan: Local tests (and iOS CI run) do not yield any errors, but I'm not sure how the CI pipeline would react to those changes. That is the reason why this PR is being posted as Draft. Some tweaks and code adjustment could be required.

Reviewed By: PeteTheHeat

Differential Revision: D22619441

Pulled By: shergin

fbshipit-source-id: 9aaf3840c5e8bd469c2cfcfa7c5b441ef71b30b6
2020-09-28 21:26:01 -07:00
Panagiotis Vekris
f350c7a58e explicitly set types_first=false in flowconfigs
Summary:
In Flow version 0.134, [types-first](https://flow.org/en/docs/lang/types-first/) will become the default mode for Flow.
Given that this mode might introduce some errors due to missing annotations,
we're pinning the previously default mode, to avoid introducing new errors.

Note that in Jan 2021 we will be removing support for Flow classic mode.

* Documentation for properly upgrading to types-first: https://flow.org/en/docs/cli/annotate-exports/
* Announcement post: https://medium.com/flow-type/types-first-a-scalable-new-architecture-for-flow-3d8c7ba1d4eb

Reviewed By: mroch

Differential Revision: D23606450

fbshipit-source-id: f849275269974e17c0ebe00885e387ccd9956b6d
2020-09-10 16:13:45 -07:00
Paco Estevez Garcia
e0ae96368c Add DoNotStripAny
Summary:
This diff adds an annotation that also prevents stripping methods, fields and static blocks.

This is necessary for D23373168 to be OSS'd

Reviewed By: SidharthGuglani

Differential Revision: D23395925

fbshipit-source-id: 8456234cb75b15ae87580835e76f8e251ba09a9b
2020-08-28 06:44:45 -07:00
Jiawei Lv
e1c9d8800e Assign test_ownership_2020 as owner for unowned java tests in fbandroid
Summary: Changelog: [Internal]

Reviewed By: IanChilds

Differential Revision: D22980855

fbshipit-source-id: d5e394f16eaf0e50367b95b1eec98024b906d3d9
2020-08-11 17:19:05 -07:00
Thomas Nardone
084d5935e6 Tweak stdlib imports in event, utils
Summary:
Changelog:
[Internal][Fixed] - Tweaked stdlib imports

Reviewed By: SidharthGuglani

Differential Revision: D22860196

fbshipit-source-id: fc0fc1bf05ebbfae7e86bce5e960e58d5944ee5c
2020-08-03 09:39:32 -07:00
Valentin Shergin
fc88b2f774 Introducing YGPositionTypeStatic
Summary:
Changelog: [Internal] Fabric-specific internal change.
This diff introduces a new value for `YGPositionType`: `YGPositionTypeStatic`.
No part of Yoga, RN, Litho or CK uses this value yet. `relative` and `static` values behave the same way for now. We also do not change any defaults. So, it should be fine.

Reviewed By: SidharthGuglani

Differential Revision: D22386732

fbshipit-source-id: 39cd9e818458ac2a91efb175f24a74c8c303ff08
2020-07-20 00:33:02 -07:00
Stanislau Hlebik
5ac5624e3f remediation of S205607
fbshipit-source-id: 798decc90db4f13770e97cdce3c0df7d5421b2a3
2020-07-17 17:23:52 -07:00
Stanislau Hlebik
16f676eccf remediation of S205607
fbshipit-source-id: 5113fe0c527595e4227ff827253b7414abbdf7ac
2020-07-17 17:23:51 -07:00
Valentin Shergin
0767f4d105 Using YGPositionTypeAbsolute value where we compare absolute vs relative
Summary:
Now Yoga.cpp does not use the `YGPositionTypeRelative` value/constant, it uses `YGPositionTypeAbsolute` instead.
Now `YGPositionType` can only be `YGPositionTypeRelative` or `YGPositionTypeAbsolute`, so expressions `x == YGPositionTypeRelative` and `x != YGPositionTypeAbsolute` are equivalent.
The reasoning behind the change is that in all cases we actually check a node to be (or not to be) `absolute`, not `relative`. This will make a difference in the coming diffs in the stack when we will introduce a new value for the type: `static`.

We need to differentiate `static` and `relative` values t implement the `stacking context` feature in the W3C-compliant way (to fix bugs and avoid developer confusion). Read more here:
https://developer.mozilla.org/en-US/docs/Web/CSS/position

Changelog: [Internal] Internal change in Yoga.

Reviewed By: SidharthGuglani

Differential Revision: D22386733

fbshipit-source-id: 8e2c2b88b404660639f845783c8f93f0c62c0fbb
2020-07-14 15:31:07 -07:00
Amir Shalem
a93e5d63c9 Don't call config->setLogger(nullptr) directly to avoid having no logger at all
Summary:
Changelog: [Internal][Yoga] Don't call config->setLogger(nullptr) directly to avoid having no logger at all

Broken in D14151037 (05f36a835a) when it started calling
```
config->setLogger(nullptr);
```
instead of going thru
```
YGConfigSetLogger(config, nullptr);
```
which does the right thing by setting the logger to its default value:
https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/yoga/yoga/Yoga.cpp?commit=835911317e8b3cf7da1866e40e1c79cda0690136&lines=4320-4330

Also by default YogaConfig always have a logger:
https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/yoga/yoga/Yoga.cpp?commit=835911317e8b3cf7da1866e40e1c79cda0690136&lines=335-343

Reviewed By: SidharthGuglani

Differential Revision: D22387459

fbshipit-source-id: 4da91da87a696d38cc9d8db2acb5845d29398adb
2020-07-06 03:53:19 -07:00
Stiopa Koltsov
d74a1069a0 xplat: Disable Starlark in several files
Summary: Disable Starlark in several files which are not trivial to fix.

Reviewed By: scottrice

Differential Revision: D22202463

fbshipit-source-id: a3ff717f0f4b9cd7f492b8fcebdb91f232207222
2020-06-24 12:29:48 -07:00
Sidharth Guglani
633cdc9088 use fmod and YGDoubleEquals for double operations instead of float
Summary: Changelog: [Internal][Yoga] Use double operations during rounding

Reviewed By: mdvacca

Differential Revision: D21840018

fbshipit-source-id: c5d17fcb8984b1da9832a15ccd4d628e8d742c6a
2020-06-08 08:11:18 -07:00
Steven Koeber
ede65bbce4 Buckification of Yoga build script
Reviewed By: liorisraeli87, k21

Differential Revision: D21429174

fbshipit-source-id: f12c8349cc59398553773df7bc15f0f83bd571b4
2020-06-04 06:54:18 -07:00
Jon Janzen
4135420cba Fix GitHub Actions secrets access (#1005)
Summary:
Ref: [Secrets documentation](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#using-encrypted-secrets-in-a-workflow)

In combination with setting the secrets in the GitHub settings, this should fully migrate yoga to GH actions.

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

Test Plan: GitHub Actions CI on the PR attached to this diff

Reviewed By: SidharthGuglani

Differential Revision: D21574995

Pulled By: bigfootjon

fbshipit-source-id: e9ee6d7cf1ae131afdc3aa3778667f1e9b9de833
2020-05-14 12:21:28 -07:00
Sidharth Guglani
07c0d539bd throw std::logic_error instead of aborting the process and convert to java exception
Summary: Changelog: [Internal][Yoga] throw std::logic_error instead of aborting the process and convert to java exception for jni layer

Reviewed By: pasqualeanatriello

Differential Revision: D21301235

fbshipit-source-id: 148b27920e62990a271e1d0df8c85a2cc42f4fd4
2020-05-14 06:39:25 -07:00
Jon Janzen
ac7c85c0a6 Migrate CI from TravisCI to GitHub Actions (#1004)
Summary:
Migrate from TravisCI to GitHub Actions. Facebook employees can read about this migration [here](https://fburl.com/rfp033ou).

CC: wittgenst
Pull Request resolved: https://github.com/facebook/yoga/pull/1004

Test Plan: GitHub Actions CI on my personal GitHub: https://github.com/bigfootjon/yoga/runs/653755729

Reviewed By: passy

Differential Revision: D21431309

Pulled By: bigfootjon

fbshipit-source-id: 490a8679bc0cfec26b13c8c584a928f03c6e26e7
2020-05-12 12:01:53 -07:00
Sidharth Guglani
83b27417ae Fix rounding error using double instead of float
Summary: Changelog: [Internal] [Yoga] Use double instead of float during rounding process to prevent loss of precision.

Reviewed By: mdvacca

Differential Revision: D21227565

fbshipit-source-id: 380b57535a356624cda8dc2017871a4ef3c882d1
2020-04-27 14:48:15 -07:00
Valentin Shergin
884f147742 Fixed incorrect owner assignment in YGNode move constructor
Summary:
Assigning self as an owner makes a cycle which is obviously a bug.

Changelog: [Internal] Small change in Yoga (should not affect RN).

Reviewed By: SidharthGuglani

Differential Revision: D21111423

fbshipit-source-id: 1835561c055ac827f5ce98a044f25aed0d1845a5
2020-04-20 12:05:55 -07:00
Gavin Weng
a96a36ef59 Link yogacore statically into yoga
Summary: A revert of D20879886.

Reviewed By: iliagore

Differential Revision: D20979490

fbshipit-source-id: cb37f931654450c408e72578abcc549f35727b07
2020-04-17 17:34:17 -07:00
acton393
1bd4123df1 fix typo as there is no file called YGJNI.cpp (#990)
Summary:
fix typo in `YogaJNIBase.java` as there is no such file called `YGJNI.cpp`
Pull Request resolved: https://github.com/facebook/yoga/pull/990

Reviewed By: pasqualeanatriello

Differential Revision: D20735102

Pulled By: SidharthGuglani

fbshipit-source-id: 3f9f4d78ba390feae3451330f997a221ab4ec70e
2020-04-17 05:45:41 -07:00
Sidharth Guglani
92b76447b7 use default value of enums YGDirection and YGMeasureMode instead of -1
Summary:
Changelog:
[Internal][Yoga] YGDirection variable was initialized incorrectly by casting -1 to YGDirection. Changing it to default value of direction

Same for YGMeasureMode.

Reviewed By: pasqualeanatriello

Differential Revision: D20869042

fbshipit-source-id: 7bfe490193321baae875ef6fb49a938851950c9f
2020-04-17 05:32:05 -07:00
Sidharth Guglani
e637cf2d72 Add Yoga also as a dependency of testutil-jni
Summary:
`scripts/deploy_jcenter.sh` was failing

{F234018047}

Added `yoga` also as a dependency of `testutil-jni`

Reviewed By: gavinweng

Differential Revision: D21017796

fbshipit-source-id: 0c34e7fc2373906441bd7805f5687b2c5dab6242
2020-04-15 00:49:53 -07:00
empyrical
9b96a5362a Yoga Podspec: Export YGNode and YGStyle headers (#997)
Summary:
This pull request adds `YGNode.h` and `YGStyle.h` to the headers exported by Yoga's podspec. They are required by the new Fabric architecture of React Native.

The modulemap and its umbrella header automatically generated by Cocoapods adds all exported headers to the `modulemap`. Having YGNode and YGStyle exported through here has problems, because they are only available in environments that have C++ available, and will produce errors otherwise.

This pull request fences off the contents of those headers in an `#ifdef __cplusplus` block, so they will not cause errors when imported into environments where C++ isn't available.

I had considered adding a custom modulemap to the podspec as part of this pull request, but this way seems the least "invasive", and this way you are able to add and remove exported headers in the podspec without needing to worry about updating the umbrella header at the same time.

Changelog:

[Internal] - Yoga Podspec: Export YGNore and YGStyle headers

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

Reviewed By: hramos

Differential Revision: D20966075

Pulled By: mdvacca

fbshipit-source-id: 5f5caa6b639d11e660b968d681da9a4de6c0eb8e
2020-04-14 16:42:27 -07:00
Sidharth Guglani
e5743e851b Set width/height also to Undefined when we change the measure mode to Undefined
Summary:
Make sure width/height is always passed as Undefined when measure mode is changed to Undefined.

Changelog: [Internal][Yoga] Set width and height as Undefined when we change measure mode to Undefined

Reviewed By: alickbass

Differential Revision: D20029838

fbshipit-source-id: b9931f6ddb13ffd1565889535ade5bbffbe0c304
2020-04-14 02:09:29 -07:00
George Zahariev
f7bc0ad248 Upgrade Prettier in Xplat to version 1.19.1: format files
Summary:
Part two of D20879147 where we update the versions of Prettier used in Xplat. I will stack land the diffs.
Here, we format all the files, and use the drop conflicts flag. After this lands, I will go and format the files which had conflicts again.

Changelog: [Internal]

drop-conflicts
bypass-lint
allow-large-files

Reviewed By: gkz

Differential Revision: D20929844

fbshipit-source-id: 2c1df8966a48b5db4f890e2cc494cb1c69422b7d
2020-04-09 11:06:06 -07:00
George Zahariev
8c53c2dcca Upgrade Prettier in Xplat to version 1.19.1
Summary:
Upgrades Prettier in Xplat to 1.19.1
Ignores upgrading packages on already on versions greater than 1.19.1

Changelog: [Internal]

allow-large-files
bypass-lint

(Note: this ignores all push blocking failures!)

Reviewed By: gkz, cpojer

Differential Revision: D20879147

fbshipit-source-id: 0deee7ac941e91e1c3c3a1e7d3d3ed20de1d657d
2020-04-09 11:06:04 -07:00
Gavin Weng
be51bc44a4 Revert Name Change for FBLite
Summary: To unblock

Reviewed By: Arieg419

Differential Revision: D20879886

fbshipit-source-id: 428f9147e540b94dec7f72a7f844949722165a07
2020-04-06 19:53:50 -07:00
Gavin Weng
5eba2d42bd Enhance build process (#994)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/994

After building yoga aar, we found several issues:
1. More dynamic so files. This is bad as lower-end Android devices cannot load that many sos.
2. Size increase.
3. (Minor) The libs are stored in asset folder rather than "libs/".

We apply the following optimizations:
1. Remove dependency on memalign16 (this is brought in by a pure header dependency jni-hack);
2. Enable native relinker to remove unused symbols in the so files.
3. Link yogacore statically to reduce size churn.

Reviewed By: SidharthGuglani

Differential Revision: D20808623

fbshipit-source-id: 6c6bbd4f71b6bf6ad272ec05dd56696ddb14a8e0
2020-04-06 11:51:16 -07:00
Sidharth Guglani
2049c85a6c Unit tests for flexshrink min width cases
Reviewed By: pasqualeanatriello

Differential Revision: D20219428

fbshipit-source-id: 8cbd028627095d9f7b393489ddba1f31c3207b67
2020-04-01 14:56:49 -07:00
Sidharth Guglani
ecd7790dd8 Fix Yoga flexshrink with min-width sizing issue
Summary:
While resolving the flexible items we calculate totalFlexShrinkScaledFactors which uses the flexBasis or initial width of node (Not min-width).

At a later stage during distribution of space we are subtracting value from this which also takes care of min-width.

For example
If node has flexShrink 1 and width 100 and min-width 301  then totalFlexShrinkScaledFactors will become -1*100 = -100
but later we are subtracting -1 * 301 (min-width) = -301 which is ambiguous and causing layout inconsistencies with how web behaves.

Fixed this by only using the flexBasis or width for these calculations.

Changelog:
[Internal][Yoga] Fix layout issue when flexShrink and min-width are used together

Reviewed By: pasqualeanatriello

Differential Revision: D20219419

fbshipit-source-id: 948fbc06ca541d4ad307c88c8a2df65d157778b1
2020-04-01 14:56:45 -07:00
Michael Bolin
0f08aa53da Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:41:08 -07:00
Michael Bolin
5bf93e81ba Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:26:19 -07:00
Lior Israeli
4f1231f411 Fix typo in buck targets
Summary: Proguard is spelled wrong

Reviewed By: SidharthGuglani

Differential Revision: D20619173

fbshipit-source-id: 463788454ad7e72337121ed63ab79129db45113e
2020-03-24 05:37:47 -07:00
Adam Ernst
b280a19b0a Run 'arc lint-deps'
Reviewed By: d16r

Differential Revision: D20362505

fbshipit-source-id: f3b7e62f7665d20a32788042772b731d6ed53f36
2020-03-10 10:58:46 -07:00
Nate Stedman
63a463d011 Mark YogaKit as modular
Differential Revision: D20364340

fbshipit-source-id: ce4bc1f474177ffc9c77eb2f10bdb7cb549dd6d8
2020-03-10 09:38:56 -07:00
Jesse Katsumata
adb87e347f chore: fix typo in comments (#28269)
Summary:
Fixed some typos in the comment.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments
Pull Request resolved: https://github.com/facebook/react-native/pull/28269

Test Plan: Changes are only made in the comments, so test is not necessary.

Reviewed By: cpojer

Differential Revision: D20342637

Pulled By: shergin

fbshipit-source-id: f6e7dd538ee54c43e1570c35e1f8c4502054e328
2020-03-09 16:03:44 -07:00
Sidharth Guglani
2d52b5a873 fix layout tab height issue in playground on home page
Summary: Fixed layout tab height issue properly

Reviewed By: danielbuechele

Differential Revision: D20003594

fbshipit-source-id: 6d9ce89a5d82a83937e5cb0f989bb028e07d576f
2020-02-25 07:34:37 -08:00
Sidharth Guglani
6c61cd5f05 Fix layout tab scrolling in playground
Summary: Add a scroll bar to layout tab in playground to fix the UI issue where margin, border were not accessible.

Reviewed By: danielbuechele

Differential Revision: D19906128

fbshipit-source-id: 2c2d7695f731b2d312b78eab31c66d737915eaae
2020-02-19 11:12:41 -08:00
Sidharth Guglani
bfc3b2f86f fix lint errors
Summary:
Changelog: [Internal][Yoga] Fixed lint errors

```arc lint --apply-patches --take CLANGFORMAT --paths-cmd 'hg files xplat/yoga'
```
Added .clang-tidy file

Reviewed By: zertosh

Differential Revision: D19948702

fbshipit-source-id: f77a16d6f2c532267597a84a9caded0aae68c3aa
2020-02-18 08:24:46 -08:00
Christoph Purrer
a1278cee05 Make YGValue.h compile with Clang on Windows
Summary:
- We use a fork of Microsoft's react-native-windows which uses a fork of Facebook's react-native
- YGValue.h does not compile with Clang on Windows
- This change should fix that
- I want to put the change here so that it bubbles back to our fork > https://our.intern.facebook.com/intern/diff/D19656093/

#Changelog:
[General][Fixed] Make YGValue.h compile with Clang on Windows

Reviewed By: SidharthGuglani

Differential Revision: D19717489

fbshipit-source-id: ad867ecaf910bb64a777a06c656a1867bb15484b
2020-02-05 13:44:21 -08:00
Pasquale Anatriello
e983c4a5ef Swap child Yoga
Summary:
Changelog: [Internal]

Expose the replaceChild Yoga call to Java

Reviewed By: SidharthGuglani

Differential Revision: D19497193

fbshipit-source-id: 153243cc1d8c23dcaf2c772ca794bd59a230f652
2020-01-30 04:32:20 -08:00
Amir Shalem
7f97e8b232 Allow redex to optimize more of yoga by removing unneeded @DoNotStrip marks
Summary:
There are multiple `DoNotStrip` in Yoga java binding, they aren't needed.

##Changelog:
[Internal][Yoga] Allow redex to optimize more of yoga by removing unneeded DoNotStrip marks

Reviewed By: SidharthGuglani

Differential Revision: D17519844

fbshipit-source-id: 8b26800d720f34cae87754d85460abf88acbe713
2019-12-04 01:34:54 -08:00
Sidharth Guglani
089095f532 create global ref properly in YogaJNIException
Summary:
##Changelog:
[Internal][Yoga] create global ref properly in YogaJNIException

Reviewed By: astreet

Differential Revision: D18775982

fbshipit-source-id: ee529d6178d40b5f887fa1327fe156fa466f154f
2019-12-03 16:02:13 -08:00
Sidharth Guglani
ac8eb111a9 Add defensive check for result returned after JNI function calls
Summary:
Added method which checks if value(methodId, fieldId, class ...) returned by JNI functions (getMethod, getField, getClass ...) is valid or not and throw exception if they are not valid

##Changelog:
[Internal][Yoga] Add defensive check for result returned after JNI calls

Reviewed By: astreet

Differential Revision: D18745718

fbshipit-source-id: 2af26eda15fbe7834e1c9b274deeed4f106274ab
2019-12-02 05:24:54 -08:00
Sidharth Guglani
073f49d0d0 Use YogaJniException in jni call exception handling
Summary:
##Changelog:
[Internal][Yoga] Use YogaJniException in jni call exception handling

Reviewed By: astreet

Differential Revision: D18745615

fbshipit-source-id: 5fcf4c31f04fade94ef98a5349782ed3d43805b0
2019-12-02 05:24:54 -08:00
Sidharth Guglani
67915b5905 Add YogaJniException class
Summary:
## Changelog:
[Internal][Yoga] Add YogaJniException class to be used later for jni exceptions

Reviewed By: astreet

Differential Revision: D18745609

fbshipit-source-id: 53503b54dbc59e9fe47f599dee6be9cb68134cb2
2019-12-02 05:24:53 -08:00
Sidharth Guglani
015df9c512 Remove bitfield.h
Summary:
##Changelog:

[Internal][Yoga] Remove Bitfield.h

Reviewed By: astreet

Differential Revision: D18519647

fbshipit-source-id: b46fe585d3ef5f1da7d2726b2d9f759a649be121
2019-11-27 14:19:47 -08:00
Sidharth Guglani
f7f134274c Remove bitfield from YGNode.h
Summary:
##Changelog:

[Internal][Yoga] remove Bitfield from YGNode.h

Reviewed By: astreet

Differential Revision: D18519633

fbshipit-source-id: b5a7d8d5ee960c5618df382900c4ded3da0587a6
2019-11-27 14:19:46 -08:00
Sergey Ryabov
aeb9549af7 Fix javadocs
Summary: Changelog: [Internal]

Reviewed By: muraziz

Differential Revision: D15538725

fbshipit-source-id: 5cf60f47b07ce355e40d5b064add1df980beed89
2019-11-22 10:25:41 -08:00
Sidharth Guglani
f3498a2959 Remove BItfield from YGLayout.h
Summary:
##Changelog:

[Internal][Yoga] Remove Bitfield from YGLayout

Reviewed By: astreet

Differential Revision: D18519623

fbshipit-source-id: 950b8cb1ca2cd0424b8d8748c4b71336b40fc15f
2019-11-22 04:51:14 -08:00
Sidharth Guglani
9d2ca758fa Remove Bitfield from YGStyle
Summary:
##Changelog:

[Internal][Yoga] Remove Bitfield from YGStyle

Reviewed By: astreet

Differential Revision: D18519614

fbshipit-source-id: 70f18bc679b62712d40d76bd793cf85906b067a1
2019-11-22 04:51:13 -08:00
Sidharth Guglani
9650c1903d converts BitfieldTests to BitUtilsTest
Summary: Use BitUtils for testing bit operations

Reviewed By: astreet

Differential Revision: D18596312

fbshipit-source-id: 83f93cd7f1f056b3f64070debbc452877b44ac7a
2019-11-22 04:51:13 -08:00
Sidharth Guglani
f4840a0148 Added BitUtils
Summary:
Adds BitUtils to be used later instead of Bitfield.h

##Changelog:
[Internal][Yoga] : Adds BitUtils to be used later instead of Bitfield.h

Reviewed By: astreet

Differential Revision: D18519609

fbshipit-source-id: 8353929543505a7d80d66281adb801d34372beed
2019-11-22 04:51:12 -08:00
Sidharth Guglani
198e99d30c Back out "not using templates for updating styles which are used via bitfield"
Reviewed By: astreet

Differential Revision: D18628090

fbshipit-source-id: 9d006534111f10ec25a0d56214792aeb96fbdef9
2019-11-22 04:51:11 -08:00
Sidharth Guglani
cd0191c247 not using templates for updating styles which are used via bitfield
Summary:
We want completely remove usages of Bitfield as it uses templates which bloats binary size
This stack will reduce 2.2 Kb in binary size bringing it down to 61.3KB on armv7

In this diff we are removing usage of template while updating styles.

## Changelog:
[Internal][Yoga] : Not using templates for updating styles

Reviewed By: astreet

Differential Revision: D18519570

fbshipit-source-id: 2324088b8c63154f818b1da1edf24c0533e10082
2019-11-15 06:39:29 -08:00
Sidharth Guglani
7ec0ef8470 add test for margin and padding percent applied on leaf nodes with measure function
Summary: Add tests for using margin and padding percent on nodes with measure function set on them

Reviewed By: alickbass

Differential Revision: D17130693

fbshipit-source-id: 9a5c963671f7649dead459969b008335f15e45ce
2019-11-15 05:13:35 -08:00
Sidharth Guglani
b88cf7ff67 use owner's width for resolving the margin and padding for node
Summary:
The margin and padding are resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages.
Here we were using node's width instead of container width to calculate the margin and padding.

Fixed this to use container's width.

## Changelog:

[General][Yoga] : Fixed an issue where margin and padding were resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages.

Reviewed By: alickbass

Differential Revision: D17130520

fbshipit-source-id: ac904d432f121973e7739debd9136909b5ca1427
2019-11-15 05:13:34 -08:00
Sidharth Guglani
20fe53b254 Add --version-script
Summary: Adds version script to exclude all exported symbols and export only JNI_onLoad

Reviewed By: Andrey-Mishanin

Differential Revision: D18076602

fbshipit-source-id: cac4ef9c800de6a3b2081a1f847fa918687896fe
2019-11-13 16:46:09 -08:00
Sidharth Guglani
f99da09716 Remove useVanillaJNI flag and usage of fbjni in yoga build
Summary:
## Changelog:

[General] [Yoga] - Use vanilla jni instead of fbjni for all the jni communication

Reviewed By: astreet

Differential Revision: D17808005

fbshipit-source-id: 5e9a1ed73978f519c71c248774a28e5a294e7c7f
2019-11-13 15:16:37 -08:00
Sidharth Guglani
5960dd888d Add test for margin top not calculated correctly if defined in percentage
Summary:
Unit tests for margin percent scenario where height was being used instead of width

## Changelog:

[Internal] [Yoga] - Added unit tests for margin percent

Reviewed By: alickbass

Differential Revision: D18448365

fbshipit-source-id: f4404b0c493938fc04dc685e97effa08bfd553b0
2019-11-13 07:25:59 -08:00
Sidharth Guglani
b0a0007d6e using width for calculating margin top percent
Summary:
In Yoga, margin is not calculated correctly when defined in terms of percentage at one place.
According to CSS docs , margin percentage should be calculated according to width of container's block in case of horizontal writing mode. (https://fburl.com/5imus0it)
We were using height of container causing some issues in both android and iOS.

## Changelog:

[Yoga] [Fixed] - margin if defined in percentage should use container's width in horizontal writing mode

Reviewed By: alickbass

Differential Revision: D18395285

fbshipit-source-id: 87ebd013e3cba36da45f6548e4dff1bce69cce9b
2019-11-13 05:29:36 -08:00
Pritesh Nandgaonkar
73a4a6d29f Fixes the Yogakit compilation bug for xcode11
Summary:
This fixes the yogakit compilation bug for xcode 11, where it fails to find swift core frameworks for pure objc project.

https://github.com/Carthage/Carthage/issues/2825
https://twitter.com/krzyzanowskim/status/1151549874653081601?s=21

Also published this podspec on cocoapods and deleted .swift-version file as it was not required, because swift version is mentioned in podspec

Reviewed By: SidharthGuglani

Differential Revision: D18420963

fbshipit-source-id: d617bf643ac6481d6add86e6a4bfadd6e0d0c229
2019-11-11 10:18:52 -08:00
Pritesh Nandgaonkar
0be0e9fc01 Solve lib lint failure
Summary:
This diff solves `pod lib lint` failure.

We want to make a new yoga release, as I landed some changes in its podspec which solves the broken flipper build for xcode 11.

{F221612119}

Reviewed By: passy

Differential Revision: D18382588

fbshipit-source-id: efddfa3e93ca59b79b887d04f83407b004d9a199
2019-11-08 04:03:00 -08:00
Pritesh Nandgaonkar
ddf748a99d Add Swift extension as a separate pod
Summary:
Adds swift extension file as a separate subspec, as it is not required for the objc projects.

Also this fixes the current issue where the flipper sample app fails to build on xcode 11, as it fails to link the Swift specific literals.

Fixes this too https://github.com/facebook/yoga/issues/565

Reviewed By: SidharthGuglani

Differential Revision: D18373993

fbshipit-source-id: 0c058886a837c7ceafcd0167f878b3e0f7763aa1
2019-11-07 10:51:42 -08:00
Sidharth Guglani
4d16ee4ed4 Use double for YGRoundValueToPixelGrid calculations
Summary:
Use double for YGRoundValueToPixelGrid calculations as we were losing some precision in float operations

#Changelog:
[Internal][Yoga] Use double for YGRoundValueToPixelGrid calculations

Reviewed By: astreet

Differential Revision: D18225999

fbshipit-source-id: 69c05f56a0e0f3433bf0bd958aa07d26dd83fe02
2019-11-05 17:26:00 -08:00
Dmytro Kasianchuk
b72efaaaca Added missing YOGA_EXPORT
Summary:
Added missing YOGA_EXPORT

#Changelog:
[Internal] [Fixed] - Added missing YOGA_EXPORT

Reviewed By: SidharthGuglani

Differential Revision: D18289071

fbshipit-source-id: a2e16a59427aa33b34b3d1fab9d1088904ee62f5
2019-11-02 20:43:17 -07:00
Sidharth Guglani
6327893b9b Use compiler flags -ffunction-sections, -fdata-sections and gc sections in both jni and core
Summary: Use compiler flags -ffunction-sections, -fdata-sections and  -Wl,--gc-sections  in both jni and yoga core

Reviewed By: amir-shalem

Differential Revision: D18029671

fbshipit-source-id: 5192fb6d682248b16781dead0d7b0a0377861fb6
2019-11-01 11:54:45 -07:00
Sidharth Guglani
8c3ee81d6e Use compiler flag -fvisibility=hidden
Summary:
Using compiler flag -fvisibility=hidden and explicitly setting visibility to default to public methods

#Changelog:
[Internal] [Yoga] Use compiler flag -fvisibility=hidden for reducing yoga binary size

Reviewed By: astreet

Differential Revision: D18029030

fbshipit-source-id: 545e73f9c25f3108fc9d9bb7f08c157dbc8da005
2019-11-01 11:54:45 -07:00
Scott Wolchok
fb07dcff40 Fix data race with gCurrentGenerationCount
Summary:
Yoga layout can be invoked on multiple threads, and gCurrentGenerationCount is a shared global without synchronization.

Changelog: [General] [Fixed] - Fix an internal thread safety issue in Yoga

Reviewed By: SidharthGuglani

Differential Revision: D18092734

fbshipit-source-id: 85753d139549b4e5507f97a56d589fb6854557fa
2019-10-28 12:54:52 -07:00
Sidharth Guglani
27f42c90db Remove setStyleInputs API
Summary:
setStyleInputs batching API was added to reduce the number of jni calls and although it improved performance in yoga world but was not impactful in litho and is not used anywhere.

Removing this saves around 500 bytes per architecture

#Changelog:
[Internal][Yoga] Removed unused code setStyleInputs batching API form Yoga

Reviewed By: amir-shalem

Differential Revision: D18036536

fbshipit-source-id: 7436b55dcd464dd9f9cc46406d4fd78d12babe55
2019-10-23 02:38:03 -07:00
Sidharth Guglani
688bd4ef72 Add exception handling in vanilla jni
Summary:
Exception handling in vanilla jni

## Changelog:
[Internal] [Added] Added exception handling for vanilla jni implementation in yoga

Reviewed By: amir-shalem

Differential Revision: D18036134

fbshipit-source-id: 965eaa2fddbc00b9ac0120b79678608e280d03db
2019-10-22 11:01:00 -07:00
Andres Suarez
42bba10894 Tidy up license headers
Summary: Changelog: Tidy up license headers

Reviewed By: SidharthGuglani

Differential Revision: D17919414

fbshipit-source-id: 0501b495dc0a42256ca6ba3284a873da1ab175c0
2019-10-15 10:36:38 -07:00
Sidharth Guglani
495d8da596 useVanilla flag for measure and baseline methods as well
Summary: UseVanillaJNI flag was missing for measure and baseline functions

Reviewed By: amir-shalem

Differential Revision: D17868201

fbshipit-source-id: 95d6843d643e90157a51550d6efbf059f0ca2c39
2019-10-11 02:04:02 -07:00
Sidharth Guglani
869a33eb13 no need to pass env to ref method , we can directly use getCurrentEnv()
Summary: We can use getCurrentEnv() instead of passing environment variable around

Reviewed By: amir-shalem

Differential Revision: D17842042

fbshipit-source-id: 185b174ae7c08e746bc76c0600c2e326b15c4993
2019-10-10 05:33:20 -07:00
Sidharth Guglani
050893f15a rename PtrJNodeMap to PtrJNodeMapVanilla in yoga vanilla jni files
Summary: Rename PtrJNodeMap in vanilla files top PtrJNodeMapVanilla , otherwise they conflict

Reviewed By: amir-shalem

Differential Revision: D17842001

fbshipit-source-id: eb164076ee2a68d79dc376826508a4143056ea31
2019-10-10 05:33:19 -07:00
Sidharth Guglani
8aa67abdb2 Fix YGNodeJobject method
Summary: We can use getCurrentEnv() , no need to pass env around methods

Reviewed By: amir-shalem

Differential Revision: D17841281

fbshipit-source-id: a4a58292e70ac05b0f0b9eb962a82a8501ad0226
2019-10-10 05:33:19 -07:00
Sidharth Guglani
2e321fc69f Move JNI_OnLoad to separate file which registers both fbjni and jni methods
Summary: Move JNI_ONLoad to a separate file so that both fbjni native methods and vanillla jni native methods can be initialized correctly

Reviewed By: amir-shalem

Differential Revision: D17840166

fbshipit-source-id: 045df0df7a95bc331cbbefb3a118a349f3029465
2019-10-10 05:33:18 -07:00
Amir Shalem
aa2610c2dd Set missing useVanillaJNI in constructor for YogaNode
Summary: set missing useVanillaJNI, it was causing part of the unit-tests to run in fbjni instead of vanillajni.

Reviewed By: SidharthGuglani

Differential Revision: D17852635

fbshipit-source-id: 5bc187d90fbdc430015be55a015a7d1e0ba0ebc6
2019-10-10 02:45:00 -07:00
Sidharth Guglani
293b657aef Use TestParametrization for testing both fbjni and vanillaJNI version
Summary: Use TestParametrization to test both fbjni and vanilla jni versions

Reviewed By: amir-shalem

Differential Revision: D17788718

fbshipit-source-id: 0f3317b7403cadca7b7ccd9140f1933d746bf433
2019-10-09 09:28:41 -07:00
Sidharth Guglani
d6591439d1 move YGSetLogger and YGConfigFree with global ref to vanilla jni
Summary: Move YGSetLogger and YGConfigFree methods to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17754999

fbshipit-source-id: 8dfcf1a54e4d54ebf91e38c6513e6a703a40ae92
2019-10-09 09:28:41 -07:00
Sidharth Guglani
2ef674edd3 move measure and baseline methods
Summary: Measure and baseline callbacks moved to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17714334

fbshipit-source-id: dafbde36984aba948a6345a21d3808a6ef4013e8
2019-10-08 17:51:35 -07:00
Sidharth Guglani
22a60e82b0 move yg node new and ygnode new with config
Summary: YGNode creation methods to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17714230

fbshipit-source-id: 74e14e876ab7efc67771d92091c2a78f09072b83
2019-10-08 17:51:34 -07:00
Sidharth Guglani
34739ec652 Move calculate layout method to vanilla JNI
Summary: Using vanilla JNI for calculate layout

Reviewed By: amir-shalem

Differential Revision: D17714219

fbshipit-source-id: bb05de4a0112eefc2b731997a4c1ecef5c0c7361
2019-10-08 17:51:34 -07:00
Sidharth Guglani
b9b0217a07 Add Scoped Local and Global Ref
Summary: Add ScopedLocalRef, ScopedGlobalRef and some common methods to be used later.

Reviewed By: amir-shalem

Differential Revision: D17711284

fbshipit-source-id: be43d5e246bc2406765057783be11854877c41f1
2019-10-08 17:51:33 -07:00
Sidharth Guglani
7c2683fe52 move setStyleInputs to vanilla jni (YogaStyleProperties Part 5)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17686117

fbshipit-source-id: e79bee1188c24e301b23416486b10f613434eebc
2019-10-08 14:37:27 -07:00
Sidharth Guglani
ee73f556b4 move config jni methods to vanilla jni
Summary: Move yoga node config related jni methods to vanilla jni

Reviewed By: amir-shalem

Differential Revision: D17684821

fbshipit-source-id: 31a667b3ad67501aaef83a132971e4e0826cacd4
2019-10-08 14:37:26 -07:00
Sidharth Guglani
34b68cf1d2 move YGNode related methods to vanilla jni
Summary: This diff moves methods related to actions on YGNode like free node, reset node etc. to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17668008

fbshipit-source-id: 03bfc51ec1fcf06569713400f984d551827e22fe
2019-10-08 14:37:26 -07:00
Sidharth Guglani
8975019269 move edge style properties to vanilla jni (YogaStyleProperties Part 4)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17667201

fbshipit-source-id: 448134d6d7d0dd0c6ff2734b3eb39e65d1cb403f
2019-10-08 14:37:25 -07:00
Sidharth Guglani
6e6b1369ac move percent auto style properties to vanilla jni (YogaStyleProperties Part 3)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666674

fbshipit-source-id: 08490bf7c214c856a93214088a27dd4e6df9e0fd
2019-10-08 14:37:25 -07:00
Sidharth Guglani
25b8c94788 move common code to YGJNI.h header class
Summary: Moving common code to YGJNI.h header class so that same can be used in fbjni and vanilla jni implementations

Reviewed By: amir-shalem

Differential Revision: D17666457

fbshipit-source-id: 1e6cd2506fb773b8a17ebef277a2c7ef9728e66b
2019-10-08 14:37:24 -07:00
Sidharth Guglani
3fce27c48c Migrate YGNodeStyleGetFlex method to vanilla jni (YogaStyleProperties Part 2)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666090

fbshipit-source-id: 121b939c310799c79f2fce0ea293f88b2940c4fc
2019-10-08 14:37:24 -07:00
Sidharth Guglani
32a973ebd1 Move style properties which accept one parameter to vanilla JNI (YogaStyleProperties Part 1)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666048

fbshipit-source-id: 6565acd35ab04ef0c3a2544447a25dc6edc3e7a5
2019-10-08 14:37:24 -07:00
Andres Suarez
c37f5956e4 Fix license headers
Reviewed By: scottrice

Differential Revision: D17673223

fbshipit-source-id: 42a3a25934ef63b24ebf9f5f1909cb562d0d4172
2019-09-30 15:09:48 -07:00
Sidharth Guglani
0875b6b542 Add boolean flag to decide whether to use fbjni or jni
Summary:
Adds a flag useVanillaJNI in YogaConfig to determine whether to use FbJNI or JNI.
Currently default is set to false.

We will experiment based on this flag once all code have been migrated.

Reviewed By: Andrey-Mishanin

Differential Revision: D17601703

fbshipit-source-id: 377a5bd2a6f8a7584e84932e87fa7044d8165efd
2019-09-26 17:34:18 -07:00
Sidharth Guglani
b29e144649 Add separate classes to implement JNI methods suing vanilla JNI
Summary:
This diffs adds a separate file YGJNIVanilla.cpp to add jni methods which uses vanilla JNI instead of FBJNI.
In this diff only one method has been added to setup the experiment boolean setup.

At the end of this diff stack , we will be able to experiment between fbjni and vanilla jni in yoga and finally get rid of fbjni which saves us around 300Kb per architecture in yoga binary size.

Reviewed By: Andrey-Mishanin

Differential Revision: D17601591

fbshipit-source-id: a88520c625bd8b5d9ffcf8ab5f02fc71dc800081
2019-09-26 17:34:17 -07:00
Uts Sikder
f00116c3a6 BREAKING: rm YogaNode parameter from YogaLogger#log
Summary:
In D17439957, I noted that YogaLogger#log throws a NoMethodFoundException when called from C++ b/c C++ and Java's signatures of that method don't match. C++ uses YogaNodeJNIBase for the first param, Java uses YogaNode. Both my attempts to fix this failed.

Attempt #1 - Make Java use YogaNodeJNIBase. This doesn't work because the :java-interface target includes YogaLogger but not YogaNodeJNIBase. Moving YogaLogger to the impl target doesn't work either b/c other files in :java-interface reference YogaLogger.

Attempt #2 - Make C++ use YogaNode. This doesn't work b/c we try to call the log method with objects of fbjni type YogaNodeJNIBase. This would be fine in Java since YogaNodeJNIBase extends YogaNode. But fbjni's typing isn't advanced enough to know this, so the Yoga C++ fails to compile.

At this point, I was wondering what the value of having this param in the log function at all was. None of the implementations in our codebase use it today. It might be easier to just remove it all together. This also removes a bug with YGNodePrint where we pass a null layout context that eventually causes a SIG_ABRT when we use it to try to find a YogaNode to pass to this function. (https://fburl.com/diffusion/ssw9h8lv).

Reviewed By: amir-shalem

Differential Revision: D17470379

fbshipit-source-id: 8fc2d95505971a52af2399a9fbb60b63f27f0ec2
2019-09-25 09:15:45 -07:00
Amir Shalem
f1baf8336b Use direct access to YogaConfig mNativePointer parameter
Summary:
Use direct access to YogaConfig mNativePointer parameter

Results:
```
The following primary metrics showed statistically significant changes at the 95% confidence level:
javaFullLifecycleAllocateCalculateReadLayout	-1.25%
javaLayoutReading	0.44%
javaYogaNodeAllocateAndSetProps	-1.92%
javaYogaNodeAllocation	-2.11%
javaYogaNodeStylePropAssignment	-0.89%
```

Differential Revision: D17519542

fbshipit-source-id: c39bfe1b0ecae9149dc6da2a0a7e936df215ec5b
2019-09-22 13:53:06 -07:00
Uts Sikder
36eae205e1 fix type mismatches in YogaLogger#log function
Summary: This diff fixes two issues with the JNI integration of YogaLogger#log. (1) The YogaLogger class descriptor was missing a semicolon. This causes a ClassNotFoundException whenever you try to call the log method from C++. (2) The C++ signature for the class was using YogaNodeJNIBase as an arg but the Java signature was using YogaNode. This causes a MethodNotFoundException whenever you try to call the method after fixing problem 1.

Reviewed By: astreet

Differential Revision: D17439957

fbshipit-source-id: be3c16512558050265565b3688fb09a7da31b9b2
2019-09-18 21:32:09 -07:00
Amir Shalem
ad5b3410f0 Remove dead code of mYogaNodeCloneFunction
Summary: Code cleanup, remove mYogaNodeCloneFunction completely and its `YogaNodeCloneFunction`

Reviewed By: SidharthGuglani

Differential Revision: D17284191

fbshipit-source-id: 36dae0c0548cfdd3e85182a8e3c6ff9a2d3a5011
2019-09-18 05:52:56 -07:00
Amir Shalem
e2dbff0ca6 Split interface and jni java target
Summary:
Split the yoga buck targets from interface to actual implementation.

This is currently done without moving any files folder, since only we will make the distinction between interface<-->implementation only this buck target (and not in the litho/reactnative yoga copies).

Buck does insures that the `java-interface` is pure since it doesn't depend on any fbjni code.

Reviewed By: SidharthGuglani

Differential Revision: D17266406

fbshipit-source-id: 46aa469b74c2c3114f1d3d762c41d32cfe269f57
2019-09-18 00:40:28 -07:00
Amir Shalem
96eb94afd0 Remove YogaNode.create() from the abstract class
Summary:
Remove YogaNode.create() from the abstract class after we made sure nothing uses it anymore
This is the final stage to make `YogaNode` a pure class without JNI references

Reviewed By: SidharthGuglani

Differential Revision: D17280571

fbshipit-source-id: bd0eb138f7a6a9de8988fc0a7b90badbf635dac5
2019-09-18 00:40:27 -07:00
Amir Shalem
9100019c0a Split YogaConfig into interface and actual implementation
Summary:
Split YogaConfig into the same way YogaNode is split today.

Into an abstract class defining the interface, and actual JNI implementation

Reviewed By: SidharthGuglani

Differential Revision: D17266404

fbshipit-source-id: 3d5d6aa65c55cfa61d47c662d140cdce6dcb0ea1
2019-09-18 00:40:27 -07:00
Sidharth Guglani
21f814b2a6 remove infer-annotations dependency (#922)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/922

We are not using this dependency anywhere in yoga. Removed in this diff.

Reviewed By: passy

Differential Revision: D17131081

fbshipit-source-id: 5544b892f4ef5ca0207d9e21a5b97a2940ac6d53
2019-09-17 12:08:19 -07:00
Amir Shalem
499d28d021 Expose native pointer thru an interface function for YogaConfig
Summary:
Expose native pointer thru an interface function for YogaConfig (its package private to `com.facebook.yoga` namespace),
This way we can make later on YogaConfig a pure abstract class.

Plus, it makes sure external users don't modify the pointer

Reviewed By: SidharthGuglani

Differential Revision: D17266401

fbshipit-source-id: f39b488cea0b73bc3578bb3aa90ab00139bf9271
2019-09-17 07:15:24 -07:00
Amir Shalem
d697bbe0a5 Switch to YogaConfigFactory.create
Summary: Switch to `YogaNodeFactory.create()` instead of using `YogaNode.create()`

Reviewed By: SidharthGuglani

Differential Revision: D17266408

fbshipit-source-id: 69e1e59c7345d16eb174af97c2e231666a02354b
2019-09-17 07:15:23 -07:00
Amir Shalem
67a3841164 Switch to YogaNodeFactory.create
Summary: Switch to `YogaNodeFactory.create()` instead of using `YogaNode.create()`

Reviewed By: SidharthGuglani

Differential Revision: D17258195

fbshipit-source-id: 5f31540724a16e401fcd0fbdf19a4baa354b2d72
2019-09-17 07:15:23 -07:00
Sidharth Guglani
6ac38d188c use implementation instead of compile for yoga dependencies
Summary: Use implementation instead of compile in build.gradle

Reviewed By: passy

Differential Revision: D17343602

fbshipit-source-id: a2ec21a46ebbf3feb5dcc0d9ae2684f8efb096e3
2019-09-16 09:14:28 -07:00
Sidharth Guglani
8216c54b05 update build tools versions
Summary:
Update build tools version to 28.0.3 to fix the below warning

WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.

Reviewed By: passy

Differential Revision: D17343575

fbshipit-source-id: aa12bf2b55666aacb18f09b1cca22eab05f38220
2019-09-16 09:14:28 -07:00
Sidharth Guglani
968c075e39 bump version to 1.16.0-SNAPSHOT
Summary: Bump version to 1.16.0-SNAPSHOT for new yoga release

Reviewed By: amir-shalem

Differential Revision: D17396540

fbshipit-source-id: ddd01454752d88548ae7490cfd9fccfb8c591ec9
2019-09-16 08:25:31 -07:00
Sidharth Guglani
26dbe8b4ff bump version to 1.16.0
Summary: Bump version to 1.16.0 for new yoga release

Reviewed By: amir-shalem

Differential Revision: D17395785

fbshipit-source-id: b01b31d58b5b1a2a9532e9cce0892c08960ec31c
2019-09-16 07:48:59 -07:00
Sidharth Guglani
a5c2f7f27a fix yoga build issue Could not find yoga:libfb:unspecified.
Summary:
Fixes the yoga build 1:15:0 build issue

    Could not find yoga:libfb:unspecified.
    Required by:
    project :app > com.facebook.yoga:yoga:1.15.0

libfb dependency was added to solve import issue in YogaPhantomJNIRefs but since we don't have that file now in codebase , it will not be a problem.

Reviewed By: amir-shalem

Differential Revision: D17395380

fbshipit-source-id: ab8eb2c89afe29b4688787db2214c328d875041e
2019-09-16 05:25:39 -07:00
Sidharth Guglani
10811e1a94 bump version to 1.15.0-SNAPSHOT
Summary: Bumping version to 1.15.0-SNAPSHOT

Reviewed By: amir-shalem

Differential Revision: D17394807

fbshipit-source-id: 2ba8ecbb903b9810905fabf3b60efaa8458b6bfd
2019-09-16 04:37:39 -07:00
Sidharth Guglani
10f4bceac0 bump version to 1.15.0
Summary: Bumping version to 1.15.0 for new yoga release

Reviewed By: amir-shalem

Differential Revision: D17394805

fbshipit-source-id: de43e97a0c155f332ecbe4e98b78c2f7c9ffe771
2019-09-16 03:42:43 -07:00
Sidharth Guglani
47717324d4 fix fbjni and yoga event files not found in testutil issue
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/928

Reviewed By: amir-shalem

Differential Revision: D17383979

fbshipit-source-id: 755c2cc3749d5e23fbd1e0ac7a41632c1400ae24
2019-09-15 13:54:06 -07:00
Amir Shalem
1043c35f2b Fix libfbjni compilation (#927)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/927

When D16220924 brought a new fbjni copy (with new directories), we forgot to fix the cmake files which are used by gradle build system.

Reviewed By: SidharthGuglani

Differential Revision: D17367160

fbshipit-source-id: 3e7d20d4c53ff3012a164bf6e32f1000ecb3ffc2
2019-09-13 09:21:06 -07:00
Amir Shalem
fde89b056d Add standalone factory classes which generate YogaNode + YogaConfig
Summary:
Add standalone factory classes which generate YogaNode + YogaConfig, later on it will allow us to separate the yoga interface and actual implementation buck targets (see D17266406)

We've done such breakage change previously in D14122974.

Reviewed By: SidharthGuglani

Differential Revision: D17258196

fbshipit-source-id: b12f1a0d23c3f82b14cee0731a1daf1c015ee32c
2019-09-12 06:05:02 -07:00
Sidharth Guglani
a08a57b33c Remove unused YogaNodeJNIPhantomRefs.java
Summary:
Removed unused file YogaNodeJNIPhantomRefs.java as this was causing oss build failures because of an import.

````:yoga:compileDebugJavaWithJavac/home/travis/build/facebook/yoga/java/com/facebook/yoga/YogaNodeJNIPhantomRefs.java:9: error: package com.facebook.jni does not exist
import com.facebook.jni.DestructorThread;
                       ^
/home/travis/build/facebook/yoga/java/com/facebook/yoga/YogaNodeJNIPhantomRefs.java:30: error: package DestructorThread does not exist
    new DestructorThread.Destructor(node) {
                        ^
2 errors
 FAILED

Reviewed By: pasqualeanatriello

Differential Revision: D17257330

fbshipit-source-id: 98b0c5d5b7dcd94bee559b58194c13b07f47723d
2019-09-11 10:28:56 -07:00
Amir Shalem
31de91bbac fix gradle compliation (#925)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/925

Gradle is failing to compile yoga for two reasons:
1. Ever since `YogaNodeJNIPhantomRefs` was introduced which uses `DestructorThread.Destructor` from fbjni which was the first direct Java dependency from yoga java to fbjni java code.

2. Adding a missing gradle endpoint for `testutil` since it is now required for yoga unit-tests

Reviewed By: SidharthGuglani

Differential Revision: D17274226

fbshipit-source-id: 3df9648321162d34f81fd3675ca1474e8a1c6d3a
2019-09-10 08:18:56 -07:00
Sidharth Guglani
e6e224ce48 Add dist: trusty to yoga travis configuration
Summary:
clang 6.0 install was failing in yoga oss tests

Travis has made xenial as default distribution
https://changelog.travis-ci.com/xenial-as-the-default-build-environment-is-coming-97772

Added dist: trusty to the configuration to fix this.

Reviewed By: passy

Differential Revision: D17257300

fbshipit-source-id: f9fcd6ba774dad1c28bd953c0d850c7078d02015
2019-09-09 03:34:52 -07:00
Paul O'Shannessy
a04a6b5e8f Adopt Contributor Covenant
Summary:
In order to foster healthy open source communities, we're adopting the
[Contributor Covenant](https://www.contributor-covenant.org/). It has been
built by open source community members and represents a shared understanding of
what is expected from a healthy community.

Reviewed By: josephsavona, danobi, rdzhabarov

Differential Revision: D17104640

fbshipit-source-id: d210000de686c5f0d97d602b50472d5869bc6a49
2019-08-29 23:48:24 -07:00
Pascal Hartig
442d84ccfc Remove built-in DoNotStrip annotations
Summary:
Use the Yoga dependency instead which can be deduplicated by Gradle.

This solves (parts of) a bunch of issues concerning the use of
multiple FB libraries in one Android project.

Reviewed By: danielbuechele

Differential Revision: D16783243

fbshipit-source-id: 7f7915821dd286c51ec4ccbd95a2cdcb18b53bde
2019-08-15 04:21:56 -07:00
Pascal Hartig
4a2ccc658e Target Java 7
Summary: The artifacts generated otherwise can cause issues in Android projects.

Reviewed By: SidharthGuglani

Differential Revision: D16803253

fbshipit-source-id: db139560dfbddb917c27bdfd80e1bf5747e4a74b
2019-08-14 05:37:32 -07:00
Pascal Hartig
58622fa747 Set up proguard-annotations as separate Maven artifact
Summary:
We need one place, any place really, to publish that good old `DoNotStrip` annotation
from that we currently copy across various repos, causing havoc for anybody who
tries to integrate more than one FB Android library into their project.

Yoga is very well positioned for this because it's already its own Gradle module and
all that's missing are these few lines.

Reviewed By: SidharthGuglani

Differential Revision: D16783035

fbshipit-source-id: 69b6224a725194d036c6a23a36bd76d3487b9811
2019-08-13 06:26:15 -07:00
Sidharth Guglani
90cded3819 use array for passing measure callback reasons count
Summary:
Use an array for counting measure callbacks due to each reason.
and this is now added as qpl metadata in Layout Calculation qpl event

Reviewed By: davidaurelio

Differential Revision: D16666786

fbshipit-source-id: ff85fba835148f06b9c5d90c4604e552a813777a
2019-08-08 07:18:03 -07:00
Adlai Holler
d1e188341b Don't copy children in YGNodeComputeFlexBasisForChildren (#919)
Summary:
No need for a copy here.
Pull Request resolved: https://github.com/facebook/yoga/pull/919

Differential Revision: D16701461

Pulled By: davidaurelio

fbshipit-source-id: 3a90adbb2b5c43d5aefe693a8525aa3a37e53b3d
2019-08-08 00:24:07 -07:00
Nicola Ferruzzi
0f2350308e Properly test for the lack of a node measure func in YogaKit (#915)
Summary:
The test was broken and caused a few crashes on my project.
Pull Request resolved: https://github.com/facebook/yoga/pull/915

Differential Revision: D16701613

Pulled By: davidaurelio

fbshipit-source-id: 9ab5c43bb74e77593bc2426a249750a7ee8f4034
2019-08-08 00:10:25 -07:00
Luis Miguel Alvarado
9b120eded9 add space-evenly prop to justify-content.md (#918)
Summary:
This PR add the `space-evenly` prop, to the [justify-content.md](https://github.com/facebook/yoga/blob/master/website/contents/properties/justify-content.md) file.

The description was taken from [Mozilla](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
Pull Request resolved: https://github.com/facebook/yoga/pull/918

Differential Revision: D16701547

Pulled By: davidaurelio

fbshipit-source-id: cd1bb7dd20cb1184a1bafb0d8f33e851051bd9e5
2019-08-08 00:01:12 -07:00
Tim
a218880216 Fix compilation with CMake (#909)
Summary:
This adds the root of the source tree to the include path, which allow `#include <yoga/YGEnums.h>` to work.

Fixes https://github.com/facebook/yoga/issues/908
Pull Request resolved: https://github.com/facebook/yoga/pull/909

Differential Revision: D16701716

Pulled By: davidaurelio

fbshipit-source-id: 0fdc6479e4f3119a3e4ddbcd4b48541b282c1bbd
2019-08-07 23:53:44 -07:00
Denis
1a2802028b Update link: (#920)
Summary:
Update link for component kit on docs to `https://componentkit.org/docs/getting-started/`
Pull Request resolved: https://github.com/facebook/yoga/pull/920

Differential Revision: D16701505

Pulled By: davidaurelio

fbshipit-source-id: 10f7df4f7aa29d884d21135a92041b0630e1a31e
2019-08-07 19:51:39 -07:00
Tim
a37b286bae Yoga is written in C++ (#907)
Summary:
As far as I can tell now. Would be nice if you had an actual changelog somewhere!
Pull Request resolved: https://github.com/facebook/yoga/pull/907

Differential Revision: D16701738

Pulled By: davidaurelio

fbshipit-source-id: cf32dc96eca5258979bcaa9947d6ed6b5496398d
2019-08-07 19:44:24 -07:00
David Aurelio
dcfdb955b3 Back out "[Yoga] Experiment: double invocations of measure callbacks"
Summary:
Removes the double measure callbacks experiment
Original commit changesets: c6cf9c01a173,  b157d8137c72

Reviewed By: SidharthGuglani

Differential Revision: D16687367

fbshipit-source-id: 9649f8731bd1b27f4d291cee4fa30153165cea02
2019-08-07 18:24:32 -07:00
David Aurelio
72cefead02 Use Bitfield in YGLayout
Summary: Replaces the usage of C++ bitfields with our portable `Bitfield` class.

Reviewed By: SidharthGuglani

Differential Revision: D16656361

fbshipit-source-id: 05f679e2e994e109b2bd1090c879d6850fabdc40
2019-08-07 16:29:04 -07:00
David Aurelio
884e064a99 Use Bitfield in YGNode and YGStyle
Summary:
@public

Replaces the usage of C++ bitfields with our portable `Bitfield` class.

Reviewed By: SidharthGuglani

Differential Revision: D16649875

fbshipit-source-id: 539f016d5e1c9a8c48cc9bacbbf6ed985e385e69
2019-08-07 16:29:03 -07:00
David Aurelio
3ed9bec05c Remove style property bitmask
Summary:
@public

Removes the style properties bitmask. We have used this for experimentation, and it's no longer necessary.

This simplifyies the code, and allows us to cut over to `Bitfield.h` more easily.

Reviewed By: astreet

Differential Revision: D16648862

fbshipit-source-id: 17c0899807af976f4ba34db54f8f0f6a3cd92519
2019-08-07 16:29:03 -07:00
David Aurelio
dadf0473b7 Add portable bit field implementation
Summary:
@public
Our usage of C++ bit fields has lead to quite some problems with different compiler setups. Problems include sign bits, alignment, etc.

Here we introduce a portable implementation as a variadic template, allowing the user to store a number of booleans and enums (defined with `YG_ENUM_SEQ_DECL`) in an unsigned integer type of their choice.

This will replace all usages of bit fields across the Yoga code base.

Differential Revision: D16647801

fbshipit-source-id: 230ffab500885a3ad662ea8f19e35a5e9357a563
2019-08-07 16:29:02 -07:00
Daniel Büchele
947230958d make npm module
Summary: We want to use the yoga playground as a standalone package as well. This adds a webpack config to bundle the playground for npm. The package can then be distributed as `yoga-playground` via npm

Reviewed By: fabiomassimo

Differential Revision: D16583334

fbshipit-source-id: 84807ddd8983ba9f0fb43570b518c975f35544ab
2019-08-01 04:15:25 -07:00
Sidharth Guglani
095c991b85 Added counts for measure callbacks reasons in an array inside qpl annotations
Summary:
Added an array to maintain the counts of each of the reason of measure callbacks
and this is now added as qpl metadata in Layout Calculation qpl event

Reviewed By: davidaurelio

Differential Revision: D16516379

fbshipit-source-id: 201c5d2463f0a921841a0bbfec8f4d5e007000c8
2019-07-31 14:37:37 -07:00
Sidharth Guglani
825da1e868 create two layout pass reason flexLayout and flexMeasure instead of flex
Summary:
We had flex as a reason for both layout and measure. Now creating separating reason flexLayout and flexMeasure in this diff.

Also changed ordering of items in Enum to group layout and measure reasons

Reviewed By: davidaurelio

Differential Revision: D16562350

fbshipit-source-id: 75501f9d4dde0974009193b3991a8acc97b02ad0
2019-07-31 14:37:36 -07:00
Sidharth Guglani
5a25805cb5 Update flow-copy-source to use latest version
Summary:
Fixes vulnerability in mem dependency by updating the version of flow-copy-source in javascript/yarn.lock
da4e4398cb

Reviewed By: danielbuechele

Differential Revision: D16542191

fbshipit-source-id: e900ac2d358883fc269688b93faad3ffbec10f0d
2019-07-31 06:48:07 -07:00
Sidharth Guglani
adff8d96dd remove getInstanceCount usages
Summary:
This diffs removes the usages of getInstanceCount as it has been removed from yoga.
We will add event support in js later to handle these test cases

Reviewed By: davidaurelio

Differential Revision: D16560269

fbshipit-source-id: 52590c426faf87209f8635602b401fd5760af8ab
2019-07-31 06:48:06 -07:00
Sidharth Guglani
8c270e68cc add subdirectories of yoga also to js sources
Summary: Update build file to include subdirectories of yoga also in sources

Reviewed By: davidaurelio

Differential Revision: D16560253

fbshipit-source-id: 5dee4379912e003d4a1fa611882fbf736321615c
2019-07-31 06:48:06 -07:00
Samuel Susla
a2aa1b7fca Fix onDismiss in Modal
Summary:
# Disclaimer:
I might be missing something as the solution I implemented here seems like something that was considered by original author. If this solution isn't good, I have a plan B.

# Problem:
`onDismiss` prop isn't being called once the modal is dismissed, this diff fixes it.

Also I've noticed that `onDismiss` is meant to only work on iOS, why is that? By landing this diff, it'll be called on Android as well so we need to change the docs (https://facebook.github.io/react-native/docs/modal.html#ondismiss).

## Video that shows the problem
Following code is in playground.js P70222409 which just increments number everytime onDismiss is called

{F166303269}

Reviewed By: shergin

Differential Revision: D16109536

fbshipit-source-id: 3fba56f5671912387b217f03b613dffd89614c9d
2019-07-29 11:18:00 -07:00
Min ho Kim
ae956f06fb Fix typos (#25770)
Summary:
Fix typos mostly in comments and some string literals.

## Changelog

[General] [Fixed] - Fix typos
Pull Request resolved: https://github.com/facebook/react-native/pull/25770

Differential Revision: D16437857

Pulled By: cpojer

fbshipit-source-id: ffeb4d6b175e341381352091134f7c97d78c679f
2019-07-23 03:24:00 -07:00
David Aurelio
8c0eed3c75 Add PhantomRef based YogaNode subclass
Summary: Adds a subclass of `YogaNodeJNIBase` that uses `PhantomReference` for deallocating native memory rather than `Object#finalize()`. This should help making garbage collection more efficient.

Reviewed By: amir-shalem

Differential Revision: D16182667

fbshipit-source-id: d310fdb6af184168c43462b24f5e18ab5d0d7ad0
2019-07-19 17:24:49 -07:00
David Aurelio
4e4ef06de1 Implement double measure experiment
Reviewed By: SidharthGuglani

Differential Revision: D16340462

fbshipit-source-id: b157d8137c72f83a3bea46f30d0f46f65055f9ef
2019-07-19 10:40:17 -07:00
David Aurelio
a53c14dc75 Add internal experiments API
Summary: Adds internal API that we can use to conduct experiments.

Reviewed By: SidharthGuglani

Differential Revision: D16340463

fbshipit-source-id: 07a8bb7dbc4a02c5c95f1ad29b18845ab43752cf
2019-07-19 10:40:16 -07:00
Sidharth Guglani
c99fc9c4da using enum struct for LayoutPassReason and LayoutType
Summary: Using enum struct for using enums in form ENUM_NAME::ENUM_VALUE for better code readablility

Reviewed By: davidaurelio

Differential Revision: D16356562

fbshipit-source-id: cbe7adadad78eb5d0756c44679c0e102b7d31ec6
2019-07-18 07:04:47 -07:00
Uladzislau Paulovich
2fb857d73d yoga | Fix error about implicit conversion to bit-field
Summary:
`YGStyle` puts Yoga enums (which are signed integers by default) into bitfields: https://fburl.com/7fowlunu

Mixing signed values and bit-fields can be error-prone and it also fails to build on Windows with `clang-cl` due to `-Wbitfield-constant-conversion` warning being treated as error:

```
stderr: In file included from xplat\yoga\yoga\YGLayout.cpp:8:
In file included from xplat\yoga\yoga/Utils.h:8:
In file included from xplat\yoga\yoga/YGNode.h:13:
xplat\yoga\yoga/YGStyle.h(110,9): error: implicit truncation from 'YGAlign' to bit-field changes value from 4 to -4 [-Werror,-Wbitfield-constant-conversion]
        alignItems_(YGAlignStretch),
```

This diff fixes the problem by making all enums unsigned integers. This change can be problematic only if values of the enums are serialized somewhere. CC: David Aurelio

Reviewed By: davidaurelio

Differential Revision: D16336729

fbshipit-source-id: ee4dabd7bd1ee429e644bd322b375ec2694cc742
2019-07-18 06:20:18 -07:00
Sidharth Guglani
e6dfe04388 Pass reason for measure pass along with measurecallbackend event (#566)
Summary:
Pull Request resolved: https://github.com/facebook/litho/pull/566

Pull Request resolved: https://github.com/facebook/react-native/pull/25702

Pass reason for each measure callback to the flipper plugin

Reviewed By: davidaurelio

Differential Revision: D16221771

fbshipit-source-id: 2e72e1ebb3c7e633d189e7a7a81d655ac9531e51
2019-07-18 05:21:11 -07:00
Sidharth Guglani
5e40e4b682 remove YGMarker code
Summary: Removes code for now unused marker based approach

Reviewed By: davidaurelio

Differential Revision: D16048800

fbshipit-source-id: 228e0e906252782ee0bed543728b666d1f9cc854
2019-07-17 08:11:38 -07:00
Sidharth Guglani
7c891db9af move YGMarkerMeasure and YGMarkerBaselineFn to event based system
Summary: Using yoga event listener for adding systrace sections for measure and baseline events

Reviewed By: davidaurelio

Differential Revision: D16048795

fbshipit-source-id: 3c2161328250184929ed1a3357b8c42ec8ca2e29
2019-07-17 08:11:37 -07:00
David Aurelio
6d916ab063 Do not depend on libfb
Reviewed By: SidharthGuglani

Differential Revision: D16220913

fbshipit-source-id: c6851d8dbda572aa50117b92353460f8a5b6df36
2019-07-17 06:57:18 -07:00
David Aurelio
59d680f4e9 Upgrade fbjni
Summary:
Upgrades Yoga’s copy of *fbjni* to the latest version.

This will enable us

- to move from `finalize()` to `PhantomReference` to deallocate native memory, with the potential of making GC more efficient.
- to remove the internal dependency to *libfb,* allowing apps without an own dependency to ship less code

Reviewed By: passy

Differential Revision: D16220924

fbshipit-source-id: e8233fe2b5403946ff51f43cb6def558ded52fda
2019-07-17 06:57:18 -07:00
Amir Shalem
be305b5d0f Rename fbjni shared library name to the standard soname
Summary:
Before we can upgrade to latest fbjni, we need to make sure our shared libraries are named the same.

Currently when we compile libfbjni it is named as `liblib_fb_fbjni.so`, where as the regular fbjni is expected to be named as `libfbjni.so`

Reviewed By: davidaurelio

Differential Revision: D16250801

fbshipit-source-id: 9a7f0f803d7e525985b40a49edcc0e660e9025f5
2019-07-17 03:35:31 -07:00
Sidharth Guglani
d676d917e3 moved all yoga node jni batching code to YogaNodeJNIBase and removed subclasses
Summary: Removed classes YogaNodeJNI and YogaNodeJNIBatching and all the logic have been moved to base class

Reviewed By: davidaurelio

Differential Revision: D16221484

fbshipit-source-id: 830819f5bc6010291b8bc0c6d90897cea991909f
2019-07-15 11:16:38 -07:00
Sidharth Guglani
838fc3f019 remove useBatchingForLayoutOutputs config param and start using batching for layout outputs
Summary: Removes config param useBatchingForLayoutOutputs and now we are using batching of layout outputs as float array while passing data from c++ to java

Reviewed By: davidaurelio

Differential Revision: D16221483

fbshipit-source-id: 326c668d4dfd13b2cf031f98a84bfa50b1440513
2019-07-15 11:16:38 -07:00
David Aurelio
296982a29e Enable events in OSS
Summary:
- Events are our new approach to instrumentation, and keeping debug code out of the core library
- This has run internally at FB for some time now
- Enabling for OSS, too, to make Java tests pass

Reviewed By: SidharthGuglani

Differential Revision: D16202541

fbshipit-source-id: c13f5270f04bba59f9f0a06d9c793da92b73d4ff
2019-07-12 01:43:49 -07:00
David Aurelio
1d0668692b Make tests runnable with Buck/OSS again
Summary:
Fixes test execution for open source:

- adds hamcrest jar and dependency, as required by buck (to not throw `"Unable to locate hamcrest on the classpath. Please add as a test dependency."`)
- enables events for OSS, to make tests pass

Reviewed By: SidharthGuglani

Differential Revision: D16202542

fbshipit-source-id: a56069de162f739b3b989961b5dc00f3d37f5849
2019-07-12 01:43:48 -07:00
Sidharth Guglani
39e512f691 Add tests for measure and baseline events
Summary: Add tests for measure and baseline events , same as we had in InstrumentationTests for marker based approach

Reviewed By: davidaurelio

Differential Revision: D16074402

fbshipit-source-id: 8b11cd6468420428701fd5be5c57700cbd913d23
2019-07-10 08:50:44 -07:00
Sidharth Guglani
0f250490d4 add baseline start and baseline end events
Summary: Adds Baseline start and end events to be handled later for instrumentation

Reviewed By: davidaurelio

Differential Revision: D16048790

fbshipit-source-id: 8409dbb633168753a7bf8fab20bc6551d113ddd6
2019-07-10 08:50:43 -07:00
Sidharth Guglani
eeae39d707 move YGMarkerLayout to event based system
Summary: Using layoutPassStart and LayoutPassEnd events instead of YGMarkerLayout for instrumentation

Reviewed By: davidaurelio

Differential Revision: D16048789

fbshipit-source-id: 041a35bc2cb1b7281ca83cf9d35041b4011cfeb9
2019-07-10 08:50:42 -07:00
Sidharth Guglani
ce517689ff add tests for layoutPassStart and layoutPassEnd
Summary: Add tests for layout pass start and end , same as what we had in InstrumentationTests for marker based approach

Reviewed By: davidaurelio

Differential Revision: D16073121

fbshipit-source-id: 838f01cb2a41d2d2764ba7ce2f317147f737b287
2019-07-10 08:50:42 -07:00
Sidharth Guglani
9c82ba783f Adds typed event test data for test cases
Summary: We are now using custom TypedEventTestData for test cases as we need to copy some data passed from the yoga event system

Reviewed By: davidaurelio

Differential Revision: D16090931

fbshipit-source-id: 4d11bdbdd73b67172ad4bba4b294c71f1c24cc10
2019-07-10 08:50:41 -07:00
James Burnett
1c8e8d3aec Compile Issues with Recent GCC (#895)
Summary:
GCC 8.3.0 (and possibly all gcc 7+) identified several warnings for signed unsigned integer comparison. With `-Werror` enabled this broke compiling tests. I suspect the warning is related to google/googletest#683. This diff updates those `ASSERT_EQ` calls that attempt to compare signed and unsigned errors by specifically declaring the literals to be unsigned.

There is also an issue with Buck where it will not link to pthreads. facebook/buck#1443. Adding a `prebuilt_cxx_library` for pthread fixes that issue and the tests will compile and run.

Finally, there was a warning about a missing return after a switch in `InstrumentationTest.cpp`. I added a `return ""` as a default, but it might be better to throw something. Thoughts?
Pull Request resolved: https://github.com/facebook/yoga/pull/895

Reviewed By: davidaurelio

Differential Revision: D15393082

Pulled By: davidaurelio

fbshipit-source-id: 4f13ec2f016af39537c08fb591b188a6a0ed55ce
2019-07-04 19:08:18 -07:00
Uladzislau Paulovich
cc27d85110 Remove incorrect constexpr specifier in YGLayout (#25430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/25430

Pull Request resolved: https://github.com/facebook/litho/pull/561

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

* According to C++ standard values which produce undefined behavior cannot be declared as `constexpr`.
* Expressions which evaluate to `nan, infinity, etc` are undefined behavior.

For more details you can checkout this Stackoverflow answer: https://stackoverflow.com/a/46373136

Reviewed By: davidaurelio

Differential Revision: D16055108

fbshipit-source-id: ee85ba63a714b18bfb8aa8c0770652e184454f74
2019-07-01 08:52:10 -07:00
David Aurelio
cd5324378d Move YG_ENABLE_EVENTS checks to event.h
Summary:
Instead of checking whether `YG_ENABLE_EVENTS` is defined for every publish, we simply wrap the body of the `publish` function macro that delegates to the method that actually publishes the event.

This way we get

1. easier to write code where we publish events
2. more type safety when editing, enabling editors/IDEs to show errors without knowing about `YG_ENABLE_EVENTS`

Reviewed By: SidharthGuglani

Differential Revision: D16049888

fbshipit-source-id: cbf362d6f7be5053c3f377125d303b7137d6a241
2019-06-28 09:58:57 -07:00
David Aurelio
c6ae314202 Stop recording measure callback duration
Summary: Removes time measurements for measure callbacks. This functionality should not be part of Yoga/core, and can now be done by event subscribers themselves, as we have two events per measure callback.

Reviewed By: SidharthGuglani

Differential Revision: D16049812

fbshipit-source-id: e16556f3854e42f4bada39a97a668e718719b22c
2019-06-28 09:58:57 -07:00
David Aurelio
73224c62b5 Publish two events for measure callbacks
Summary: Publishing two events will allow us to replace marker functionality completely with events. This also allows us to remove measuring time spent from Yoga itself.

Reviewed By: SidharthGuglani

Differential Revision: D16049810

fbshipit-source-id: 98628a92ed3c94d479e9fbcd53fac90c5f524087
2019-06-28 09:58:56 -07:00
David Aurelio
2c6a4485f5 Remove duplicate declaration of YGRoundValueToPixelGrid from Yoga-internal.h
Summary:
@public

Removes the declaration of `YGRoundValueToPixelGrid` from `Yoga-internal.h`, as it is already declared in `Yoga.h`. `Yoga.h` is included from `Yoga-internal.h`

Reviewed By: SidharthGuglani

Differential Revision: D16047832

fbshipit-source-id: 72d9d2510372c983eedacc5d7af406b9346f18e6
2019-06-28 05:17:06 -07:00
dattc2
cf005df828 make yoga threadsafe (#852)
Summary:
Continuing https://github.com/facebook/yoga/pull/791
nokia6686 is a former member of our team, so we are trying to pick up what he left and carry out the pull request.
# Solution
Improved from previous solution with jpap's suggestions.
2. Passing ```gDepth``` and ```gCurrentGenerationCount``` (renamed to **_depth_** and **_generationCount_** respectively) between function calls that stem from ```YGNodeCalculateLayout```.
In ```YGNodeCalculateLayout```, pass ```depth``` as value 0, to indicate the root depth.
Pull Request resolved: https://github.com/facebook/yoga/pull/852

Reviewed By: SidharthGuglani

Differential Revision: D15537450

Pulled By: davidaurelio

fbshipit-source-id: 338f51383591ba27702ebe759f6c47c2dede3530
2019-06-25 12:10:23 -07:00
Chris Hopman
f539d68049 Force ordering of :yoga/:yogaForDebug
Summary:
Due to testutil depending on :yoga, we are always linking against both
:yoga and :yogaForDebug in tests. This is only working right now due to luck in
how Buck orders the link line. Adding a dependency is silly but it enforces
that Buck maintain the ordering that we currently have even when it changes how
it does its traversal.

Reviewed By: philipjameson

Differential Revision: D15973581

fbshipit-source-id: 3d18aff578ee4d56175ce5efae52b56aeb2d9586
2019-06-24 17:10:45 -07:00
Sidharth Guglani
39996512fc pass cachedLayout and cachedMeasure measures to plugin
Summary: Passing whether layout cache or measure cache was used or not

Reviewed By: davidaurelio

Differential Revision: D15920937

fbshipit-source-id: a6728e7af07ea228a285f824fbdfddc8130c5990
2019-06-24 08:37:18 -07:00
Sidharth Guglani
2dc5a16d1f Move event NodeLayout to end of NodeLayout step
Summary:
Added event NodeLayoutEnd and this is being used now instead of NodeLayout
It will be used later to add more information about caches

Reviewed By: davidaurelio

Differential Revision: D15920935

fbshipit-source-id: c9f5e193bc8cc70d26ff5d84882d483c9b09f67d
2019-06-24 08:37:17 -07:00
David Aurelio
d667ebd66e Replace relative include
Summary: Replaces the relative include to `YGEnums.h` in `yoga/event/event.h` with `#include <yoga/YGEnums.h>

Reviewed By: SidharthGuglani

Differential Revision: D15778634

fbshipit-source-id: 2bceeb58f26c0d9d0df6c0e7ea20b8ddf68a1ee5
2019-06-21 04:11:36 -07:00
Sidharth Guglani
2b8217ce8d Send measure pass duration
Summary: Send measure callback duration time to yoga plugin

Reviewed By: davidaurelio

Differential Revision: D15917548

fbshipit-source-id: 2c947f14ddbc5932cedd0aab8622260478ec29a6
2019-06-21 02:38:57 -07:00
Stiopa Koltsov
9dac56e824 Migrate Yoga targets to raw_headers
Summary:
In "regular" header mode, Buck will symlink from `buck-out/` to the actual header file. This works fine with GCC and clang, but not with MSVC. Headers will be treated as different file, sidestepping `#pragma once` directives.

As a result, all kinds of symbols get declared twice, leading to compile errors.

Reviewed By: davidaurelio

Differential Revision: D15781947

fbshipit-source-id: a3b4e211b8b74b9ef44fc39471a3009b2cf47260
2019-06-15 12:07:14 -07:00
David Aurelio
a7e8aec3d9 Allow to end markers early
Summary:
Adds the ability to `MarkerSection` to end the marker before it goes out of scope.

This unlocks two scenarios:
- reuse the data associated with a marker after ending it.
- end markers in the middle of a function without adding arbitrary blocks.

Reviewed By: SidharthGuglani

Differential Revision: D15837840

fbshipit-source-id: c0afaeeabd169c65189b5028be54ea7dac3e3b84
2019-06-15 10:26:32 -07:00
David Aurelio
6b5bf570c8 Count the number measure callback invocations
Summary: Counts how many times measure callbacks have been invoked during a layout pass. This is made available via the marker and event APIs.

Reviewed By: SidharthGuglani

Differential Revision: D15836983

fbshipit-source-id: 3835bef94e497375821c9f2ad8209447b4f11518
2019-06-15 10:26:31 -07:00
Sidharth Guglani
a130ac2f9c pass measure callback data from c++ to java
Summary:
Passing Measure callback data - width, widthMeasureMode, height, heightMeasureMode, measuredWidth and measuredHeight along with NodeMeasure event
This data is then propagated to java layer in this diff

Reviewed By: davidaurelio

Differential Revision: D15697523

fbshipit-source-id: 615463da237175ff88abef3f6528b55333ccd915
2019-06-12 00:33:31 -07:00
David Aurelio
19fd066507 Pass layout context for Event::LayoutPassStart
Summary: Adds the layout context pointer when publishing `Event::LayoutPassStart`.

Reviewed By: SidharthGuglani

Differential Revision: D15754425

fbshipit-source-id: 6295ae1ebec9eab72a79c43bc1cb0e05a6d7ae68
2019-06-11 01:41:22 -07:00
David Aurelio
204e849218 rm YogaEventListener
Reviewed By: SidharthGuglani

Differential Revision: D15742456

fbshipit-source-id: b90a221e177e936e141c582500dccf0ac38027c2
2019-06-11 01:41:22 -07:00
Aditya Sharat
8ff13c922a Back out "[litho] Adds check to unset a YogaNode's parent during reconciliation."
Summary: Removes `unsetOwner` from Yoga. This was temporarily for patching a crash.

Reviewed By: colriot

Differential Revision: D15737613

fbshipit-source-id: 8ab93ecf7ffb913df6207fe5db47a8cc93eded2c
2019-06-10 06:57:05 -07:00
Sidharth Guglani
af219f8836 add node layout event and pass it java layer
Summary: Listen to NodeLayout event and passes this event callback to java layer along with the information whether layout or measure was done in this pass

Reviewed By: davidaurelio

Differential Revision: D15696021

fbshipit-source-id: 8c5ca69330a9baca26b77052d4965cc67fe97c75
2019-06-10 01:51:53 -07:00
Aditya Sharat
e33123f955 Adds check to unset a YogaNode's parent during reconciliation.
Summary: Adds check to unset a YogaNode's parent during reconciliation.

Reviewed By: davidaurelio

Differential Revision: D15714899

fbshipit-source-id: 6e2c2a28106574d062fec722c9a051acea87d0b6
2019-06-07 09:28:24 -07:00
Sidharth Guglani
755fa07b39 add node measure event and passing the callback to java layer
Summary: Adds measure event and its listener initial code structure

Reviewed By: davidaurelio

Differential Revision: D15600738

fbshipit-source-id: d15764e0b64edb170fcb15e0912ecce5f7e53595
2019-06-06 21:03:24 -07:00
Sidharth Guglani
2701d80078 passing layout context and getting local reference from it
Summary: We are passing layout context from yoga as event data for Layout Pass End event and it is being then used to get the local reference of node so that we can pass it as method parameter to java layer

Reviewed By: davidaurelio

Differential Revision: D15619640

fbshipit-source-id: 5f6c29d9e6acb73a8d87f8e0cb1577d35a271aeb
2019-06-06 21:03:24 -07:00
Sidharth Guglani
c393ed1381 moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga

Reviewed By: davidaurelio

Differential Revision: D15619629

fbshipit-source-id: 1bf213efd38ec7bcac6a38070f21fa837c5f17da
2019-06-06 21:03:23 -07:00
Rain ⁣
a4bdd9cd9b standardize C-like MIT copyright headers throughout fbsource
Summary:
`/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3

In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf.

Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too.

Reviewed By: zertosh

Differential Revision: D15640366

fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
2019-06-06 19:44:16 -07:00
Joshua Gross
4a4325afb6 Revert D15602627: [yoga] moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Differential Revision:
D15602627

Original commit changeset: bb5bd5bbf8dc

fbshipit-source-id: 5ae08826eb706c3794c36738cb9625f82b58641e
2019-06-03 19:57:53 -07:00
Joshua Gross
586eb6102a Revert D15602923: [yoga] passing layout context and getting local reference from it
Differential Revision:
D15602923

Original commit changeset: 54b25956af09

fbshipit-source-id: 8ce26a7f00d76bd5ade18f32ad14d943118a6f31
2019-06-03 19:57:53 -07:00
Sidharth Guglani
b1e6793460 passing layout context and getting local reference from it
Summary: We are passing layout context from yoga as event data for Layout Pass End event and it is being then used to get the local reference of node so that we can pass it as method parameter to java layer

Reviewed By: davidaurelio

Differential Revision: D15602923

fbshipit-source-id: 54b25956af098700cea25c4f7f8ffe0b9117432c
2019-06-03 16:01:51 -07:00
Sidharth Guglani
8b17459254 moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga

Reviewed By: davidaurelio

Differential Revision: D15602627

fbshipit-source-id: bb5bd5bbf8dcb279f5f87a4fd7287909d4e895d8
2019-06-03 16:01:50 -07:00
David Aurelio
195c166efe Back out "[Yoga] Remove comparison to YGUndefined *and* 0.0f"
Summary: Original commit changeset: 13c8f24e1bc8

Reviewed By: fabiomassimo

Differential Revision: D15583502

fbshipit-source-id: efc6175f6c4925a383fea723195c073f49e2eff1
2019-05-31 15:56:50 -07:00
David Aurelio
0908d3a173 Data structure for exclusive writing
Summary:
Adds a data structure that holds a series of values that can be *borrowed* for exclusive writing.
That means, that only a single consumer can write to any value owned by the data structure.

In addition, the data structure exposes read access via iteration over all contained values.

A typical use case would be a counter with thread-local values that are accumulated by readers in other parts of a programm. The design carefully avoids the use of atomics or locks for reading and writing. This approach avoids cache flushes and bus sync between cores.

Borrowing and returning a value go through a central lock to guarantee the consistency of the underlying data structure.

Values are allocated in a `std::forward_list`, which typically should avoid two values in the same cache line -- in that case, writing to one value would still cause cache flushing on other cores. An alternative approach would be to allocate values continuously on cache line boundaries (with padding between them). We can still change the code if the current approach turns out to be too naive (non-deterministic).

Reviewed By: SidharthGuglani

Differential Revision: D15535018

fbshipit-source-id: 212ac88bba9682a4c9d4326b46de0ee2fb5d9a7e
2019-05-31 09:43:43 -07:00
David Aurelio
f304990656 Use atomic list for event subscribers
Summary:
Replace the *copy on write* vector with an atomic pointer to a linked list.

This allows to publish without locking a mutex, at the cost of the slower traversal of a linked list (a vector has better locality).

At the moment, the typical use case is to have one subscriber, meaning that the afforementioned slower traversal is not a problem.

Adding subscribers is implemented as atomic *compare and swap.*

Reviewed By: SidharthGuglani

Differential Revision: D15546964

fbshipit-source-id: 41bfa41f1ac6be5c9b6bf4288ea3271ee995877e
2019-05-31 01:26:42 -07:00
David Aurelio
cea3865c74 Deprecate YGNode::setConfig
Summary:
We want to phase out usage of config pointers on nodes. Setting configs is no longer needed, as a config is unly used during construction.

Here we deprecate the setter, as it is no longer working as it used to (e.g. changing `useWebDefaults` after a node is constructed).

Reviewed By: SidharthGuglani

Differential Revision: D15416474

fbshipit-source-id: a2cc06cad0c5148cecce056ece5f141b3defe9a9
2019-05-29 07:50:11 -07:00
David Aurelio
b74c0d4766 Remove comparison to YGUndefined *and* 0.0f
Summary: Removes a check introduced in D6969537, comparing `totalFlexGrowFactors` and `resolveFlexGrow` to both `0.0` *and* undefined.

Reviewed By: SidharthGuglani

Differential Revision: D15431425

fbshipit-source-id: 13c8f24e1bc8c49496097a6aa78e20ee5d3964a7
2019-05-22 09:44:36 -07:00
David Aurelio
54e863cef2 Remove YGNode::setAndPropogateUseLegacyFlag
Summary:
`YGNode::setAndPropogateUseLegacyFlag` was only used for debugging purposes.
Here, we replace it with a free function in `Yoga.cpp`.

Now that we have events, the diffing functionality should go into a separate debugging package and be implemented in terms of an event listener. Let's do that as soon as we can support multiple listeners.

Reviewed By: SidharthGuglani

Differential Revision: D15316863

fbshipit-source-id: db929eba7c2de8aa1550e362dd2c175929c0070e
2019-05-21 06:06:37 -07:00
David Aurelio
1938792517 YGNode: Field for web defaults
Summary:
In order to remove the config pointer from nodes, we have to keep track of whether the node is using web defaults.
This information fits into one bit that we can place in padding (i.e. no extra memory needed).

This allows us to get rid of config usage withing `YGNode` with some exceptions:

- `iterChildrenAfterCloningIfNeeded` -- this function will simply receive the configuration, or the cloning callback.
- `setAndPropogateUseLegacyFlag` -- will be removed in D15316863
- in `YGNode::reset` -- will go away utomatically once we remove the config pointer

Reviewed By: SidharthGuglani

Differential Revision: D15391536

fbshipit-source-id: 0fa0d0805c6862bd741fe4a7d9b637ed534f56a4
2019-05-20 10:51:38 -07:00
Sidharth Guglani
aa71dbb5bd mutex lock while accessing event subscribers vector for thread safety
Summary: Using Mutex lock_guard mechanism when writing to subscribers and when accessing them in publish to make a copy

Reviewed By: davidaurelio

Differential Revision: D15391679

fbshipit-source-id: 16713ff28ce1762a5ca4c48c152897a92417e80b
2019-05-19 23:34:41 -07:00
David Aurelio
8dc46c0a87 YGNode: one byte of private storage
Summary:
Adds one byte of private storage to `YGNode`, intended to be used by Yoga itself.

This is in previously unused alignment space, and won’t cause more memory to be allocated.

Reviewed By: SidharthGuglani

Differential Revision: D15296732

fbshipit-source-id: 3caf0a3cd506e4e324e51c31869c69be5781d476
2019-05-16 11:47:30 -07:00
David Aurelio
1180afed9c Fix style property bits
Summary: Style bits had overlap, because `dimensionBit` was set with an incorrect increment.

Reviewed By: SidharthGuglani

Differential Revision: D15335134

fbshipit-source-id: 370e1a73547d76b0e26bc6ab67acb96d33ddf180
2019-05-16 11:47:30 -07:00
Sidharth Guglani
1562bce9b4 use shared_ptr for subscribers vector in event system
Summary:
using shared_ptr for vector of subscribers
Further changes in commit stack support the mutiple subscribers in event system

Reviewed By: davidaurelio

Differential Revision: D15352512

fbshipit-source-id: fac7f4268abf9ca4277734aca2f21cd711eb7d6e
2019-05-15 09:01:06 -07:00
Sidharth Guglani
a9514513a7 use vector for subscribers in event system
Summary:
Replaced global event subscriber with a vector of subscriber functions
Further changes in commit stack support the mutiple subscribers in event system

Reviewed By: davidaurelio

Differential Revision: D15352451

fbshipit-source-id: 7ca6f0943735bf1f76a906c23e15e14ae3c5f42c
2019-05-15 09:01:04 -07:00
Sidharth Guglani
cf809b8e8b added listener in flipper plugin for yoga
Summary:
Adds YogaEventListener interface and it's implementation which will be used in flipper for events coming from Yoga
After this diff , we will start getting layout calculate events in flipper listener

Reviewed By: davidaurelio

Differential Revision: D15316928

fbshipit-source-id: da3a53374a52386037b553d460038d988b0162c2
2019-05-15 01:18:11 -07:00
Yadong Wen
d7ff5c0689 Remove c++1y compiler flag
Reviewed By: meyering

Differential Revision: D15326600

fbshipit-source-id: 837f454ccf27299bc9360174bf54e48e4209bb52
2019-05-14 13:48:02 -07:00
David Aurelio
e3156279fc Travis: Fix C++ compilation
Summary:
@public

Removes the usage of C++14 features, and enforces C++11 via compiler flags.

Reviewed By: SidharthGuglani

Differential Revision: D15334938

fbshipit-source-id: 011764b5f226fef6a35e0c7c1dd170a39ae2261e
2019-05-14 07:45:31 -07:00
gengjiawen
0ce42d83e0 add missing gradle script for windows
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/885

Differential Revision: D15334309

Pulled By: davidaurelio

fbshipit-source-id: c594c0216a967c776606443a50f14e81da228d64
2019-05-14 06:24:18 -07:00
Shawn Presser
afc1108659 Fix cmake build / update CMakeLists.txt to use C++11 (#887)
Summary:
On MacOS, the following steps result in build errors:

```
mkdir build
cd build
cmake ..
make
```

The problem is that yogacore uses C++11 features (`constexpr`) but C++11 isn't specified in CMakeLists.txt.

This PR solves the poblem by adding the following code to the bottom of CMakeLists.txt:

```
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
```

This solution was derived from https://stackoverflow.com/questions/45688522/how-to-enable-c17-in-cmake
Pull Request resolved: https://github.com/facebook/yoga/pull/887

Differential Revision: D15334282

Pulled By: davidaurelio

fbshipit-source-id: a599d8a8f555f7f9cd8dc333e12dc2387d5b2d7a
2019-05-14 05:28:19 -07:00
David Aurelio
a15bf6e701 Publish events for layout pass
Summary:
Adds `LayoutPassStart` and `LayoutPassEnd` events.

The existing `NodeLayout` event in isolation is not as useful as it could be. Having events that mark start and end of a layout pass are a useful addition.

Differential Revision: D15305467

fbshipit-source-id: 14af6f65e698fb1e3112eb2ffd87a74d31df4840
2019-05-10 19:05:07 -07:00
Sidharth Guglani
74fc37efc8 move event files to yoga/events folder
Summary: Moved events files to yoga/events for better code structure

Reviewed By: davidaurelio

Differential Revision: D15198566

fbshipit-source-id: 74d451011841d59fae5a1c637f9c33a7d2d1f87e
2019-05-09 07:46:10 -07:00
David Aurelio
5824dbda66 Publish event when visiting nodes during layout
Summary:
@public

Publish an event when visiting nodes during layouts.

Reviewed By: SidharthGuglani

Differential Revision: D15206965

fbshipit-source-id: c201f084b1d4186bc64560b8033be965f2549236
2019-05-09 04:31:25 -07:00
David Aurelio
e96a09e5ff **breaking:** remove YGNodeGetInstanceCount
Summary:
@public

`YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments.

It was completely replaced with event-based counting for tests.

Here we remove public API around the counter, and the counter itself.

Reviewed By: SidharthGuglani

Differential Revision: D15174857

fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
2019-05-09 04:31:24 -07:00
David Aurelio
9e20dfeea1 Switch tests to test utility for counting nodes
Summary:
@public
replaces the global node counter with the event-based one for all tests.

Reviewed By: SidharthGuglani

Differential Revision: D15174856

fbshipit-source-id: f4401d502bdbaf3b6e4632a4d985aac260cb35a8
2019-05-09 04:31:24 -07:00
David Aurelio
6e04631862 Add test utilities for C++ and Java
Summary:
@public

Test utility on top of the new event system that maintains a counter of instantiated nodes. Meant to replace the global node counter.

Reviewed By: SidharthGuglani

Differential Revision: D15174855

fbshipit-source-id: 6998472f95a09b8da652257a26596164bdcf43d6
2019-05-09 04:31:23 -07:00
David Aurelio
88b23ebb3d Publish events for node allocation and deallocation
Summary:
@public

Publish two events, `NodeAllocation` and `NodeDeallocation`, in the same places where the global node counter is changed.

Reviewed By: SidharthGuglani

Differential Revision: D15174858

fbshipit-source-id: 6e4e9add88513b9e987189ca5035d76da2a1de55
2019-05-09 04:31:23 -07:00
David Aurelio
018916403e Reduce measure cache size to 8
Summary:
@public

Reduces measure cache size to a number that is enough for 95% of nodes, according to our (FB-internal) measurements.

Node size: 776b -> 584b

Reviewed By: SidharthGuglani

Differential Revision: D15183567

fbshipit-source-id: 9ae8cc78074271a015e7618b931ba0356de87a0c
2019-05-09 03:24:31 -07:00
Adrian Zgorzalek
af38fd31f8 Upgrade prettier to 1.17.0
Summary:
Run `js1 upgrade prettier 1.17.0` and `xplat/js/scripts/update-oss-yarn-lockfile.sh` and `hg revert -r .^ xplat/js/rome`

allow-large-files

Reviewed By: zackargyle, pvdz

Differential Revision: D15164375

fbshipit-source-id: 2fe68733dfa93ea64a67d170ba2f80c5af086917
2019-05-07 12:39:46 -07:00
David Aurelio
1e0ebdae2f Remove API to constrain measure cache size
Summary: We conducted an experiment with different measure cache sizes. This has now been deallocatedi (D15183473). Remove the necessary APIs.

Reviewed By: SidharthGuglani

Differential Revision: D15183486

fbshipit-source-id: a38fa5a3ab0321c2521265f7d1cd6b495efd76cf
2019-05-03 05:54:40 -07:00
David Aurelio
1adbafe950 Fix YGConfig constructors
Summary:
@public

`YGConfig::YGConfig(YGConfig*)` was not initializing the same fields as the default constructors.

Here, we make the default constructor delegate to the more specialized one to remove duplication.

Reviewed By: SidharthGuglani

Differential Revision: D15164599

fbshipit-source-id: 27247709091b7664386057d09ac67d481877871f
2019-05-03 05:01:32 -07:00
David Aurelio
e51ca95713 Add foundations for event system
Summary:
@public

We want to enable tooling, instrumentation, and statistics within Yoga without coupling these functionalities to our core code.

This commit introduces the foundations of a simple, global event system.
For the time being, we will only support a single subscriber. Should we require more than one, we can add support for it later.

Reviewed By: SidharthGuglani

Differential Revision: D15153678

fbshipit-source-id: 7d96f4c8def646a6a1b3908f946e7f81a6dba9c3
2019-05-01 17:08:02 -07:00
David Aurelio
a803421739 YGStyle: Make getters/setters template args of BitfieldRef
Summary:
@public

Makes bitfield getters/setters part of the bitfield ref template.
Since we introduced the tracking bit as template parameter in D14933022, every bitfield ref is an individual class anyway, and having function pointers doesn’t potentially lead to less code generation anyway.

Furthermore, this change can (in the absence of tracking bits) avoid less specialized templates dealing with refs, and to dynamic dispatch as a consequence.

Reviewed By: SidharthGuglani

Differential Revision: D15085495

fbshipit-source-id: 0dd70fa05e9d43a29e38a619cddb642c9ca3f7ab
2019-05-01 06:52:55 -07:00
David Aurelio
011c1964a0 Track which style properties have been set on YGStyle
Summary:
@public

In order to optimise property storage, we have to know how style properties are used in our apps.
Here, we add a bitmask that allows us to track which properties are set explicitely, and use that for our analysis.

Reviewed By: SidharthGuglani

Differential Revision: D14933022

fbshipit-source-id: 1ab8af562b14baba1d02057e527aa36d5c9a7823
2019-05-01 06:52:55 -07:00
David Aurelio
05d205cf89 Deduplicate updateStyle overloads
Summary:
@public

The extra overload of `updateStyle` introduced in D15078961 can also handle `BitfieldRef`.
That means that we can remove the more specific implementation previously introduced for `BitfieldRef`

Reviewed By: SidharthGuglani

Differential Revision: D15081069

fbshipit-source-id: 98f1f3478627974c5273c85d268ca07350f303d7
2019-05-01 06:52:54 -07:00
David Aurelio
0a4f7bd558 YGStyle: mutable accessors return Ref instances
Summary:
@public

Change style property accessors to return `Ref` instances instead of references to `CompactValue`.

This will allow to track assignments to properties later on, e.g. for instrumentation or dynamic property storage.

Reviewed By: SidharthGuglani

Differential Revision: D15078961

fbshipit-source-id: 259f05f7d30f093c04bf333c5bd4fb3601b8e933
2019-05-01 06:52:54 -07:00
David Aurelio
cea862a6bf Expose the value type used by YGStyle as ValueRepr
Summary:
@public

Adds `YGStyle::ValueRepr` to make code depending on the actual type easier to write.

So far, we have treated `yoga::detail::CompactValue` as an implementation detail, and that’s what it’s supposed to stay.

React Native Fabric has one value conversion overload that depends on that type, though, and used `decltype(YGStyle{}.margin()[0])` until now.
That’s problematic for two reasons:

- we want to constrain the parameter of `operator[](...)` to enum types, making the `0` unsuitable
- we want to return the non-const overload of the operator to return a custom `Ref` type, which is not the type needed by Fabric.

Making the storage type explicit allows to write more forward-compatible code.

Reviewed By: SidharthGuglani

Differential Revision: D15078960

fbshipit-source-id: 932c27ef2f2cdc6ce965b79894268170f0ccdce5
2019-04-29 09:23:18 -07:00
David Aurelio
cc02a20c9e More constness
Summary:
@public

Some `YGNode*` passed as `const YGNode*`, some const refs to sub-objects introduced.
This helps selecting the desired methods in more places, i.e. `const` overloads of accessors on `YGStyle`.

Reviewed By: SidharthGuglani

Differential Revision: D15078963

fbshipit-source-id: 5013721d6edcc68f42f4504f5c331da647a294bd
2019-04-29 09:23:17 -07:00
David Aurelio
98fda9c587 YGFloatOptional: Move binary operators to free functions
Summary:
@public

Having binary operators as member functions has disadvantages:

- the left hand side cannot be converted to `YGFloatOptional` implicitly (which we need for `YGStyle` refs)
- Operators are not necessarily commutative.

By moving these operators into free functions, and adding overloads for both variants if one operand is `float`, we get these properties.

Reviewed By: SidharthGuglani

Differential Revision: D15078962

fbshipit-source-id: 2e228a2ef90a8083c91788caa9eedfd4d140677f
2019-04-29 09:23:16 -07:00
David Aurelio
2eed95f3e4 YGNodeToString: take const ref to node style
Summary:
@public

Takes a const reference to the style of the printed node once, instead of using repeated calls to `node->getStyle()`.
Makes the code a bit shorter, and ensures that we are operating on `const YGStyle&`, which helps selecting the correct methods further up the stack.

Reviewed By: SidharthGuglani

Differential Revision: D14999094

fbshipit-source-id: 814f06b7e3179ac8cfb43d79fbec48ee4115d6e3
2019-04-26 02:15:06 -07:00
David Aurelio
e5d3baca81 Introduce YGNodeConstRef
Summary:
@public

Introduces `YGNodeConstRef` as `const YGNode*`, i.e. a pointer to a constant `YGNode`.
We also use it for all style getters, which will avoid casts to `const YGNode*` in diffs up the stack.

We should use this pointer type for all functions that do not modify the underlying node.

Reviewed By: SidharthGuglani

Differential Revision: D14999095

fbshipit-source-id: 61cc53bb35e787a12ae12e70438d84c0a4983752
2019-04-23 10:10:24 -07:00
David Aurelio
dee93017f7 YGStyle: wrap all fields into accessors
Summary:
@public

In order to encapsulate property access on `YGStyle`, as a first measure we wrap all fields with accessors.

This will e.g. enable dynamic property storage and instrumentation in the future.

All accessors have a `const` version that allows direct access via `const&`. For mutation, bit fields are wrapped with a custom reference object.

This style allows for the least amount of changes in client code. Property access simply needs appended parens, eg `style.direction` becomes `style.direction`.

Reviewed By: shergin

Differential Revision: D14999096

fbshipit-source-id: fbf29f7ddab520513d4618f5e70094c4f6330b30
2019-04-23 08:17:18 -07:00
David Aurelio
e167642672 Yoga.h: clean up const / extern
Summary:
@public

Remove unnecessary `const` and `extern` specifiers from `Yoga.h`.

- Function declarations are `extern` by default
- The removed `const` specifiers for pass-by-valye parameters are only meaningful for the *definition* of functions, not for the declaration.
In this specific case, I found `const YGNodeRef` particularly confusing, as it is a `typedef` for a pointer type. `const` does not refer to the pointed-to object, but to the parameter itself, i.e. `const YGNodeRef` is `YGNode * const`, and not `const YGNode *`.

Reviewed By: SidharthGuglani

Differential Revision: D14999097

fbshipit-source-id: 8350870cb67f4a34722f796c4f4a2fc7dde41b99
2019-04-23 08:17:16 -07:00
David Aurelio
e9bb1efb03 Code formatting: allow short inline methods on one line
Summary:
@public

This allows short methods defined in class declarations to occupy a single line.
The change makes class declarations more readable.

Reviewed By: SidharthGuglani

Differential Revision: D14950012

fbshipit-source-id: 1321949475184181c6cceb86613f730e430763e2
2019-04-16 07:12:58 -07:00
David Aurelio
3f7d03b443 Define all style getters/setters explicitely
Summary:
@public

For better grepping, we define all `YGNodeStyle...` accessors explicitely. This also replaces all macros with a set of templates that can easily be updated when we switch to style accessors on `YGNode`.

Transitioning to a consistent set of templates also allowed to end up with a single *needs update* / *do update* / *mark dirty* block.

The new template code also takes full advantage of the properties of `YGOptional` (constructor call with *not a number* creates an empty optional) and `detail::CompactValue` (conversions of *auto* and *undefined* are always well-formed) to get rid of some additional code:

Removed `NAN` check:
```
 _YGNodeStyleSetFlex:
 	pushq	%rbp
 	movq	%rsp, %rbp
 	movss	0x34(%rdi), %xmm1
 	ucomiss	%xmm0, %xmm1
 	jne	0x____
 	jnp	0x____
 	ucomiss	%xmm0, %xmm0
 	jnp	0x____
 	ucomiss	%xmm1, %xmm1
 	jnp	0x____
 	popq	%rbp
 	retq
-	ucomiss	%xmm0, %xmm0
-	movd	%xmm0, %eax
-	movl	$0x7fc00000, %ecx
-	cmovnpl	%eax, %ecx
-	movl	%ecx, 0x34(%rdi)
+	movss	%xmm0, 0x34(%rdi)
 	popq	%rbp
 	jmp	0x____
-	nopw	%cs:(%rax,%rax)
-	nop
+	nopw	(%rax,%rax)
```

Removed well-formedness check:
```
 _YGNodeStyleGetPosition:
 	pushq	%rbp
 	movq	%rsp, %rbp
 	movl	%esi, %eax
 	movl	0x68(%rdi,%rax,4), %ecx
+	xorl	%eax, %eax
 	movq	(%rip), %rcx
 	movl	(%rcx), %eax
 	movl	0x4(%rcx), %ecx
-	movq	%rcx, %rdx
-	shlq	$0x20, %rdx
+	shlq	$0x20, %rcx
 	movl	%eax, %eax
-	orq	%rdx, %rax
-	cmpl	$0x3, %ecx
-	je	0x____
-	testl	%ecx, %ecx
-	jne	0x____
-	movl	$0x7fc00000, %ecx
-	jmp	0x____
-	movq	%rax, %rcx
-	movabsq	$-0x100000000, %rdx
-	andq	%rax, %rdx
-	movl	%ecx, %eax
-	orq	%rdx, %rax
+	orq	%rcx, %rax
 	popq	%rbp
 	retq
 	nopw	(%rax,%rax)
```

Reviewed By: SidharthGuglani

Differential Revision: D14911973

fbshipit-source-id: db6eef65f8fdaf70875f7fe8799919ca88bd50ee
2019-04-15 10:51:44 -07:00
Sidharth Guglani
ffce716557 Use only 4 edges for margin, padding, border in YGLayout
Summary:
We were using four edges for margin, padding and border. This diff changes the array size in YGLayout for margin, padding, border to reduce YGNode size and corresponding changes while we are setting values in YGLayout.
Reduces the YGNode size by 24 bytes

Reviewed By: davidaurelio

Differential Revision: D14892666

fbshipit-source-id: 94013d5183ee869901267c4c9941fd94fa05d848
2019-04-15 05:41:59 -07:00
Andres Suarez
fcfb19e9cf Enable black for xplat/yoga
Summary:
This directory was excluded from Black formatting in D14888843 when Black
was turned on for all of `xplat/`. Since there aren't a lot of `.py` files in
this directory, the opt-out is being removed, and the outstanding issues fixed.

Reviewed By: d16r

Differential Revision: D14889104

fbshipit-source-id: 440077c1efcb4c653151bca1da5636212978add5
2019-04-11 05:24:34 -07:00
David Aurelio
c5f105a7b6 JNI: set language level to C++11
Summary:
@public

compiler flags were pushed to C++14, but we don’t currently have any code that requires it. Setting to `-std=c++11` in order to fix the OSS build.

Reviewed By: SidharthGuglani

Differential Revision: D14833737

fbshipit-source-id: df2cd7da8c7124e89863c90d7b77bcf86c495618
2019-04-09 03:12:32 -07:00
David Aurelio
b062d23947 Add -SNAPSHOT to gradle version
Summary:
@public

needed for snapshot releases off of master.

Reviewed By: colriot

Differential Revision: D14833415

fbshipit-source-id: f3b1fb1c41318a9b8f634cd16d37d5e2d050398f
2019-04-08 10:57:18 -07:00
David Aurelio
7fc6fcb38c v1.14.0
Summary:
@public

Push version to *1.14.0.*

This release contains some bug fixes around `align-content`.

Reviewed By: colriot

Differential Revision: D14833417

fbshipit-source-id: f653d5fbb36f307c92b14c091c3206290256f036
2019-04-08 10:57:17 -07:00
David Aurelio
bc7e504b29 Fix bugs around align-content
Summary:
@public

Regenerating the “golden master” tests with chrome surfaced different bugs around `align-content`:

- a misunderstanding that values in `align-content` only applied *if there is only one line.* In fact, it applies *every time* a container is set to `flex-wrap: wrap`. Chrome had this wrong, and as such our tests were generated with incorrect parameters.
- empty children growing to the cross axis size of the container, even when `align-content` is different from `stretch`. This was implemented incorrectly in Chrome as well. Here, we fix it with an extra check.

Reviewed By: SidharthGuglani

Differential Revision: D14725402

fbshipit-source-id: a45bebdadb9c694dc0eb7e27cb52b3d247f81c50
2019-04-08 03:20:27 -07:00
Daniel Büchele
3d8afa9e90 fixing playground links
Summary: Updating links to playgrounds

Reviewed By: davidaurelio

Differential Revision: D14775759

fbshipit-source-id: 8c5c30aa63f2ec2787c1a15a72d09f4e642dd672
2019-04-04 08:52:05 -07:00
Aditya Sharat
a1e47e37ae Add YogaNode.cloneWithoutChildren
Summary: Adding flat clone method back to YogaNode for reconciliation.

Reviewed By: davidaurelio

Differential Revision: D14683019

fbshipit-source-id: 08ed2ffbb16052cb11aa464f67a7ba9a64297985
2019-04-03 11:34:06 -07:00
David Aurelio
e0bc0ebe29 Move YGSetUsedCachedEntries to internal header
Summary:
@public

In order to get out of pre-releases again, we move `YGSetUsedCachedEntries` from `Yoga.h` to `Yoga-internal.h`.
This way, it’s obvious that the function is not public, and we can remove it from future versions without breaking semver contracts.

Reviewed By: SidharthGuglani

Differential Revision: D14726029

fbshipit-source-id: 8d7e747e843bf5c4b5e1d4cfbfa37ca9d240dffb
2019-04-03 08:44:14 -07:00
Pritesh Nandgaonkar
498c0ff4bf New yoga and yogakit pod released
Summary: I have released a new yoga and yogakit pod with 1.12.0-pre.2

Reviewed By: davidaurelio

Differential Revision: D14722676

fbshipit-source-id: 7b379ee41d04a15e25dcb2e992f361d9403269c4
2019-04-02 05:08:05 -07:00
Daniel Büchele
d42d43e90f use tinyURL
Summary: As of today, Google URL shortener is retired. Moving to tinyURL instead. However, tinyURL doesn't support CORS headers, therefore additionally adding a CORS proxy.

Reviewed By: davidaurelio

Differential Revision: D14722636

fbshipit-source-id: 2ec41bb43287102543f1ac31bb76df57d71ba134
2019-04-02 05:03:19 -07:00
Daniel Büchele
bfc6319daa use search instead of hash
Summary:
The state of the playground was stores in a hash appended to the URL. However, tinyURL ignores the hash part of the URL. For this reason, we are using the search part of the URL instead.

Before: `yogalayout.com/playground#ey...`
After: `yogalayout.com/playground?ey...`

Reviewed By: davidaurelio

Differential Revision: D14722638

fbshipit-source-id: ed135f60269e9136bb850c4c661bd88f8ee19323
2019-04-02 04:15:31 -07:00
Sidharth Guglani
74ce5afd9e added flag for useBatchingForLayoutOutputs experiment
Summary:
Using a config flag to switch between different implementations of transferring layout outputs
- YogaNodeJNI uses multiple access of java fields to pass all properties like width, height, margin etc...
- YogaNodeJNIBatching uses a float array to pass all the data in one java field access

Reviewed By: davidaurelio

Differential Revision: D14378301

fbshipit-source-id: 0da5b28e6a67ad8fd60eb7efe622d9b2deaf177f
2019-04-01 06:17:20 -07:00
Sidharth Guglani
c11faf2d56 Added implementation for YogaNodeJNIBatching and logic for passing array from c++ to java
Summary: This diff adds the logic to transfer layout outputs using a float array

Reviewed By: davidaurelio

Differential Revision: D14368120

fbshipit-source-id: d1f22283bcea051d15657f42c15b90edaa0a8a7a
2019-04-01 06:17:19 -07:00
Sidharth Guglani
5fad8008ab added test for reset method in YogaNodeJNI to verify all layout outputs are reset properly
Summary: This diff adds a test for reset method in YogaNodeJNI to verify all layout outputs are reset properly

Reviewed By: davidaurelio

Differential Revision: D14643926

fbshipit-source-id: fffbcd07ccb6d2df83fc0bf187d992ef194f3bd0
2019-04-01 06:17:19 -07:00
Sidharth Guglani
948ade4b1c moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14642995

fbshipit-source-id: 5d0bc7fa18c1985be7e216d7351f5eab2e03861d
2019-04-01 06:17:19 -07:00
David Aurelio
b1a7f2b4d9 gentest: Fix editing messup
Summary:
@public

Messed this one up when fixing the test generation script.

Reviewed By: SidharthGuglani

Differential Revision: D14684224

fbshipit-source-id: 2696ce9ff7d825d00c7ad1ab1627a5ffe56d123f
2019-03-29 10:22:31 -07:00
Pritesh Nandgaonkar
d44a6d936f Release a new version to cocoapods
Summary: Xcode 10.2 drops the support of swift version 3.0. Thus updated the swift version and also the yoga dependency.

Reviewed By: SidharthGuglani

Differential Revision: D14684332

fbshipit-source-id: d42e5979639c9fceec81627d4ac153566c2c0ab1
2019-03-29 10:08:10 -07:00
David Aurelio
1fc8472d35 gentest: allow for different default values
Summary:
@public

We use Chrome for generating test cases, which since v67 (or so) for `min-width` and `min-height` has a default value of either `0px` (CSS 2) or `auto` (CSS 3), depending on style properties.

Our setup only allowed for a single default value, and our test cases produce *both.*
This changes the test gen logic to allow for more than one value.

Reviewed By: SidharthGuglani

Differential Revision: D14682387

fbshipit-source-id: e76361f5cc0b88f9c2d74a5f3248c66abd6907a7
2019-03-29 06:32:21 -07:00
David Aurelio
c235301b52 gentest: remove empty line after license
Summary:
@public

This gets flagged by the linter. Remove it.

Reviewed By: SidharthGuglani

Differential Revision: D14682386

fbshipit-source-id: 612508b0906285e6420a553ac7a96d1024f1eac6
2019-03-29 06:32:20 -07:00
David Aurelio
2fb81500c1 gentest: adapt license
Summary:
@public

Adapts the license header text to the format we currently use.

Reviewed By: SidharthGuglani

Differential Revision: D14653591

fbshipit-source-id: f79446e4f85623326f770fe73482eab00edd9234
2019-03-28 04:47:56 -07:00
Alexander Vasyuk
68d9209dd9 Revert D14368107: [yoga] moved all the properties used for layout outputs to YogaNodeJNI
Differential Revision:
D14368107

Original commit changeset: 75ca330c1e7f

fbshipit-source-id: 9a9f5140bf8b1563c9ba85b3fe5f93fc6d8fdf41
2019-03-26 20:21:24 -07:00
Alexander Vasyuk
e91569cdad Revert D14368114: [yoga] removing unused const int
Differential Revision:
D14368114

Original commit changeset: f63b978813a0

fbshipit-source-id: 86a517b1483b0635f283702602712c42c3d51e20
2019-03-26 20:21:23 -07:00
Sidharth Guglani
f31917aa01 removing unused const int
Summary: Removed unused const int

Reviewed By: davidaurelio

Differential Revision: D14368114

fbshipit-source-id: f63b978813a01a37710fac299dc7ec9aff610844
2019-03-26 08:51:41 -07:00
Will Wilson
74202aecff Adds workspace for more efficient yoga development
Summary: This workspace should ease yoga development

Reviewed By: dinhviethoa

Differential Revision: D14600002

fbshipit-source-id: 49f6d36680acad5835fcf96e80bcd547b667c0c8
2019-03-26 07:43:30 -07:00
Sidharth Guglani
9c2108c69e moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368107

fbshipit-source-id: 75ca330c1e7f07adc0ab8e7a5927d93977088918
2019-03-26 07:35:17 -07:00
David Aurelio
3d2836a947 CompactValue overrides of YGResolveValue/YGValueEqual
Summary:
@public

I would like to get rid of implicit conversions between `YGValue` and `CompactValue`, because they don’t come for free.

That’s why I am adding `CompactValue` specific overrides for `YGResolveValue` and  `YGValueEqual`, that do explicit casts. Up the commit stack, we will be able mark both `CompactValue(const YGValue&)` and `CompactValue::operator YGValue()` as `explicit`.

Reviewed By: SidharthGuglani

Differential Revision: D14598447

fbshipit-source-id: 75dc15cefb2dddcf8def891c5fb37893cacd9d46
2019-03-26 05:21:35 -07:00
David Aurelio
e4856a2264 Remove duplicated function declaration
Summary:
@public

Just removes a duplicated function declaration.

Reviewed By: SidharthGuglani

Differential Revision: D14598446

fbshipit-source-id: b4d8fe192f9a07f512f6a346f27d9046bb3bae23
2019-03-26 05:21:35 -07:00
Sidharth Guglani
a2ee0f65bd fixed @Nullable missing infer errors
Summary: Fixed Nullable lint errors

Reviewed By: davidaurelio

Differential Revision: D14383930

fbshipit-source-id: 0847e19c50a0b8d4039199045b74aa86c96ac096
2019-03-25 06:36:28 -07:00
David Aurelio
85352c4e45 Automatic lint fixes
Summary:
@public
A round of automatic lint fixes.

Reviewed By: SidharthGuglani

Differential Revision: D14590396

fbshipit-source-id: f0b4a0ce503a1d9d46ea7ae788f9f2eac09c2ac7
2019-03-25 05:41:30 -07:00
David Aurelio
7d7b7b9e18 Sample workspace: remove XML comment
Summary:
@public

Xcode does not like it

Reviewed By: astreet

Differential Revision: D14580168

fbshipit-source-id: 6d26b3961b45a59ef9dc977b21493e60e3cf9396
2019-03-22 11:46:58 -07:00
David Aurelio
62d8a911ff Switch style getters to JNI fast calls
Summary:
@public

After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.

Reviewed By: pasqualeanatriello

Differential Revision: D14576815

fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
2019-03-22 10:36:56 -07:00
David Aurelio
ca46c67e9e Create YogaValue instances in Java, not C++
Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
2019-03-22 10:36:55 -07:00
1009 changed files with 190217 additions and 100451 deletions

View File

@@ -1,10 +0,0 @@
[cxx]
gtest_dep = //lib/gtest:gtest
[android]
target = android-25
build_tools_version = 26.0.2
[ndk]
ndk_version = 15.2.4203891
compiler = clang
app_platform = android-21
cpu_abis = arm64, armv7, x86, x86_64

View File

@@ -1,48 +1,91 @@
Language: Cpp
AccessModifierOffset: -2
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros:
- FOR_EACH
- FOR_EACH_R
- FOR_EACH_RANGE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyReturnTypeOnItsOwnLine: 2000
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
@@ -50,7 +93,17 @@ SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
Standard: Cpp11
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
TabWidth: 8
UseCRLF: false
UseTab: Never

View File

@@ -1 +0,0 @@
^lib/.*

217
.clang-tidy Normal file
View File

@@ -0,0 +1,217 @@
---
InheritParentConfig: true
Checks: '>
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bool-pointer-implicit-conversion,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-exception-escape,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
bugprone-incorrect-enable-if,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-optional-value-conversion,
bugprone-parent-virtual-call,
bugprone-redundant-branch-condition,
bugprone-shared-ptr-array-mismatch,
bugprone-signed-char-misuse,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unique-ptr-array-mismatch,
bugprone-unsafe-functions,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
clang-analyzer-apiModeling.google.GTest,
clang-analyzer-apiModeling.StdCLibraryFunctions,
clang-analyzer-apiModeling.TrustNonnull,
clang-analyzer-core.builtin.BuiltinFunctions,
clang-analyzer-core.builtin.NoReturnFunctions,
clang-analyzer-core.CallAndMessage,
clang-analyzer-core.DivideZero,
clang-analyzer-core.DynamicTypePropagation,
clang-analyzer-core.NonnilStringConstants,
clang-analyzer-core.NonNullParamChecker,
clang-analyzer-core.NullDereference,
clang-analyzer-core.StackAddressEscape,
clang-analyzer-core.UndefinedBinaryOperatorResult,
clang-analyzer-core.uninitialized.ArraySubscript,
clang-analyzer-core.uninitialized.Assign,
clang-analyzer-core.uninitialized.Branch,
clang-analyzer-core.uninitialized.CapturedBlockVariable,
clang-analyzer-core.uninitialized.UndefReturn,
clang-analyzer-core.VLASize,
clang-analyzer-cplusplus.InnerPointer,
clang-analyzer-cplusplus.Move,
clang-analyzer-cplusplus.NewDelete,
clang-analyzer-cplusplus.NewDeleteLeaks,
clang-analyzer-cplusplus.SelfAssignment,
clang-analyzer-deadcode.DeadStores,
clang-analyzer-nullability.NullableDereferenced,
clang-analyzer-nullability.NullablePassedToNonnull,
clang-analyzer-nullability.NullableReturnedFromNonnull,
clang-analyzer-nullability.NullPassedToNonnull,
clang-analyzer-nullability.NullReturnedFromNonnull,
clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-optin.mpi.MPI-Checker,
clang-analyzer-optin.performance.GCDAntipattern,
clang-analyzer-optin.performance.Padding,
clang-analyzer-optin.portability.UnixAPI,
clang-analyzer-security.FloatLoopCounter,
clang-analyzer-security.insecureAPI.bcmp,
clang-analyzer-security.insecureAPI.bcopy,
clang-analyzer-security.insecureAPI.bzero,
clang-analyzer-security.insecureAPI.getpw,
clang-analyzer-security.insecureAPI.gets,
clang-analyzer-security.insecureAPI.mkstemp,
clang-analyzer-security.insecureAPI.mktemp,
clang-analyzer-security.insecureAPI.rand,
clang-analyzer-security.insecureAPI.strcpy,
clang-analyzer-security.insecureAPI.UncheckedReturn,
clang-analyzer-security.insecureAPI.vfork,
clang-analyzer-unix.API,
clang-analyzer-unix.cstring.BadSizeArg,
clang-analyzer-unix.cstring.NullArg,
clang-analyzer-unix.Malloc,
clang-analyzer-unix.MallocSizeof,
clang-analyzer-unix.MismatchedDeallocator,
clang-analyzer-unix.Vfork,
clang-analyzer-valist.CopyToSelf,
clang-analyzer-valist.Uninitialized,
clang-analyzer-valist.Unterminated,
clang-diagnostic-*,
cppcoreguidelines-avoid-const-or-ref-data-members,
cppcoreguidelines-avoid-non-const-global-variables,
cppcoreguidelines-init-variables,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-macro-usage,
cppcoreguidelines-missing-std-forward,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-no-malloc,
cppcoreguidelines-prefer-member-initializer,
cppcoreguidelines-pro-bounds-pointer-arithmetic,
cppcoreguidelines-pro-type-const-cast,
cppcoreguidelines-pro-type-cstyle-cast,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-reinterpret-cast,
cppcoreguidelines-pro-type-union-access,
cppcoreguidelines-pro-type-vararg,
cppcoreguidelines-slicing,
cppcoreguidelines-special-member-functions,
facebook-hte-BadEnum,
facebook-hte-MissingStatic,
google-build-using-namespace,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-misplaced-const,
misc-new-delete-overloads,
misc-non-copyable-objects,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-alias-decls,
misc-unused-parameters,
misc-unused-using-decls,
modernize-avoid-bind,
modernize-avoid-c-arrays,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-random-shuffle,
modernize-return-braced-init-list,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-auto,
modernize-use-bool-literals,
modernize-use-constraints,
modernize-use-default-member-init,
modernize-use-designated-initializers,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-starts-ends-with,
modernize-use-transparent-functors,
modernize-use-using,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-string-concatenation,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-noexcept-move-constructor,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
readability-deleted-default,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-isolate-declaration,
readability-misplaced-array-index,
readability-named-parameter,
readability-non-const-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-preprocessor,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release,
'
CheckOptions:
- key: performance-unnecessary-value-param.AllowedTypes
value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$;'
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'
...

84
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,84 @@
/**
* 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.
*
* @format
*/
module.exports = {
root: true,
ignorePatterns: ['**/binaries/**', '**/build/**', '**/generated/**'],
overrides: [
// Catch-all
{
files: ['**/*.?(m|c){j,t}s?(x)'],
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
plugins: ['prettier'],
rules: {
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
'no-var': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-object-spread': 'error',
'prefer-spread': 'error',
'require-await': 'error',
},
env: {
es2020: true,
'shared-node-browser': true,
},
parserOptions: {
ecmaVersion: 'latest',
},
},
// ES Modules
{
files: ['**/*.?(m){j,t}s?(x)'],
parserOptions: {
sourceType: 'module',
},
},
// CommonJS Modules
{
files: ['**/*.c{j,t}s?(x)'],
env: {
commonjs: true,
},
parserOptions: {
sourceType: 'commonjs',
},
},
// TypeScript
{
files: ['**/*.?(m|c)ts?(x)'],
extends: ['plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_'},
],
'@typescript-eslint/no-var-requires': 'off',
},
},
// Node
{
files: ['**/.*rc.(c){j,t}s', '**/*.config.?(c){j,t}s'],
env: {
node: true,
},
},
// Jest
{
files: ['**/tests/**'],
extends: ['plugin:jest/recommended'],
},
],
};

25
.github/actions/black/action.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Black Formatter
inputs:
directory:
description: Directory to Lint
required: true
version:
description: pypi version of "black" to use
required: false
default: 22.3.0
runs:
using: "composite"
steps:
- name: Ensure supported Python selected
uses: actions/setup-python@v4
with:
python-version: '>=3.6.2'
- name: pip install
shell: bash
run: pip install black==${{ inputs.version }}
- name: black
shell: bash
run: black --check ${{ inputs.directory }}

10
.github/actions/cache-emsdk/action.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
name: Cache the installed copy of emsdk and its build artifacts
runs:
using: "composite"
steps:
- name: Cache emsdk
uses: actions/cache@v3
with:
path: javascript/.emsdk
key: emsdk-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock', 'javascript/package.json', 'javascript/just.config.cjs')}}

23
.github/actions/clang-format/action.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
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

@@ -0,0 +1,14 @@
name: Install Ninja
runs:
using: "composite"
steps:
- name: Install ninja (Linux)
if: ${{ runner.os == 'Linux' }}
shell: bash
run: sudo apt-get install -y ninja-build
- name: Install ninja (Windows)
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: choco install ninja

View File

@@ -0,0 +1,12 @@
name: Setup Android environment
runs:
using: "composite"
steps:
- name: Select Java Version
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 17
- name: Configure Gradle Caches
uses: gradle/gradle-build-action@v2

13
.github/actions/setup-apple/action.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: Setup Apple envirionment
runs:
using: "composite"
steps:
# TODO: This and Ruby should be versioned
- name: Install Cocoapods
shell: bash
run: sudo gem install cocoapods
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 14.3.1

33
.github/actions/setup-cpp/action.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Setup C++ envirionment
inputs:
toolchain:
description: Compiler toolchain to use (Clang, GCC, or MSVC)
required: false
default: 'Clang'
runs:
using: "composite"
steps:
- name: Install Ninja
if: ${{ runner.os != 'Windows' }}
uses: ./.github/actions/install-ninja
- name: Set Clang as compiler
if: ${{ inputs.toolchain == 'Clang' }}
shell: bash
run: |
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
echo "LDFLAGS=-stdlib=libc++" >> $GITHUB_ENV
- name: Set GCC as compiler
if: ${{ inputs.toolchain == 'GCC' }}
shell: bash
run: |
echo "CC=/usr/bin/gcc" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++" >> $GITHUB_ENV
- name: Setup VS Developer Command Prompt
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1

18
.github/actions/setup-js/action.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Setup JavaScript envirionment
runs:
using: "composite"
steps:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: yarn
cache-dependency-path: yarn.lock
env:
# https://github.com/actions/setup-node/issues/317
FORCE_COLOR: 0
- name: yarn install
shell: bash
run: yarn install --frozen-lockfile

View File

@@ -0,0 +1,38 @@
name: Publish Android Release
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-android
- name: Publish to Maven Local
run: ./gradlew publishToMavenLocal
env:
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: 'snapshot-artifacts'
path: '~/.m2/repository/'
- name: Publish to the Maven Central
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}

View File

@@ -0,0 +1,36 @@
name: Publish Android Snapshot
on:
push:
branches:
- main
workflow_dispatch:
jobs:
publish:
name: Publish Snapshot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-android
- name: Publish to Maven Local
run: ./gradlew publishToMavenLocal
env:
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: 'snapshot-artifacts'
path: '~/.m2/repository/'
- name: Publish to the Snapshot Repository
run: ./gradlew publishToSonatype
env:
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true

View File

@@ -0,0 +1,23 @@
name: Publish CocoaPods Release
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
publish:
name: Publish to CocoaPods trunk
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-apple
- name: Publish Yoga
run: pod trunk push Yoga.podspec
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

View File

@@ -0,0 +1,25 @@
name: Publish NPM Release
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
publish:
name: Publish to npmjs registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: Store auth token in config file
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: yarn publish
run: yarn publish
working-directory: javascript

27
.github/workflows/validate-android.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: Validate Android
on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:
jobs:
build:
name: Build [${{ matrix.os }}][${{ matrix.mode }}]
runs-on: ${{ matrix.os }}
strategy:
matrix:
mode: [Debug, Release]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-android
- name: Build
run: ./gradlew assemble${{ matrix.mode }} --stacktrace

39
.github/workflows/validate-apple.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: Validate Apple
on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:
jobs:
lint-pods:
name: Build [CocoaPods]
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-apple
- name: pod lib lint
run: pod lib lint --verbose --include-podspecs=**/*.podspec
test:
name: Build [SwiftPM]
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-apple
- name: Build Debug
run: swift build -c debug
- name: Build Release
run: swift build -c release

109
.github/workflows/validate-cpp.yml vendored Normal file
View File

@@ -0,0 +1,109 @@
name: Validate C++
on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:
env:
GTEST_COLOR: 1
jobs:
test:
name: Build and Test [${{ matrix.toolchain }}][${{ matrix.mode }}]
runs-on: ${{ (matrix.toolchain == 'MSVC') && 'windows-latest' || 'ubuntu-latest' }}
strategy:
matrix:
mode: [Debug, Release]
toolchain: [Clang, GCC] # TODO: fix issues building GTest Binary with MSVC in GitHub Actions
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-cpp
with:
toolchain: ${{ matrix.toolchain }}
- name: Unit tests
run: ./unit_tests ${{ matrix.mode }}
build_fuzzers:
name: Build fuzzers [${{ matrix.toolchain }}][${{ matrix.mode }}]
runs-on: ubuntu-latest
strategy:
matrix:
mode: [Debug, Release]
toolchain: [Clang]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-cpp
with:
toolchain: ${{ matrix.toolchain }}
- name: Unit tests
run: ./build_fuzz_tests ${{ matrix.mode }}
benchmark:
name: Benchmark [${{ matrix.toolchain }}]
runs-on: ${{ (matrix.toolchain == 'MSVC') && 'windows-latest' || 'ubuntu-latest' }}
strategy:
matrix:
toolchain: [Clang, GCC, MSVC]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-cpp
with:
toolchain: ${{ matrix.toolchain }}
- name: Build and run benchmark
run: |
cmake -S . -B build -G Ninja -D CMAKE_BUILD_TYPE=Release
cmake --build build
./build/benchmark ./captures
working-directory: benchmark
- name: Build and run benchmarklegacy
run: ./build/benchmarklegacy
working-directory: benchmark
capture:
name: Capture [${{ matrix.toolchain }}]
runs-on: ${{ (matrix.toolchain == 'MSVC') && 'windows-latest' || 'ubuntu-latest' }}
strategy:
matrix:
toolchain: [Clang, GCC, MSVC]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-cpp
with:
toolchain: ${{ matrix.toolchain }}
- name: Build capture
run: |
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

116
.github/workflows/validate-js.yml vendored Normal file
View File

@@ -0,0 +1,116 @@
name: Validate JavaScript
on:
pull_request:
push:
branches:
- main
- 'release-*'
workflow_dispatch:
env:
FORCE_COLOR: 3
jobs:
benchmark:
name: Benchmark [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: Restore emsdk
uses: ./.github/actions/cache-emsdk
- name: yarn benchmark
run: yarn benchmark
working-directory: javascript
build:
name: Build [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: Restore emsdk
uses: ./.github/actions/cache-emsdk
- name: yarn build
run: yarn build --verbose
working-directory: javascript
test:
name: Test [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: Restore emsdk
uses: ./.github/actions/cache-emsdk
- name: yarn test
run: yarn test
working-directory: javascript
lint:
name: ESLint (All Packages)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: yarn lint
run: yarn lint
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: yarn tsc
run: yarn tsc
working-directory: javascript
pack:
name: Pack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: Restore emsdk
uses: ./.github/actions/cache-emsdk
- name: yarn pack
run: yarn pack --filename yoga-layout.tar.gz
working-directory: javascript
- uses: actions/upload-artifact@v3
with:
name: npm-package
path: javascript/yoga-layout.tar.gz

32
.github/workflows/validate-tests.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Validate Tests
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup JS
uses: ./.github/actions/setup-js
- name: yarn gentest-validate
run: yarn gentest-validate
- name: yarn gentest
run: yarn gentest -h
- name: Check for modified tests
run: |
if [[ -n $(git status -s) ]]; then
git status -s
echo "yarn gentest modified these tests. Please run yarn gentest to resolve."
exit 1
fi

42
.github/workflows/validate-website.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Validate Website
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
build_next:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: Restore emsdk
uses: ./.github/actions/cache-emsdk
- name: Build Website
run: yarn build
working-directory: website
typecheck:
name: Typecheck [Docusaurus]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-js
- name: yarn tsc
run: yarn tsc
working-directory: website

12
.gitignore vendored
View File

@@ -5,14 +5,16 @@
/.buckconfig.local
/.buckd
/gentest/test.html
.buckversion
.buck-java11
node_modules
# Jekyll
/.sass-cache/
/_site/
# Visual studio code
.vscode
!.vscode
*.pdb
*.tlog
*.obj
@@ -63,5 +65,11 @@ Carthage/Build
# Gradle
.gradle
local.properties
# NDK/CMake
.cxx
.externalNativeBuild
# Docusarus build
.docusaurus

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "lib/gtest/googletest"]
path = lib/gtest/googletest
url = https://github.com/google/googletest.git

3
.prettierignore Normal file
View File

@@ -0,0 +1,3 @@
**/binaries/**
**/build/**
**/generated/**

16
.prettierrc.js Normal file
View File

@@ -0,0 +1,16 @@
/**
* 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.
*
* @format
*/
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};

View File

@@ -1 +0,0 @@
3.0

View File

@@ -1,76 +0,0 @@
language: java
os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-6.0
- ubuntu-toolchain-r-test
packages:
- clang-6.0
env:
- TARGET: website
- TARGET: android
install:
- cd website
- yarn --ignore-scripts
- cd ..
cache:
directories:
- $HOME/buck
- $HOME/.gradle
before_install:
- |
if [[ -n "$encrypted_d27e803291ff_iv" ]]; then
openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties;
fi
# Android
- |
if [[ $TARGET = "android" ]]; then
pushd $HOME
git clone --depth 1 https://github.com/facebook/buck.git
cd buck
ant
popd
export PATH=$PATH:$HOME/buck/bin/
buck --version
export TERMINAL=dumb
source scripts/android-setup.sh && installAndroidSDK
export ANDROID_SDK=$ANDROID_HOME
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
export ANDROID_NDK_HOME=$ANDROID_NDK_REPOSITORY/android-ndk-r15c
fi
# Website
- |
if [[ $TARGET = "website" ]]; then
nvm install 8
nvm use 8
fi
script:
- |
if [[ $TARGET = "android" ]]; then
./gradlew testDebugUnit && scripts/publish-snapshot.sh
fi
- |
if [[ $TARGET = "website" ]]; then
pushd website
yarn build
popd
fi
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
fqdn: yogalayout.com
local-dir: website/public
email: yogabot@fb.com
name: Yoga-bot
keep-history: true
on:
branch: master
condition: $TARGET = website

7
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"recommendations": [
"ms-vscode.cpptools",
"EditorConfig.EditorConfig",
"dbaeumer.vscode-eslint",
]
}

25
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug C++ Unit tests (lldb)",
"type": "cppdbg",
"MIMode": "lldb",
"request": "launch",
"program": "${workspaceFolder}/tests/build/yogatests",
"cwd": "${workspaceFolder}",
"preLaunchTask": "Build Unit Tests"
},
{
"name": "Debug C++ Unit tests (vsdbg)",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/tests/build/yogatests",
"cwd": "${workspaceFolder}",
"preLaunchTask": "Build Unit Tests"
}
]
}

20
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.format.enable": true,
"eslint.packageManager": "yarn",
"eslint.enable": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
}

23
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,23 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build Unit Tests",
"type": "shell",
"command": "(which ninja && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug -G Ninja || cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug) && cmake --build build",
"windows": {
"command": "(where ninja && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug -G Ninja || cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug) && cmake --build build",
},
"group": "build",
"options": {
"cwd": "tests"
},
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}

60
BUCK
View File

@@ -1,60 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep")
GMOCK_OVERRIDE_FLAGS = [
# gmock does not mark mocked methods as override, ignore the warnings in tests
"-Wno-inconsistent-missing-override",
]
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
"-std=c++1y",
]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
"-std=c++1y",
"-DDEBUG",
]
yoga_cxx_library(
name = "yoga",
srcs = glob(["yoga/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = COMPILER_FLAGS,
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
yoga_dep("lib/fb:ndklog"),
],
)
yoga_cxx_library(
name = "yogaForDebug",
srcs = glob(["yoga/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = TEST_COMPILER_FLAGS,
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
yoga_dep("lib/fb:ndklog"),
],
)
yoga_cxx_test(
name = "YogaTests",
srcs = glob(["tests/*.cpp"]),
headers = subdir_glob([("", "yoga/**/*.h")]),
compiler_flags = TEST_COMPILER_FLAGS,
contacts = ["emilsj@fb.com"],
visibility = ["PUBLIC"],
deps = [
":yogaForDebug",
GTEST_TARGET,
],
)

View File

@@ -1,15 +1,58 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
# 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.
#
cmake_minimum_required(VERSION 3.4.1)
cmake_minimum_required(VERSION 3.13...3.26)
project(yoga-all)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB yogacore_SRC yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/project-defaults.cmake)
target_link_libraries(yogacore android log)
add_subdirectory(yoga)
add_subdirectory(tests)
option(BUILD_FUZZ_TESTS "Build fuzz tests" OFF)
if ('${CMAKE_CXX_COMPILER_ID}' MATCHES 'Clang' AND BUILD_FUZZ_TESTS)
add_subdirectory(fuzz)
endif()
# cmake install config
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# declare target to install
install(TARGETS yogacore EXPORT yoga-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install header files
install(DIRECTORY
"${CMAKE_CURRENT_LIST_DIR}/yoga"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
# install target config
install(EXPORT yoga-targets
FILE yogaTargets.cmake
NAMESPACE yoga::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yoga
)
# generate config file
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/yoga-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/yogaConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yoga
)
# install config file
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/yogaConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yoga
)

View File

@@ -1,3 +1,76 @@
# Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <opensource-conduct@fb.com>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@@ -8,7 +8,7 @@ Facebook has adopted a Code of Conduct that we expect project participants to ad
## Pull Requests
We actively welcome your pull requests.
1. Fork the repo and create your branch from `master`.
1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.

32
Package.swift Normal file
View File

@@ -0,0 +1,32 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
/*
* 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.
*/
import PackageDescription
let package = Package(
name: "yoga",
products: [
.library(name: "yoga", targets: [ "core" ])
],
targets: [
.target(
name: "core",
path: ".",
sources: [
"yoga"
],
publicHeadersPath: ".",
cxxSettings: [
.headerSearchPath(".")
]
)
],
cxxLanguageStandard: CXXLanguageStandard(rawValue: "c++20")
)

View File

@@ -1,14 +1,22 @@
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg)](http://cocoapods.org/pods/YogaKit) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![bintray](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga:yoga.svg)](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [![NuGet](https://img.shields.io/nuget/v/Facebook.Yoga.svg)](https://www.nuget.org/packages/Facebook.Yoga)
# 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 is an embeddable and performant flexbox layout engine with bindings for multiple languages.
## Building
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
## Testing
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
Yoga's main implementation targets C++ 20 with accompanying build logic in CMake. A wrapper is provided to build the main library and run unit tests.
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
```sh
./unit_tests <Debug|Release>
```
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generate a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
While not required, this script will use [ninja](https://ninja-build.org/) if it is installed for faster builds.
Yoga is additionally part of the [vcpkg](https://github.com/Microsoft/vcpkg/) collection of ports maintained by Microsoft and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
## Adding Tests
Many of Yoga's tests are automatically generated, using HTML fixtures describing node structure. These are rendered in Chrome to generate an expected layout result for the tree. New fixtures can be added to `gentest/fixtures`.
```html
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
@@ -16,33 +24,12 @@ Instead of manually writing a test which ensures parity with web implementations
</div>
```
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:yoga` to validate the behavior. One test case will be generated for every root `div` in the input html.
To generate new tests from added fixtures:
You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script.
1. Ensure you have [yarn classic](https://classic.yarnpkg.com) installed.
2. Run `yarn install` to install dependencies for the test generator.
3. Run `yarn gentest` in the `yoga` directory.
### .NET
.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.Yoga/test_macos.sh`.
## Debugging
## Benchmarks
Benchmarks are located in `benchmark/YGBenchmark.c` and can be run with `buck run //benchmark:benchmark`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.
### JavaScript
Installing through NPM
```sh
npm install yoga-layout
```
By default this will install the library and try to build for all platforms (node, browser asm, and standalone webpack). You may receive errors if you do not have the required platform development tools already installed. To preset the platform you'd like to build for you can set a .npmrc property first.
```sh
npm config set yoga-layout:platform standalone
```
This will now only run the standalone webpack build upon install.
## Build Platforms
| name | description |
|----------------|-------------------------------------------------|
| all (default) | Builds all of these platforms. |
| browser | Builds asm js browser version. |
| node | Builds node js version. |
| standalone | Runs webpack. |
| none | Does nothing. You can use the prepackaged libs. |
Yoga provides a VSCode "launch.json" configuration which allows debugging unit tests. Simply add your breakpoints, and run "Debug C++ Unit tests (lldb)" (or "Debug C++ Unit tests (vsdbg)" on Windows).

View File

@@ -1,39 +1,50 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '1.12.0-pre.1'
spec.version = '0.0.0'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://yogalayout.com/docs'
spec.homepage = 'https://yogalayout.dev/'
spec.documentation_url = 'https://yogalayout.dev/docs'
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
spec.summary = 'An embeddable and performant flexbox layout engine with bindings for multiple languages'
spec.authors = 'Facebook'
spec.authors = {'Meta Open Source' => 'opensource@meta.com'}
spec.source = {
:git => 'https://github.com/facebook/yoga.git',
:tag => spec.version.to_s,
:tag => "v#{spec.version.to_s}",
}
spec.platforms = { :ios => "4.3", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
spec.ios.deployment_target = "13.4"
spec.module_name = 'yoga'
spec.requires_arc = false
spec.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES'
'DEFINES_MODULE' => 'YES',
'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
}
spec.compiler_flags = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-std=c++1y',
'-std=c++20',
'-fPIC'
]
spec.source_files = 'yoga/**/*.{c,h,cpp}'
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
spec.swift_version = '5.1'
spec.source_files = 'yoga/**/*.{h,cpp}'
spec.header_mappings_dir = 'yoga'
public_header_files = 'yoga/*.h'
spec.public_header_files = public_header_files
all_header_files = 'yoga/**/*.h'
spec.private_header_files = Dir.glob(all_header_files) - Dir.glob(public_header_files)
spec.preserve_paths = [all_header_files]
end

View File

@@ -1,36 +0,0 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit'
spec.version = '1.12.0'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
spec.authors = 'Facebook'
spec.source = {
:git => 'https://github.com/facebook/yoga.git',
:tag => spec.version.to_s,
}
spec.platform = :ios
spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'UIKit'
spec.dependency 'Yoga', '~> 1.9'
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
spec.swift_version = '3.0'
end
# See https://github.com/facebook/yoga/pull/366
podspec.attributes_hash["readme"] = "YogaKit/README.md"
podspec

View File

@@ -1 +0,0 @@
3.0.2

View File

@@ -1,64 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
COMPILER_FLAGS = [
"-fobjc-arc",
"-Wconditional-uninitialized",
"-Wdangling-else",
"-Wdeprecated-declarations",
"-Wimplicit-retain-self",
"-Wincomplete-implementation",
"-Wobjc-method-access",
"-Wobjc-missing-super-calls",
"-Wmismatched-return-types",
"-Wreturn-type",
"-Wno-global-constructors",
"-Wno-shadow",
"-Wunused-const-variable",
"-Wunused-function",
"-Wunused-property-ivar",
"-Wunused-result",
"-Wunused-value",
]
yoga_apple_library(
name = "YogaKit",
srcs = glob(["Source/**/*.m"]),
header_namespace = "",
exported_headers = subdir_glob(
[
("", "Source/**/*.h"),
("Source", "**/*.h"),
],
prefix = "YogaKit",
),
compiler_flags = COMPILER_FLAGS,
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
],
header_path_prefix = "",
link_whole = True,
visibility = ["PUBLIC"],
deps = [
yoga_dep(":yoga"),
],
)
yoga_apple_test(
name = "YogaKitTests",
srcs = glob(["Tests/**/*.m"]),
compiler_flags = COMPILER_FLAGS,
frameworks = [
"$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework",
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
],
info_plist = "Tests/Info.plist",
visibility = ["PUBLIC"],
deps = [
":YogaKit",
],
)

View File

@@ -1,22 +0,0 @@
# YogaKit
[![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg?style=flat)](https://cocoapods.org/pods/YogaKit)
[![Platform](https://img.shields.io/badge/platforms-iOS-orange.svg)](https://facebook.github.io/yoga/docs/api/yogakit/)
[![Languages](https://img.shields.io/badge/languages-ObjC%20%7C%20Swift-orange.svg)](https://facebook.github.io/yoga/docs/api/yogakit/)
## Installation
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
```
pod 'YogaKit', '~> 1.7'
```
## Getting Started
Checkout the docs [here](https://facebook.github.io/yoga/docs/api/yogakit/).
We also have a sample project. To try it out, clone this repo and open `YogaKitSample.xcodeproj` in the [YogaKitSample](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample) directory.
## Contributing
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) file for how to help out.

View File

@@ -1,35 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#import "YGLayout.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef void (^YGLayoutConfigurationBlock)(YGLayout *layout);
@interface UIView (Yoga)
/**
The YGLayout that is attached to this view. It is lazily created.
*/
@property (nonatomic, readonly, strong) YGLayout *yoga;
/**
Indicates whether or not Yoga is enabled
*/
@property (nonatomic, readonly, assign) BOOL isYogaEnabled;
/**
In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend`
to your code. If you plan on making multiple changes to YGLayout, it's more performant
to use this method, which uses a single objc_msgSend call.
*/
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
NS_SWIFT_NAME(configureLayout(block:));
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,39 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "UIView+Yoga.h"
#import "YGLayout+Private.h"
#import <objc/runtime.h>
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
@implementation UIView (YogaKit)
- (YGLayout *)yoga
{
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
if (!yoga) {
yoga = [[YGLayout alloc] initWithView:self];
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return yoga;
}
- (BOOL)isYogaEnabled
{
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
}
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
{
if (block != nil) {
block(self.yoga);
}
}
@end

View File

@@ -1,16 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#import "YGLayout.h"
#import <yoga/Yoga.h>
@interface YGLayout ()
@property (nonatomic, assign, readonly) YGNodeRef node;
- (instancetype)initWithView:(UIView *)view;
@end

View File

@@ -1,169 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import <yoga/YGEnums.h>
#import <yoga/Yoga.h>
#import <yoga/YGMacros.h>
YG_EXTERN_C_BEGIN
extern YGValue YGPointValue(CGFloat value)
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
extern YGValue YGPercentValue(CGFloat value)
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
YG_EXTERN_C_END
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
YGDimensionFlexibilityFlexibleWidth = 1 << 0,
YGDimensionFlexibilityFlexibleHeight = 1 << 1,
};
@interface YGLayout : NSObject
/**
Make default init unavailable, as it will not initialise YGNode which is
required for the setters and getters of YGLayout's properties to work properly.
*/
- (instancetype)init
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
Make default init unavailable, as it will not initialise YGNode which is
required for the setters and getters of YGLayout's properties to work properly.
*/
+ (instancetype)new
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
The property that decides if we should include this view when calculating
layout. Defaults to YES.
*/
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
/**
The property that decides during layout/sizing whether or not styling properties should be applied.
Defaults to NO.
*/
@property (nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
@property (nonatomic, readwrite, assign) YGDirection direction;
@property (nonatomic, readwrite, assign) YGFlexDirection flexDirection;
@property (nonatomic, readwrite, assign) YGJustify justifyContent;
@property (nonatomic, readwrite, assign) YGAlign alignContent;
@property (nonatomic, readwrite, assign) YGAlign alignItems;
@property (nonatomic, readwrite, assign) YGAlign alignSelf;
@property (nonatomic, readwrite, assign) YGPositionType position;
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
@property (nonatomic, readwrite, assign) YGOverflow overflow;
@property (nonatomic, readwrite, assign) YGDisplay display;
@property (nonatomic, readwrite, assign) CGFloat flex;
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
@property (nonatomic, readwrite, assign) YGValue flexBasis;
@property (nonatomic, readwrite, assign) YGValue left;
@property (nonatomic, readwrite, assign) YGValue top;
@property (nonatomic, readwrite, assign) YGValue right;
@property (nonatomic, readwrite, assign) YGValue bottom;
@property (nonatomic, readwrite, assign) YGValue start;
@property (nonatomic, readwrite, assign) YGValue end;
@property (nonatomic, readwrite, assign) YGValue marginLeft;
@property (nonatomic, readwrite, assign) YGValue marginTop;
@property (nonatomic, readwrite, assign) YGValue marginRight;
@property (nonatomic, readwrite, assign) YGValue marginBottom;
@property (nonatomic, readwrite, assign) YGValue marginStart;
@property (nonatomic, readwrite, assign) YGValue marginEnd;
@property (nonatomic, readwrite, assign) YGValue marginHorizontal;
@property (nonatomic, readwrite, assign) YGValue marginVertical;
@property (nonatomic, readwrite, assign) YGValue margin;
@property (nonatomic, readwrite, assign) YGValue paddingLeft;
@property (nonatomic, readwrite, assign) YGValue paddingTop;
@property (nonatomic, readwrite, assign) YGValue paddingRight;
@property (nonatomic, readwrite, assign) YGValue paddingBottom;
@property (nonatomic, readwrite, assign) YGValue paddingStart;
@property (nonatomic, readwrite, assign) YGValue paddingEnd;
@property (nonatomic, readwrite, assign) YGValue paddingHorizontal;
@property (nonatomic, readwrite, assign) YGValue paddingVertical;
@property (nonatomic, readwrite, assign) YGValue padding;
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
@property (nonatomic, readwrite, assign) CGFloat borderRightWidth;
@property (nonatomic, readwrite, assign) CGFloat borderBottomWidth;
@property (nonatomic, readwrite, assign) CGFloat borderStartWidth;
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
@property (nonatomic, readwrite, assign) YGValue width;
@property (nonatomic, readwrite, assign) YGValue height;
@property (nonatomic, readwrite, assign) YGValue minWidth;
@property (nonatomic, readwrite, assign) YGValue minHeight;
@property (nonatomic, readwrite, assign) YGValue maxWidth;
@property (nonatomic, readwrite, assign) YGValue maxHeight;
// Yoga specific properties, not compatible with flexbox specification
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
/**
Get the resolved direction of this node. This won't be YGDirectionInherit
*/
@property (nonatomic, readonly, assign) YGDirection resolvedDirection;
/**
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
If the origin is not preserved, the root view's layout results will applied from {0,0}.
*/
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
/**
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
If the origin is not preserved, the root view's layout results will applied from {0,0}.
*/
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
/**
Returns the size of the view if no constraints were given. This could equivalent to calling [self
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
*/
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
/**
Returns the size of the view based on provided constraints. Pass NaN for an unconstrained dimension.
*/
- (CGSize)calculateLayoutWithSize:(CGSize)size
NS_SWIFT_NAME(calculateLayout(with:));
/**
Returns the number of children that are using Flexbox.
*/
@property (nonatomic, readonly, assign) NSUInteger numberOfChildren;
/**
Return a BOOL indiciating whether or not we this node contains any subviews that are included in
Yoga's layout.
*/
@property (nonatomic, readonly, assign) BOOL isLeaf;
/**
Return's a BOOL indicating if a view is dirty. When a node is dirty
it usually indicates that it will be remeasured on the next layout pass.
*/
@property (nonatomic, readonly, assign) BOOL isDirty;
/**
Mark that a view's layout needs to be recalculated. Only works for leaf views.
*/
- (void)markDirty;
@end

View File

@@ -1,482 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout+Private.h"
#import "UIView+Yoga.h"
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
- (type)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(type)lowercased_name \
{ \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
}
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
case YGUnitAuto: \
YGNodeStyleSet##capitalized_name##Auto(self.node); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
- (type)lowercased_name \
{ \
return YGNodeStyleGet##property(self.node, edge); \
}
#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \
- (void)set##capitalized_name:(CGFloat)lowercased_name \
{ \
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
}
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(CGFloat, lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
{ \
switch (objc_lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##c_name##Percent(self.node, edge, objc_lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(YGValue, lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
YGValue YGPointValue(CGFloat value)
{
return (YGValue) { .value = value, .unit = YGUnitPoint };
}
YGValue YGPercentValue(CGFloat value)
{
return (YGValue) { .value = value, .unit = YGUnitPercent };
}
static YGConfigRef globalConfig;
@interface YGLayout ()
@property (nonatomic, weak, readonly) UIView *view;
@property(nonatomic, assign, readonly) BOOL isUIView;
@end
@implementation YGLayout
@synthesize isEnabled=_isEnabled;
@synthesize isIncludedInLayout=_isIncludedInLayout;
@synthesize node=_node;
+ (void)initialize
{
globalConfig = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
}
- (instancetype)initWithView:(UIView*)view
{
if (self = [super init]) {
_view = view;
_node = YGNodeNewWithConfig(globalConfig);
YGNodeSetContext(_node, (__bridge void *) view);
_isEnabled = NO;
_isIncludedInLayout = YES;
_isUIView = [view isMemberOfClass:[UIView class]];
}
return self;
}
- (void)dealloc
{
YGNodeFree(self.node);
}
- (BOOL)isDirty
{
return YGNodeIsDirty(self.node);
}
- (void)markDirty
{
if (self.isDirty || !self.isLeaf) {
return;
}
// Yoga is not happy if we try to mark a node as "dirty" before we have set
// the measure function. Since we already know that this is a leaf,
// this *should* be fine. Forgive me Hack Gods.
const YGNodeRef node = self.node;
if (YGNodeHasMeasureFunc(node)) {
YGNodeSetMeasureFunc(node, YGMeasureView);
}
YGNodeMarkDirty(node);
}
- (NSUInteger)numberOfChildren
{
return YGNodeGetChildCount(self.node);
}
- (BOOL)isLeaf
{
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
if (self.isEnabled) {
for (UIView *subview in self.view.subviews) {
YGLayout *const yoga = subview.yoga;
if (yoga.isEnabled && yoga.isIncludedInLayout) {
return NO;
}
}
}
return YES;
}
#pragma mark - Style
- (YGPositionType)position
{
return YGNodeStyleGetPositionType(self.node);
}
- (void)setPosition:(YGPositionType)position
{
YGNodeStyleSetPositionType(self.node, position);
}
YG_PROPERTY(YGDirection, direction, Direction)
YG_PROPERTY(YGFlexDirection, flexDirection, FlexDirection)
YG_PROPERTY(YGJustify, justifyContent, JustifyContent)
YG_PROPERTY(YGAlign, alignContent, AlignContent)
YG_PROPERTY(YGAlign, alignItems, AlignItems)
YG_PROPERTY(YGAlign, alignSelf, AlignSelf)
YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
YG_PROPERTY(YGOverflow, overflow, Overflow)
YG_PROPERTY(YGDisplay, display, Display)
YG_PROPERTY(CGFloat, flex, Flex)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft)
YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop)
YG_VALUE_EDGE_PROPERTY(right, Right, Position, YGEdgeRight)
YG_VALUE_EDGE_PROPERTY(bottom, Bottom, Position, YGEdgeBottom)
YG_VALUE_EDGE_PROPERTY(start, Start, Position, YGEdgeStart)
YG_VALUE_EDGE_PROPERTY(end, End, Position, YGEdgeEnd)
YG_VALUE_EDGES_PROPERTIES(margin, Margin)
YG_VALUE_EDGES_PROPERTIES(padding, Padding)
YG_EDGE_PROPERTY(borderLeftWidth, BorderLeftWidth, Border, YGEdgeLeft)
YG_EDGE_PROPERTY(borderTopWidth, BorderTopWidth, Border, YGEdgeTop)
YG_EDGE_PROPERTY(borderRightWidth, BorderRightWidth, Border, YGEdgeRight)
YG_EDGE_PROPERTY(borderBottomWidth, BorderBottomWidth, Border, YGEdgeBottom)
YG_EDGE_PROPERTY(borderStartWidth, BorderStartWidth, Border, YGEdgeStart)
YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd)
YG_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll)
YG_AUTO_VALUE_PROPERTY(width, Width)
YG_AUTO_VALUE_PROPERTY(height, Height)
YG_VALUE_PROPERTY(minWidth, MinWidth)
YG_VALUE_PROPERTY(minHeight, MinHeight)
YG_VALUE_PROPERTY(maxWidth, MaxWidth)
YG_VALUE_PROPERTY(maxHeight, MaxHeight)
YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
#pragma mark - Layout and Sizing
- (YGDirection)resolvedDirection
{
return YGNodeLayoutGetDirection(self.node);
}
- (void)applyLayout
{
[self calculateLayoutWithSize:self.view.bounds.size];
YGApplyLayoutToViewHierarchy(self.view, NO);
}
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
{
[self calculateLayoutWithSize:self.view.bounds.size];
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
}
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
{
CGSize size = self.view.bounds.size;
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
size.width = YGUndefined;
}
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeight) {
size.height = YGUndefined;
}
[self calculateLayoutWithSize:size];
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
}
- (CGSize)intrinsicSize
{
const CGSize constrainedSize = {
.width = YGUndefined,
.height = YGUndefined,
};
return [self calculateLayoutWithSize:constrainedSize];
}
- (CGSize)calculateLayoutWithSize:(CGSize)size
{
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
YGAttachNodesFromViewHierachy(self.view);
const YGNodeRef node = self.node;
YGNodeCalculateLayout(
node,
size.width,
size.height,
YGNodeStyleGetDirection(node));
return (CGSize) {
.width = YGNodeLayoutGetWidth(node),
.height = YGNodeLayoutGetHeight(node),
};
}
#pragma mark - Private
static YGSize YGMeasureView(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode)
{
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
CGSize sizeThatFits = CGSizeZero;
// The default implementation of sizeThatFits: returns the existing size of
// the view. That means that if we want to layout an empty UIView, which
// already has got a frame set, its measured size should be CGSizeZero, but
// UIKit returns the existing size.
//
// See https://github.com/facebook/yoga/issues/606 for more information.
if (!view.yoga.isUIView || [view.subviews count] > 0) {
sizeThatFits = [view sizeThatFits:(CGSize){
.width = constrainedWidth,
.height = constrainedHeight,
}];
}
return (YGSize) {
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
};
}
static CGFloat YGSanitizeMeasurement(
CGFloat constrainedSize,
CGFloat measuredSize,
YGMeasureMode measureMode)
{
CGFloat result;
if (measureMode == YGMeasureModeExactly) {
result = constrainedSize;
} else if (measureMode == YGMeasureModeAtMost) {
result = MIN(constrainedSize, measuredSize);
} else {
result = measuredSize;
}
return result;
}
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
{
if (YGNodeGetChildCount(node) != subviews.count) {
return NO;
}
for (int i=0; i<subviews.count; i++) {
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
return NO;
}
}
return YES;
}
static void YGAttachNodesFromViewHierachy(UIView *const view)
{
YGLayout *const yoga = view.yoga;
const YGNodeRef node = yoga.node;
// Only leaf nodes should have a measure function
if (yoga.isLeaf) {
YGRemoveAllChildren(node);
YGNodeSetMeasureFunc(node, YGMeasureView);
} else {
YGNodeSetMeasureFunc(node, NULL);
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView *subview in view.subviews) {
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
[subviewsToInclude addObject:subview];
}
}
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
YGRemoveAllChildren(node);
for (int i=0; i<subviewsToInclude.count; i++) {
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
}
}
for (UIView *const subview in subviewsToInclude) {
YGAttachNodesFromViewHierachy(subview);
}
}
}
static void YGRemoveAllChildren(const YGNodeRef node)
{
if (node == NULL) {
return;
}
YGNodeRemoveAllChildren(node);
}
static CGFloat YGRoundPixelValue(CGFloat value)
{
static CGFloat scale;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^(){
scale = [UIScreen mainScreen].scale;
});
return roundf(value * scale) / scale;
}
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
{
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
const YGLayout *yoga = view.yoga;
if (!yoga.isIncludedInLayout) {
return;
}
YGNodeRef node = yoga.node;
const CGPoint topLeft = {
YGNodeLayoutGetLeft(node),
YGNodeLayoutGetTop(node),
};
const CGPoint bottomRight = {
topLeft.x + YGNodeLayoutGetWidth(node),
topLeft.y + YGNodeLayoutGetHeight(node),
};
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
view.frame = (CGRect) {
.origin = {
.x = YGRoundPixelValue(topLeft.x + origin.x),
.y = YGRoundPixelValue(topLeft.y + origin.y),
},
.size = {
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
},
};
if (!yoga.isLeaf) {
for (NSUInteger i=0; i<view.subviews.count; i++) {
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
}
}
}
@end

View File

@@ -1,44 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
postfix operator %
extension Int {
public static postfix func %(value: Int) -> YGValue {
return YGValue(value: Float(value), unit: .percent)
}
}
extension Float {
public static postfix func %(value: Float) -> YGValue {
return YGValue(value: value, unit: .percent)
}
}
extension CGFloat {
public static postfix func %(value: CGFloat) -> YGValue {
return YGValue(value: Float(value), unit: .percent)
}
}
extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
public init(integerLiteral value: Int) {
self = YGValue(value: Float(value), unit: .point)
}
public init(floatLiteral value: Float) {
self = YGValue(value: value, unit: .point)
}
public init(_ value: Float) {
self = YGValue(value: value, unit: .point)
}
public init(_ value: CGFloat) {
self = YGValue(value: Float(value), unit: .point)
}
}

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.facebook.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -1,754 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <XCTest/XCTest.h>
#import <YogaKit/UIView+Yoga.h>
#import <YogaKit/YGLayout+Private.h>
#import <yoga/Yoga.h>
@interface YogaKitTests : XCTestCase
@end
@implementation YogaKitTests
- (void)testConfigureLayoutIsNoOpWithNilBlock
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
id block = nil;
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
}
- (void)testConfigureLayoutBlockWorksWithValidBlock
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view configureLayoutWithBlock:^(YGLayout *layout){
XCTAssertNotNil(layout);
layout.isEnabled = YES;
layout.width = YGPointValue(25);
}];
XCTAssertTrue(view.yoga.isEnabled);
XCTAssertEqual(view.yoga.width.value, 25);
}
- (void)testNodesAreDeallocedWithSingleView
{
__weak YGLayout *layoutRef = nil;
@autoreleasepool {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.flexBasis = YGPointValue(1);
layoutRef = view.yoga;
XCTAssertNotNil(layoutRef);
view = nil;
}
XCTAssertNil(layoutRef);
}
- (void)testNodesAreDeallocedCascade
{
__weak YGLayout *topLayout = nil;
__weak YGLayout *subviewLayout = nil;
@autoreleasepool {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
topLayout = view.yoga;
topLayout.flexBasis = YGPointValue(1);
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
subviewLayout = subview.yoga;
subviewLayout.flexBasis = YGPointValue(1);
view = nil;
}
XCTAssertNil(topLayout);
XCTAssertNil(subviewLayout);
}
- (void)testIsEnabled
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertFalse(view.yoga.isEnabled);
view.yoga.isEnabled = YES;
XCTAssertTrue(view.yoga.isEnabled);
view.yoga.isEnabled = NO;
XCTAssertFalse(view.yoga.isEnabled);
}
- (void)testSizeThatFitsAsserts
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){
XCTAssertThrows(view.yoga.intrinsicSize);
});
}
- (void)testSizeThatFitsSmoke
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
container.yoga.alignItems = YGAlignFlexStart;
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
longTextLabel.numberOfLines = 1;
longTextLabel.yoga.isEnabled = YES;
longTextLabel.yoga.flexShrink = 1;
[container addSubview:longTextLabel];
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
textBadgeView.yoga.isEnabled = YES;
textBadgeView.yoga.margin = YGPointValue(0);
textBadgeView.yoga.width = YGPointValue(10);
textBadgeView.yoga.height = YGPointValue(10);
[container addSubview:textBadgeView];
const CGSize textBadgeViewSize = textBadgeView.yoga.intrinsicSize;
XCTAssertEqual(textBadgeViewSize.height, 10);
XCTAssertEqual(textBadgeViewSize.width, 10);
const CGSize containerSize = container.yoga.intrinsicSize;
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
}
- (void)testSizeThatFitsEmptyView {
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
view.yoga.isEnabled = YES;
const CGSize viewSize = view.yoga.intrinsicSize;
XCTAssertEqual(viewSize.height, 0);
XCTAssertEqual(viewSize.width, 0);
}
- (void)testPreservingOrigin
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.isEnabled = YES;
view.yoga.flexBasis = YGPointValue(0);
view.yoga.flexGrow = 1;
[container addSubview:view];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectZero];
view2.yoga.isEnabled = YES;
view2.yoga.marginTop = YGPointValue(25);
view2.yoga.flexBasis = YGPointValue(0);
view2.yoga.flexGrow = 1;
[container addSubview:view2];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(50, view2.frame.origin.y);
[view2.yoga applyLayoutPreservingOrigin:NO];
XCTAssertEqual(25, view2.frame.origin.y);
}
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(200, container.frame.size.height);
}
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleHeight];
XCTAssertEqual(200, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth |
YGDimensionFlexibilityFlexibleHeight];
XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
subview.yoga.isEnabled = YES;
[container addSubview:subview];
XCTAssertFalse(container.yoga.isDirty);
[container.yoga markDirty];
XCTAssertFalse(container.yoga.isDirty);
XCTAssertFalse(subview.yoga.isDirty);
[subview.yoga markDirty];
XCTAssertTrue(subview.yoga.isDirty);
}
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
container.yoga.alignItems = YGAlignFlexStart;
UILabel *view = [[UILabel alloc] initWithFrame:CGRectZero];
view.text = @"This is a short text.";
view.numberOfLines = 1;
view.yoga.isEnabled = YES;
[container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES];
CGSize const viewSizeAfterFirstPass = view.frame.size;
view.text = @"This is a slightly longer text.";
XCTAssertTrue(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
[view.yoga markDirty];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertFalse(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
}
- (void)testFrameAndOriginPlacement
{
const CGSize containerSize = CGSizeMake(320, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqualWithAccuracy(subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
XCTAssertEqualWithAccuracy(subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
CGFloat totalWidth = 0;
for (UIView *view in container.subviews) {
totalWidth += view.bounds.size.width;
}
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
}
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
{
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
subview2.yoga.isIncludedInLayout = NO;
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
// this frame shouldn't have been modified since last time.
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
}
- (void)testThatWeRespectIncludeInLayoutFlag
{
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
for (UIView *subview in container.subviews) {
XCTAssertEqual(subview.bounds.size.width, 100);
}
subview3.yoga.isIncludedInLayout = NO;
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(subview1.bounds.size.width, 150);
XCTAssertEqual(subview2.bounds.size.width, 150);
// We don't set the frame to zero, so, it should be set to what it was previously at.
XCTAssertEqual(subview3.bounds.size.width, 100);
}
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.isIncludedInLayout = NO;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.isIncludedInLayout = NO;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.isIncludedInLayout = YES;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(container.yoga.numberOfChildren, 1);
subview2.yoga.isIncludedInLayout = YES;
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(container.yoga.numberOfChildren, 2);
}
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
subview3.yoga.isIncludedInLayout = NO;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(subview1.bounds.size.width, 150);
XCTAssertEqual(subview2.bounds.size.width, 150);
XCTAssertEqual(subview3.bounds.size.width, 0);
subview3.yoga.isIncludedInLayout = YES;
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(subview1.bounds.size.width, 100);
XCTAssertEqual(subview2.bounds.size.width, 100);
XCTAssertEqual(subview3.bounds.size.width, 100);
}
- (void)testIsLeafFlag
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertTrue(view.yoga.isLeaf);
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[view addSubview:subview];
}
XCTAssertTrue(view.yoga.isLeaf);
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(50);
XCTAssertTrue(view.yoga.isLeaf);
UIView *const subview = view.subviews[0];
subview.yoga.isEnabled = YES;
subview.yoga.width = YGPointValue(50);
XCTAssertFalse(view.yoga.isLeaf);
}
- (void)testThatWeCorrectlyAttachNestedViews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionColumn;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.width = YGPointValue(100);
subview1.yoga.flexGrow = 1;
subview1.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.width = YGPointValue(150);
subview2.yoga.flexGrow = 1;
subview2.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview2];
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayoutPreservingOrigin:YES];
// Add the same amount of new views, reapply layout.
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(subview1.bounds.size.width, 100);
XCTAssertEqual(subview1.bounds.size.height, 25);
for (UIView *subview in subview1.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertNotEqual(subviewSize.width, 0);
XCTAssertNotEqual(subviewSize.height, 0);
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
XCTAssertEqual(subview2.bounds.size.width, 150);
XCTAssertEqual(subview2.bounds.size.height, 25);
for (UIView *subview in subview2.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertNotEqual(subviewSize.width, 0);
XCTAssertNotEqual(subviewSize.height, 0);
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
}
- (void)testThatANonLeafNodeCanBecomeALeafNode
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
[subview1 addSubview:subview2];
[container.yoga applyLayoutPreservingOrigin:YES];
[subview2 removeFromSuperview];
[container.yoga applyLayoutPreservingOrigin:YES];
}
- (void)testPointPercent
{
XCTAssertEqual(YGPointValue(1).value, 1);
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
XCTAssertEqual(YGPercentValue(2).value, 2);
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
}
- (void)testPositionalPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.left = YGPointValue(1);
XCTAssertEqual(view.yoga.left.value, 1);
XCTAssertEqual(view.yoga.left.unit, YGUnitPoint);
view.yoga.left = YGPercentValue(2);
XCTAssertEqual(view.yoga.left.value, 2);
XCTAssertEqual(view.yoga.left.unit, YGUnitPercent);
view.yoga.right = YGPointValue(3);
XCTAssertEqual(view.yoga.right.value, 3);
XCTAssertEqual(view.yoga.right.unit, YGUnitPoint);
view.yoga.right = YGPercentValue(4);
XCTAssertEqual(view.yoga.right.value, 4);
XCTAssertEqual(view.yoga.right.unit, YGUnitPercent);
view.yoga.top = YGPointValue(5);
XCTAssertEqual(view.yoga.top.value, 5);
XCTAssertEqual(view.yoga.top.unit, YGUnitPoint);
view.yoga.top = YGPercentValue(6);
XCTAssertEqual(view.yoga.top.value, 6);
XCTAssertEqual(view.yoga.top.unit, YGUnitPercent);
view.yoga.bottom = YGPointValue(7);
XCTAssertEqual(view.yoga.bottom.value, 7);
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPoint);
view.yoga.bottom = YGPercentValue(8);
XCTAssertEqual(view.yoga.bottom.value, 8);
XCTAssertEqual(view.yoga.bottom.unit, YGUnitPercent);
view.yoga.start = YGPointValue(9);
XCTAssertEqual(view.yoga.start.value, 9);
XCTAssertEqual(view.yoga.start.unit, YGUnitPoint);
view.yoga.start = YGPercentValue(10);
XCTAssertEqual(view.yoga.start.value, 10);
XCTAssertEqual(view.yoga.start.unit, YGUnitPercent);
view.yoga.end = YGPointValue(11);
XCTAssertEqual(view.yoga.end.value, 11);
XCTAssertEqual(view.yoga.end.unit, YGUnitPoint);
view.yoga.end = YGPercentValue(12);
XCTAssertEqual(view.yoga.end.value, 12);
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
}
- (void)testMarginPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.margin = YGPointValue(1);
XCTAssertEqual(view.yoga.margin.value, 1);
XCTAssertEqual(view.yoga.margin.unit, YGUnitPoint);
view.yoga.margin = YGPercentValue(2);
XCTAssertEqual(view.yoga.margin.value, 2);
XCTAssertEqual(view.yoga.margin.unit, YGUnitPercent);
view.yoga.marginHorizontal = YGPointValue(3);
XCTAssertEqual(view.yoga.marginHorizontal.value, 3);
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPoint);
view.yoga.marginHorizontal = YGPercentValue(4);
XCTAssertEqual(view.yoga.marginHorizontal.value, 4);
XCTAssertEqual(view.yoga.marginHorizontal.unit, YGUnitPercent);
view.yoga.marginVertical = YGPointValue(5);
XCTAssertEqual(view.yoga.marginVertical.value, 5);
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPoint);
view.yoga.marginVertical = YGPercentValue(6);
XCTAssertEqual(view.yoga.marginVertical.value, 6);
XCTAssertEqual(view.yoga.marginVertical.unit, YGUnitPercent);
view.yoga.marginLeft = YGPointValue(7);
XCTAssertEqual(view.yoga.marginLeft.value, 7);
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPoint);
view.yoga.marginLeft = YGPercentValue(8);
XCTAssertEqual(view.yoga.marginLeft.value, 8);
XCTAssertEqual(view.yoga.marginLeft.unit, YGUnitPercent);
view.yoga.marginRight = YGPointValue(9);
XCTAssertEqual(view.yoga.marginRight.value, 9);
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPoint);
view.yoga.marginRight = YGPercentValue(10);
XCTAssertEqual(view.yoga.marginRight.value, 10);
XCTAssertEqual(view.yoga.marginRight.unit, YGUnitPercent);
view.yoga.marginTop = YGPointValue(11);
XCTAssertEqual(view.yoga.marginTop.value, 11);
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPoint);
view.yoga.marginTop = YGPercentValue(12);
XCTAssertEqual(view.yoga.marginTop.value, 12);
XCTAssertEqual(view.yoga.marginTop.unit, YGUnitPercent);
view.yoga.marginBottom = YGPointValue(13);
XCTAssertEqual(view.yoga.marginBottom.value, 13);
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPoint);
view.yoga.marginBottom = YGPercentValue(14);
XCTAssertEqual(view.yoga.marginBottom.value, 14);
XCTAssertEqual(view.yoga.marginBottom.unit, YGUnitPercent);
view.yoga.marginStart = YGPointValue(15);
XCTAssertEqual(view.yoga.marginStart.value, 15);
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPoint);
view.yoga.marginStart = YGPercentValue(16);
XCTAssertEqual(view.yoga.marginStart.value, 16);
XCTAssertEqual(view.yoga.marginStart.unit, YGUnitPercent);
view.yoga.marginEnd = YGPointValue(17);
XCTAssertEqual(view.yoga.marginEnd.value, 17);
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPoint);
view.yoga.marginEnd = YGPercentValue(18);
XCTAssertEqual(view.yoga.marginEnd.value, 18);
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
}
- (void)testPaddingPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.padding = YGPointValue(1);
XCTAssertEqual(view.yoga.padding.value, 1);
XCTAssertEqual(view.yoga.padding.unit, YGUnitPoint);
view.yoga.padding = YGPercentValue(2);
XCTAssertEqual(view.yoga.padding.value, 2);
XCTAssertEqual(view.yoga.padding.unit, YGUnitPercent);
view.yoga.paddingHorizontal = YGPointValue(3);
XCTAssertEqual(view.yoga.paddingHorizontal.value, 3);
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPoint);
view.yoga.paddingHorizontal = YGPercentValue(4);
XCTAssertEqual(view.yoga.paddingHorizontal.value, 4);
XCTAssertEqual(view.yoga.paddingHorizontal.unit, YGUnitPercent);
view.yoga.paddingVertical = YGPointValue(5);
XCTAssertEqual(view.yoga.paddingVertical.value, 5);
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPoint);
view.yoga.paddingVertical = YGPercentValue(6);
XCTAssertEqual(view.yoga.paddingVertical.value, 6);
XCTAssertEqual(view.yoga.paddingVertical.unit, YGUnitPercent);
view.yoga.paddingLeft = YGPointValue(7);
XCTAssertEqual(view.yoga.paddingLeft.value, 7);
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPoint);
view.yoga.paddingLeft = YGPercentValue(8);
XCTAssertEqual(view.yoga.paddingLeft.value, 8);
XCTAssertEqual(view.yoga.paddingLeft.unit, YGUnitPercent);
view.yoga.paddingRight = YGPointValue(9);
XCTAssertEqual(view.yoga.paddingRight.value, 9);
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPoint);
view.yoga.paddingRight = YGPercentValue(10);
XCTAssertEqual(view.yoga.paddingRight.value, 10);
XCTAssertEqual(view.yoga.paddingRight.unit, YGUnitPercent);
view.yoga.paddingTop = YGPointValue(11);
XCTAssertEqual(view.yoga.paddingTop.value, 11);
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPoint);
view.yoga.paddingTop = YGPercentValue(12);
XCTAssertEqual(view.yoga.paddingTop.value, 12);
XCTAssertEqual(view.yoga.paddingTop.unit, YGUnitPercent);
view.yoga.paddingBottom = YGPointValue(13);
XCTAssertEqual(view.yoga.paddingBottom.value, 13);
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPoint);
view.yoga.paddingBottom = YGPercentValue(14);
XCTAssertEqual(view.yoga.paddingBottom.value, 14);
XCTAssertEqual(view.yoga.paddingBottom.unit, YGUnitPercent);
view.yoga.paddingStart = YGPointValue(15);
XCTAssertEqual(view.yoga.paddingStart.value, 15);
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPoint);
view.yoga.paddingStart = YGPercentValue(16);
XCTAssertEqual(view.yoga.paddingStart.value, 16);
XCTAssertEqual(view.yoga.paddingStart.unit, YGUnitPercent);
view.yoga.paddingEnd = YGPointValue(17);
XCTAssertEqual(view.yoga.paddingEnd.value, 17);
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPoint);
view.yoga.paddingEnd = YGPercentValue(18);
XCTAssertEqual(view.yoga.paddingEnd.value, 18);
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
}
- (void)testBorderWidthPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.borderWidth = 1;
XCTAssertEqual(view.yoga.borderWidth, 1);
view.yoga.borderLeftWidth = 2;
XCTAssertEqual(view.yoga.borderLeftWidth, 2);
view.yoga.borderRightWidth = 3;
XCTAssertEqual(view.yoga.borderRightWidth, 3);
view.yoga.borderTopWidth = 4;
XCTAssertEqual(view.yoga.borderTopWidth, 4);
view.yoga.borderBottomWidth = 5;
XCTAssertEqual(view.yoga.borderBottomWidth, 5);
view.yoga.borderStartWidth = 6;
XCTAssertEqual(view.yoga.borderStartWidth, 6);
view.yoga.borderEndWidth = 7;
XCTAssertEqual(view.yoga.borderEndWidth, 7);
}
@end

View File

@@ -1,6 +0,0 @@
use_frameworks!
target 'YogaKitSample' do
pod 'YogaKit', :path => '../../YogaKit.podspec'
pod 'IGListKit', '~> 2.1.0'
end

View File

@@ -1,26 +0,0 @@
PODS:
- IGListKit (2.1.0):
- IGListKit/Default (= 2.1.0)
- IGListKit/Default (2.1.0):
- IGListKit/Diffing
- IGListKit/Diffing (2.1.0)
- Yoga (1.7.0)
- YogaKit (1.7.0):
- Yoga (~> 1.7)
DEPENDENCIES:
- IGListKit (~> 2.1.0)
- YogaKit (from `../../YogaKit.podspec`)
EXTERNAL SOURCES:
YogaKit:
:path: ../../YogaKit.podspec
SPEC CHECKSUMS:
IGListKit: b826c68ef7a4ae1626c09d4d3e1ea7a169e6c36e
Yoga: 2ed1d7accfef3610a67f58c0cf101a0662137f2c
YogaKit: 31576530e8fcae3175469719ec3212397403330b
PODFILE CHECKSUM: 216f8e7127767709e0e43f3711208d238fa5c404
COCOAPODS: 1.1.1

View File

@@ -1,529 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
15A7CB5995C9DAB1C8803834 /* Pods_YogaKitSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C80A931E90C7F3088CB86822 /* Pods_YogaKitSample.framework */; };
40BD9F461E477A09002790A9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F451E477A09002790A9 /* AppDelegate.swift */; };
40BD9F4B1E47850C002790A9 /* BasicViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F4A1E47850C002790A9 /* BasicViewController.swift */; };
40BD9F501E479079002790A9 /* SingleLabelCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F4F1E479079002790A9 /* SingleLabelCollectionCell.swift */; };
40BD9F521E479173002790A9 /* LayoutInclusionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40BD9F511E479173002790A9 /* LayoutInclusionViewController.swift */; };
638A94481E1F06D100A726AD /* ExamplesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638A94471E1F06D100A726AD /* ExamplesViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
638A94541E215CC800A726AD /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 13687D3B1DF8748300E7C260 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 13687D421DF8748300E7C260;
remoteInfo = YogaKitSample;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
13687D771DF878A000E7C260 /* yoga */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = include/yoga;
dstSubfolderSpec = 16;
files = (
);
name = yoga;
runOnlyForDeploymentPostprocessing = 0;
};
13687D7B1DF878CE00E7C260 /* YogaKit */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = include/YogaKit;
dstSubfolderSpec = 16;
files = (
);
name = YogaKit;
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
13687D431DF8748400E7C260 /* YogaKitSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YogaKitSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D2FF4D5FCA6A8C54A4074A3 /* Pods-YogaKitSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YogaKitSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample.debug.xcconfig"; sourceTree = "<group>"; };
40BD9F451E477A09002790A9 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
40BD9F4A1E47850C002790A9 /* BasicViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BasicViewController.swift; path = ViewControllers/BasicViewController.swift; sourceTree = "<group>"; };
40BD9F4F1E479079002790A9 /* SingleLabelCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SingleLabelCollectionCell.swift; path = Views/SingleLabelCollectionCell.swift; sourceTree = "<group>"; };
40BD9F511E479173002790A9 /* LayoutInclusionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LayoutInclusionViewController.swift; path = ViewControllers/LayoutInclusionViewController.swift; sourceTree = "<group>"; };
638A94471E1F06D100A726AD /* ExamplesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExamplesViewController.swift; sourceTree = "<group>"; };
638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YogaKitSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
82F0896A88112E957EF37C7F /* Pods-YogaKitSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YogaKitSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample.release.xcconfig"; sourceTree = "<group>"; };
C80A931E90C7F3088CB86822 /* Pods_YogaKitSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_YogaKitSample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
13687D401DF8748300E7C260 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */,
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */,
15A7CB5995C9DAB1C8803834 /* Pods_YogaKitSample.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
638A944C1E215CC800A726AD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
13687D3A1DF8748300E7C260 = {
isa = PBXGroup;
children = (
13687D451DF8748400E7C260 /* YogaKitSample */,
13687D441DF8748400E7C260 /* Products */,
13687D831DF87D1E00E7C260 /* Frameworks */,
E1C759E3C8E84821213ECE8D /* Pods */,
);
sourceTree = "<group>";
};
13687D441DF8748400E7C260 /* Products */ = {
isa = PBXGroup;
children = (
13687D431DF8748400E7C260 /* YogaKitSample.app */,
638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
13687D451DF8748400E7C260 /* YogaKitSample */ = {
isa = PBXGroup;
children = (
40BD9F4E1E47902F002790A9 /* Views */,
40BD9F481E4784B3002790A9 /* ViewControllers */,
638A94471E1F06D100A726AD /* ExamplesViewController.swift */,
13687D521DF8748400E7C260 /* Assets.xcassets */,
13687D571DF8748400E7C260 /* Info.plist */,
40BD9F451E477A09002790A9 /* AppDelegate.swift */,
);
path = YogaKitSample;
sourceTree = "<group>";
};
13687D831DF87D1E00E7C260 /* Frameworks */ = {
isa = PBXGroup;
children = (
13687D861DF87D2400E7C260 /* Foundation.framework */,
13687D841DF87D1E00E7C260 /* UIKit.framework */,
C80A931E90C7F3088CB86822 /* Pods_YogaKitSample.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
40BD9F481E4784B3002790A9 /* ViewControllers */ = {
isa = PBXGroup;
children = (
40BD9F4A1E47850C002790A9 /* BasicViewController.swift */,
40BD9F511E479173002790A9 /* LayoutInclusionViewController.swift */,
);
name = ViewControllers;
sourceTree = "<group>";
};
40BD9F4E1E47902F002790A9 /* Views */ = {
isa = PBXGroup;
children = (
40BD9F4F1E479079002790A9 /* SingleLabelCollectionCell.swift */,
);
name = Views;
sourceTree = "<group>";
};
E1C759E3C8E84821213ECE8D /* Pods */ = {
isa = PBXGroup;
children = (
1D2FF4D5FCA6A8C54A4074A3 /* Pods-YogaKitSample.debug.xcconfig */,
82F0896A88112E957EF37C7F /* Pods-YogaKitSample.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
13687D421DF8748300E7C260 /* YogaKitSample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
buildPhases = (
513B543F92B2E4F4D1EE1CE7 /* [CP] Check Pods Manifest.lock */,
13687D771DF878A000E7C260 /* yoga */,
13687D7B1DF878CE00E7C260 /* YogaKit */,
13687D3F1DF8748300E7C260 /* Sources */,
13687D401DF8748300E7C260 /* Frameworks */,
13687D411DF8748300E7C260 /* Resources */,
FA2FB9DD6471BDD3FBCE503B /* [CP] Embed Pods Frameworks */,
6E01EB987F1564F3D71EBE5A /* [CP] Copy Pods Resources */,
);
buildRules = (
);
dependencies = (
);
name = YogaKitSample;
productName = YogaKitSample;
productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */;
productType = "com.apple.product-type.application";
};
638A944E1E215CC800A726AD /* YogaKitSampleTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */;
buildPhases = (
638A944B1E215CC800A726AD /* Sources */,
638A944C1E215CC800A726AD /* Frameworks */,
638A944D1E215CC800A726AD /* Resources */,
);
buildRules = (
);
dependencies = (
638A94551E215CC800A726AD /* PBXTargetDependency */,
);
name = YogaKitSampleTests;
productName = YogaKitSampleTests;
productReference = 638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
13687D3B1DF8748300E7C260 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = facebook;
TargetAttributes = {
13687D421DF8748300E7C260 = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
638A944E1E215CC800A726AD = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
TestTargetID = 13687D421DF8748300E7C260;
};
};
};
buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 13687D3A1DF8748300E7C260;
productRefGroup = 13687D441DF8748400E7C260 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
13687D421DF8748300E7C260 /* YogaKitSample */,
638A944E1E215CC800A726AD /* YogaKitSampleTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
13687D411DF8748300E7C260 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
638A944D1E215CC800A726AD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
513B543F92B2E4F4D1EE1CE7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
6E01EB987F1564F3D71EBE5A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
FA2FB9DD6471BDD3FBCE503B /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YogaKitSample/Pods-YogaKitSample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
13687D3F1DF8748300E7C260 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
40BD9F501E479079002790A9 /* SingleLabelCollectionCell.swift in Sources */,
40BD9F521E479173002790A9 /* LayoutInclusionViewController.swift in Sources */,
638A94481E1F06D100A726AD /* ExamplesViewController.swift in Sources */,
40BD9F4B1E47850C002790A9 /* BasicViewController.swift in Sources */,
40BD9F461E477A09002790A9 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
638A944B1E215CC800A726AD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
638A94551E215CC800A726AD /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 13687D421DF8748300E7C260 /* YogaKitSample */;
targetProxy = 638A94541E215CC800A726AD /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
13687D581DF8748400E7C260 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
13687D591DF8748400E7C260 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
13687D5B1DF8748400E7C260 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 1D2FF4D5FCA6A8C54A4074A3 /* Pods-YogaKitSample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = YogaKitSample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
13687D5C1DF8748400E7C260 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 82F0896A88112E957EF37C7F /* Pods-YogaKitSample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = YogaKitSample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_VERSION = 3.0;
};
name = Release;
};
638A94571E215CC800A726AD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
INFOPLIST_FILE = YogaKitSampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample";
};
name = Debug;
};
638A94581E215CC800A726AD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
INFOPLIST_FILE = YogaKitSampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13687D581DF8748400E7C260 /* Debug */,
13687D591DF8748400E7C260 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13687D5B1DF8748400E7C260 /* Debug */,
13687D5C1DF8748400E7C260 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
638A94571E215CC800A726AD /* Debug */,
638A94581E215CC800A726AD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 13687D3B1DF8748300E7C260 /* Project object */;
}

View File

@@ -1,14 +0,0 @@
<!--
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:YogaKitSample.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -1,101 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "638A944E1E215CC800A726AD"
BuildableName = "YogaKitSampleTests.xctest"
BlueprintName = "YogaKitSampleTests"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:YogaKitSample.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -1,27 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import Foundation
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func applicationDidFinishLaunching(_ application: UIApplication) {
self.window = UIWindow(frame: UIScreen.main.bounds)
if let window = self.window {
let navigationController = UINavigationController(rootViewController: ExamplesViewController())
navigationController.navigationBar.isTranslucent = false
window.rootViewController = navigationController
window.backgroundColor = .white
window.makeKeyAndVisible()
}
}
}

View File

@@ -1,74 +0,0 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Yoga-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Yoga-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Yoga-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Yoga-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Yoga-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Yoga-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Yoga-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "Yoga-57x57@1x.png",
"scale" : "1x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "Yoga-57x57@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Yoga-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Yoga-60x60@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -1,6 +0,0 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -1,100 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import UIKit
import IGListKit
private final class ExampleModel {
let title: String
let controllerClass: UIViewController.Type
init(title: String, controllerClass: UIViewController.Type) {
self.title = title
self.controllerClass = controllerClass
}
}
extension ExampleModel: IGListDiffable {
fileprivate func diffIdentifier() -> NSObjectProtocol {
return title as NSString
}
fileprivate func isEqual(toDiffableObject object: IGListDiffable?) -> Bool {
guard let otherObj = object as? ExampleModel else { return false }
return (title == otherObj.title) &&
(controllerClass == otherObj.controllerClass)
}
}
final class ExamplesViewController: UIViewController, IGListAdapterDataSource, IGListSingleSectionControllerDelegate {
private lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
private let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
// Update this to array to create more examples.
private let models: [ExampleModel] = [ExampleModel(title: "Basic Layout", controllerClass: BasicViewController.self),
ExampleModel(title: "Exclude Views in Layout", controllerClass: LayoutInclusionViewController.self)]
//MARK: UIViewController
override func viewDidLoad() {
super.viewDidLoad()
title = "Examples"
view.addSubview(collectionView)
adapter.collectionView = collectionView
adapter.dataSource = self
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
collectionView.frame = view.bounds
}
//MARK: IGListAdapterDataSource
func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
return models as [IGListDiffable]
}
func listAdapter(_ listAdapter: IGListAdapter, sectionControllerFor object: Any) -> IGListSectionController {
let sizeBlock: IGListSingleSectionCellSizeBlock = { (model, context) in
return CGSize(width: (context?.containerSize.width)!, height: 75.0)
}
let configureBlock: IGListSingleSectionCellConfigureBlock = { (model, cell) in
guard let m = model as? ExampleModel, let c = cell as? SingleLabelCollectionCell else {
return
}
c.label.text = m.title
}
let sectionController = IGListSingleSectionController(cellClass: SingleLabelCollectionCell.self,
configureBlock: configureBlock,
sizeBlock: sizeBlock)
sectionController.selectionDelegate = self
return sectionController
}
func emptyView(for listAdapter: IGListAdapter) -> UIView? { return nil }
//MARK: IGListSingleSectionControllerDelegate
func didSelect(_ sectionController: IGListSingleSectionController) {
let section = adapter.section(for: sectionController)
let model = models[section]
let controller = model.controllerClass.init()
controller.title = model.title
self.navigationController?.pushViewController(controller, animated: true)
}
}

View File

@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string></string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -1,71 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import UIKit
import IGListKit
import YogaKit
struct DemoItem {
let name: String
root.backgroundColor = .red
root.yoga.isEnabled = true
root.yoga.width = YGValue(self.view.bounds.size.width)
root.yoga.height = YGValue(self.view.bounds.size.height)
root.yoga.alignItems = .center
}
final class SwiftViewController: UIViewController, IGListAdapterDataSource {
lazy var adapter: IGListAdapter = {
return IGListAdapter(updater: IGListAdapterUpdater(), viewController: self, workingRangeSize: 0)
}()
let collectionView = IGListCollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
//MARK: UIViewController
override func viewDidLoad() {
super.viewDidLoad()
title = "YogaKit Examples"
view.addSubview(collectionView)
adapter.collectionView = collectionView
adapter.dataSource = self
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
collectionView.frame = view.bounds
}
//MARK: IGListAdapterDataSource
func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
return ["Dustin" as IGListDiffable, "Ryan" as IGListDiffable]
}
func listAdapter(_ listAdapter: IGListAdapter, sectionControllerFor object: Any) -> IGListSectionController {
let sizeBlock: IGListSingleSectionCellSizeBlock = { (model, context) in
return CGSize(width: (context?.containerSize.width)!, height: 100.0)
}
let configureBlock: IGListSingleSectionCellConfigureBlock = { (model, cell) in
guard let m = model as? String else {
return
}
cell.backgroundColor = (m == "Dustin") ? .blue : .red
}
return IGListSingleSectionController(cellClass: UICollectionViewCell.self,
configureBlock: configureBlock,
sizeBlock: sizeBlock)
}
func emptyView(for listAdapter: IGListAdapter) -> UIView? {
return nil
}
}

View File

@@ -1,56 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import "ViewController.h"
#import <YogaKit/UIView+Yoga.h>
@implementation ViewController
- (void)viewDidLoad
{
UIView *root = self.view;
root.backgroundColor = [UIColor redColor];
root.yoga.isEnabled = YES;
root.yoga.width = YGPointValue(self.view.bounds.size.width);
root.yoga.height = YGPointValue(self.view.bounds.size.height);
root.yoga.alignItems = YGAlignCenter;
root.yoga.justifyContent = YGJustifyCenter;
UIView *child1 = [UIView new];
child1.backgroundColor = [UIColor blueColor];
child1.yoga.isEnabled = YES;
child1.yoga.width = YGPointValue(100);
child1.yoga.height = YGPointValue(100);
UIView *child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor];
child2.frame = (CGRect) {
.size = {
.width = 200,
.height = 100,
}
};
UIView *child3 = [UIView new];
child3.backgroundColor = [UIColor yellowColor];
child3.frame = (CGRect) {
.size = {
.width = 100,
.height = 100,
}
};
[child2 addSubview:child3];
[root addSubview:child1];
[root addSubview:child2];
[root.yoga applyLayoutPreservingOrigin:NO];
}
@end

View File

@@ -1,54 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import UIKit
import YogaKit
final class BasicViewController: UIViewController {
override func viewDidLoad() {
let containerSize = self.view.bounds.size
let root = self.view!
root.backgroundColor = .white
root.configureLayout { (layout) in
layout.isEnabled = true
layout.width = YGValue(containerSize.width)
layout.height = YGValue(containerSize.height)
layout.alignItems = .center
layout.justifyContent = .center
}
let child1 = UIView()
child1.backgroundColor = .blue
child1.configureLayout { (layout) in
layout.isEnabled = true
layout.width = 100
layout.height = 10
layout.marginBottom = 25
}
root.addSubview(child1)
let child2 = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
child2.backgroundColor = .green
child2.configureLayout { (layout) in
layout.isEnabled = true
layout.alignSelf = .flexEnd
}
root.addSubview(child2)
let child3 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
child3.backgroundColor = .yellow
child3.configureLayout { (layout) in
layout.isEnabled = true
layout.alignSelf = .flexStart
}
root.addSubview(child3)
root.yoga.applyLayout(preservingOrigin: true)
}
}

View File

@@ -1,80 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import UIKit
import YogaKit
final class LayoutInclusionViewController: UIViewController {
private let button: UIButton = UIButton(type: .system)
private let disappearingView: UIView = UIView(frame: .zero)
private let contentView: UIView = UIView(frame: .zero)
override func viewDidLoad() {
let root = self.view!
root.backgroundColor = .white
root.configureLayout { (layout) in
layout.isEnabled = true
layout.flexDirection = .column
layout.justifyContent = .spaceAround
}
contentView.backgroundColor = .clear
contentView.layer.borderColor = UIColor.lightGray.cgColor
contentView.layer.borderWidth = 1.0
contentView.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 300
layout.width = YGValue(self.view.bounds.size.width)
layout.flexDirection = .row
layout.justifyContent = .center
layout.paddingHorizontal = 25
}
self.view.addSubview(contentView)
let redView = UIView(frame: .zero)
redView.backgroundColor = .red
redView.configureLayout { (layout) in
layout.isEnabled = true
layout.flexGrow = 1
layout.flexShrink = 1
}
contentView.addSubview(redView)
disappearingView.backgroundColor = .blue
disappearingView.configureLayout { (layout) in
layout.isEnabled = true
layout.flexGrow = 1
}
contentView.addSubview(disappearingView)
button.setTitle("Add Blue View", for: UIControlState.selected)
button.setTitle("Remove Blue View", for: UIControlState.normal)
button.addTarget(self, action: #selector(buttonWasTapped), for: UIControlEvents.touchUpInside)
button.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 300
layout.width = 300
layout.alignSelf = .center
}
root.addSubview(button)
root.yoga.applyLayout(preservingOrigin: false)
}
// MARK - UIButton Action
func buttonWasTapped() {
button.isSelected = !button.isSelected
button.isUserInteractionEnabled = false
disappearingView.yoga.isIncludedInLayout = !disappearingView.yoga.isIncludedInLayout
disappearingView.isHidden = !disappearingView.isHidden
contentView.yoga.applyLayout(preservingOrigin: true)
button.isUserInteractionEnabled = true
}
}

View File

@@ -1,49 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import UIKit
import YogaKit
final class SingleLabelCollectionCell: UICollectionViewCell {
let label: UILabel = UILabel(frame: .zero)
override init(frame: CGRect) {
super.init(frame: frame)
contentView.configureLayout { (layout) in
layout.isEnabled = true
layout.flexDirection = .column
layout.justifyContent = .flexEnd
}
label.textAlignment = .center
label.numberOfLines = 1
label.yoga.isIncludedInLayout = false
contentView.addSubview(label)
let border = UIView(frame: .zero)
border.backgroundColor = .lightGray
border.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 0.5
layout.marginHorizontal = 25
}
contentView.addSubview(border)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
contentView.yoga.applyLayout(preservingOrigin: false)
label.frame = contentView.bounds
}
}

View File

@@ -1,30 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
yoga_android_aar(
name = "android",
manifest_skeleton = "src/main/AndroidManifest.xml",
visibility = [
"PUBLIC",
],
deps = [
ANDROID_JAVA_TARGET,
ANDROID_RES_TARGET,
INFER_ANNOTATIONS_TARGET,
JAVA_TARGET,
PROGRUARD_ANNOTATIONS_TARGET,
],
)
yoga_android_resource(
name = "res",
package = "com.facebook.yoga.android",
res = "src/main/res",
visibility = [
"PUBLIC",
],
)

View File

@@ -1,21 +0,0 @@
# YogaLayout [![Platform](https://img.shields.io/badge/platforms-Android-orange.svg)](https://facebook.github.io/yoga/docs/api/android/) [![Languages](https://img.shields.io/badge/languages-Java-orange.svg)](https://facebook.github.io/yoga/docs/api/android/) [![Download](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga.android:yoga-layout.svg)](https://bintray.com/facebook/maven/com.facebook.yoga.android%3Ayoga-layout/_latestVersion)
## Installation
YogaLayout is available via jcenter:
compile 'com.facebook.yoga.android:yoga-layout:1.2.0'
## Getting Started
Check out the docs [here](https://facebook.github.io/yoga/docs/api/android/).
We also have a sample project. To try it, clone the repo and run (with a device attached)
buck install -r android/sample
## Contributing
We welcome all pull-requests! At Facebook we sync the open source version of YogaKit daily, so we're always testing the latest changes.
See the CONTRIBUTING file for how to help out.

View File

@@ -1,52 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
version = VERSION_NAME
group = GROUP
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
}
compileOptions {
targetCompatibility rootProject.targetCompatibilityVersion
sourceCompatibility rootProject.sourceCompatibilityVersion
}
}
dependencies {
api project(':yoga')
}
task sourcesJar(type: Jar) {
classifier = 'source'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
apply from: rootProject.file('gradle/release.gradle')

View File

@@ -1,12 +0,0 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
GROUP=com.facebook.yoga.android
POM_NAME=YogaLayout
POM_DESCRIPTION=YogaLayout
POM_ARTIFACT_ID=yoga-layout
POM_PACKAGING=aar

View File

@@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the license found in the
LICENSE-examples file in the root directory of this source tree.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.samples.yoga"
android:versionCode="1"
android:versionName="1.0"
>
<variable name="applicationId" value="com.facebook.yoga"/>
<variable name="app_label" value="Yoga Sample App"/>
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19"
/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="false"
android:theme="@style/NoTitleBarWhiteBG"
android:supportsRtl="true"
>
<activity
android:name=".MainActivity"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".BenchmarkActivity"
android:exported="false"
/>
</application>
</manifest>

View File

@@ -1,36 +0,0 @@
# Copyright 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE-examples file in the root directory of this source tree.
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
yoga_android_binary(
name = "sample",
keystore = ":debug_keystore",
manifest = "AndroidManifest.xml",
deps = [
ANDROID_SAMPLE_JAVA_TARGET,
ANDROID_SAMPLE_RES_TARGET,
],
)
yoga_android_resource(
name = "res",
package = "com.facebook.samples.yoga",
res = "res",
visibility = [
"PUBLIC",
],
deps = [
ANDROID_RES_TARGET,
],
)
fb_native.keystore(
name = "debug_keystore",
properties = "debug.keystore.properties",
store = "debug.keystore",
)

Binary file not shown.

View File

@@ -1,3 +0,0 @@
key.alias=androiddebugkey
key.store.password=android
key.alias.password=android

View File

@@ -1,21 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the license found in the
# LICENSE-examples file in the root directory of this source tree.
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
yoga_android_library(
name = "yoga",
srcs = glob(["**/*.java"]),
visibility = [
"PUBLIC",
],
deps = [
ANDROID_JAVA_TARGET,
ANDROID_SAMPLE_RES_TARGET,
ANDROID_SUPPORT_TARGET,
APPCOMPAT_TARGET,
SOLOADER_TARGET,
],
)

View File

@@ -1,113 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Menu;
import android.support.v7.app.ActionBar;
import com.facebook.samples.yoga.R;
import com.facebook.yoga.android.YogaViewLayoutFactory;
public class BenchmarkActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
LayoutInflater.from(this).setFactory(YogaViewLayoutFactory.getInstance());
super.onCreate(savedInstanceState);
setContentView(R.layout.benchmark_select_layout);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
};
actionBar.addTab(
actionBar.newTab()
.setText("Inflate")
.setTabListener(tabListener));
actionBar.addTab(
actionBar.newTab()
.setText("Measure")
.setTabListener(tabListener));
actionBar.addTab(
actionBar.newTab()
.setText("Layout")
.setTabListener(tabListener));
viewPager.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// When swiping between pages, select the
// corresponding tab.
actionBar.setSelectedNavigationItem(position);
}
});
viewPager.setOffscreenPageLimit(3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_bar_benchmark, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// There is only one option
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
this.finish();
return true;
}
public static class PagerAdapter extends FragmentPagerAdapter {
public PagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
switch (i) {
case 0:
return new BenchmarkInflate();
case 1:
return new BenchmarkMeasure();
default:
return new BenchmarkLayout();
}
}
@Override
public int getCount() {
return 3;
}
}
}

View File

@@ -1,193 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.lang.Math;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.text.DateFormat;
import java.util.Date;
import android.content.Context;
import android.util.Log;
import android.os.Environment;
import static java.util.Collections.sort;
public class BenchmarkAggregator {
private final int GRAPH_WIDTH = 30;
private final int GRAPH_HEIGHT = 6;
private List<Long> times;
private boolean tracing;
private long lastTraceStart;
private boolean statsFresh;
private long mean;
private long variance;
private long stddev;
private long min;
private long max;
private long p10;
private long p50;
private long p90;
private String name;
public BenchmarkAggregator(String name) {
times = new ArrayList<>();
tracing = false;
this.name = name;
}
public void startTrace() {
if (tracing) {
throw new RuntimeException("Cannot start trace while running previous one");
}
tracing = true;
lastTraceStart = System.nanoTime();
}
public void endTrace() {
if (!tracing) {
throw new RuntimeException("Cannot stop trace if none are running!");
}
times.add(System.nanoTime() - lastTraceStart);
tracing = false;
statsFresh = false;
}
private void computeStats() {
if (statsFresh) {
return;
}
sort(times);
min = Long.MAX_VALUE;
max = -1;
mean = 0;
for (long f: times) {
mean += f;
if (f < min) {
min = f;
}
if (f > max) {
max = f;
}
}
mean /= times.size();
variance = 0;
for (long f: times) {
variance += (f-mean)*(f-mean);
}
variance /= times.size();
stddev = (long) Math.sqrt((double) variance);
p10 = times.get(times.size()*10/100);
p50 = times.get(times.size()*50/100);
p90 = times.get(times.size()*90/100);
statsFresh = true;
}
public String toString() {
computeStats();
return String.format(
"%s:\n" +
"| %d samples\n" +
"| Mean %.3f\u00B1%.3fms\n" + // plusminus
"| Min %.3fms ; Max %.3fms\n" +
"| p10 %.3fms ; p50 %.3fms ; p90 %.3fms\n" +
"%s",
name,
times.size(),
mean/10e6,
stddev/10e6,
min/10e6,
max/10e6,
p10/10e6,
p50/10e6,
p90/10e6,
makeGraph());
}
private String makeGraph() {
char canvas[][] = new char[GRAPH_HEIGHT][GRAPH_WIDTH];
for (int i = 0; i < GRAPH_HEIGHT; i++)
for (int j = 0; j < GRAPH_WIDTH; j++)
canvas[i][j] = ' ';
long bucketSize = (p90 - p10) / GRAPH_WIDTH+1;
int bucketCount[] = new int[GRAPH_WIDTH];
for (long time : times) {
if (time<p90 && time>p10) {
bucketCount[(int) ((time - p10) / bucketSize)]++;
}
}
int maxBucket = 0;
for (int i = 0; i < GRAPH_WIDTH; i++)
if (bucketCount[i] > maxBucket) {
maxBucket = bucketCount[i];
}
for (int i = 0; i < GRAPH_HEIGHT; i++)
for (int j = 0; j < GRAPH_WIDTH; j++)
if (i < bucketCount[j] * GRAPH_HEIGHT / maxBucket) {
canvas[i][j] = 'Z';
}
String graph = new String();
for (int i = 0; i < GRAPH_HEIGHT; i++)
{
int percentage = 100 * (GRAPH_HEIGHT - i - 1) * maxBucket / (times.size() * GRAPH_HEIGHT);
graph += String.format("| %2d%% ", percentage);
for (int j = 0; j < GRAPH_WIDTH; j++)
graph += canvas[GRAPH_HEIGHT-1-i][j];
graph += '\n';
}
graph += "| p10";
for (int i = 0; i < GRAPH_WIDTH-6; i++)
graph += " ";
graph += "p90\n";
return graph;
}
/**
* Dumps the collected times to a file on the device. This allows us to grab the raw data
* and perform more in-depth analysis.
*/
public void dump(Context context) {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
Log.e("YogaLayoutBenchmark","No external file storage");
return;
}
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
String filename = format.format(new Date()) + "_" + name.replace(' ','_');
File file = new File(context.getExternalFilesDir(
Environment.DIRECTORY_DOCUMENTS), filename);
try {
PrintWriter printWriter = new PrintWriter(file);
for (long l : times) {
printWriter.println(l);
}
printWriter.close();
Log.i("YogaLayoutBenchmark","Benchmark data saved in "+file.getPath());
} catch (java.io.IOException e) {
Log.e("YogaLayoutBenchmark", "Could not save benchmark data", e);
}
}
}

View File

@@ -1,110 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import java.util.Random;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView;
import com.facebook.samples.yoga.R;
import com.facebook.yoga.android.YogaLayout;
public class BenchmarkFragment extends Fragment implements AdapterView.OnItemSelectedListener {
private LayoutInflater mInflater;
protected com.facebook.yoga.android.YogaLayout rootLayout;
protected int yogaLayout;
protected int linearLayout;
static final Random random = new Random();
static void randomizeText(View root) {
if (root instanceof TextView) {
((TextView) root).setText("" + random.nextInt(1000));
((TextView) root).setTextSize(10 + random.nextInt(20));
ViewParent parent = root.getParent();
if (parent instanceof YogaLayout) {
((YogaLayout) parent).invalidate(root);
}
} else if (root instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) root).getChildCount(); i++) {
randomizeText(((ViewGroup) root).getChildAt(i));
}
}
}
public BenchmarkFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
mInflater = inflater;
rootLayout = (YogaLayout) inflater.inflate(
R.layout.benchmark_fragment,
container,
false);
Spinner benchmarkSelect = (Spinner) rootLayout.findViewById(R.id.benchmarkSelect);
String[] items = new String[]{"Basic", "Typical", "Nested"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items);
benchmarkSelect.setAdapter(adapter);
benchmarkSelect.setOnItemSelectedListener(this);
return rootLayout;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
switch (pos) {
case 0:
yogaLayout = R.layout.benchmark_layout_1;
linearLayout = R.layout.benchmark_layout_1_linear;
break;
case 1:
yogaLayout = R.layout.benchmark_layout_2;
linearLayout = R.layout.benchmark_layout_2_linear;
break;
case 2:
default:
yogaLayout = R.layout.benchmark_layout_3;
linearLayout = R.layout.benchmark_layout_3_linear;
break;
}
updatePreview();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
yogaLayout = R.layout.benchmark_layout_1;
linearLayout = R.layout.benchmark_layout_1_linear;
updatePreview();
}
private void updatePreview() {
LinearLayout previewLayout = (LinearLayout) rootLayout.findViewById(R.id.preview);
View v = mInflater.inflate(yogaLayout, rootLayout, false);
v.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
previewLayout.removeAllViews();
previewLayout.addView(v);
}
}

View File

@@ -1,65 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
import android.view.ViewGroup;
import android.util.Log;
import com.facebook.samples.yoga.R;
public class BenchmarkInflate extends BenchmarkFragment {
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Button b = (Button) rootLayout.findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startBenchmark();
}
});
return rootLayout;
}
protected void startBenchmark() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
final int ITERATIONS = 500;
inflater.inflate(yogaLayout, null);
inflater.inflate(linearLayout, null);
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Inflate");
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Inflate");
for (int i = 0; i < ITERATIONS; i++) {
yogaInflationAggregator.startTrace();
inflater.inflate(yogaLayout, null);
yogaInflationAggregator.endTrace();
linearInflationAggregator.startTrace();
inflater.inflate(linearLayout, null);
linearInflationAggregator.endTrace();
}
textView.setText(
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
Log.i(
"YogaLayoutBenchmark",
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
rootLayout.invalidate();
}
}

View File

@@ -1,74 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.facebook.samples.yoga.R;
import java.util.Random;
public class BenchmarkLayout extends BenchmarkFragment {
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Button b = (Button) rootLayout.findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startBenchmark();
}
});
return rootLayout;
}
protected void startBenchmark() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
Random random = new Random();
final int ITERATIONS = 500;
BenchmarkAggregator yogaInflationAggregator = new BenchmarkAggregator("Yoga Layout");
BenchmarkAggregator linearInflationAggregator = new BenchmarkAggregator("Linear Layout");
View yogaView = inflater.inflate(yogaLayout, null);
View linearView = inflater.inflate(linearLayout, null);
for (int i = 0; i < ITERATIONS; i++) {
randomizeText(yogaView);
randomizeText(linearView);
yogaView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
linearView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
yogaInflationAggregator.startTrace();
yogaView.layout(0, 0, yogaView.getMeasuredWidth(), yogaView.getMeasuredHeight());
yogaInflationAggregator.endTrace();
linearInflationAggregator.startTrace();
linearView.layout(0, 0, linearView.getMeasuredWidth(), linearView.getMeasuredHeight());
linearInflationAggregator.endTrace();
}
textView.setText(
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
Log.i(
"YogaLayoutBenchmark",
yogaInflationAggregator.toString()+
"\n"+
linearInflationAggregator.toString());
}
}

View File

@@ -1,75 +0,0 @@
// Copyright 2004-present Facebook. All Rights Reserved.
package com.facebook.samples.yoga;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.facebook.samples.yoga.R;
import java.util.Random;
public class BenchmarkMeasure extends BenchmarkFragment {
@Override
public View onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Button b = (Button) rootLayout.findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startBenchmark();
}
});
return rootLayout;
}
protected void startBenchmark() {
LayoutInflater inflater = LayoutInflater.from(getActivity());
TextView textView = (TextView) rootLayout.findViewById(R.id.text);
Random random = new Random();
final int ITERATIONS = 500;
BenchmarkAggregator yogaMeasureAggregator = new BenchmarkAggregator("Yoga Measure");
BenchmarkAggregator linearMeasureAggregator = new BenchmarkAggregator("Linear Measure");
View yogaView = inflater.inflate(yogaLayout, null);
View linearView = inflater.inflate(linearLayout, null);
for (int i = 0; i < ITERATIONS; i++) {
randomizeText(yogaView);
randomizeText(linearView);
yogaMeasureAggregator.startTrace();
yogaView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
yogaMeasureAggregator.endTrace();
linearMeasureAggregator.startTrace();
linearView.measure(
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY));
linearMeasureAggregator.endTrace();
}
textView.setText(
yogaMeasureAggregator.toString()+
"\n"+
linearMeasureAggregator.toString());
Log.i(
"YogaLayoutBenchmark",
yogaMeasureAggregator.toString()+
"\n"+
linearMeasureAggregator.toString());
yogaMeasureAggregator.dump(getActivity());
linearMeasureAggregator.dump(getActivity());
}
}

View File

@@ -1,54 +0,0 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
package com.facebook.samples.yoga;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Menu;
import com.facebook.samples.yoga.R;
import com.facebook.soloader.SoLoader;
import com.facebook.yoga.android.YogaViewLayoutFactory;
/**
* An activity to show off Yoga in Android. This activity shows a simple layout (defined in
* {@code main_layout.xml}) that shows off the awesome functionality of the Yoga layout engine
* as well as some optimisations on layout systems that it facilitates.
*/
public class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
LayoutInflater.from(this).setFactory(YogaViewLayoutFactory.getInstance());
super.onCreate(savedInstanceState);
SoLoader.init(this, false);
setContentView(R.layout.main_layout);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_bar_home, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// There is only one option
Intent intent = new Intent(this, BenchmarkActivity.class);
startActivity(intent);
this.finish();
return true;
}
}

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the license found in the
LICENSE-examples file in the root directory of this source tree.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<solid
android:color="@color/yoga_grey"
/>
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the license found in the
LICENSE-examples file in the root directory of this source tree.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
android:radius="4dp"
/>
<stroke
android:width="1dp"
android:color="@color/children_stroke"
/>
<padding
android:top="6dp"
android:bottom="6dp"
android:left="8dp"
android:right="8dp"
/>
<solid
android:color="@color/children_background"
/>
</shape>

View File

@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:id="@+id/rt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
yoga:yg_flexDirection="column"
>
<VirtualYogaLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
yoga:yg_flexDirection="row"
yoga:yg_height="50dp"
>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Run benchmark"
yoga:yg_flex="1"
/>
<Spinner
android:id="@+id/benchmarkSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
/>
</VirtualYogaLayout>
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="10sp"
android:fontFamily="monospace"
yoga:yg_flex="1"
/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/yoga_grey"
/>
<LinearLayout
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
/>
</YogaLayout>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<YogaLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yoga="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="60dp"
yoga:yg_flexDirection="row"
yoga:yg_alignItems="center"
>
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/yoga_blue"
yoga:yg_flex="0"
yoga:yg_marginAll="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_1_text"
yoga:yg_flex="0"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/child_2_text"
yoga:yg_flex="1"
yoga:yg_marginHorizontal="5dp"
/>
</YogaLayout>

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