Commit Graph

2158 Commits

Author SHA1 Message Date
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