Compare commits

...

41 Commits

Author SHA1 Message Date
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
68 changed files with 1065 additions and 919 deletions

View File

@@ -32,6 +32,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install NDK 21
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
- name: Install dependencies - name: Install dependencies
run: | run: |
if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then
@@ -44,13 +50,9 @@ jobs:
cd buck cd buck
ant ant
popd popd
echo "::set-env name=PATH::$PATH:$HOME/buck/bin/" echo "$HOME/buck/bin" >> $GITHUB_PATH
export PATH=$PATH:$HOME/buck/bin/ export PATH=$PATH:$HOME/buck/bin/
buck --version buck --version
export TERMINAL=dumb
source scripts/android-setup.sh && installAndroidSDK
echo "::set-env name=ANDROID_SDK::$ANDROID_HOME"
echo "::set-env name=ANDROID_NDK_REPOSITORY::$HOME/android-ndk"
echo "::set-env name=ANDROID_NDK_HOME::$ANDROID_NDK_REPOSITORY/android-ndk-r15c"
- name: Build - name: Build
run: ./gradlew testDebugUnit && scripts/publish-snapshot.sh # TODO: Run the tests here again. They're currently crashing the JVM in GitHub Actions for some reason.
run: ./gradlew :yoga-layout:assembleDebug && scripts/publish-snapshot.sh

32
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Publish
on:
release:
types:
- created
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Install dependencies
run: source scripts/android-setup.sh && installAndroidSDK
- name: Write GPG Sec Ring
run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg
- name: Update gradle.properties
run: echo -e "signing.secretKeyRingFile=/tmp/secring.gpg\nsigning.keyId=${{ secrets.SIGNING_KEY_ID }}\nsigning.password=${{ secrets.SIGNING_PASSWORD }}\nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}\nmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties
- name: Upload Android Archives
run: ./gradlew :yoga:assembleRelease publish --info
- name: Release and close
run: ./gradlew closeAndReleaseRepository
- name: Clean secrets
if: always()
run: rm /tmp/secring.gpg

3
.gitignore vendored
View File

@@ -6,6 +6,9 @@
/.buckd /.buckd
/gentest/test.html /gentest/test.html
.buckversion .buckversion
.cxx
.idea
/local.properties
# Jekyll # Jekyll
/.sass-cache/ /.sass-cache/

View File

@@ -46,3 +46,29 @@ This will now only run the standalone webpack build upon install.
| node | Builds node js version. | | node | Builds node js version. |
| standalone | Runs webpack. | | standalone | Runs webpack. |
| none | Does nothing. You can use the prepackaged libs. | | none | Does nothing. You can use the prepackaged libs. |
## Maintainer Release Guide
To publish a new release, follow these steps:
1. Ensure you have your GPG key set up and your [OSS Sonatype](https://oss.sonatype.org/) credentials handy.
2. Add the follow entries to either your local `gradle.properties` (don't forget to revert) or your global `~/.gradle/gradle.properties`:
```
# You get these from https://oss.sonatype.org/#profile;User%20Token
mavenCentralRepositoryUsername=<username>
mavenCentralRepositoryPassword=<password>
# You can get the keyId (in GPG 1.4 format) by running `gpg1 --list-keys`.
signing.secretKeyRingFile=</path/to/secring.gpg>
signing.keyId=<key_id>
signing.password=<key_password>
```
3. Change the `VERSION_NAME` in `gradle.properties` to a non-SNAPSHOT release.
4. Commit and land the version change.
5. Run `./gradlew publishToMaven`.
6. Run `./gradlew closeAndReleaseRepository`.
7. Change the `VERSION_NAME` in `gradle.properties` back to a new SNAPSHOT release.
8. Commit and land the version change.
9. Celebrate! You've made a release!

View File

@@ -191,7 +191,6 @@
27595AD71E575C7800CCE2B1 /* SampleCxxModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D92B0D41E03699D0018521A /* SampleCxxModule.h */; }; 27595AD71E575C7800CCE2B1 /* SampleCxxModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D92B0D41E03699D0018521A /* SampleCxxModule.h */; };
27595AD81E575C7800CCE2B1 /* SystraceSection.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D92B0D51E03699D0018521A /* SystraceSection.h */; }; 27595AD81E575C7800CCE2B1 /* SystraceSection.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D92B0D51E03699D0018521A /* SystraceSection.h */; };
2D0EB9F32021067800CAF88A /* RCTUIUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = F1EFDA4E201F660F00EE6E4C /* RCTUIUtils.m */; }; 2D0EB9F32021067800CAF88A /* RCTUIUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = F1EFDA4E201F660F00EE6E4C /* RCTUIUtils.m */; };
2D16E68E1FA4FD3900B85C8A /* RCTTVNavigationEventEmitter.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3D0B842D1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h */; };
2D1D83CE1F74E2DA00615550 /* libdouble-conversion.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D383D621EBD27B9005632C8 /* libdouble-conversion.a */; }; 2D1D83CE1F74E2DA00615550 /* libdouble-conversion.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D383D621EBD27B9005632C8 /* libdouble-conversion.a */; };
2D3B5E931D9B087300451313 /* RCTErrorInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */; }; 2D3B5E931D9B087300451313 /* RCTErrorInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */; };
2D3B5E941D9B087900451313 /* RCTBundleURLProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 68EFE4ED1CF6EB3900A1DE13 /* RCTBundleURLProvider.m */; }; 2D3B5E941D9B087900451313 /* RCTBundleURLProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 68EFE4ED1CF6EB3900A1DE13 /* RCTBundleURLProvider.m */; };
@@ -269,8 +268,6 @@
3D0B842A1EC0B49400B2BD8E /* RCTTVRemoteHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0B84281EC0B49400B2BD8E /* RCTTVRemoteHandler.h */; }; 3D0B842A1EC0B49400B2BD8E /* RCTTVRemoteHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0B84281EC0B49400B2BD8E /* RCTTVRemoteHandler.h */; };
3D0B842B1EC0B49400B2BD8E /* RCTTVRemoteHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0B84291EC0B49400B2BD8E /* RCTTVRemoteHandler.m */; }; 3D0B842B1EC0B49400B2BD8E /* RCTTVRemoteHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0B84291EC0B49400B2BD8E /* RCTTVRemoteHandler.m */; };
3D0B842C1EC0B4EA00B2BD8E /* RCTTVView.m in Sources */ = {isa = PBXBuildFile; fileRef = 130443D71E401AD800D93A67 /* RCTTVView.m */; }; 3D0B842C1EC0B4EA00B2BD8E /* RCTTVView.m in Sources */ = {isa = PBXBuildFile; fileRef = 130443D71E401AD800D93A67 /* RCTTVView.m */; };
3D0B842F1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0B842D1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h */; };
3D0B84301EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0B842E1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.m */; };
3D0E378A1F1CC40000DCAC9F /* RCTWebSocketModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */; }; 3D0E378A1F1CC40000DCAC9F /* RCTWebSocketModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */; };
3D0E378E1F1CC59100DCAC9F /* RCTWebSocketModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */; }; 3D0E378E1F1CC59100DCAC9F /* RCTWebSocketModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */; };
3D0E378F1F1CC5CF00DCAC9F /* RCTWebSocketModule.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */; }; 3D0E378F1F1CC5CF00DCAC9F /* RCTWebSocketModule.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */; };
@@ -1275,7 +1272,6 @@
594F0A471FD233BD007FBE96 /* RCTSurfaceView.h in Copy Headers */, 594F0A471FD233BD007FBE96 /* RCTSurfaceView.h in Copy Headers */,
594F0A481FD233BD007FBE96 /* RCTSurfaceHostingView.h in Copy Headers */, 594F0A481FD233BD007FBE96 /* RCTSurfaceHostingView.h in Copy Headers */,
594F0A491FD233BD007FBE96 /* RCTSurfaceSizeMeasureMode.h in Copy Headers */, 594F0A491FD233BD007FBE96 /* RCTSurfaceSizeMeasureMode.h in Copy Headers */,
2D16E68E1FA4FD3900B85C8A /* RCTTVNavigationEventEmitter.h in Copy Headers */,
59500D481F71C67600B122B7 /* RCTUIManagerUtils.h in Copy Headers */, 59500D481F71C67600B122B7 /* RCTUIManagerUtils.h in Copy Headers */,
3D0E37901F1CC5E100DCAC9F /* RCTWebSocketModule.h in Copy Headers */, 3D0E37901F1CC5E100DCAC9F /* RCTWebSocketModule.h in Copy Headers */,
5960C1BF1F0804F50066FD5B /* RCTLayoutAnimation.h in Copy Headers */, 5960C1BF1F0804F50066FD5B /* RCTLayoutAnimation.h in Copy Headers */,
@@ -1876,8 +1872,6 @@
39C50FFA2046EE3500CEE534 /* RCTVersion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVersion.m; sourceTree = "<group>"; }; 39C50FFA2046EE3500CEE534 /* RCTVersion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVersion.m; sourceTree = "<group>"; };
3D0B84281EC0B49400B2BD8E /* RCTTVRemoteHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTVRemoteHandler.h; sourceTree = "<group>"; }; 3D0B84281EC0B49400B2BD8E /* RCTTVRemoteHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTVRemoteHandler.h; sourceTree = "<group>"; };
3D0B84291EC0B49400B2BD8E /* RCTTVRemoteHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTVRemoteHandler.m; sourceTree = "<group>"; }; 3D0B84291EC0B49400B2BD8E /* RCTTVRemoteHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTVRemoteHandler.m; sourceTree = "<group>"; };
3D0B842D1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTVNavigationEventEmitter.h; sourceTree = "<group>"; };
3D0B842E1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTVNavigationEventEmitter.m; sourceTree = "<group>"; };
3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTWebSocketModule.h; path = WebSocket/RCTWebSocketModule.h; sourceTree = "<group>"; }; 3D0E37891F1CC40000DCAC9F /* RCTWebSocketModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTWebSocketModule.h; path = WebSocket/RCTWebSocketModule.h; sourceTree = "<group>"; };
3D1E68D81CABD13900DD7465 /* RCTDisplayLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDisplayLink.h; sourceTree = "<group>"; }; 3D1E68D81CABD13900DD7465 /* RCTDisplayLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDisplayLink.h; sourceTree = "<group>"; };
3D1E68D91CABD13900DD7465 /* RCTDisplayLink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDisplayLink.m; sourceTree = "<group>"; }; 3D1E68D91CABD13900DD7465 /* RCTDisplayLink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDisplayLink.m; sourceTree = "<group>"; };
@@ -2346,8 +2340,6 @@
0EEEA8DE2239002200A8C82D /* RCTSurfacePresenterStub.m */, 0EEEA8DE2239002200A8C82D /* RCTSurfacePresenterStub.m */,
13B07FED1A69327A00A75B9A /* RCTTiming.h */, 13B07FED1A69327A00A75B9A /* RCTTiming.h */,
13B07FEE1A69327A00A75B9A /* RCTTiming.m */, 13B07FEE1A69327A00A75B9A /* RCTTiming.m */,
3D0B842D1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h */,
3D0B842E1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.m */,
13E067481A70F434002CDEE1 /* RCTUIManager.h */, 13E067481A70F434002CDEE1 /* RCTUIManager.h */,
13E067491A70F434002CDEE1 /* RCTUIManager.m */, 13E067491A70F434002CDEE1 /* RCTUIManager.m */,
59EB6DB91EBD6FC90072A5E7 /* RCTUIManagerObserverCoordinator.h */, 59EB6DB91EBD6FC90072A5E7 /* RCTUIManagerObserverCoordinator.h */,
@@ -2945,7 +2937,6 @@
3D302F311DF828F800D6DDAE /* RCTBundleURLProvider.h in Headers */, 3D302F311DF828F800D6DDAE /* RCTBundleURLProvider.h in Headers */,
3D302F321DF828F800D6DDAE /* RCTConvert.h in Headers */, 3D302F321DF828F800D6DDAE /* RCTConvert.h in Headers */,
3D302F331DF828F800D6DDAE /* RCTDefines.h in Headers */, 3D302F331DF828F800D6DDAE /* RCTDefines.h in Headers */,
3D0B842F1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h in Headers */,
3D302F341DF828F800D6DDAE /* RCTDisplayLink.h in Headers */, 3D302F341DF828F800D6DDAE /* RCTDisplayLink.h in Headers */,
3D302F351DF828F800D6DDAE /* RCTErrorCustomizer.h in Headers */, 3D302F351DF828F800D6DDAE /* RCTErrorCustomizer.h in Headers */,
3D302F361DF828F800D6DDAE /* RCTErrorInfo.h in Headers */, 3D302F361DF828F800D6DDAE /* RCTErrorInfo.h in Headers */,
@@ -3994,7 +3985,6 @@
2D3B5EC81D9B095800451313 /* RCTActivityIndicatorViewManager.m in Sources */, 2D3B5EC81D9B095800451313 /* RCTActivityIndicatorViewManager.m in Sources */,
3DCD185D1DF978E7007FE5A1 /* RCTReloadCommand.m in Sources */, 3DCD185D1DF978E7007FE5A1 /* RCTReloadCommand.m in Sources */,
130443DB1E401ADD00D93A67 /* RCTConvert+Transform.m in Sources */, 130443DB1E401ADD00D93A67 /* RCTConvert+Transform.m in Sources */,
3D0B84301EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.m in Sources */,
2D3B5EC61D9B095000451313 /* RCTProfileTrampoline-x86_64.S in Sources */, 2D3B5EC61D9B095000451313 /* RCTProfileTrampoline-x86_64.S in Sources */,
2D3B5EA61D9B08CA00451313 /* RCTTouchEvent.m in Sources */, 2D3B5EA61D9B08CA00451313 /* RCTTouchEvent.m in Sources */,
2D8C2E331DA40441000EE098 /* RCTMultipartStreamReader.m in Sources */, 2D8C2E331DA40441000EE098 /* RCTMultipartStreamReader.m in Sources */,

View File

@@ -28,17 +28,19 @@
UIView* child2 = [UIView new]; UIView* child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor]; child2.backgroundColor = [UIColor greenColor];
child2.frame = (CGRect){.size = { child2.frame = (CGRect){
.width = 200, .size = {
.height = 100, .width = 200,
}}; .height = 100,
}};
UIView* child3 = [UIView new]; UIView* child3 = [UIView new];
child3.backgroundColor = [UIColor yellowColor]; child3.backgroundColor = [UIColor yellowColor];
child3.frame = (CGRect){.size = { child3.frame = (CGRect){
.width = 100, .size = {
.height = 100, .width = 100,
}}; .height = 100,
}};
[child2 addSubview:child3]; [child2 addSubview:child3];
[root addSubview:child1]; [root addSubview:child1];

View File

@@ -5,17 +5,12 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
version = VERSION_NAME
group = GROUP
android { android {
compileSdkVersion rootProject.compileSdkVersion compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion buildToolsVersion rootProject.buildToolsVersion
ndkVersion rootProject.ndkVersion
defaultConfig { defaultConfig {
minSdkVersion rootProject.minSdkVersion minSdkVersion rootProject.minSdkVersion
@@ -32,21 +27,10 @@ dependencies {
api project(':yoga') api project(':yoga')
} }
task sourcesJar(type: Jar) { // We don't build Javadoc at this time as we can't disable "BUCK" files
classifier = 'source' // from mistakenly getting parsed as Java.
from android.sourceSets.main.java.srcDirs tasks.withType(Javadoc).all {
enabled = false
} }
task javadoc(type: Javadoc) { apply plugin: 'com.vanniktech.maven.publish'
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

@@ -8,6 +8,7 @@ load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAM
yoga_android_library( yoga_android_library(
name = "yoga", name = "yoga",
srcs = glob(["**/*.java"]), srcs = glob(["**/*.java"]),
autoglob = False,
visibility = [ visibility = [
"PUBLIC", "PUBLIC",
], ],

View File

@@ -8,6 +8,7 @@ load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTA
yoga_android_library( yoga_android_library(
name = "android", name = "android",
srcs = glob(["**/*.java"]), srcs = glob(["**/*.java"]),
autoglob = False,
visibility = [ visibility = [
"PUBLIC", "PUBLIC",
], ],

View File

@@ -10,14 +10,11 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() mavenCentral()
maven { url 'https://maven.google.com/' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.0' classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }
@@ -26,15 +23,16 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
} }
ext { ext {
minSdkVersion = 14 minSdkVersion = 14
targetSdkVersion = 25 targetSdkVersion = 29
compileSdkVersion = 26 compileSdkVersion = 29
buildToolsVersion = '28.0.3' buildToolsVersion = '30.0.2'
ndkVersion = '21.3.6528147'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7 sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7 targetCompatibilityVersion = JavaVersion.VERSION_1_7
} }

View File

@@ -36,7 +36,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
@@ -48,7 +48,7 @@
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
@@ -62,13 +62,13 @@
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
@@ -227,6 +227,8 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\yoga\event\event.h" />
<ClInclude Include="..\..\yoga\log.h" />
<ClInclude Include="..\..\yoga\Utils.h" /> <ClInclude Include="..\..\yoga\Utils.h" />
<ClInclude Include="..\..\yoga\YGConfig.h" /> <ClInclude Include="..\..\yoga\YGConfig.h" />
<ClInclude Include="..\..\yoga\YGEnums.h" /> <ClInclude Include="..\..\yoga\YGEnums.h" />
@@ -236,6 +238,7 @@
<ClInclude Include="..\..\yoga\YGNode.h" /> <ClInclude Include="..\..\yoga\YGNode.h" />
<ClInclude Include="..\..\yoga\YGNodePrint.h" /> <ClInclude Include="..\..\yoga\YGNodePrint.h" />
<ClInclude Include="..\..\yoga\YGStyle.h" /> <ClInclude Include="..\..\yoga\YGStyle.h" />
<ClInclude Include="..\..\yoga\YGValue.h" />
<ClInclude Include="..\..\yoga\Yoga-internal.h" /> <ClInclude Include="..\..\yoga\Yoga-internal.h" />
<ClInclude Include="..\..\yoga\Yoga.h" /> <ClInclude Include="..\..\yoga\Yoga.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
@@ -243,14 +246,16 @@
<ClInclude Include="targetver.h" /> <ClInclude Include="targetver.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\yoga\event\event.cpp" />
<ClCompile Include="..\..\yoga\log.cpp" />
<ClCompile Include="..\..\yoga\Utils.cpp" /> <ClCompile Include="..\..\yoga\Utils.cpp" />
<ClCompile Include="..\..\yoga\YGConfig.cpp" /> <ClCompile Include="..\..\yoga\YGConfig.cpp" />
<ClCompile Include="..\..\yoga\YGEnums.cpp" /> <ClCompile Include="..\..\yoga\YGEnums.cpp" />
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp" />
<ClCompile Include="..\..\yoga\YGLayout.cpp" /> <ClCompile Include="..\..\yoga\YGLayout.cpp" />
<ClCompile Include="..\..\yoga\YGNode.cpp" /> <ClCompile Include="..\..\yoga\YGNode.cpp" />
<ClCompile Include="..\..\yoga\YGNodePrint.cpp" /> <ClCompile Include="..\..\yoga\YGNodePrint.cpp" />
<ClCompile Include="..\..\yoga\YGStyle.cpp" /> <ClCompile Include="..\..\yoga\YGStyle.cpp" />
<ClCompile Include="..\..\yoga\YGValue.cpp" />
<ClCompile Include="..\..\yoga\Yoga.cpp" /> <ClCompile Include="..\..\yoga\Yoga.cpp" />
<ClCompile Include="YGInterop.cpp" /> <ClCompile Include="YGInterop.cpp" />
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">

View File

@@ -57,6 +57,15 @@
<ClInclude Include="..\..\yoga\YGConfig.h"> <ClInclude Include="..\..\yoga\YGConfig.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGValue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\log.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\event\event.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
@@ -74,9 +83,6 @@
<ClCompile Include="..\..\yoga\YGEnums.cpp"> <ClCompile Include="..\..\yoga\YGEnums.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGLayout.cpp"> <ClCompile Include="..\..\yoga\YGLayout.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@@ -95,6 +101,15 @@
<ClCompile Include="..\..\yoga\YGConfig.cpp"> <ClCompile Include="..\..\yoga\YGConfig.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\yoga\YGValue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\event\event.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\log.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Yoga.rc"> <ResourceCompile Include="Yoga.rc">

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
using System; using System;
@@ -333,5 +334,47 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
} }
[Test]
public void Test_display_none_with_position_absolute()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode(config);
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.Width = 100;
root_child0.Height = 100;
root_child0.Display = YogaDisplay.None;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(0f, root_child0.LayoutHeight);
}
} }
} }

View File

@@ -25,3 +25,7 @@
<div style="flex-grow: 1;"></div> <div style="flex-grow: 1;"></div>
<div style="flex-grow: 1; display:none; top: 10px;"></div> <div style="flex-grow: 1; display:none; top: 10px;"></div>
</div> </div>
<div id="display_none_with_position_absolute" style="width: 100px; height: 100px;">
<div style="display:none; position: absolute; width: 100px; height: 100px"></div>
</div>

View File

@@ -120,8 +120,9 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
YGOverflowHidden:{value:'YogaOverflow.Hidden'}, YGOverflowHidden:{value:'YogaOverflow.Hidden'},
YGOverflowVisible:{value:'YogaOverflow.Visible'}, YGOverflowVisible:{value:'YogaOverflow.Visible'},
YGPositionTypeAbsolute:{value:'YogaPositionType.Absolute'}, YGPositionTypeAbsolute:{value:'YogaPositionType.Static'},
YGPositionTypeRelative:{value:'YogaPositionType.Relative'}, YGPositionTypeRelative:{value:'YogaPositionType.Relative'},
YGPositionTypeAbsolute:{value:'YogaPositionType.Absolute'},
YGUndefined:{value:'YogaConstants.Undefined'}, YGUndefined:{value:'YogaConstants.Undefined'},

View File

@@ -41,11 +41,11 @@ function assert(condition, message) {
function printTest(e, LTRContainer, RTLContainer, genericContainer) { function printTest(e, LTRContainer, RTLContainer, genericContainer) {
e.push([ e.push([
'/**', '/*',
' * Copyright (c) Facebook, Inc. and its affiliates.', ' * Copyright (c) Facebook, Inc. and its affiliates.',
' *', ' *',
' * This source code is licensed under the MIT license found in the LICENSE', ' * This source code is licensed under the MIT license found in the',
' * file in the root directory of this source tree.', ' * LICENSE file in the root directory of this source tree.',
' */', ' */',
'// @Generated by gentest/gentest.rb from gentest/fixtures/' + document.title + '.html', '// @Generated by gentest/gentest.rb from gentest/fixtures/' + document.title + '.html',
'', '',

View File

@@ -7,13 +7,14 @@
require 'watir' require 'watir'
require 'fileutils' require 'fileutils'
caps = Selenium::WebDriver::Remote::Capabilities.chrome( browser = Watir::Browser.new(:chrome, "goog:loggingPrefs" => {
"loggingPrefs"=>{ "browser" => "ALL",
"browser"=>"ALL", "performance" => "ALL"
"performance"=>"ALL" },
} "chromeOptions" => {
) "w3c" => "false"
browser = Watir::Browser.new(:chrome, :desired_capabilities => caps, :switches => ['--force-device-scale-factor=1', '--window-position=0,0']) },
:switches => ['--force-device-scale-factor=1', '--window-position=0,0'])
Dir.chdir(File.dirname($0)) Dir.chdir(File.dirname($0))

View File

@@ -9,7 +9,7 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
VERSION_NAME=1.16.0-SNAPSHOT VERSION_NAME=1.19.0
POM_URL=https://github.com/facebook/yoga POM_URL=https://github.com/facebook/yoga
POM_SCM_URL=https://github.com/facebook/yoga.git POM_SCM_URL=https://github.com/facebook/yoga.git
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git
@@ -17,5 +17,8 @@ POM_SCM_DEV_CONNECTION=scm:git:git@github.com:facebook/yoga.git
POM_LICENSE_NAME=MIT License POM_LICENSE_NAME=MIT License
POM_LICENSE_URL=https://github.com/facebook/yoga/blob/master/LICENSE POM_LICENSE_URL=https://github.com/facebook/yoga/blob/master/LICENSE
POM_LICENSE_DIST=repo POM_LICENSE_DIST=repo
POM_LICENCE_NAME=MIT License
POM_LICENCE_URL=https://github.com/facebook/yoga/blob/master/LICENSE
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=facebook POM_DEVELOPER_ID=facebook
POM_DEVELOPER_NAME=facebook POM_DEVELOPER_NAME=facebook

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.
*/
// Configure the Android maven publication
apply plugin: 'com.github.dcendents.android-maven'
version = VERSION_NAME
group = GROUP
// Set the .aar / .jar base file name to match the artifact ID
// in case the module has a different name
project.archivesBaseName = POM_ARTIFACT_ID
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom.project {
name POM_NAME
artifactId POM_ARTIFACT_ID
packaging POM_PACKAGING
description POM_DESCRIPTION
url projectUrl
scm {
url scmUrl
connection scmConnection
developerConnection scmDeveloperConnection
}
licenses projectLicenses
developers {
developer {
id developerId
name developerName
}
}
}
}
}

View File

@@ -1,54 +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.
*/
// Android tasks for Javadoc and sources.jar generation
afterEvaluate { project ->
if (POM_PACKAGING == 'aar') {
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
exclude '**/pom.xml'
exclude '**/proguard_annotations.pro'
classpath += files(android.bootClasspath)
}
task androidJavadocJar(type: Jar) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) {
from variant.javaCompile.destinationDir
}
}
artifacts.add('archives', androidJavadocJar)
artifacts.add('archives', androidSourcesJar)
}
if (POM_PACKAGING == 'jar') {
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts.add('archives', javadocJar)
artifacts.add('archives', sourcesJar)
}
}

View File

@@ -1,70 +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.
*/
// Upload to Bintray
apply plugin: 'com.jfrog.bintray'
def getBintrayUsername() {
return project.hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
}
def getBintrayApiKey() {
return project.hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
}
def getBintrayGpgPassword() {
return project.hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
}
def getMavenCentralUsername() {
return project.hasProperty('mavenCentralUsername') ? property('mavenCentralUsername') : System.getenv('MAVEN_CENTRAL_USERNAME')
}
def getMavenCentralPassword() {
return project.hasProperty('mavenCentralPassword') ? property('mavenCentralPassword') : System.getenv('MAVEN_CENTRAL_PASSWORD')
}
def shouldSyncWithMavenCentral() {
return project.hasProperty('syncWithMavenCentral') ? property('syncWithMavenCentral').toBoolean() : false
}
def dryRunOnly() {
return project.hasProperty('dryRun') ? property('dryRun').toBoolean() : false
}
bintray {
user = getBintrayUsername()
key = getBintrayApiKey()
configurations = ['archives']
pkg {
repo = bintrayRepo
userOrg = bintrayUserOrg
name = bintrayName
desc = bintrayDescription
websiteUrl = projectUrl
issueTrackerUrl = issuesUrl
vcsUrl = scmUrl
licenses = projectLicenses
dryRun = dryRunOnly()
override = true
publish = true
publicDownloadNumbers = true
version {
desc = bintrayDescription
gpg {
sign = true
passphrase = getBintrayGpgPassword()
}
mavenCentralSync {
sync = shouldSyncWithMavenCentral()
user = getMavenCentralUsername()
password = getMavenCentralPassword()
close = '1' // If set to 0, you have to manually click release
}
}
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'signing'
version = VERSION_NAME
group = GROUP
def isReleaseBuild() {
return VERSION_NAME.contains('SNAPSHOT') == false
}
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
}
def getRepositoryPassword() {
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENSE_NAME
url POM_LICENSE_URL
distribution POM_LICENSE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
sign configurations.archives
}
}

View File

@@ -1,40 +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.
*/
// Set up everything required for releasing on Bintray
ext {
bintrayRepo = 'maven'
bintrayUserOrg = 'facebook'
bintrayName = "${GROUP}:${POM_ARTIFACT_ID}"
bintrayDescription = POM_DESCRIPTION
projectUrl = POM_URL
issuesUrl = 'https://github.com/facebook/yoga/issues'
scmUrl = POM_SCM_URL
scmConnection = POM_SCM_CONNECTION
scmDeveloperConnection = POM_SCM_DEV_CONNECTION
publishedGroupId = GROUP
libraryName = 'yoga'
artifact = 'yoga'
developerId = POM_DEVELOPER_ID
developerName = POM_DEVELOPER_NAME
projectLicenses = {
license {
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DIST
}
}
}
// Set up the Android Maven publication (POM etc.)
apply from: rootProject.file('gradle/android-maven-install.gradle')
// Upload to Bintray
apply from: rootProject.file('gradle/bintray.gradle')

View File

@@ -1,15 +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.
*/
// Common Android tasks for all releases that generate Javadocs, sources, etc.
apply from: rootProject.file('gradle/android-tasks.gradle')
// Upload to Bintray
apply from: rootProject.file('gradle/release-bintray.gradle')
// Upload directly to standard Maven Central (for SNAPSHOTs)
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

View File

@@ -108,6 +108,7 @@ yoga_java_library(
yoga_java_test( yoga_java_test(
name = "tests", name = "tests",
srcs = glob(["tests/**/*.java"]), srcs = glob(["tests/**/*.java"]),
contacts = ["oncall+yoga@xmail.facebook.com"],
cxx_library_whitelist = CXX_LIBRARY_WHITELIST_FOR_TESTS, cxx_library_whitelist = CXX_LIBRARY_WHITELIST_FOR_TESTS,
use_cxx_libraries = True, use_cxx_libraries = True,
visibility = ["PUBLIC"], visibility = ["PUBLIC"],

View File

@@ -5,17 +5,12 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
group = GROUP
version = VERSION_NAME
android { android {
compileSdkVersion rootProject.compileSdkVersion compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion buildToolsVersion rootProject.buildToolsVersion
ndkVersion rootProject.ndkVersion
defaultConfig { defaultConfig {
minSdkVersion rootProject.minSdkVersion minSdkVersion rootProject.minSdkVersion
@@ -35,7 +30,6 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path 'CMakeLists.txt' path 'CMakeLists.txt'
version '3.6.0-rc2'
} }
} }
@@ -58,32 +52,11 @@ android {
} }
dependencies { dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.1' implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation project(':yoga:proguard-annotations') implementation project(':yoga:proguard-annotations')
implementation 'com.facebook.soloader:soloader:0.5.1' implementation 'com.facebook.soloader:soloader:0.10.1'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation project(':testutil') testImplementation project(':testutil')
} }
task sourcesJar(type: Jar) { apply plugin: 'com.vanniktech.maven.publish'
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
}
ext {
bintrayName = 'com.facebook.yoga:yoga'
}
apply from: rootProject.file('gradle/release.gradle')

View File

@@ -9,7 +9,15 @@ package com.facebook.yoga;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public abstract class YogaNode { public abstract class YogaNode implements YogaProps {
/** The interface the {@link #getData()} object can optionally implement. */
public interface Inputs {
/** Requests the data object to disable mutations of its inputs. */
void freeze(final YogaNode node, final @Nullable YogaNode parent);
}
public abstract void reset(); public abstract void reset();
public abstract int getChildCount(); public abstract int getChildCount();
@@ -25,12 +33,10 @@ public abstract class YogaNode {
public abstract YogaNode removeChildAt(int i); public abstract YogaNode removeChildAt(int i);
/** /**
* @returns the {@link YogaNode} that owns this {@link YogaNode}. * @returns the {@link YogaNode} that owns this {@link YogaNode}. The owner is used to identify
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs * the YogaTree that a {@link YogaNode} belongs to. This method will return the parent of the
* to. * {@link YogaNode} when the {@link YogaNode} only belongs to one YogaTree or null when the
* This method will return the parent of the {@link YogaNode} when the * {@link YogaNode} is shared between two or more YogaTrees.
* {@link YogaNode} only belongs to one YogaTree or null when the
* {@link YogaNode} is shared between two or more YogaTrees.
*/ */
@Nullable @Nullable
public abstract YogaNode getOwner(); public abstract YogaNode getOwner();

View File

@@ -83,6 +83,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
} }
public void addChildAt(YogaNode c, int i) { public void addChildAt(YogaNode c, int i) {
if (!(c instanceof YogaNodeJNIBase)) {
return;
}
YogaNodeJNIBase child = (YogaNodeJNIBase) c; YogaNodeJNIBase child = (YogaNodeJNIBase) c;
if (child.mOwner != null) { if (child.mOwner != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first."); throw new IllegalStateException("Child already has a parent, it must be removed first.");
@@ -105,6 +108,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
} }
public void swapChildAt(YogaNode newChild, int position) { public void swapChildAt(YogaNode newChild, int position) {
if (!(newChild instanceof YogaNodeJNIBase)) {
return;
}
YogaNodeJNIBase child = (YogaNodeJNIBase) newChild; YogaNodeJNIBase child = (YogaNodeJNIBase) newChild;
mChildren.remove(position); mChildren.remove(position);
mChildren.add(position, child); mChildren.add(position, child);
@@ -116,6 +122,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
public YogaNodeJNIBase cloneWithChildren() { public YogaNodeJNIBase cloneWithChildren() {
try { try {
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone(); YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
if (clonedYogaNode.mChildren != null) {
clonedYogaNode.mChildren = new ArrayList<>(clonedYogaNode.mChildren);
}
long clonedNativePointer = YogaNative.jni_YGNodeCloneJNI(mNativePointer); long clonedNativePointer = YogaNative.jni_YGNodeCloneJNI(mNativePointer);
clonedYogaNode.mOwner = null; clonedYogaNode.mOwner = null;
clonedYogaNode.mNativePointer = clonedNativePointer; clonedYogaNode.mNativePointer = clonedNativePointer;
@@ -188,12 +197,18 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
long[] nativePointers = null; long[] nativePointers = null;
YogaNodeJNIBase[] nodes = null; YogaNodeJNIBase[] nodes = null;
freeze(null);
ArrayList<YogaNodeJNIBase> n = new ArrayList<>(); ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
n.add(this); n.add(this);
for (int i = 0; i < n.size(); ++i) { for (int i = 0; i < n.size(); ++i) {
List<YogaNodeJNIBase> children = n.get(i).mChildren; final YogaNodeJNIBase parent = n.get(i);
List<YogaNodeJNIBase> children = parent.mChildren;
if (children != null) { if (children != null) {
n.addAll(children); for (YogaNodeJNIBase child : children) {
child.freeze(parent);
n.add(child);
}
} }
} }
@@ -206,6 +221,13 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes); YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
} }
private void freeze(YogaNode parent) {
Object data = getData();
if (data instanceof Inputs) {
((Inputs) data).freeze(this, parent);
}
}
public void dirty() { public void dirty() {
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer); YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
} }
@@ -220,6 +242,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
@Override @Override
public void copyStyle(YogaNode srcNode) { public void copyStyle(YogaNode srcNode) {
if (!(srcNode instanceof YogaNodeJNIBase)) {
return;
}
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer); YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
} }

View File

@@ -8,8 +8,9 @@
package com.facebook.yoga; package com.facebook.yoga;
public enum YogaPositionType { public enum YogaPositionType {
RELATIVE(0), STATIC(0),
ABSOLUTE(1); RELATIVE(1),
ABSOLUTE(2);
private final int mIntValue; private final int mIntValue;
@@ -23,8 +24,9 @@ public enum YogaPositionType {
public static YogaPositionType fromInt(int value) { public static YogaPositionType fromInt(int value) {
switch (value) { switch (value) {
case 0: return RELATIVE; case 0: return STATIC;
case 1: return ABSOLUTE; case 1: return RELATIVE;
case 2: return ABSOLUTE;
default: throw new IllegalArgumentException("Unknown enum value: " + value); default: throw new IllegalArgumentException("Unknown enum value: " + value);
} }
} }

View File

@@ -0,0 +1,151 @@
/*
* 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.
*/
package com.facebook.yoga;
public interface YogaProps {
/* Width properties */
void setWidth(float width);
void setWidthPercent(float percent);
void setMinWidth(float minWidth);
void setMinWidthPercent(float percent);
void setMaxWidth(float maxWidth);
void setMaxWidthPercent(float percent);
void setWidthAuto();
/* Height properties */
void setHeight(float height);
void setHeightPercent(float percent);
void setMinHeight(float minHeight);
void setMinHeightPercent(float percent);
void setMaxHeight(float maxHeight);
void setMaxHeightPercent(float percent);
void setHeightAuto();
/* Margin properties */
void setMargin(YogaEdge edge, float margin);
void setMarginPercent(YogaEdge edge, float percent);
void setMarginAuto(YogaEdge edge);
/* Padding properties */
void setPadding(YogaEdge edge, float padding);
void setPaddingPercent(YogaEdge edge, float percent);
/* Position properties */
void setPositionType(YogaPositionType positionType);
void setPosition(YogaEdge edge, float position);
void setPositionPercent(YogaEdge edge, float percent);
/* Alignment properties */
void setAlignContent(YogaAlign alignContent);
void setAlignItems(YogaAlign alignItems);
void setAlignSelf(YogaAlign alignSelf);
/* Flex properties */
void setFlex(float flex);
void setFlexBasisAuto();
void setFlexBasisPercent(float percent);
void setFlexBasis(float flexBasis);
void setFlexDirection(YogaFlexDirection direction);
void setFlexGrow(float flexGrow);
void setFlexShrink(float flexShrink);
/* Other properties */
void setJustifyContent(YogaJustify justifyContent);
void setDirection(YogaDirection direction);
void setBorder(YogaEdge edge, float value);
void setWrap(YogaWrap wrap);
void setAspectRatio(float aspectRatio);
void setIsReferenceBaseline(boolean isReferenceBaseline);
void setMeasureFunction(YogaMeasureFunction measureFunction);
void setBaselineFunction(YogaBaselineFunction yogaBaselineFunction);
/* Getters */
YogaValue getWidth();
YogaValue getMinWidth();
YogaValue getMaxWidth();
YogaValue getHeight();
YogaValue getMinHeight();
YogaValue getMaxHeight();
YogaDirection getStyleDirection();
YogaFlexDirection getFlexDirection();
YogaJustify getJustifyContent();
YogaAlign getAlignItems();
YogaAlign getAlignSelf();
YogaAlign getAlignContent();
YogaPositionType getPositionType();
float getFlexGrow();
float getFlexShrink();
YogaValue getFlexBasis();
float getAspectRatio();
YogaValue getMargin(YogaEdge edge);
YogaValue getPadding(YogaEdge edge);
YogaValue getPosition(YogaEdge edge);
float getBorder(YogaEdge edge);
}

View File

@@ -196,7 +196,7 @@ static void jni_YGConfigSetLoggerJNI(
delete context; delete context;
YGConfigSetContext(config, nullptr); YGConfigSetContext(config, nullptr);
} }
config->setLogger(nullptr); YGConfigSetLogger(config, nullptr);
} }
} }
@@ -726,8 +726,7 @@ static void jni_YGNodePrintJNI(JNIEnv* env, jobject obj, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint( YGNodePrint(
node, node,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
#endif #endif
} }

View File

@@ -10,4 +10,4 @@ apply plugin: 'java'
sourceCompatibility = '1.7' sourceCompatibility = '1.7'
targetCompatibility = '1.7' targetCompatibility = '1.7'
apply from: rootProject.file('gradle/release.gradle') apply plugin: 'com.vanniktech.maven.publish'

View File

@@ -0,0 +1,24 @@
/*
* 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.
*/
package com.facebook.proguard.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.CLASS;
/**
* Add this annotation to a class to instruct Proguard to not strip it or any of its fields or
* methods out.
*
* <p>This is useful for methods called via reflection that could appear as unused to Proguard.
*/
@Target({ElementType.TYPE})
@Retention(CLASS)
public @interface DoNotStripAny {}

View File

@@ -1,9 +1,10 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
package com.facebook.yoga; package com.facebook.yoga;
@@ -337,6 +338,47 @@ public class YGDisplayTest {
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test
public void test_display_none_with_position_absolute() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root_child0.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) { private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config); return mNodeFactory.create(config);
} }

View File

@@ -9,10 +9,62 @@ package com.facebook.yoga;
import org.junit.Test; import org.junit.Test;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
public class YogaLoggerTest { public class YogaLoggerTest {
@Test
public void testRemovingLoggerFromConfig() throws Exception {
final List<String> logs = new ArrayList<>();
final YogaConfig config = YogaConfigFactory.create();
YogaLogger logger = new YogaLogger() {
@Override
public void log(YogaLogLevel level, String message) {
logs.add(message);
}
};
config.setLogger(logger);
final YogaNode root = YogaNodeFactory.create(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignItems(YogaAlign.BASELINE);
final YogaNode child1 = YogaNodeFactory.create(config);
root.addChildAt(child1, 0);
final YogaNode child2 = YogaNodeFactory.create(config);
child2.setBaselineFunction(new YogaBaselineFunction() {
public float baseline(YogaNode node, float width, float height) {
return Float.NaN;
}
});
root.addChildAt(child2, 1);
assertEquals(logs.size(), 0);
try {
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
fail("Expected calculateLayout to throw");
} catch (IllegalStateException e) {
}
assertEquals(logs.size(), 1);
config.setLogger(null);
try {
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
fail("Expected calculateLayout to throw again");
} catch (IllegalStateException e) {
}
assertEquals(logs.size(), 1);
}
@Test @Test
public void testLoggerLeak() throws Exception { public void testLoggerLeak() throws Exception {
final YogaConfig config = YogaConfigFactory.create(); final YogaConfig config = YogaConfigFactory.create();

View File

@@ -191,7 +191,7 @@ public class YogaNodeStylePropertiesTest {
public void testPositionTypeDefault() { public void testPositionTypeDefault() {
final YogaNode node = createNode(); final YogaNode node = createNode();
assertEquals(YogaPositionType.RELATIVE, node.getPositionType()); assertEquals(YogaPositionType.STATIC, node.getPositionType());
} }
@Test @Test

View File

@@ -7,5 +7,9 @@
[lints] [lints]
[options] [options]
types_first=false
[strict] [strict]
[version]
^0.140.0

View File

@@ -23,8 +23,8 @@ static YGSize globalMeasureFunc(
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef)); Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
Size size = node.callMeasureFunc(width, widthMode, height, heightMode); Size size = node.callMeasureFunc(width, widthMode, height, heightMode);
YGSize ygSize = {static_cast<float>(size.width), YGSize ygSize = {
static_cast<float>(size.height)}; static_cast<float>(size.width), static_cast<float>(size.height)};
return ygSize; return ygSize;
} }

View File

@@ -1,9 +1,10 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY); var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
@@ -342,3 +343,48 @@ it("display_none_with_position", function () {
config.free(); config.free();
} }
}); });
it("display_none_with_position_absolute", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setWidth(100);
root.setHeight(100);
var root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
root_child0.setWidth(100);
root_child0.setHeight(100);
root_child0.setDisplay(Yoga.DISPLAY_NONE);
root.insertChild(root_child0, 0);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});

View File

@@ -33,8 +33,8 @@ android {
} }
dependencies { dependencies {
implementation 'com.facebook.soloader:soloader:0.5.1' implementation 'com.facebook.soloader:soloader:0.10.1'
implementation 'com.google.code.findbugs:jsr305:3.0.1' implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation project(':yoga:proguard-annotations') implementation project(':yoga:proguard-annotations')
} }
} }

View File

@@ -14,17 +14,8 @@ set -e
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")" IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")"
if [ "$GITHUB_REPOSITORY" != "facebook/yoga" ]; then if [ "$IS_SNAPSHOT" == "" ]; then
echo >&2 "Skipping repository. Expected project to be 'facebook/yoga', but was '$GITHUB_REPOSITORY'."
exit
elif [ "$GITHUB_REF" != "refs/heads/master" ]; then
echo >&2 "Skipping build. Expected ref name to be 'refs/heads/master', but was '$GITHUB_REF'."
exit
elif [ "$GITHUB_EVENT_NAME" != "push" ]; then
echo >&2 "Skipping build. Only considering push builds, but event was '$GITHUB_EVENT_NAME'."
exit
elif [ "$IS_SNAPSHOT" == "" ]; then
echo >&2 "Skipping build. Given build doesn't appear to be a SNAPSHOT release." echo >&2 "Skipping build. Given build doesn't appear to be a SNAPSHOT release."
else else
env TERMINAL=dumb "$BASEDIR/gradlew" uploadArchives env TERMINAL=dumb "$BASEDIR/gradlew" publish
fi fi

View File

@@ -303,8 +303,8 @@ EventArgs createArgs(
}; };
EventArgs args = createArgs<E>(node, data); EventArgs args = createArgs<E>(node, data);
args.eventTestDataPtr = {new EventTestData{eventTestData}, args.eventTestDataPtr = {
deleteEventTestData}; new EventTestData{eventTestData}, deleteEventTestData};
return args; return args;
} }

View File

@@ -29,12 +29,13 @@ TEST(YogaTest, computed_layout_margin) {
} }
TEST(YogaTest, margin_side_overrides_horizontal_and_vertical) { TEST(YogaTest, margin_side_overrides_horizontal_and_vertical) {
const std::array<YGEdge, 6> edges = {{YGEdgeTop, const std::array<YGEdge, 6> edges = {
YGEdgeBottom, {YGEdgeTop,
YGEdgeStart, YGEdgeBottom,
YGEdgeEnd, YGEdgeStart,
YGEdgeLeft, YGEdgeEnd,
YGEdgeRight}}; YGEdgeLeft,
YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (float edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {
@@ -58,12 +59,13 @@ TEST(YogaTest, margin_side_overrides_horizontal_and_vertical) {
} }
TEST(YogaTest, margin_side_overrides_all) { TEST(YogaTest, margin_side_overrides_all) {
const std::array<YGEdge, 6> edges = {{YGEdgeTop, const std::array<YGEdge, 6> edges = {
YGEdgeBottom, {YGEdgeTop,
YGEdgeStart, YGEdgeBottom,
YGEdgeEnd, YGEdgeStart,
YGEdgeLeft, YGEdgeEnd,
YGEdgeRight}}; YGEdgeLeft,
YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (float edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {

View File

@@ -29,12 +29,13 @@ TEST(YogaTest, computed_layout_padding) {
} }
TEST(YogaTest, padding_side_overrides_horizontal_and_vertical) { TEST(YogaTest, padding_side_overrides_horizontal_and_vertical) {
const std::array<YGEdge, 6> edges = {{YGEdgeTop, const std::array<YGEdge, 6> edges = {
YGEdgeBottom, {YGEdgeTop,
YGEdgeStart, YGEdgeBottom,
YGEdgeEnd, YGEdgeStart,
YGEdgeLeft, YGEdgeEnd,
YGEdgeRight}}; YGEdgeLeft,
YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (float edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {
@@ -58,12 +59,13 @@ TEST(YogaTest, padding_side_overrides_horizontal_and_vertical) {
} }
TEST(YogaTest, padding_side_overrides_all) { TEST(YogaTest, padding_side_overrides_all) {
const std::array<YGEdge, 6> edges = {{YGEdgeTop, const std::array<YGEdge, 6> edges = {
YGEdgeBottom, {YGEdgeTop,
YGEdgeStart, YGEdgeBottom,
YGEdgeEnd, YGEdgeStart,
YGEdgeLeft, YGEdgeEnd,
YGEdgeRight}}; YGEdgeLeft,
YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (float edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {

View File

@@ -20,7 +20,7 @@ TEST(YogaTest, assert_default_values) {
ASSERT_EQ(YGAlignFlexStart, YGNodeStyleGetAlignContent(root)); ASSERT_EQ(YGAlignFlexStart, YGNodeStyleGetAlignContent(root));
ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignItems(root)); ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignItems(root));
ASSERT_EQ(YGAlignAuto, YGNodeStyleGetAlignSelf(root)); ASSERT_EQ(YGAlignAuto, YGNodeStyleGetAlignSelf(root));
ASSERT_EQ(YGPositionTypeRelative, YGNodeStyleGetPositionType(root)); ASSERT_EQ(YGPositionTypeStatic, YGNodeStyleGetPositionType(root));
ASSERT_EQ(YGWrapNoWrap, YGNodeStyleGetFlexWrap(root)); ASSERT_EQ(YGWrapNoWrap, YGNodeStyleGetFlexWrap(root));
ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root));

View File

@@ -1,9 +1,10 @@
/* /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the
* file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -327,3 +328,45 @@ TEST(YogaTest, display_none_with_position) {
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, display_none_with_position_absolute) {
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root_child0, 100);
YGNodeStyleSetHeight(root_child0, 100);
YGNodeStyleSetDisplay(root_child0, YGDisplayNone);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -73,8 +73,7 @@ TEST(YogaTest, logger_default_node_should_print_no_style_info) {
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint( YGNodePrint(
root, root,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFree(root); YGNodeFree(root);
@@ -98,8 +97,7 @@ TEST(YogaTest, logger_node_with_percentage_absolute_position_and_margin) {
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint( YGNodePrint(
root, root,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFree(root); YGNodeFree(root);
@@ -122,8 +120,7 @@ TEST(YogaTest, logger_node_with_children_should_print_indented) {
YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUnitUndefined, YGUnitUndefined, YGDirectionLTR);
YGNodePrint( YGNodePrint(
root, root,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGConfigSetLogger(config, NULL); YGConfigSetLogger(config, NULL);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);

View File

@@ -132,9 +132,10 @@ ACCESSOR_TEST(
ACCESSOR_TEST( ACCESSOR_TEST(
positionType, positionType,
YGPositionTypeRelative, YGPositionTypeStatic,
YGPositionTypeAbsolute, YGPositionTypeAbsolute,
YGPositionTypeRelative) YGPositionTypeRelative,
YGPositionTypeStatic)
ACCESSOR_TEST( ACCESSOR_TEST(
flexWrap, flexWrap,

View File

@@ -29,8 +29,8 @@ TEST(YogaTest, set_children_adds_children_to_parent) {
const std::vector<YGNodeRef> expectedChildren = {root_child0, root_child1}; const std::vector<YGNodeRef> expectedChildren = {root_child0, root_child1};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), const std::vector<YGNodeRef> owners = {
YGNodeGetOwner(root_child1)}; YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)};
const std::vector<YGNodeRef> expectedOwners = {root, root}; const std::vector<YGNodeRef> expectedOwners = {root, root};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);
@@ -49,8 +49,8 @@ TEST(YogaTest, set_children_to_empty_removes_old_children) {
const std::vector<YGNodeRef> expectedChildren = {}; const std::vector<YGNodeRef> expectedChildren = {};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), const std::vector<YGNodeRef> owners = {
YGNodeGetOwner(root_child1)}; YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)};
const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr}; const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);
@@ -73,8 +73,8 @@ TEST(YogaTest, set_children_replaces_non_common_children) {
const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child3}; const std::vector<YGNodeRef> expectedChildren = {root_child2, root_child3};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), const std::vector<YGNodeRef> owners = {
YGNodeGetOwner(root_child1)}; YGNodeGetOwner(root_child0), YGNodeGetOwner(root_child1)};
const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr}; const std::vector<YGNodeRef> expectedOwners = {nullptr, nullptr};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);
@@ -100,10 +100,11 @@ TEST(YogaTest, set_children_keeps_and_reorders_common_children) {
root_child2, root_child1, root_child3}; root_child2, root_child1, root_child3};
ASSERT_EQ(children, expectedChildren); ASSERT_EQ(children, expectedChildren);
const std::vector<YGNodeRef> owners = {YGNodeGetOwner(root_child0), const std::vector<YGNodeRef> owners = {
YGNodeGetOwner(root_child1), YGNodeGetOwner(root_child0),
YGNodeGetOwner(root_child2), YGNodeGetOwner(root_child1),
YGNodeGetOwner(root_child3)}; YGNodeGetOwner(root_child2),
YGNodeGetOwner(root_child3)};
const std::vector<YGNodeRef> expectedOwners = {nullptr, root, root, root}; const std::vector<YGNodeRef> expectedOwners = {nullptr, root, root, root};
ASSERT_EQ(owners, expectedOwners); ASSERT_EQ(owners, expectedOwners);

View File

@@ -29,11 +29,10 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path 'src/main/cpp/CMakeLists.txt' path 'src/main/cpp/CMakeLists.txt'
version '3.6.0-rc2'
} }
} }
dependencies { dependencies {
implementation 'com.facebook.soloader:soloader:0.5.1' implementation 'com.facebook.soloader:soloader:0.10.1'
} }
} }

View File

@@ -7,5 +7,9 @@
[lints] [lints]
[options] [options]
types_first=false
[strict] [strict]
[version]
^0.140.0

View File

@@ -73,9 +73,9 @@ function keyLookup(key: string): string {
function getValue(value) { function getValue(value) {
if (typeof value === 'string' && /%$/.test(value)) { if (typeof value === 'string' && /%$/.test(value)) {
return `CKRelativeDimension::Percent(${parseFloat(value)})`; return `RCRelativeDimension::Percent(${parseFloat(value)})`;
} else if (value === 'auto') { } else if (value === 'auto') {
return 'CKRelativeDimension::Auto()'; return 'RCRelativeDimension::Auto()';
} else { } else {
return String(parseFloat(value)); return String(parseFloat(value));
} }

View File

@@ -24,7 +24,7 @@ function getEnum(yogaEnum: string, value: string | number): string {
position: 'Position', position: 'Position',
flexWrap: 'Wrap', flexWrap: 'Wrap',
positionType: 'PositionType', positionType: 'PositionType',
direction: 'Driection', direction: 'Direction',
}; };
if (!enumLookup[yogaEnum]) { if (!enumLookup[yogaEnum]) {

View File

@@ -45,8 +45,9 @@ void setEnumData(uint32_t& flags, size_t index, int newValue) {
template <typename Enum> template <typename Enum>
void setEnumData(uint8_t& flags, size_t index, int newValue) { void setEnumData(uint8_t& flags, size_t index, int newValue) {
flags = (flags & ~mask(bitWidthFn<Enum>(), index)) | flags = (flags & ~static_cast<uint8_t>(mask(bitWidthFn<Enum>(), index))) |
((newValue << index) & (mask(bitWidthFn<Enum>(), index))); ((newValue << index) &
(static_cast<uint8_t>(mask(bitWidthFn<Enum>(), index))));
} }
constexpr bool getBooleanData(int flags, size_t index) { constexpr bool getBooleanData(int flags, size_t index) {

View File

@@ -125,8 +125,8 @@ public:
data.repr &= ~PERCENT_BIT; data.repr &= ~PERCENT_BIT;
data.repr += BIAS; data.repr += BIAS;
return YGValue{data.value, return YGValue{
payload_.repr & 0x40000000 ? YGUnitPercent : YGUnitPoint}; data.value, payload_.repr & 0x40000000 ? YGUnitPercent : YGUnitPoint};
} }
bool isUndefined() const noexcept { bool isUndefined() const noexcept {

View File

@@ -6,6 +6,7 @@
*/ */
#include "Utils.h" #include "Utils.h"
#include <stdexcept>
using namespace facebook; using namespace facebook;
@@ -52,6 +53,13 @@ bool YGFloatsEqual(const float a, const float b) {
return yoga::isUndefined(a) && yoga::isUndefined(b); return yoga::isUndefined(a) && yoga::isUndefined(b);
} }
bool YGDoubleEqual(const double a, const double b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fabs(a - b) < 0.0001;
}
return yoga::isUndefined(a) && yoga::isUndefined(b);
}
float YGFloatSanitize(const float val) { float YGFloatSanitize(const float val) {
return yoga::isUndefined(val) ? 0 : val; return yoga::isUndefined(val) ? 0 : val;
} }

View File

@@ -64,6 +64,8 @@ inline bool YGValueEqual(
// difference between two floats is less than 0.0001f or both are undefined. // difference between two floats is less than 0.0001f or both are undefined.
bool YGFloatsEqual(const float a, const float b); bool YGFloatsEqual(const float a, const float b);
bool YGDoubleEqual(const double a, const double b);
float YGFloatMax(const float a, const float b); float YGFloatMax(const float a, const float b);
YGFloatOptional YGFloatOptionalMax( YGFloatOptional YGFloatOptionalMax(

View File

@@ -179,6 +179,8 @@ const char* YGOverflowToString(const YGOverflow value) {
const char* YGPositionTypeToString(const YGPositionType value) { const char* YGPositionTypeToString(const YGPositionType value) {
switch (value) { switch (value) {
case YGPositionTypeStatic:
return "static";
case YGPositionTypeRelative: case YGPositionTypeRelative:
return "relative"; return "relative";
case YGPositionTypeAbsolute: case YGPositionTypeAbsolute:

View File

@@ -128,7 +128,11 @@ YG_ENUM_SEQ_DECL(
YGOverflowHidden, YGOverflowHidden,
YGOverflowScroll) YGOverflowScroll)
YG_ENUM_SEQ_DECL(YGPositionType, YGPositionTypeRelative, YGPositionTypeAbsolute) YG_ENUM_SEQ_DECL(
YGPositionType,
YGPositionTypeStatic,
YGPositionTypeRelative,
YGPositionTypeAbsolute)
YG_ENUM_DECL( YG_ENUM_DECL(
YGPrintOptions, YGPrintOptions,

View File

@@ -50,89 +50,111 @@ void YGNode::print(void* printContext) {
} }
} }
CompactValue YGNode::computeEdgeValueForRow(
const YGStyle::Edges& edges,
YGEdge rowEdge,
YGEdge edge,
CompactValue defaultValue) {
if (!edges[rowEdge].isUndefined()) {
return edges[rowEdge];
} else if (!edges[edge].isUndefined()) {
return edges[edge];
} else if (!edges[YGEdgeHorizontal].isUndefined()) {
return edges[YGEdgeHorizontal];
} else if (!edges[YGEdgeAll].isUndefined()) {
return edges[YGEdgeAll];
} else {
return defaultValue;
}
}
CompactValue YGNode::computeEdgeValueForColumn(
const YGStyle::Edges& edges,
YGEdge edge,
CompactValue defaultValue) {
if (!edges[edge].isUndefined()) {
return edges[edge];
} else if (!edges[YGEdgeVertical].isUndefined()) {
return edges[YGEdgeVertical];
} else if (!edges[YGEdgeAll].isUndefined()) {
return edges[YGEdgeAll];
} else {
return defaultValue;
}
}
YGFloatOptional YGNode::getLeadingPosition( YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const float axisSize) const {
if (YGFlexDirectionIsRow(axis)) { auto leadingPosition = YGFlexDirectionIsRow(axis)
auto leadingPosition = YGComputedEdgeValue( ? computeEdgeValueForRow(
style_.position(), YGEdgeStart, CompactValue::ofUndefined()); style_.position(),
if (!leadingPosition.isUndefined()) { YGEdgeStart,
return YGResolveValue(leadingPosition, axisSize); leading[axis],
} CompactValue::ofZero())
} : computeEdgeValueForColumn(
style_.position(), leading[axis], CompactValue::ofZero());
auto leadingPosition = YGComputedEdgeValue( return YGResolveValue(leadingPosition, axisSize);
style_.position(), leading[axis], CompactValue::ofUndefined());
return leadingPosition.isUndefined()
? YGFloatOptional{0}
: YGResolveValue(leadingPosition, axisSize);
} }
YGFloatOptional YGNode::getTrailingPosition( YGFloatOptional YGNode::getTrailingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const float axisSize) const {
if (YGFlexDirectionIsRow(axis)) { auto trailingPosition = YGFlexDirectionIsRow(axis)
auto trailingPosition = YGComputedEdgeValue( ? computeEdgeValueForRow(
style_.position(), YGEdgeEnd, CompactValue::ofUndefined()); style_.position(),
if (!trailingPosition.isUndefined()) { YGEdgeEnd,
return YGResolveValue(trailingPosition, axisSize); trailing[axis],
} CompactValue::ofZero())
} : computeEdgeValueForColumn(
style_.position(), trailing[axis], CompactValue::ofZero());
auto trailingPosition = YGComputedEdgeValue( return YGResolveValue(trailingPosition, axisSize);
style_.position(), trailing[axis], CompactValue::ofUndefined());
return trailingPosition.isUndefined()
? YGFloatOptional{0}
: YGResolveValue(trailingPosition, axisSize);
} }
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const { bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const {
return (YGFlexDirectionIsRow(axis) && auto leadingPosition = YGFlexDirectionIsRow(axis)
!YGComputedEdgeValue( ? computeEdgeValueForRow(
style_.position(), YGEdgeStart, CompactValue::ofUndefined()) style_.position(),
.isUndefined()) || YGEdgeStart,
!YGComputedEdgeValue( leading[axis],
style_.position(), leading[axis], CompactValue::ofUndefined()) CompactValue::ofUndefined())
.isUndefined(); : computeEdgeValueForColumn(
style_.position(), leading[axis], CompactValue::ofUndefined());
return !leadingPosition.isUndefined();
} }
bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const { bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
return (YGFlexDirectionIsRow(axis) && auto trailingPosition = YGFlexDirectionIsRow(axis)
!YGComputedEdgeValue( ? computeEdgeValueForRow(
style_.position(), YGEdgeEnd, CompactValue::ofUndefined()) style_.position(),
.isUndefined()) || YGEdgeEnd,
!YGComputedEdgeValue( trailing[axis],
style_.position(), trailing[axis], CompactValue::ofUndefined()) CompactValue::ofUndefined())
.isUndefined(); : computeEdgeValueForColumn(
style_.position(), trailing[axis], CompactValue::ofUndefined());
return !trailingPosition.isUndefined();
} }
YGFloatOptional YGNode::getLeadingMargin( YGFloatOptional YGNode::getLeadingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
if (YGFlexDirectionIsRow(axis) && auto leadingMargin = YGFlexDirectionIsRow(axis)
!style_.margin()[YGEdgeStart].isUndefined()) { ? computeEdgeValueForRow(
return YGResolveValueMargin(style_.margin()[YGEdgeStart], widthSize); style_.margin(), YGEdgeStart, leading[axis], CompactValue::ofZero())
} : computeEdgeValueForColumn(
style_.margin(), leading[axis], CompactValue::ofZero());
return YGResolveValueMargin( return YGResolveValueMargin(leadingMargin, widthSize);
YGComputedEdgeValue(
style_.margin(), leading[axis], CompactValue::ofZero()),
widthSize);
} }
YGFloatOptional YGNode::getTrailingMargin( YGFloatOptional YGNode::getTrailingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) { auto trailingMargin = YGFlexDirectionIsRow(axis)
return YGResolveValueMargin(style_.margin()[YGEdgeEnd], widthSize); ? computeEdgeValueForRow(
} style_.margin(), YGEdgeEnd, trailing[axis], CompactValue::ofZero())
: computeEdgeValueForColumn(
return YGResolveValueMargin( style_.margin(), trailing[axis], CompactValue::ofZero());
YGComputedEdgeValue( return YGResolveValueMargin(trailingMargin, widthSize);
style_.margin(), trailing[axis], CompactValue::ofZero()),
widthSize);
} }
YGFloatOptional YGNode::getMarginForAxis( YGFloatOptional YGNode::getMarginForAxis(
@@ -147,7 +169,6 @@ YGSize YGNode::measure(
float height, float height,
YGMeasureMode heightMode, YGMeasureMode heightMode,
void* layoutContext) { void* layoutContext) {
return facebook::yoga::detail::getBooleanData(flags, measureUsesContext_) return facebook::yoga::detail::getBooleanData(flags, measureUsesContext_)
? measure_.withContext( ? measure_.withContext(
this, width, widthMode, height, heightMode, layoutContext) this, width, widthMode, height, heightMode, layoutContext)
@@ -307,6 +328,9 @@ void YGNode::setPosition(
const YGFlexDirection crossAxis = const YGFlexDirection crossAxis =
YGFlexDirectionCross(mainAxis, directionRespectingRoot); YGFlexDirectionCross(mainAxis, directionRespectingRoot);
// Here we should check for `YGPositionTypeStatic` and in this case zero inset
// properties (left, right, top, bottom, begin, end).
// https://www.w3.org/TR/css-position-3/#valdef-position-static
const YGFloatOptional relativePositionMain = const YGFloatOptional relativePositionMain =
relativePosition(mainAxis, mainSize); relativePosition(mainAxis, mainSize);
const YGFloatOptional relativePositionCross = const YGFloatOptional relativePositionCross =
@@ -440,73 +464,53 @@ float YGNode::resolveFlexShrink() const {
bool YGNode::isNodeFlexible() { bool YGNode::isNodeFlexible() {
return ( return (
(style_.positionType() == YGPositionTypeRelative) && (style_.positionType() != YGPositionTypeAbsolute) &&
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0)); (resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
} }
float YGNode::getLeadingBorder(const YGFlexDirection axis) const { float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
YGValue leadingBorder; YGValue leadingBorder = YGFlexDirectionIsRow(axis)
if (YGFlexDirectionIsRow(axis) && ? computeEdgeValueForRow(
!style_.border()[YGEdgeStart].isUndefined()) { style_.border(), YGEdgeStart, leading[axis], CompactValue::ofZero())
leadingBorder = style_.border()[YGEdgeStart]; : computeEdgeValueForColumn(
if (leadingBorder.value >= 0) { style_.border(), leading[axis], CompactValue::ofZero());
return leadingBorder.value; return fmaxf(leadingBorder.value, 0.0f);
}
}
leadingBorder = YGComputedEdgeValue(
style_.border(), leading[axis], CompactValue::ofZero());
return YGFloatMax(leadingBorder.value, 0.0f);
} }
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const { float YGNode::getTrailingBorder(const YGFlexDirection axis) const {
YGValue trailingBorder; YGValue trailingBorder = YGFlexDirectionIsRow(axis)
if (YGFlexDirectionIsRow(flexDirection) && ? computeEdgeValueForRow(
!style_.border()[YGEdgeEnd].isUndefined()) { style_.border(), YGEdgeEnd, trailing[axis], CompactValue::ofZero())
trailingBorder = style_.border()[YGEdgeEnd]; : computeEdgeValueForColumn(
if (trailingBorder.value >= 0.0f) { style_.border(), trailing[axis], CompactValue::ofZero());
return trailingBorder.value; return fmaxf(trailingBorder.value, 0.0f);
}
}
trailingBorder = YGComputedEdgeValue(
style_.border(), trailing[flexDirection], CompactValue::ofZero());
return YGFloatMax(trailingBorder.value, 0.0f);
} }
YGFloatOptional YGNode::getLeadingPadding( YGFloatOptional YGNode::getLeadingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
const YGFloatOptional paddingEdgeStart = auto leadingPadding = YGFlexDirectionIsRow(axis)
YGResolveValue(style_.padding()[YGEdgeStart], widthSize); ? computeEdgeValueForRow(
if (YGFlexDirectionIsRow(axis) && style_.padding(),
!style_.padding()[YGEdgeStart].isUndefined() && YGEdgeStart,
!paddingEdgeStart.isUndefined() && paddingEdgeStart.unwrap() >= 0.0f) { leading[axis],
return paddingEdgeStart; CompactValue::ofZero())
} : computeEdgeValueForColumn(
style_.padding(), leading[axis], CompactValue::ofZero());
YGFloatOptional resolvedValue = YGResolveValue( return YGFloatOptionalMax(
YGComputedEdgeValue( YGResolveValue(leadingPadding, widthSize), YGFloatOptional(0.0f));
style_.padding(), leading[axis], CompactValue::ofZero()),
widthSize);
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
} }
YGFloatOptional YGNode::getTrailingPadding( YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
const YGFloatOptional paddingEdgeEnd = auto trailingPadding = YGFlexDirectionIsRow(axis)
YGResolveValue(style_.padding()[YGEdgeEnd], widthSize); ? computeEdgeValueForRow(
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) { style_.padding(), YGEdgeEnd, trailing[axis], CompactValue::ofZero())
return paddingEdgeEnd; : computeEdgeValueForColumn(
} style_.padding(), trailing[axis], CompactValue::ofZero());
return YGFloatOptionalMax(
YGFloatOptional resolvedValue = YGResolveValue( YGResolveValue(trailingPadding, widthSize), YGFloatOptional(0.0f));
YGComputedEdgeValue(
style_.padding(), trailing[axis], CompactValue::ofZero()),
widthSize);
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
} }
YGFloatOptional YGNode::getLeadingPaddingAndBorder( YGFloatOptional YGNode::getLeadingPaddingAndBorder(

View File

@@ -193,6 +193,17 @@ public:
return resolvedDimensions_[index]; return resolvedDimensions_[index];
} }
static CompactValue computeEdgeValueForColumn(
const YGStyle::Edges& edges,
YGEdge edge,
CompactValue defaultValue);
static CompactValue computeEdgeValueForRow(
const YGStyle::Edges& edges,
YGEdge rowEdge,
YGEdge edge,
CompactValue defaultValue);
// Methods related to positions, margin, padding and border // Methods related to positions, margin, padding and border
YGFloatOptional getLeadingPosition( YGFloatOptional getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,

View File

@@ -104,10 +104,13 @@ static void appendEdgeIfNotUndefined(
const string& str, const string& str,
const YGStyle::Edges& edges, const YGStyle::Edges& edges,
const YGEdge edge) { const YGEdge edge) {
appendNumberIfNotUndefined( // TODO: this doesn't take RTL / YGEdgeStart / YGEdgeEnd into account
base, auto value = (edge == YGEdgeLeft || edge == YGEdgeRight)
str, ? YGNode::computeEdgeValueForRow(
YGComputedEdgeValue(edges, edge, detail::CompactValue::ofUndefined())); edges, edge, edge, detail::CompactValue::ofUndefined())
: YGNode::computeEdgeValueForColumn(
edges, edge, detail::CompactValue::ofUndefined());
appendNumberIfNotUndefined(base, str, value);
} }
void YGNodeToString( void YGNodeToString(

View File

@@ -33,6 +33,10 @@ inline bool isUndefined(float value) {
return std::isnan(value); return std::isnan(value);
} }
inline bool isUndefined(double value) {
return std::isnan(value);
}
} // namespace yoga } // namespace yoga
} // namespace facebook } // namespace facebook
@@ -144,8 +148,3 @@ static const float kDefaultFlexShrink = 0.0f;
static const float kWebDefaultFlexShrink = 1.0f; static const float kWebDefaultFlexShrink = 1.0f;
extern bool YGFloatsEqual(const float a, const float b); extern bool YGFloatsEqual(const float a, const float b);
extern facebook::yoga::detail::CompactValue YGComputedEdgeValue(
const facebook::yoga::detail::Values<
facebook::yoga::enums::count<YGEdge>()>& edges,
YGEdge edge,
facebook::yoga::detail::CompactValue defaultValue);

View File

@@ -106,38 +106,12 @@ static int YGDefaultLog(
#undef YG_UNUSED #undef YG_UNUSED
#endif #endif
YOGA_EXPORT bool YGFloatIsUndefined(const float value) { static inline bool YGDoubleIsUndefined(const double value) {
return facebook::yoga::isUndefined(value); return facebook::yoga::isUndefined(value);
} }
detail::CompactValue YGComputedEdgeValue( YOGA_EXPORT bool YGFloatIsUndefined(const float value) {
const YGStyle::Edges& edges, return facebook::yoga::isUndefined(value);
YGEdge edge,
detail::CompactValue defaultValue) {
if (!edges[edge].isUndefined()) {
return edges[edge];
}
if ((edge == YGEdgeTop || edge == YGEdgeBottom) &&
!edges[YGEdgeVertical].isUndefined()) {
return edges[YGEdgeVertical];
}
if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart ||
edge == YGEdgeEnd) &&
!edges[YGEdgeHorizontal].isUndefined()) {
return edges[YGEdgeHorizontal];
}
if (!edges[YGEdgeAll].isUndefined()) {
return edges[YGEdgeAll];
}
if (edge == YGEdgeStart || edge == YGEdgeEnd) {
return detail::CompactValue::ofUndefined();
}
return defaultValue;
} }
YOGA_EXPORT void* YGNodeGetContext(YGNodeRef node) { YOGA_EXPORT void* YGNodeGetContext(YGNodeRef node) {
@@ -1131,7 +1105,7 @@ static bool YGIsBaselineLayout(const YGNodeRef node) {
const uint32_t childCount = YGNodeGetChildCount(node); const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) { for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i); const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getStyle().positionType() == YGPositionTypeRelative && if (child->getStyle().positionType() != YGPositionTypeAbsolute &&
child->getStyle().alignSelf() == YGAlignBaseline) { child->getStyle().alignSelf() == YGAlignBaseline) {
return true; return true;
} }
@@ -1681,40 +1655,33 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
availableHeight = YGUndefined; availableHeight = YGUndefined;
} }
const float paddingAndBorderAxisRow = const auto& padding = node->getLayout().padding;
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, ownerWidth); const auto& border = node->getLayout().border;
const float paddingAndBorderAxisColumn = const float paddingAndBorderAxisRow = padding[YGEdgeLeft] +
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, ownerWidth); padding[YGEdgeRight] + border[YGEdgeLeft] + border[YGEdgeRight];
const float marginAxisRow = const float paddingAndBorderAxisColumn = padding[YGEdgeTop] +
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap(); padding[YGEdgeBottom] + border[YGEdgeTop] + border[YGEdgeBottom];
const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
// We want to make sure we don't call measure with negative size // We want to make sure we don't call measure with negative size
const float innerWidth = YGFloatIsUndefined(availableWidth) const float innerWidth = YGFloatIsUndefined(availableWidth)
? availableWidth ? availableWidth
: YGFloatMax(0, availableWidth - marginAxisRow - paddingAndBorderAxisRow); : YGFloatMax(0, availableWidth - paddingAndBorderAxisRow);
const float innerHeight = YGFloatIsUndefined(availableHeight) const float innerHeight = YGFloatIsUndefined(availableHeight)
? availableHeight ? availableHeight
: YGFloatMax( : YGFloatMax(0, availableHeight - paddingAndBorderAxisColumn);
0, availableHeight - marginAxisColumn - paddingAndBorderAxisColumn);
if (widthMeasureMode == YGMeasureModeExactly && if (widthMeasureMode == YGMeasureModeExactly &&
heightMeasureMode == YGMeasureModeExactly) { heightMeasureMode == YGMeasureModeExactly) {
// Don't bother sizing the text if both dimensions are already defined. // Don't bother sizing the text if both dimensions are already defined.
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(
node, node, YGFlexDirectionRow, availableWidth, ownerWidth, ownerWidth),
YGFlexDirectionRow,
availableWidth - marginAxisRow,
ownerWidth,
ownerWidth),
YGDimensionWidth); YGDimensionWidth);
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(
node, node,
YGFlexDirectionColumn, YGFlexDirectionColumn,
availableHeight - marginAxisColumn, availableHeight,
ownerHeight, ownerHeight,
ownerWidth), ownerWidth),
YGDimensionHeight); YGDimensionHeight);
@@ -1751,7 +1718,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
(widthMeasureMode == YGMeasureModeUndefined || (widthMeasureMode == YGMeasureModeUndefined ||
widthMeasureMode == YGMeasureModeAtMost) widthMeasureMode == YGMeasureModeAtMost)
? measuredSize.width + paddingAndBorderAxisRow ? measuredSize.width + paddingAndBorderAxisRow
: availableWidth - marginAxisRow, : availableWidth,
ownerWidth, ownerWidth,
ownerWidth), ownerWidth),
YGDimensionWidth); YGDimensionWidth);
@@ -1763,7 +1730,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
(heightMeasureMode == YGMeasureModeUndefined || (heightMeasureMode == YGMeasureModeUndefined ||
heightMeasureMode == YGMeasureModeAtMost) heightMeasureMode == YGMeasureModeAtMost)
? measuredSize.height + paddingAndBorderAxisColumn ? measuredSize.height + paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn, : availableHeight,
ownerHeight, ownerHeight,
ownerWidth), ownerWidth),
YGDimensionHeight); YGDimensionHeight);
@@ -1780,37 +1747,28 @@ static void YGNodeEmptyContainerSetMeasuredDimensions(
const YGMeasureMode heightMeasureMode, const YGMeasureMode heightMeasureMode,
const float ownerWidth, const float ownerWidth,
const float ownerHeight) { const float ownerHeight) {
const float paddingAndBorderAxisRow = const auto& padding = node->getLayout().padding;
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, ownerWidth); const auto& border = node->getLayout().border;
const float paddingAndBorderAxisColumn =
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, ownerWidth);
const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
float width = availableWidth;
if (widthMeasureMode == YGMeasureModeUndefined ||
widthMeasureMode == YGMeasureModeAtMost) {
width = padding[YGEdgeLeft] + padding[YGEdgeRight] + border[YGEdgeLeft] +
border[YGEdgeRight];
}
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(node, YGFlexDirectionRow, width, ownerWidth, ownerWidth),
node,
YGFlexDirectionRow,
(widthMeasureMode == YGMeasureModeUndefined ||
widthMeasureMode == YGMeasureModeAtMost)
? paddingAndBorderAxisRow
: availableWidth - marginAxisRow,
ownerWidth,
ownerWidth),
YGDimensionWidth); YGDimensionWidth);
float height = availableHeight;
if (heightMeasureMode == YGMeasureModeUndefined ||
heightMeasureMode == YGMeasureModeAtMost) {
height = padding[YGEdgeTop] + padding[YGEdgeBottom] + border[YGEdgeTop] +
border[YGEdgeBottom];
}
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(
node, node, YGFlexDirectionColumn, height, ownerHeight, ownerWidth),
YGFlexDirectionColumn,
(heightMeasureMode == YGMeasureModeUndefined ||
heightMeasureMode == YGMeasureModeAtMost)
? paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn,
ownerHeight,
ownerWidth),
YGDimensionHeight); YGDimensionHeight);
} }
@@ -1828,11 +1786,6 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) || heightMeasureMode == YGMeasureModeAtMost && availableHeight <= 0.0f) ||
(widthMeasureMode == YGMeasureModeExactly && (widthMeasureMode == YGMeasureModeExactly &&
heightMeasureMode == YGMeasureModeExactly)) { heightMeasureMode == YGMeasureModeExactly)) {
auto marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
auto marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
node->setLayoutMeasuredDimension( node->setLayoutMeasuredDimension(
YGNodeBoundAxis( YGNodeBoundAxis(
node, node,
@@ -1841,7 +1794,7 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
(widthMeasureMode == YGMeasureModeAtMost && (widthMeasureMode == YGMeasureModeAtMost &&
availableWidth < 0.0f) availableWidth < 0.0f)
? 0.0f ? 0.0f
: availableWidth - marginAxisRow, : availableWidth,
ownerWidth, ownerWidth,
ownerWidth), ownerWidth),
YGDimensionWidth); YGDimensionWidth);
@@ -1854,7 +1807,7 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
(heightMeasureMode == YGMeasureModeAtMost && (heightMeasureMode == YGMeasureModeAtMost &&
availableHeight < 0.0f) availableHeight < 0.0f)
? 0.0f ? 0.0f
: availableHeight - marginAxisColumn, : availableHeight,
ownerHeight, ownerHeight,
ownerWidth), ownerWidth),
YGDimensionHeight); YGDimensionHeight);
@@ -1878,21 +1831,11 @@ static void YGZeroOutLayoutRecursivly(
static float YGNodeCalculateAvailableInnerDim( static float YGNodeCalculateAvailableInnerDim(
const YGNodeConstRef node, const YGNodeConstRef node,
YGFlexDirection axis, const YGDimension dimension,
float availableDim, const float availableDim,
float ownerDim, const float paddingAndBorder,
float ownerDimForMarginPadding) { const float ownerDim) {
YGFlexDirection direction = float availableInnerDim = availableDim - paddingAndBorder;
YGFlexDirectionIsRow(axis) ? YGFlexDirectionRow : YGFlexDirectionColumn;
YGDimension dimension =
YGFlexDirectionIsRow(axis) ? YGDimensionWidth : YGDimensionHeight;
const float margin =
node->getMarginForAxis(direction, ownerDimForMarginPadding).unwrap();
const float paddingAndBorder =
YGNodePaddingAndBorderForAxis(node, direction, ownerDimForMarginPadding);
float availableInnerDim = availableDim - margin - paddingAndBorder;
// Max dimension overrides predefined dimension value; Min dimension in turn // Max dimension overrides predefined dimension value; Min dimension in turn
// overrides both of the above // overrides both of the above
if (!YGFloatIsUndefined(availableInnerDim)) { if (!YGFloatIsUndefined(availableInnerDim)) {
@@ -2505,7 +2448,7 @@ static void YGJustifyMainAxis(
i < collectedFlexItemsValues.endOfLineIndex; i < collectedFlexItemsValues.endOfLineIndex;
i++) { i++) {
const YGNodeRef child = node->getChild(i); const YGNodeRef child = node->getChild(i);
if (child->getStyle().positionType() == YGPositionTypeRelative) { if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) { if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
numberOfAutoMarginsOnCurrentLine++; numberOfAutoMarginsOnCurrentLine++;
} }
@@ -2589,7 +2532,7 @@ static void YGJustifyMainAxis(
// Now that we placed the element, we need to update the variables. // Now that we placed the element, we need to update the variables.
// We need to do that only for relative elements. Absolute elements do not // We need to do that only for relative elements. Absolute elements do not
// take part in that phase. // take part in that phase.
if (childStyle.positionType() == YGPositionTypeRelative) { if (childStyle.positionType() != YGPositionTypeAbsolute) {
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) { if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
collectedFlexItemsValues.mainDim += collectedFlexItemsValues.mainDim +=
collectedFlexItemsValues.remainingFreeSpace / collectedFlexItemsValues.remainingFreeSpace /
@@ -2779,16 +2722,22 @@ static void YGNodelayoutImpl(
const YGEdge startEdge = const YGEdge startEdge =
direction == YGDirectionLTR ? YGEdgeLeft : YGEdgeRight; direction == YGDirectionLTR ? YGEdgeLeft : YGEdgeRight;
const YGEdge endEdge = direction == YGDirectionLTR ? YGEdgeRight : YGEdgeLeft; const YGEdge endEdge = direction == YGDirectionLTR ? YGEdgeRight : YGEdgeLeft;
node->setLayoutMargin(
node->getLeadingMargin(flexRowDirection, ownerWidth).unwrap(), startEdge); const float marginRowLeading =
node->setLayoutMargin( node->getLeadingMargin(flexRowDirection, ownerWidth).unwrap();
node->getTrailingMargin(flexRowDirection, ownerWidth).unwrap(), endEdge); node->setLayoutMargin(marginRowLeading, startEdge);
node->setLayoutMargin( const float marginRowTrailing =
node->getLeadingMargin(flexColumnDirection, ownerWidth).unwrap(), node->getTrailingMargin(flexRowDirection, ownerWidth).unwrap();
YGEdgeTop); node->setLayoutMargin(marginRowTrailing, endEdge);
node->setLayoutMargin( const float marginColumnLeading =
node->getTrailingMargin(flexColumnDirection, ownerWidth).unwrap(), node->getLeadingMargin(flexColumnDirection, ownerWidth).unwrap();
YGEdgeBottom); node->setLayoutMargin(marginColumnLeading, YGEdgeTop);
const float marginColumnTrailing =
node->getTrailingMargin(flexColumnDirection, ownerWidth).unwrap();
node->setLayoutMargin(marginColumnTrailing, YGEdgeBottom);
const float marginAxisRow = marginRowLeading + marginRowTrailing;
const float marginAxisColumn = marginColumnLeading + marginColumnTrailing;
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), startEdge); node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), startEdge);
node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), endEdge); node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), endEdge);
@@ -2811,8 +2760,8 @@ static void YGNodelayoutImpl(
if (node->hasMeasureFunc()) { if (node->hasMeasureFunc()) {
YGNodeWithMeasureFuncSetMeasuredDimensions( YGNodeWithMeasureFuncSetMeasuredDimensions(
node, node,
availableWidth, availableWidth - marginAxisRow,
availableHeight, availableHeight - marginAxisColumn,
widthMeasureMode, widthMeasureMode,
heightMeasureMode, heightMeasureMode,
ownerWidth, ownerWidth,
@@ -2827,8 +2776,8 @@ static void YGNodelayoutImpl(
if (childCount == 0) { if (childCount == 0) {
YGNodeEmptyContainerSetMeasuredDimensions( YGNodeEmptyContainerSetMeasuredDimensions(
node, node,
availableWidth, availableWidth - marginAxisRow,
availableHeight, availableHeight - marginAxisColumn,
widthMeasureMode, widthMeasureMode,
heightMeasureMode, heightMeasureMode,
ownerWidth, ownerWidth,
@@ -2841,8 +2790,8 @@ static void YGNodelayoutImpl(
if (!performLayout && if (!performLayout &&
YGNodeFixedSizeSetMeasuredDimensions( YGNodeFixedSizeSetMeasuredDimensions(
node, node,
availableWidth, availableWidth - marginAxisRow,
availableHeight, availableHeight - marginAxisColumn,
widthMeasureMode, widthMeasureMode,
heightMeasureMode, heightMeasureMode,
ownerWidth, ownerWidth,
@@ -2866,12 +2815,14 @@ static void YGNodelayoutImpl(
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight; const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth; const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
const float leadingPaddingAndBorderCross =
node->getLeadingPaddingAndBorder(crossAxis, ownerWidth).unwrap();
const float paddingAndBorderAxisMain = const float paddingAndBorderAxisMain =
YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth); YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth);
const float leadingPaddingAndBorderCross =
node->getLeadingPaddingAndBorder(crossAxis, ownerWidth).unwrap();
const float trailingPaddingAndBorderCross =
node->getTrailingPaddingAndBorder(crossAxis, ownerWidth).unwrap();
const float paddingAndBorderAxisCross = const float paddingAndBorderAxisCross =
YGNodePaddingAndBorderForAxis(node, crossAxis, ownerWidth); leadingPaddingAndBorderCross + trailingPaddingAndBorderCross;
YGMeasureMode measureModeMainDim = YGMeasureMode measureModeMainDim =
isMainAxisRow ? widthMeasureMode : heightMeasureMode; isMainAxisRow ? widthMeasureMode : heightMeasureMode;
@@ -2883,35 +2834,20 @@ static void YGNodelayoutImpl(
const float paddingAndBorderAxisColumn = const float paddingAndBorderAxisColumn =
isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain; isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain;
const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
const auto& minDimensions = node->getStyle().minDimensions();
const auto& maxDimensions = node->getStyle().maxDimensions();
const float minInnerWidth =
YGResolveValue(minDimensions[YGDimensionWidth], ownerWidth).unwrap() -
paddingAndBorderAxisRow;
const float maxInnerWidth =
YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth).unwrap() -
paddingAndBorderAxisRow;
const float minInnerHeight =
YGResolveValue(minDimensions[YGDimensionHeight], ownerHeight).unwrap() -
paddingAndBorderAxisColumn;
const float maxInnerHeight =
YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight).unwrap() -
paddingAndBorderAxisColumn;
const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight;
// STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
float availableInnerWidth = YGNodeCalculateAvailableInnerDim( float availableInnerWidth = YGNodeCalculateAvailableInnerDim(
node, YGFlexDirectionRow, availableWidth, ownerWidth, ownerWidth); node,
YGDimensionWidth,
availableWidth - marginAxisRow,
paddingAndBorderAxisRow,
ownerWidth);
float availableInnerHeight = YGNodeCalculateAvailableInnerDim( float availableInnerHeight = YGNodeCalculateAvailableInnerDim(
node, YGFlexDirectionColumn, availableHeight, ownerHeight, ownerWidth); node,
YGDimensionHeight,
availableHeight - marginAxisColumn,
paddingAndBorderAxisColumn,
ownerHeight);
float availableInnerMainDim = float availableInnerMainDim =
isMainAxisRow ? availableInnerWidth : availableInnerHeight; isMainAxisRow ? availableInnerWidth : availableInnerHeight;
@@ -2983,6 +2919,28 @@ static void YGNodelayoutImpl(
// If we don't measure with exact main dimension we want to ensure we don't // If we don't measure with exact main dimension we want to ensure we don't
// violate min and max // violate min and max
if (measureModeMainDim != YGMeasureModeExactly) { if (measureModeMainDim != YGMeasureModeExactly) {
const auto& minDimensions = node->getStyle().minDimensions();
const auto& maxDimensions = node->getStyle().maxDimensions();
const float minInnerWidth =
YGResolveValue(minDimensions[YGDimensionWidth], ownerWidth).unwrap() -
paddingAndBorderAxisRow;
const float maxInnerWidth =
YGResolveValue(maxDimensions[YGDimensionWidth], ownerWidth).unwrap() -
paddingAndBorderAxisRow;
const float minInnerHeight =
YGResolveValue(minDimensions[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn;
const float maxInnerHeight =
YGResolveValue(maxDimensions[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn;
const float minInnerMainDim =
isMainAxisRow ? minInnerWidth : minInnerHeight;
const float maxInnerMainDim =
isMainAxisRow ? maxInnerWidth : maxInnerHeight;
if (!YGFloatIsUndefined(minInnerMainDim) && if (!YGFloatIsUndefined(minInnerMainDim) &&
collectedFlexItemsValues.sizeConsumedOnCurrentLine < collectedFlexItemsValues.sizeConsumedOnCurrentLine <
minInnerMainDim) { minInnerMainDim) {
@@ -3311,7 +3269,7 @@ static void YGNodelayoutImpl(
if (child->getStyle().display() == YGDisplayNone) { if (child->getStyle().display() == YGDisplayNone) {
continue; continue;
} }
if (child->getStyle().positionType() == YGPositionTypeRelative) { if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
if (child->getLineIndex() != i) { if (child->getLineIndex() != i) {
break; break;
} }
@@ -3353,7 +3311,7 @@ static void YGNodelayoutImpl(
if (child->getStyle().display() == YGDisplayNone) { if (child->getStyle().display() == YGDisplayNone) {
continue; continue;
} }
if (child->getStyle().positionType() == YGPositionTypeRelative) { if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
switch (YGNodeAlignItem(node, child)) { switch (YGNodeAlignItem(node, child)) {
case YGAlignFlexStart: { case YGAlignFlexStart: {
child->setLayoutPosition( child->setLayoutPosition(
@@ -3531,8 +3489,8 @@ static void YGNodelayoutImpl(
YGNodeBoundAxisWithinMinAndMax( YGNodeBoundAxisWithinMinAndMax(
node, node,
crossAxis, crossAxis,
YGFloatOptional{totalLineCrossDim + YGFloatOptional{
paddingAndBorderAxisCross}, totalLineCrossDim + paddingAndBorderAxisCross},
crossAxisownerSize) crossAxisownerSize)
.unwrap()), .unwrap()),
paddingAndBorderAxisCross), paddingAndBorderAxisCross),
@@ -3544,7 +3502,7 @@ static void YGNodelayoutImpl(
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) { if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
for (uint32_t i = 0; i < childCount; i++) { for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i); const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getStyle().positionType() == YGPositionTypeRelative) { if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
child->setLayoutPosition( child->setLayoutPosition(
node->getLayout().measuredDimensions[dim[crossAxis]] - node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().position[pos[crossAxis]] - child->getLayout().position[pos[crossAxis]] -
@@ -3557,7 +3515,8 @@ static void YGNodelayoutImpl(
if (performLayout) { if (performLayout) {
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN // STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
for (auto child : node->getChildren()) { for (auto child : node->getChildren()) {
if (child->getStyle().positionType() != YGPositionTypeAbsolute) { if (child->getStyle().display() == YGDisplayNone ||
child->getStyle().positionType() != YGPositionTypeAbsolute) {
continue; continue;
} }
YGNodeAbsoluteLayoutChild( YGNodeAbsoluteLayoutChild(
@@ -3665,10 +3624,10 @@ YOGA_EXPORT float YGRoundValueToPixelGrid(
const double pointScaleFactor, const double pointScaleFactor,
const bool forceCeil, const bool forceCeil,
const bool forceFloor) { const bool forceFloor) {
double scaledValue = ((double) value) * pointScaleFactor; double scaledValue = value * pointScaleFactor;
// We want to calculate `fractial` such that `floor(scaledValue) = scaledValue // We want to calculate `fractial` such that `floor(scaledValue) = scaledValue
// - fractial`. // - fractial`.
float fractial = fmodf(scaledValue, 1.0f); double fractial = fmod(scaledValue, 1.0);
if (fractial < 0) { if (fractial < 0) {
// This branch is for handling negative numbers for `value`. // This branch is for handling negative numbers for `value`.
// //
@@ -3687,28 +3646,28 @@ YOGA_EXPORT float YGRoundValueToPixelGrid(
// - Finding the `floor`: -2.2 - fractial2 = -2.2 - 0.8 = -3 // - Finding the `floor`: -2.2 - fractial2 = -2.2 - 0.8 = -3
++fractial; ++fractial;
} }
if (YGFloatsEqual(fractial, 0)) { if (YGDoubleEqual(fractial, 0)) {
// First we check if the value is already rounded // First we check if the value is already rounded
scaledValue = scaledValue - fractial; scaledValue = scaledValue - fractial;
} else if (YGFloatsEqual(fractial, 1.0f)) { } else if (YGDoubleEqual(fractial, 1.0)) {
scaledValue = scaledValue - fractial + 1.0f; scaledValue = scaledValue - fractial + 1.0;
} else if (forceCeil) { } else if (forceCeil) {
// Next we check if we need to use forced rounding // Next we check if we need to use forced rounding
scaledValue = scaledValue - fractial + 1.0f; scaledValue = scaledValue - fractial + 1.0;
} else if (forceFloor) { } else if (forceFloor) {
scaledValue = scaledValue - fractial; scaledValue = scaledValue - fractial;
} else { } else {
// Finally we just round the value // Finally we just round the value
scaledValue = scaledValue - fractial + scaledValue = scaledValue - fractial +
(!YGFloatIsUndefined(fractial) && (!YGDoubleIsUndefined(fractial) &&
(fractial > 0.5f || YGFloatsEqual(fractial, 0.5f)) (fractial > 0.5 || YGDoubleEqual(fractial, 0.5))
? 1.0f ? 1.0
: 0.0f); : 0.0);
} }
return (YGFloatIsUndefined(scaledValue) || return (YGDoubleIsUndefined(scaledValue) ||
YGFloatIsUndefined(pointScaleFactor)) YGDoubleIsUndefined(pointScaleFactor))
? YGUndefined ? YGUndefined
: scaledValue / pointScaleFactor; : (float) (scaledValue / pointScaleFactor);
} }
YOGA_EXPORT bool YGNodeCanUseCachedMeasurement( YOGA_EXPORT bool YGNodeCanUseCachedMeasurement(
@@ -4113,11 +4072,11 @@ static void YGRoundToPixelGrid(
// whole number, we don't have any fraction To verify if the result is close // whole number, we don't have any fraction To verify if the result is close
// to whole number we want to check both floor and ceil numbers // to whole number we want to check both floor and ceil numbers
const bool hasFractionalWidth = const bool hasFractionalWidth =
!YGFloatsEqual(fmodf(nodeWidth * pointScaleFactor, 1.0), 0) && !YGDoubleEqual(fmod(nodeWidth * pointScaleFactor, 1.0), 0) &&
!YGFloatsEqual(fmodf(nodeWidth * pointScaleFactor, 1.0), 1.0); !YGDoubleEqual(fmod(nodeWidth * pointScaleFactor, 1.0), 1.0);
const bool hasFractionalHeight = const bool hasFractionalHeight =
!YGFloatsEqual(fmodf(nodeHeight * pointScaleFactor, 1.0), 0) && !YGDoubleEqual(fmod(nodeHeight * pointScaleFactor, 1.0), 0) &&
!YGFloatsEqual(fmodf(nodeHeight * pointScaleFactor, 1.0), 1.0); !YGDoubleEqual(fmod(nodeHeight * pointScaleFactor, 1.0), 1.0);
node->setLayoutDimension( node->setLayoutDimension(
YGRoundValueToPixelGrid( YGRoundValueToPixelGrid(
@@ -4235,9 +4194,7 @@ YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
if (node->getConfig()->printTree) { if (node->getConfig()->printTree) {
YGNodePrint( YGNodePrint(
node, node,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren |
YGPrintOptionsStyle));
} }
#endif #endif
} }
@@ -4297,9 +4254,7 @@ YOGA_EXPORT void YGNodeCalculateLayoutWithContext(
if (nodeWithoutLegacyFlag->getConfig()->printTree) { if (nodeWithoutLegacyFlag->getConfig()->printTree) {
YGNodePrint( YGNodePrint(
nodeWithoutLegacyFlag, nodeWithoutLegacyFlag,
(YGPrintOptions)( (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle));
YGPrintOptionsLayout | YGPrintOptionsChildren |
YGPrintOptionsStyle));
} }
#endif #endif
} }

View File

@@ -107,7 +107,7 @@ WIN_EXPORT void YGNodeMarkDirty(YGNodeRef node);
// Marks the current node and all its descendants as dirty. // Marks the current node and all its descendants as dirty.
// //
// Intended to be used for Uoga benchmarks. Don't use in production, as calling // Intended to be used for Yoga benchmarks. Don't use in production, as calling
// `YGCalculateLayout` will cause the recalculation of each and every node. // `YGCalculateLayout` will cause the recalculation of each and every node.
WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(YGNodeRef node); WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(YGNodeRef node);

View File

@@ -8,7 +8,6 @@
#include "event.h" #include "event.h"
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <stdexcept>
namespace facebook { namespace facebook {
namespace yoga { namespace yoga {

View File

@@ -11,6 +11,7 @@
#include <vector> #include <vector>
#include <array> #include <array>
#include <yoga/YGEnums.h> #include <yoga/YGEnums.h>
#include <stdint.h>
struct YGConfig; struct YGConfig;
struct YGNode; struct YGNode;