Compare commits

...

529 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
Steven Koeber
ede65bbce4 Buckification of Yoga build script
Reviewed By: liorisraeli87, k21

Differential Revision: D21429174

fbshipit-source-id: f12c8349cc59398553773df7bc15f0f83bd571b4
2020-06-04 06:54:18 -07:00
Jon Janzen
4135420cba Fix GitHub Actions secrets access (#1005)
Summary:
Ref: [Secrets documentation](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#using-encrypted-secrets-in-a-workflow)

In combination with setting the secrets in the GitHub settings, this should fully migrate yoga to GH actions.

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

Test Plan: GitHub Actions CI on the PR attached to this diff

Reviewed By: SidharthGuglani

Differential Revision: D21574995

Pulled By: bigfootjon

fbshipit-source-id: e9ee6d7cf1ae131afdc3aa3778667f1e9b9de833
2020-05-14 12:21:28 -07:00
Sidharth Guglani
07c0d539bd throw std::logic_error instead of aborting the process and convert to java exception
Summary: Changelog: [Internal][Yoga] throw std::logic_error instead of aborting the process and convert to java exception for jni layer

Reviewed By: pasqualeanatriello

Differential Revision: D21301235

fbshipit-source-id: 148b27920e62990a271e1d0df8c85a2cc42f4fd4
2020-05-14 06:39:25 -07:00
Jon Janzen
ac7c85c0a6 Migrate CI from TravisCI to GitHub Actions (#1004)
Summary:
Migrate from TravisCI to GitHub Actions. Facebook employees can read about this migration [here](https://fburl.com/rfp033ou).

CC: wittgenst
Pull Request resolved: https://github.com/facebook/yoga/pull/1004

Test Plan: GitHub Actions CI on my personal GitHub: https://github.com/bigfootjon/yoga/runs/653755729

Reviewed By: passy

Differential Revision: D21431309

Pulled By: bigfootjon

fbshipit-source-id: 490a8679bc0cfec26b13c8c584a928f03c6e26e7
2020-05-12 12:01:53 -07:00
Sidharth Guglani
83b27417ae Fix rounding error using double instead of float
Summary: Changelog: [Internal] [Yoga] Use double instead of float during rounding process to prevent loss of precision.

Reviewed By: mdvacca

Differential Revision: D21227565

fbshipit-source-id: 380b57535a356624cda8dc2017871a4ef3c882d1
2020-04-27 14:48:15 -07:00
Valentin Shergin
884f147742 Fixed incorrect owner assignment in YGNode move constructor
Summary:
Assigning self as an owner makes a cycle which is obviously a bug.

Changelog: [Internal] Small change in Yoga (should not affect RN).

Reviewed By: SidharthGuglani

Differential Revision: D21111423

fbshipit-source-id: 1835561c055ac827f5ce98a044f25aed0d1845a5
2020-04-20 12:05:55 -07:00
Gavin Weng
a96a36ef59 Link yogacore statically into yoga
Summary: A revert of D20879886.

Reviewed By: iliagore

Differential Revision: D20979490

fbshipit-source-id: cb37f931654450c408e72578abcc549f35727b07
2020-04-17 17:34:17 -07:00
acton393
1bd4123df1 fix typo as there is no file called YGJNI.cpp (#990)
Summary:
fix typo in `YogaJNIBase.java` as there is no such file called `YGJNI.cpp`
Pull Request resolved: https://github.com/facebook/yoga/pull/990

Reviewed By: pasqualeanatriello

Differential Revision: D20735102

Pulled By: SidharthGuglani

fbshipit-source-id: 3f9f4d78ba390feae3451330f997a221ab4ec70e
2020-04-17 05:45:41 -07:00
Sidharth Guglani
92b76447b7 use default value of enums YGDirection and YGMeasureMode instead of -1
Summary:
Changelog:
[Internal][Yoga] YGDirection variable was initialized incorrectly by casting -1 to YGDirection. Changing it to default value of direction

Same for YGMeasureMode.

Reviewed By: pasqualeanatriello

Differential Revision: D20869042

fbshipit-source-id: 7bfe490193321baae875ef6fb49a938851950c9f
2020-04-17 05:32:05 -07:00
Sidharth Guglani
e637cf2d72 Add Yoga also as a dependency of testutil-jni
Summary:
`scripts/deploy_jcenter.sh` was failing

{F234018047}

Added `yoga` also as a dependency of `testutil-jni`

Reviewed By: gavinweng

Differential Revision: D21017796

fbshipit-source-id: 0c34e7fc2373906441bd7805f5687b2c5dab6242
2020-04-15 00:49:53 -07:00
empyrical
9b96a5362a Yoga Podspec: Export YGNode and YGStyle headers (#997)
Summary:
This pull request adds `YGNode.h` and `YGStyle.h` to the headers exported by Yoga's podspec. They are required by the new Fabric architecture of React Native.

The modulemap and its umbrella header automatically generated by Cocoapods adds all exported headers to the `modulemap`. Having YGNode and YGStyle exported through here has problems, because they are only available in environments that have C++ available, and will produce errors otherwise.

This pull request fences off the contents of those headers in an `#ifdef __cplusplus` block, so they will not cause errors when imported into environments where C++ isn't available.

I had considered adding a custom modulemap to the podspec as part of this pull request, but this way seems the least "invasive", and this way you are able to add and remove exported headers in the podspec without needing to worry about updating the umbrella header at the same time.

Changelog:

[Internal] - Yoga Podspec: Export YGNore and YGStyle headers

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

Reviewed By: hramos

Differential Revision: D20966075

Pulled By: mdvacca

fbshipit-source-id: 5f5caa6b639d11e660b968d681da9a4de6c0eb8e
2020-04-14 16:42:27 -07:00
Sidharth Guglani
e5743e851b Set width/height also to Undefined when we change the measure mode to Undefined
Summary:
Make sure width/height is always passed as Undefined when measure mode is changed to Undefined.

Changelog: [Internal][Yoga] Set width and height as Undefined when we change measure mode to Undefined

Reviewed By: alickbass

Differential Revision: D20029838

fbshipit-source-id: b9931f6ddb13ffd1565889535ade5bbffbe0c304
2020-04-14 02:09:29 -07:00
George Zahariev
f7bc0ad248 Upgrade Prettier in Xplat to version 1.19.1: format files
Summary:
Part two of D20879147 where we update the versions of Prettier used in Xplat. I will stack land the diffs.
Here, we format all the files, and use the drop conflicts flag. After this lands, I will go and format the files which had conflicts again.

Changelog: [Internal]

drop-conflicts
bypass-lint
allow-large-files

Reviewed By: gkz

Differential Revision: D20929844

fbshipit-source-id: 2c1df8966a48b5db4f890e2cc494cb1c69422b7d
2020-04-09 11:06:06 -07:00
George Zahariev
8c53c2dcca Upgrade Prettier in Xplat to version 1.19.1
Summary:
Upgrades Prettier in Xplat to 1.19.1
Ignores upgrading packages on already on versions greater than 1.19.1

Changelog: [Internal]

allow-large-files
bypass-lint

(Note: this ignores all push blocking failures!)

Reviewed By: gkz, cpojer

Differential Revision: D20879147

fbshipit-source-id: 0deee7ac941e91e1c3c3a1e7d3d3ed20de1d657d
2020-04-09 11:06:04 -07:00
Gavin Weng
be51bc44a4 Revert Name Change for FBLite
Summary: To unblock

Reviewed By: Arieg419

Differential Revision: D20879886

fbshipit-source-id: 428f9147e540b94dec7f72a7f844949722165a07
2020-04-06 19:53:50 -07:00
Gavin Weng
5eba2d42bd Enhance build process (#994)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/994

After building yoga aar, we found several issues:
1. More dynamic so files. This is bad as lower-end Android devices cannot load that many sos.
2. Size increase.
3. (Minor) The libs are stored in asset folder rather than "libs/".

We apply the following optimizations:
1. Remove dependency on memalign16 (this is brought in by a pure header dependency jni-hack);
2. Enable native relinker to remove unused symbols in the so files.
3. Link yogacore statically to reduce size churn.

Reviewed By: SidharthGuglani

Differential Revision: D20808623

fbshipit-source-id: 6c6bbd4f71b6bf6ad272ec05dd56696ddb14a8e0
2020-04-06 11:51:16 -07:00
Sidharth Guglani
2049c85a6c Unit tests for flexshrink min width cases
Reviewed By: pasqualeanatriello

Differential Revision: D20219428

fbshipit-source-id: 8cbd028627095d9f7b393489ddba1f31c3207b67
2020-04-01 14:56:49 -07:00
Sidharth Guglani
ecd7790dd8 Fix Yoga flexshrink with min-width sizing issue
Summary:
While resolving the flexible items we calculate totalFlexShrinkScaledFactors which uses the flexBasis or initial width of node (Not min-width).

At a later stage during distribution of space we are subtracting value from this which also takes care of min-width.

For example
If node has flexShrink 1 and width 100 and min-width 301  then totalFlexShrinkScaledFactors will become -1*100 = -100
but later we are subtracting -1 * 301 (min-width) = -301 which is ambiguous and causing layout inconsistencies with how web behaves.

Fixed this by only using the flexBasis or width for these calculations.

Changelog:
[Internal][Yoga] Fix layout issue when flexShrink and min-width are used together

Reviewed By: pasqualeanatriello

Differential Revision: D20219419

fbshipit-source-id: 948fbc06ca541d4ad307c88c8a2df65d157778b1
2020-04-01 14:56:45 -07:00
Michael Bolin
0f08aa53da Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:41:08 -07:00
Michael Bolin
5bf93e81ba Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:26:19 -07:00
Lior Israeli
4f1231f411 Fix typo in buck targets
Summary: Proguard is spelled wrong

Reviewed By: SidharthGuglani

Differential Revision: D20619173

fbshipit-source-id: 463788454ad7e72337121ed63ab79129db45113e
2020-03-24 05:37:47 -07:00
Adam Ernst
b280a19b0a Run 'arc lint-deps'
Reviewed By: d16r

Differential Revision: D20362505

fbshipit-source-id: f3b7e62f7665d20a32788042772b731d6ed53f36
2020-03-10 10:58:46 -07:00
Nate Stedman
63a463d011 Mark YogaKit as modular
Differential Revision: D20364340

fbshipit-source-id: ce4bc1f474177ffc9c77eb2f10bdb7cb549dd6d8
2020-03-10 09:38:56 -07:00
Jesse Katsumata
adb87e347f chore: fix typo in comments (#28269)
Summary:
Fixed some typos in the comment.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments
Pull Request resolved: https://github.com/facebook/react-native/pull/28269

Test Plan: Changes are only made in the comments, so test is not necessary.

Reviewed By: cpojer

Differential Revision: D20342637

Pulled By: shergin

fbshipit-source-id: f6e7dd538ee54c43e1570c35e1f8c4502054e328
2020-03-09 16:03:44 -07:00
Sidharth Guglani
2d52b5a873 fix layout tab height issue in playground on home page
Summary: Fixed layout tab height issue properly

Reviewed By: danielbuechele

Differential Revision: D20003594

fbshipit-source-id: 6d9ce89a5d82a83937e5cb0f989bb028e07d576f
2020-02-25 07:34:37 -08:00
Sidharth Guglani
6c61cd5f05 Fix layout tab scrolling in playground
Summary: Add a scroll bar to layout tab in playground to fix the UI issue where margin, border were not accessible.

Reviewed By: danielbuechele

Differential Revision: D19906128

fbshipit-source-id: 2c2d7695f731b2d312b78eab31c66d737915eaae
2020-02-19 11:12:41 -08:00
Sidharth Guglani
bfc3b2f86f fix lint errors
Summary:
Changelog: [Internal][Yoga] Fixed lint errors

```arc lint --apply-patches --take CLANGFORMAT --paths-cmd 'hg files xplat/yoga'
```
Added .clang-tidy file

Reviewed By: zertosh

Differential Revision: D19948702

fbshipit-source-id: f77a16d6f2c532267597a84a9caded0aae68c3aa
2020-02-18 08:24:46 -08:00
Christoph Purrer
a1278cee05 Make YGValue.h compile with Clang on Windows
Summary:
- We use a fork of Microsoft's react-native-windows which uses a fork of Facebook's react-native
- YGValue.h does not compile with Clang on Windows
- This change should fix that
- I want to put the change here so that it bubbles back to our fork > https://our.intern.facebook.com/intern/diff/D19656093/

#Changelog:
[General][Fixed] Make YGValue.h compile with Clang on Windows

Reviewed By: SidharthGuglani

Differential Revision: D19717489

fbshipit-source-id: ad867ecaf910bb64a777a06c656a1867bb15484b
2020-02-05 13:44:21 -08:00
Pasquale Anatriello
e983c4a5ef Swap child Yoga
Summary:
Changelog: [Internal]

Expose the replaceChild Yoga call to Java

Reviewed By: SidharthGuglani

Differential Revision: D19497193

fbshipit-source-id: 153243cc1d8c23dcaf2c772ca794bd59a230f652
2020-01-30 04:32:20 -08:00
Amir Shalem
7f97e8b232 Allow redex to optimize more of yoga by removing unneeded @DoNotStrip marks
Summary:
There are multiple `DoNotStrip` in Yoga java binding, they aren't needed.

##Changelog:
[Internal][Yoga] Allow redex to optimize more of yoga by removing unneeded DoNotStrip marks

Reviewed By: SidharthGuglani

Differential Revision: D17519844

fbshipit-source-id: 8b26800d720f34cae87754d85460abf88acbe713
2019-12-04 01:34:54 -08:00
Sidharth Guglani
089095f532 create global ref properly in YogaJNIException
Summary:
##Changelog:
[Internal][Yoga] create global ref properly in YogaJNIException

Reviewed By: astreet

Differential Revision: D18775982

fbshipit-source-id: ee529d6178d40b5f887fa1327fe156fa466f154f
2019-12-03 16:02:13 -08:00
Sidharth Guglani
ac8eb111a9 Add defensive check for result returned after JNI function calls
Summary:
Added method which checks if value(methodId, fieldId, class ...) returned by JNI functions (getMethod, getField, getClass ...) is valid or not and throw exception if they are not valid

##Changelog:
[Internal][Yoga] Add defensive check for result returned after JNI calls

Reviewed By: astreet

Differential Revision: D18745718

fbshipit-source-id: 2af26eda15fbe7834e1c9b274deeed4f106274ab
2019-12-02 05:24:54 -08:00
Sidharth Guglani
073f49d0d0 Use YogaJniException in jni call exception handling
Summary:
##Changelog:
[Internal][Yoga] Use YogaJniException in jni call exception handling

Reviewed By: astreet

Differential Revision: D18745615

fbshipit-source-id: 5fcf4c31f04fade94ef98a5349782ed3d43805b0
2019-12-02 05:24:54 -08:00
Sidharth Guglani
67915b5905 Add YogaJniException class
Summary:
## Changelog:
[Internal][Yoga] Add YogaJniException class to be used later for jni exceptions

Reviewed By: astreet

Differential Revision: D18745609

fbshipit-source-id: 53503b54dbc59e9fe47f599dee6be9cb68134cb2
2019-12-02 05:24:53 -08:00
Sidharth Guglani
015df9c512 Remove bitfield.h
Summary:
##Changelog:

[Internal][Yoga] Remove Bitfield.h

Reviewed By: astreet

Differential Revision: D18519647

fbshipit-source-id: b46fe585d3ef5f1da7d2726b2d9f759a649be121
2019-11-27 14:19:47 -08:00
Sidharth Guglani
f7f134274c Remove bitfield from YGNode.h
Summary:
##Changelog:

[Internal][Yoga] remove Bitfield from YGNode.h

Reviewed By: astreet

Differential Revision: D18519633

fbshipit-source-id: b5a7d8d5ee960c5618df382900c4ded3da0587a6
2019-11-27 14:19:46 -08:00
Sergey Ryabov
aeb9549af7 Fix javadocs
Summary: Changelog: [Internal]

Reviewed By: muraziz

Differential Revision: D15538725

fbshipit-source-id: 5cf60f47b07ce355e40d5b064add1df980beed89
2019-11-22 10:25:41 -08:00
Sidharth Guglani
f3498a2959 Remove BItfield from YGLayout.h
Summary:
##Changelog:

[Internal][Yoga] Remove Bitfield from YGLayout

Reviewed By: astreet

Differential Revision: D18519623

fbshipit-source-id: 950b8cb1ca2cd0424b8d8748c4b71336b40fc15f
2019-11-22 04:51:14 -08:00
Sidharth Guglani
9d2ca758fa Remove Bitfield from YGStyle
Summary:
##Changelog:

[Internal][Yoga] Remove Bitfield from YGStyle

Reviewed By: astreet

Differential Revision: D18519614

fbshipit-source-id: 70f18bc679b62712d40d76bd793cf85906b067a1
2019-11-22 04:51:13 -08:00
Sidharth Guglani
9650c1903d converts BitfieldTests to BitUtilsTest
Summary: Use BitUtils for testing bit operations

Reviewed By: astreet

Differential Revision: D18596312

fbshipit-source-id: 83f93cd7f1f056b3f64070debbc452877b44ac7a
2019-11-22 04:51:13 -08:00
Sidharth Guglani
f4840a0148 Added BitUtils
Summary:
Adds BitUtils to be used later instead of Bitfield.h

##Changelog:
[Internal][Yoga] : Adds BitUtils to be used later instead of Bitfield.h

Reviewed By: astreet

Differential Revision: D18519609

fbshipit-source-id: 8353929543505a7d80d66281adb801d34372beed
2019-11-22 04:51:12 -08:00
Sidharth Guglani
198e99d30c Back out "not using templates for updating styles which are used via bitfield"
Reviewed By: astreet

Differential Revision: D18628090

fbshipit-source-id: 9d006534111f10ec25a0d56214792aeb96fbdef9
2019-11-22 04:51:11 -08:00
Sidharth Guglani
cd0191c247 not using templates for updating styles which are used via bitfield
Summary:
We want completely remove usages of Bitfield as it uses templates which bloats binary size
This stack will reduce 2.2 Kb in binary size bringing it down to 61.3KB on armv7

In this diff we are removing usage of template while updating styles.

## Changelog:
[Internal][Yoga] : Not using templates for updating styles

Reviewed By: astreet

Differential Revision: D18519570

fbshipit-source-id: 2324088b8c63154f818b1da1edf24c0533e10082
2019-11-15 06:39:29 -08:00
Sidharth Guglani
7ec0ef8470 add test for margin and padding percent applied on leaf nodes with measure function
Summary: Add tests for using margin and padding percent on nodes with measure function set on them

Reviewed By: alickbass

Differential Revision: D17130693

fbshipit-source-id: 9a5c963671f7649dead459969b008335f15e45ce
2019-11-15 05:13:35 -08:00
Sidharth Guglani
b88cf7ff67 use owner's width for resolving the margin and padding for node
Summary:
The margin and padding are resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages.
Here we were using node's width instead of container width to calculate the margin and padding.

Fixed this to use container's width.

## Changelog:

[General][Yoga] : Fixed an issue where margin and padding were resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages.

Reviewed By: alickbass

Differential Revision: D17130520

fbshipit-source-id: ac904d432f121973e7739debd9136909b5ca1427
2019-11-15 05:13:34 -08:00
Sidharth Guglani
20fe53b254 Add --version-script
Summary: Adds version script to exclude all exported symbols and export only JNI_onLoad

Reviewed By: Andrey-Mishanin

Differential Revision: D18076602

fbshipit-source-id: cac4ef9c800de6a3b2081a1f847fa918687896fe
2019-11-13 16:46:09 -08:00
Sidharth Guglani
f99da09716 Remove useVanillaJNI flag and usage of fbjni in yoga build
Summary:
## Changelog:

[General] [Yoga] - Use vanilla jni instead of fbjni for all the jni communication

Reviewed By: astreet

Differential Revision: D17808005

fbshipit-source-id: 5e9a1ed73978f519c71c248774a28e5a294e7c7f
2019-11-13 15:16:37 -08:00
Sidharth Guglani
5960dd888d Add test for margin top not calculated correctly if defined in percentage
Summary:
Unit tests for margin percent scenario where height was being used instead of width

## Changelog:

[Internal] [Yoga] - Added unit tests for margin percent

Reviewed By: alickbass

Differential Revision: D18448365

fbshipit-source-id: f4404b0c493938fc04dc685e97effa08bfd553b0
2019-11-13 07:25:59 -08:00
Sidharth Guglani
b0a0007d6e using width for calculating margin top percent
Summary:
In Yoga, margin is not calculated correctly when defined in terms of percentage at one place.
According to CSS docs , margin percentage should be calculated according to width of container's block in case of horizontal writing mode. (https://fburl.com/5imus0it)
We were using height of container causing some issues in both android and iOS.

## Changelog:

[Yoga] [Fixed] - margin if defined in percentage should use container's width in horizontal writing mode

Reviewed By: alickbass

Differential Revision: D18395285

fbshipit-source-id: 87ebd013e3cba36da45f6548e4dff1bce69cce9b
2019-11-13 05:29:36 -08:00
Pritesh Nandgaonkar
73a4a6d29f Fixes the Yogakit compilation bug for xcode11
Summary:
This fixes the yogakit compilation bug for xcode 11, where it fails to find swift core frameworks for pure objc project.

https://github.com/Carthage/Carthage/issues/2825
https://twitter.com/krzyzanowskim/status/1151549874653081601?s=21

Also published this podspec on cocoapods and deleted .swift-version file as it was not required, because swift version is mentioned in podspec

Reviewed By: SidharthGuglani

Differential Revision: D18420963

fbshipit-source-id: d617bf643ac6481d6add86e6a4bfadd6e0d0c229
2019-11-11 10:18:52 -08:00
Pritesh Nandgaonkar
0be0e9fc01 Solve lib lint failure
Summary:
This diff solves `pod lib lint` failure.

We want to make a new yoga release, as I landed some changes in its podspec which solves the broken flipper build for xcode 11.

{F221612119}

Reviewed By: passy

Differential Revision: D18382588

fbshipit-source-id: efddfa3e93ca59b79b887d04f83407b004d9a199
2019-11-08 04:03:00 -08:00
Pritesh Nandgaonkar
ddf748a99d Add Swift extension as a separate pod
Summary:
Adds swift extension file as a separate subspec, as it is not required for the objc projects.

Also this fixes the current issue where the flipper sample app fails to build on xcode 11, as it fails to link the Swift specific literals.

Fixes this too https://github.com/facebook/yoga/issues/565

Reviewed By: SidharthGuglani

Differential Revision: D18373993

fbshipit-source-id: 0c058886a837c7ceafcd0167f878b3e0f7763aa1
2019-11-07 10:51:42 -08:00
Sidharth Guglani
4d16ee4ed4 Use double for YGRoundValueToPixelGrid calculations
Summary:
Use double for YGRoundValueToPixelGrid calculations as we were losing some precision in float operations

#Changelog:
[Internal][Yoga] Use double for YGRoundValueToPixelGrid calculations

Reviewed By: astreet

Differential Revision: D18225999

fbshipit-source-id: 69c05f56a0e0f3433bf0bd958aa07d26dd83fe02
2019-11-05 17:26:00 -08:00
Dmytro Kasianchuk
b72efaaaca Added missing YOGA_EXPORT
Summary:
Added missing YOGA_EXPORT

#Changelog:
[Internal] [Fixed] - Added missing YOGA_EXPORT

Reviewed By: SidharthGuglani

Differential Revision: D18289071

fbshipit-source-id: a2e16a59427aa33b34b3d1fab9d1088904ee62f5
2019-11-02 20:43:17 -07:00
Sidharth Guglani
6327893b9b Use compiler flags -ffunction-sections, -fdata-sections and gc sections in both jni and core
Summary: Use compiler flags -ffunction-sections, -fdata-sections and  -Wl,--gc-sections  in both jni and yoga core

Reviewed By: amir-shalem

Differential Revision: D18029671

fbshipit-source-id: 5192fb6d682248b16781dead0d7b0a0377861fb6
2019-11-01 11:54:45 -07:00
Sidharth Guglani
8c3ee81d6e Use compiler flag -fvisibility=hidden
Summary:
Using compiler flag -fvisibility=hidden and explicitly setting visibility to default to public methods

#Changelog:
[Internal] [Yoga] Use compiler flag -fvisibility=hidden for reducing yoga binary size

Reviewed By: astreet

Differential Revision: D18029030

fbshipit-source-id: 545e73f9c25f3108fc9d9bb7f08c157dbc8da005
2019-11-01 11:54:45 -07:00
Scott Wolchok
fb07dcff40 Fix data race with gCurrentGenerationCount
Summary:
Yoga layout can be invoked on multiple threads, and gCurrentGenerationCount is a shared global without synchronization.

Changelog: [General] [Fixed] - Fix an internal thread safety issue in Yoga

Reviewed By: SidharthGuglani

Differential Revision: D18092734

fbshipit-source-id: 85753d139549b4e5507f97a56d589fb6854557fa
2019-10-28 12:54:52 -07:00
Sidharth Guglani
27f42c90db Remove setStyleInputs API
Summary:
setStyleInputs batching API was added to reduce the number of jni calls and although it improved performance in yoga world but was not impactful in litho and is not used anywhere.

Removing this saves around 500 bytes per architecture

#Changelog:
[Internal][Yoga] Removed unused code setStyleInputs batching API form Yoga

Reviewed By: amir-shalem

Differential Revision: D18036536

fbshipit-source-id: 7436b55dcd464dd9f9cc46406d4fd78d12babe55
2019-10-23 02:38:03 -07:00
Sidharth Guglani
688bd4ef72 Add exception handling in vanilla jni
Summary:
Exception handling in vanilla jni

## Changelog:
[Internal] [Added] Added exception handling for vanilla jni implementation in yoga

Reviewed By: amir-shalem

Differential Revision: D18036134

fbshipit-source-id: 965eaa2fddbc00b9ac0120b79678608e280d03db
2019-10-22 11:01:00 -07:00
Andres Suarez
42bba10894 Tidy up license headers
Summary: Changelog: Tidy up license headers

Reviewed By: SidharthGuglani

Differential Revision: D17919414

fbshipit-source-id: 0501b495dc0a42256ca6ba3284a873da1ab175c0
2019-10-15 10:36:38 -07:00
Sidharth Guglani
495d8da596 useVanilla flag for measure and baseline methods as well
Summary: UseVanillaJNI flag was missing for measure and baseline functions

Reviewed By: amir-shalem

Differential Revision: D17868201

fbshipit-source-id: 95d6843d643e90157a51550d6efbf059f0ca2c39
2019-10-11 02:04:02 -07:00
Sidharth Guglani
869a33eb13 no need to pass env to ref method , we can directly use getCurrentEnv()
Summary: We can use getCurrentEnv() instead of passing environment variable around

Reviewed By: amir-shalem

Differential Revision: D17842042

fbshipit-source-id: 185b174ae7c08e746bc76c0600c2e326b15c4993
2019-10-10 05:33:20 -07:00
Sidharth Guglani
050893f15a rename PtrJNodeMap to PtrJNodeMapVanilla in yoga vanilla jni files
Summary: Rename PtrJNodeMap in vanilla files top PtrJNodeMapVanilla , otherwise they conflict

Reviewed By: amir-shalem

Differential Revision: D17842001

fbshipit-source-id: eb164076ee2a68d79dc376826508a4143056ea31
2019-10-10 05:33:19 -07:00
Sidharth Guglani
8aa67abdb2 Fix YGNodeJobject method
Summary: We can use getCurrentEnv() , no need to pass env around methods

Reviewed By: amir-shalem

Differential Revision: D17841281

fbshipit-source-id: a4a58292e70ac05b0f0b9eb962a82a8501ad0226
2019-10-10 05:33:19 -07:00
Sidharth Guglani
2e321fc69f Move JNI_OnLoad to separate file which registers both fbjni and jni methods
Summary: Move JNI_ONLoad to a separate file so that both fbjni native methods and vanillla jni native methods can be initialized correctly

Reviewed By: amir-shalem

Differential Revision: D17840166

fbshipit-source-id: 045df0df7a95bc331cbbefb3a118a349f3029465
2019-10-10 05:33:18 -07:00
Amir Shalem
aa2610c2dd Set missing useVanillaJNI in constructor for YogaNode
Summary: set missing useVanillaJNI, it was causing part of the unit-tests to run in fbjni instead of vanillajni.

Reviewed By: SidharthGuglani

Differential Revision: D17852635

fbshipit-source-id: 5bc187d90fbdc430015be55a015a7d1e0ba0ebc6
2019-10-10 02:45:00 -07:00
Sidharth Guglani
293b657aef Use TestParametrization for testing both fbjni and vanillaJNI version
Summary: Use TestParametrization to test both fbjni and vanilla jni versions

Reviewed By: amir-shalem

Differential Revision: D17788718

fbshipit-source-id: 0f3317b7403cadca7b7ccd9140f1933d746bf433
2019-10-09 09:28:41 -07:00
Sidharth Guglani
d6591439d1 move YGSetLogger and YGConfigFree with global ref to vanilla jni
Summary: Move YGSetLogger and YGConfigFree methods to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17754999

fbshipit-source-id: 8dfcf1a54e4d54ebf91e38c6513e6a703a40ae92
2019-10-09 09:28:41 -07:00
Sidharth Guglani
2ef674edd3 move measure and baseline methods
Summary: Measure and baseline callbacks moved to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17714334

fbshipit-source-id: dafbde36984aba948a6345a21d3808a6ef4013e8
2019-10-08 17:51:35 -07:00
Sidharth Guglani
22a60e82b0 move yg node new and ygnode new with config
Summary: YGNode creation methods to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17714230

fbshipit-source-id: 74e14e876ab7efc67771d92091c2a78f09072b83
2019-10-08 17:51:34 -07:00
Sidharth Guglani
34739ec652 Move calculate layout method to vanilla JNI
Summary: Using vanilla JNI for calculate layout

Reviewed By: amir-shalem

Differential Revision: D17714219

fbshipit-source-id: bb05de4a0112eefc2b731997a4c1ecef5c0c7361
2019-10-08 17:51:34 -07:00
Sidharth Guglani
b9b0217a07 Add Scoped Local and Global Ref
Summary: Add ScopedLocalRef, ScopedGlobalRef and some common methods to be used later.

Reviewed By: amir-shalem

Differential Revision: D17711284

fbshipit-source-id: be43d5e246bc2406765057783be11854877c41f1
2019-10-08 17:51:33 -07:00
Sidharth Guglani
7c2683fe52 move setStyleInputs to vanilla jni (YogaStyleProperties Part 5)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17686117

fbshipit-source-id: e79bee1188c24e301b23416486b10f613434eebc
2019-10-08 14:37:27 -07:00
Sidharth Guglani
ee73f556b4 move config jni methods to vanilla jni
Summary: Move yoga node config related jni methods to vanilla jni

Reviewed By: amir-shalem

Differential Revision: D17684821

fbshipit-source-id: 31a667b3ad67501aaef83a132971e4e0826cacd4
2019-10-08 14:37:26 -07:00
Sidharth Guglani
34b68cf1d2 move YGNode related methods to vanilla jni
Summary: This diff moves methods related to actions on YGNode like free node, reset node etc. to vanilla JNI

Reviewed By: amir-shalem

Differential Revision: D17668008

fbshipit-source-id: 03bfc51ec1fcf06569713400f984d551827e22fe
2019-10-08 14:37:26 -07:00
Sidharth Guglani
8975019269 move edge style properties to vanilla jni (YogaStyleProperties Part 4)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17667201

fbshipit-source-id: 448134d6d7d0dd0c6ff2734b3eb39e65d1cb403f
2019-10-08 14:37:25 -07:00
Sidharth Guglani
6e6b1369ac move percent auto style properties to vanilla jni (YogaStyleProperties Part 3)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666674

fbshipit-source-id: 08490bf7c214c856a93214088a27dd4e6df9e0fd
2019-10-08 14:37:25 -07:00
Sidharth Guglani
25b8c94788 move common code to YGJNI.h header class
Summary: Moving common code to YGJNI.h header class so that same can be used in fbjni and vanilla jni implementations

Reviewed By: amir-shalem

Differential Revision: D17666457

fbshipit-source-id: 1e6cd2506fb773b8a17ebef277a2c7ef9728e66b
2019-10-08 14:37:24 -07:00
Sidharth Guglani
3fce27c48c Migrate YGNodeStyleGetFlex method to vanilla jni (YogaStyleProperties Part 2)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666090

fbshipit-source-id: 121b939c310799c79f2fce0ea293f88b2940c4fc
2019-10-08 14:37:24 -07:00
Sidharth Guglani
32a973ebd1 Move style properties which accept one parameter to vanilla JNI (YogaStyleProperties Part 1)
Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666048

fbshipit-source-id: 6565acd35ab04ef0c3a2544447a25dc6edc3e7a5
2019-10-08 14:37:24 -07:00
Andres Suarez
c37f5956e4 Fix license headers
Reviewed By: scottrice

Differential Revision: D17673223

fbshipit-source-id: 42a3a25934ef63b24ebf9f5f1909cb562d0d4172
2019-09-30 15:09:48 -07:00
Sidharth Guglani
0875b6b542 Add boolean flag to decide whether to use fbjni or jni
Summary:
Adds a flag useVanillaJNI in YogaConfig to determine whether to use FbJNI or JNI.
Currently default is set to false.

We will experiment based on this flag once all code have been migrated.

Reviewed By: Andrey-Mishanin

Differential Revision: D17601703

fbshipit-source-id: 377a5bd2a6f8a7584e84932e87fa7044d8165efd
2019-09-26 17:34:18 -07:00
Sidharth Guglani
b29e144649 Add separate classes to implement JNI methods suing vanilla JNI
Summary:
This diffs adds a separate file YGJNIVanilla.cpp to add jni methods which uses vanilla JNI instead of FBJNI.
In this diff only one method has been added to setup the experiment boolean setup.

At the end of this diff stack , we will be able to experiment between fbjni and vanilla jni in yoga and finally get rid of fbjni which saves us around 300Kb per architecture in yoga binary size.

Reviewed By: Andrey-Mishanin

Differential Revision: D17601591

fbshipit-source-id: a88520c625bd8b5d9ffcf8ab5f02fc71dc800081
2019-09-26 17:34:17 -07:00
Uts Sikder
f00116c3a6 BREAKING: rm YogaNode parameter from YogaLogger#log
Summary:
In D17439957, I noted that YogaLogger#log throws a NoMethodFoundException when called from C++ b/c C++ and Java's signatures of that method don't match. C++ uses YogaNodeJNIBase for the first param, Java uses YogaNode. Both my attempts to fix this failed.

Attempt #1 - Make Java use YogaNodeJNIBase. This doesn't work because the :java-interface target includes YogaLogger but not YogaNodeJNIBase. Moving YogaLogger to the impl target doesn't work either b/c other files in :java-interface reference YogaLogger.

Attempt #2 - Make C++ use YogaNode. This doesn't work b/c we try to call the log method with objects of fbjni type YogaNodeJNIBase. This would be fine in Java since YogaNodeJNIBase extends YogaNode. But fbjni's typing isn't advanced enough to know this, so the Yoga C++ fails to compile.

At this point, I was wondering what the value of having this param in the log function at all was. None of the implementations in our codebase use it today. It might be easier to just remove it all together. This also removes a bug with YGNodePrint where we pass a null layout context that eventually causes a SIG_ABRT when we use it to try to find a YogaNode to pass to this function. (https://fburl.com/diffusion/ssw9h8lv).

Reviewed By: amir-shalem

Differential Revision: D17470379

fbshipit-source-id: 8fc2d95505971a52af2399a9fbb60b63f27f0ec2
2019-09-25 09:15:45 -07:00
Amir Shalem
f1baf8336b Use direct access to YogaConfig mNativePointer parameter
Summary:
Use direct access to YogaConfig mNativePointer parameter

Results:
```
The following primary metrics showed statistically significant changes at the 95% confidence level:
javaFullLifecycleAllocateCalculateReadLayout	-1.25%
javaLayoutReading	0.44%
javaYogaNodeAllocateAndSetProps	-1.92%
javaYogaNodeAllocation	-2.11%
javaYogaNodeStylePropAssignment	-0.89%
```

Differential Revision: D17519542

fbshipit-source-id: c39bfe1b0ecae9149dc6da2a0a7e936df215ec5b
2019-09-22 13:53:06 -07:00
Uts Sikder
36eae205e1 fix type mismatches in YogaLogger#log function
Summary: This diff fixes two issues with the JNI integration of YogaLogger#log. (1) The YogaLogger class descriptor was missing a semicolon. This causes a ClassNotFoundException whenever you try to call the log method from C++. (2) The C++ signature for the class was using YogaNodeJNIBase as an arg but the Java signature was using YogaNode. This causes a MethodNotFoundException whenever you try to call the method after fixing problem 1.

Reviewed By: astreet

Differential Revision: D17439957

fbshipit-source-id: be3c16512558050265565b3688fb09a7da31b9b2
2019-09-18 21:32:09 -07:00
Amir Shalem
ad5b3410f0 Remove dead code of mYogaNodeCloneFunction
Summary: Code cleanup, remove mYogaNodeCloneFunction completely and its `YogaNodeCloneFunction`

Reviewed By: SidharthGuglani

Differential Revision: D17284191

fbshipit-source-id: 36dae0c0548cfdd3e85182a8e3c6ff9a2d3a5011
2019-09-18 05:52:56 -07:00
Amir Shalem
e2dbff0ca6 Split interface and jni java target
Summary:
Split the yoga buck targets from interface to actual implementation.

This is currently done without moving any files folder, since only we will make the distinction between interface<-->implementation only this buck target (and not in the litho/reactnative yoga copies).

Buck does insures that the `java-interface` is pure since it doesn't depend on any fbjni code.

Reviewed By: SidharthGuglani

Differential Revision: D17266406

fbshipit-source-id: 46aa469b74c2c3114f1d3d762c41d32cfe269f57
2019-09-18 00:40:28 -07:00
Amir Shalem
96eb94afd0 Remove YogaNode.create() from the abstract class
Summary:
Remove YogaNode.create() from the abstract class after we made sure nothing uses it anymore
This is the final stage to make `YogaNode` a pure class without JNI references

Reviewed By: SidharthGuglani

Differential Revision: D17280571

fbshipit-source-id: bd0eb138f7a6a9de8988fc0a7b90badbf635dac5
2019-09-18 00:40:27 -07:00
Amir Shalem
9100019c0a Split YogaConfig into interface and actual implementation
Summary:
Split YogaConfig into the same way YogaNode is split today.

Into an abstract class defining the interface, and actual JNI implementation

Reviewed By: SidharthGuglani

Differential Revision: D17266404

fbshipit-source-id: 3d5d6aa65c55cfa61d47c662d140cdce6dcb0ea1
2019-09-18 00:40:27 -07:00
Sidharth Guglani
21f814b2a6 remove infer-annotations dependency (#922)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/922

We are not using this dependency anywhere in yoga. Removed in this diff.

Reviewed By: passy

Differential Revision: D17131081

fbshipit-source-id: 5544b892f4ef5ca0207d9e21a5b97a2940ac6d53
2019-09-17 12:08:19 -07:00
Amir Shalem
499d28d021 Expose native pointer thru an interface function for YogaConfig
Summary:
Expose native pointer thru an interface function for YogaConfig (its package private to `com.facebook.yoga` namespace),
This way we can make later on YogaConfig a pure abstract class.

Plus, it makes sure external users don't modify the pointer

Reviewed By: SidharthGuglani

Differential Revision: D17266401

fbshipit-source-id: f39b488cea0b73bc3578bb3aa90ab00139bf9271
2019-09-17 07:15:24 -07:00
Amir Shalem
d697bbe0a5 Switch to YogaConfigFactory.create
Summary: Switch to `YogaNodeFactory.create()` instead of using `YogaNode.create()`

Reviewed By: SidharthGuglani

Differential Revision: D17266408

fbshipit-source-id: 69e1e59c7345d16eb174af97c2e231666a02354b
2019-09-17 07:15:23 -07:00
Amir Shalem
67a3841164 Switch to YogaNodeFactory.create
Summary: Switch to `YogaNodeFactory.create()` instead of using `YogaNode.create()`

Reviewed By: SidharthGuglani

Differential Revision: D17258195

fbshipit-source-id: 5f31540724a16e401fcd0fbdf19a4baa354b2d72
2019-09-17 07:15:23 -07:00
Sidharth Guglani
6ac38d188c use implementation instead of compile for yoga dependencies
Summary: Use implementation instead of compile in build.gradle

Reviewed By: passy

Differential Revision: D17343602

fbshipit-source-id: a2ec21a46ebbf3feb5dcc0d9ae2684f8efb096e3
2019-09-16 09:14:28 -07:00
Sidharth Guglani
8216c54b05 update build tools versions
Summary:
Update build tools version to 28.0.3 to fix the below warning

WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.

Reviewed By: passy

Differential Revision: D17343575

fbshipit-source-id: aa12bf2b55666aacb18f09b1cca22eab05f38220
2019-09-16 09:14:28 -07:00
Sidharth Guglani
968c075e39 bump version to 1.16.0-SNAPSHOT
Summary: Bump version to 1.16.0-SNAPSHOT for new yoga release

Reviewed By: amir-shalem

Differential Revision: D17396540

fbshipit-source-id: ddd01454752d88548ae7490cfd9fccfb8c591ec9
2019-09-16 08:25:31 -07:00
Sidharth Guglani
26dbe8b4ff bump version to 1.16.0
Summary: Bump version to 1.16.0 for new yoga release

Reviewed By: amir-shalem

Differential Revision: D17395785

fbshipit-source-id: b01b31d58b5b1a2a9532e9cce0892c08960ec31c
2019-09-16 07:48:59 -07:00
Sidharth Guglani
a5c2f7f27a fix yoga build issue Could not find yoga:libfb:unspecified.
Summary:
Fixes the yoga build 1:15:0 build issue

    Could not find yoga:libfb:unspecified.
    Required by:
    project :app > com.facebook.yoga:yoga:1.15.0

libfb dependency was added to solve import issue in YogaPhantomJNIRefs but since we don't have that file now in codebase , it will not be a problem.

Reviewed By: amir-shalem

Differential Revision: D17395380

fbshipit-source-id: ab8eb2c89afe29b4688787db2214c328d875041e
2019-09-16 05:25:39 -07:00
Sidharth Guglani
10811e1a94 bump version to 1.15.0-SNAPSHOT
Summary: Bumping version to 1.15.0-SNAPSHOT

Reviewed By: amir-shalem

Differential Revision: D17394807

fbshipit-source-id: 2ba8ecbb903b9810905fabf3b60efaa8458b6bfd
2019-09-16 04:37:39 -07:00
Sidharth Guglani
10f4bceac0 bump version to 1.15.0
Summary: Bumping version to 1.15.0 for new yoga release

Reviewed By: amir-shalem

Differential Revision: D17394805

fbshipit-source-id: de43e97a0c155f332ecbe4e98b78c2f7c9ffe771
2019-09-16 03:42:43 -07:00
Sidharth Guglani
47717324d4 fix fbjni and yoga event files not found in testutil issue
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/928

Reviewed By: amir-shalem

Differential Revision: D17383979

fbshipit-source-id: 755c2cc3749d5e23fbd1e0ac7a41632c1400ae24
2019-09-15 13:54:06 -07:00
Amir Shalem
1043c35f2b Fix libfbjni compilation (#927)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/927

When D16220924 brought a new fbjni copy (with new directories), we forgot to fix the cmake files which are used by gradle build system.

Reviewed By: SidharthGuglani

Differential Revision: D17367160

fbshipit-source-id: 3e7d20d4c53ff3012a164bf6e32f1000ecb3ffc2
2019-09-13 09:21:06 -07:00
Amir Shalem
fde89b056d Add standalone factory classes which generate YogaNode + YogaConfig
Summary:
Add standalone factory classes which generate YogaNode + YogaConfig, later on it will allow us to separate the yoga interface and actual implementation buck targets (see D17266406)

We've done such breakage change previously in D14122974.

Reviewed By: SidharthGuglani

Differential Revision: D17258196

fbshipit-source-id: b12f1a0d23c3f82b14cee0731a1daf1c015ee32c
2019-09-12 06:05:02 -07:00
Sidharth Guglani
a08a57b33c Remove unused YogaNodeJNIPhantomRefs.java
Summary:
Removed unused file YogaNodeJNIPhantomRefs.java as this was causing oss build failures because of an import.

````:yoga:compileDebugJavaWithJavac/home/travis/build/facebook/yoga/java/com/facebook/yoga/YogaNodeJNIPhantomRefs.java:9: error: package com.facebook.jni does not exist
import com.facebook.jni.DestructorThread;
                       ^
/home/travis/build/facebook/yoga/java/com/facebook/yoga/YogaNodeJNIPhantomRefs.java:30: error: package DestructorThread does not exist
    new DestructorThread.Destructor(node) {
                        ^
2 errors
 FAILED

Reviewed By: pasqualeanatriello

Differential Revision: D17257330

fbshipit-source-id: 98b0c5d5b7dcd94bee559b58194c13b07f47723d
2019-09-11 10:28:56 -07:00
Amir Shalem
31de91bbac fix gradle compliation (#925)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/925

Gradle is failing to compile yoga for two reasons:
1. Ever since `YogaNodeJNIPhantomRefs` was introduced which uses `DestructorThread.Destructor` from fbjni which was the first direct Java dependency from yoga java to fbjni java code.

2. Adding a missing gradle endpoint for `testutil` since it is now required for yoga unit-tests

Reviewed By: SidharthGuglani

Differential Revision: D17274226

fbshipit-source-id: 3df9648321162d34f81fd3675ca1474e8a1c6d3a
2019-09-10 08:18:56 -07:00
Sidharth Guglani
e6e224ce48 Add dist: trusty to yoga travis configuration
Summary:
clang 6.0 install was failing in yoga oss tests

Travis has made xenial as default distribution
https://changelog.travis-ci.com/xenial-as-the-default-build-environment-is-coming-97772

Added dist: trusty to the configuration to fix this.

Reviewed By: passy

Differential Revision: D17257300

fbshipit-source-id: f9fcd6ba774dad1c28bd953c0d850c7078d02015
2019-09-09 03:34:52 -07:00
Paul O'Shannessy
a04a6b5e8f Adopt Contributor Covenant
Summary:
In order to foster healthy open source communities, we're adopting the
[Contributor Covenant](https://www.contributor-covenant.org/). It has been
built by open source community members and represents a shared understanding of
what is expected from a healthy community.

Reviewed By: josephsavona, danobi, rdzhabarov

Differential Revision: D17104640

fbshipit-source-id: d210000de686c5f0d97d602b50472d5869bc6a49
2019-08-29 23:48:24 -07:00
Pascal Hartig
442d84ccfc Remove built-in DoNotStrip annotations
Summary:
Use the Yoga dependency instead which can be deduplicated by Gradle.

This solves (parts of) a bunch of issues concerning the use of
multiple FB libraries in one Android project.

Reviewed By: danielbuechele

Differential Revision: D16783243

fbshipit-source-id: 7f7915821dd286c51ec4ccbd95a2cdcb18b53bde
2019-08-15 04:21:56 -07:00
Pascal Hartig
4a2ccc658e Target Java 7
Summary: The artifacts generated otherwise can cause issues in Android projects.

Reviewed By: SidharthGuglani

Differential Revision: D16803253

fbshipit-source-id: db139560dfbddb917c27bdfd80e1bf5747e4a74b
2019-08-14 05:37:32 -07:00
Pascal Hartig
58622fa747 Set up proguard-annotations as separate Maven artifact
Summary:
We need one place, any place really, to publish that good old `DoNotStrip` annotation
from that we currently copy across various repos, causing havoc for anybody who
tries to integrate more than one FB Android library into their project.

Yoga is very well positioned for this because it's already its own Gradle module and
all that's missing are these few lines.

Reviewed By: SidharthGuglani

Differential Revision: D16783035

fbshipit-source-id: 69b6224a725194d036c6a23a36bd76d3487b9811
2019-08-13 06:26:15 -07:00
Sidharth Guglani
90cded3819 use array for passing measure callback reasons count
Summary:
Use an array for counting measure callbacks due to each reason.
and this is now added as qpl metadata in Layout Calculation qpl event

Reviewed By: davidaurelio

Differential Revision: D16666786

fbshipit-source-id: ff85fba835148f06b9c5d90c4604e552a813777a
2019-08-08 07:18:03 -07:00
Adlai Holler
d1e188341b Don't copy children in YGNodeComputeFlexBasisForChildren (#919)
Summary:
No need for a copy here.
Pull Request resolved: https://github.com/facebook/yoga/pull/919

Differential Revision: D16701461

Pulled By: davidaurelio

fbshipit-source-id: 3a90adbb2b5c43d5aefe693a8525aa3a37e53b3d
2019-08-08 00:24:07 -07:00
Nicola Ferruzzi
0f2350308e Properly test for the lack of a node measure func in YogaKit (#915)
Summary:
The test was broken and caused a few crashes on my project.
Pull Request resolved: https://github.com/facebook/yoga/pull/915

Differential Revision: D16701613

Pulled By: davidaurelio

fbshipit-source-id: 9ab5c43bb74e77593bc2426a249750a7ee8f4034
2019-08-08 00:10:25 -07:00
Luis Miguel Alvarado
9b120eded9 add space-evenly prop to justify-content.md (#918)
Summary:
This PR add the `space-evenly` prop, to the [justify-content.md](https://github.com/facebook/yoga/blob/master/website/contents/properties/justify-content.md) file.

The description was taken from [Mozilla](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
Pull Request resolved: https://github.com/facebook/yoga/pull/918

Differential Revision: D16701547

Pulled By: davidaurelio

fbshipit-source-id: cd1bb7dd20cb1184a1bafb0d8f33e851051bd9e5
2019-08-08 00:01:12 -07:00
Tim
a218880216 Fix compilation with CMake (#909)
Summary:
This adds the root of the source tree to the include path, which allow `#include <yoga/YGEnums.h>` to work.

Fixes https://github.com/facebook/yoga/issues/908
Pull Request resolved: https://github.com/facebook/yoga/pull/909

Differential Revision: D16701716

Pulled By: davidaurelio

fbshipit-source-id: 0fdc6479e4f3119a3e4ddbcd4b48541b282c1bbd
2019-08-07 23:53:44 -07:00
Denis
1a2802028b Update link: (#920)
Summary:
Update link for component kit on docs to `https://componentkit.org/docs/getting-started/`
Pull Request resolved: https://github.com/facebook/yoga/pull/920

Differential Revision: D16701505

Pulled By: davidaurelio

fbshipit-source-id: 10f7df4f7aa29d884d21135a92041b0630e1a31e
2019-08-07 19:51:39 -07:00
Tim
a37b286bae Yoga is written in C++ (#907)
Summary:
As far as I can tell now. Would be nice if you had an actual changelog somewhere!
Pull Request resolved: https://github.com/facebook/yoga/pull/907

Differential Revision: D16701738

Pulled By: davidaurelio

fbshipit-source-id: cf32dc96eca5258979bcaa9947d6ed6b5496398d
2019-08-07 19:44:24 -07:00
David Aurelio
dcfdb955b3 Back out "[Yoga] Experiment: double invocations of measure callbacks"
Summary:
Removes the double measure callbacks experiment
Original commit changesets: c6cf9c01a173,  b157d8137c72

Reviewed By: SidharthGuglani

Differential Revision: D16687367

fbshipit-source-id: 9649f8731bd1b27f4d291cee4fa30153165cea02
2019-08-07 18:24:32 -07:00
David Aurelio
72cefead02 Use Bitfield in YGLayout
Summary: Replaces the usage of C++ bitfields with our portable `Bitfield` class.

Reviewed By: SidharthGuglani

Differential Revision: D16656361

fbshipit-source-id: 05f679e2e994e109b2bd1090c879d6850fabdc40
2019-08-07 16:29:04 -07:00
David Aurelio
884e064a99 Use Bitfield in YGNode and YGStyle
Summary:
@public

Replaces the usage of C++ bitfields with our portable `Bitfield` class.

Reviewed By: SidharthGuglani

Differential Revision: D16649875

fbshipit-source-id: 539f016d5e1c9a8c48cc9bacbbf6ed985e385e69
2019-08-07 16:29:03 -07:00
David Aurelio
3ed9bec05c Remove style property bitmask
Summary:
@public

Removes the style properties bitmask. We have used this for experimentation, and it's no longer necessary.

This simplifyies the code, and allows us to cut over to `Bitfield.h` more easily.

Reviewed By: astreet

Differential Revision: D16648862

fbshipit-source-id: 17c0899807af976f4ba34db54f8f0f6a3cd92519
2019-08-07 16:29:03 -07:00
David Aurelio
dadf0473b7 Add portable bit field implementation
Summary:
@public
Our usage of C++ bit fields has lead to quite some problems with different compiler setups. Problems include sign bits, alignment, etc.

Here we introduce a portable implementation as a variadic template, allowing the user to store a number of booleans and enums (defined with `YG_ENUM_SEQ_DECL`) in an unsigned integer type of their choice.

This will replace all usages of bit fields across the Yoga code base.

Differential Revision: D16647801

fbshipit-source-id: 230ffab500885a3ad662ea8f19e35a5e9357a563
2019-08-07 16:29:02 -07:00
Daniel Büchele
947230958d make npm module
Summary: We want to use the yoga playground as a standalone package as well. This adds a webpack config to bundle the playground for npm. The package can then be distributed as `yoga-playground` via npm

Reviewed By: fabiomassimo

Differential Revision: D16583334

fbshipit-source-id: 84807ddd8983ba9f0fb43570b518c975f35544ab
2019-08-01 04:15:25 -07:00
Sidharth Guglani
095c991b85 Added counts for measure callbacks reasons in an array inside qpl annotations
Summary:
Added an array to maintain the counts of each of the reason of measure callbacks
and this is now added as qpl metadata in Layout Calculation qpl event

Reviewed By: davidaurelio

Differential Revision: D16516379

fbshipit-source-id: 201c5d2463f0a921841a0bbfec8f4d5e007000c8
2019-07-31 14:37:37 -07:00
Sidharth Guglani
825da1e868 create two layout pass reason flexLayout and flexMeasure instead of flex
Summary:
We had flex as a reason for both layout and measure. Now creating separating reason flexLayout and flexMeasure in this diff.

Also changed ordering of items in Enum to group layout and measure reasons

Reviewed By: davidaurelio

Differential Revision: D16562350

fbshipit-source-id: 75501f9d4dde0974009193b3991a8acc97b02ad0
2019-07-31 14:37:36 -07:00
Sidharth Guglani
5a25805cb5 Update flow-copy-source to use latest version
Summary:
Fixes vulnerability in mem dependency by updating the version of flow-copy-source in javascript/yarn.lock
da4e4398cb

Reviewed By: danielbuechele

Differential Revision: D16542191

fbshipit-source-id: e900ac2d358883fc269688b93faad3ffbec10f0d
2019-07-31 06:48:07 -07:00
Sidharth Guglani
adff8d96dd remove getInstanceCount usages
Summary:
This diffs removes the usages of getInstanceCount as it has been removed from yoga.
We will add event support in js later to handle these test cases

Reviewed By: davidaurelio

Differential Revision: D16560269

fbshipit-source-id: 52590c426faf87209f8635602b401fd5760af8ab
2019-07-31 06:48:06 -07:00
Sidharth Guglani
8c270e68cc add subdirectories of yoga also to js sources
Summary: Update build file to include subdirectories of yoga also in sources

Reviewed By: davidaurelio

Differential Revision: D16560253

fbshipit-source-id: 5dee4379912e003d4a1fa611882fbf736321615c
2019-07-31 06:48:06 -07:00
Samuel Susla
a2aa1b7fca Fix onDismiss in Modal
Summary:
# Disclaimer:
I might be missing something as the solution I implemented here seems like something that was considered by original author. If this solution isn't good, I have a plan B.

# Problem:
`onDismiss` prop isn't being called once the modal is dismissed, this diff fixes it.

Also I've noticed that `onDismiss` is meant to only work on iOS, why is that? By landing this diff, it'll be called on Android as well so we need to change the docs (https://facebook.github.io/react-native/docs/modal.html#ondismiss).

## Video that shows the problem
Following code is in playground.js P70222409 which just increments number everytime onDismiss is called

{F166303269}

Reviewed By: shergin

Differential Revision: D16109536

fbshipit-source-id: 3fba56f5671912387b217f03b613dffd89614c9d
2019-07-29 11:18:00 -07:00
Min ho Kim
ae956f06fb Fix typos (#25770)
Summary:
Fix typos mostly in comments and some string literals.

## Changelog

[General] [Fixed] - Fix typos
Pull Request resolved: https://github.com/facebook/react-native/pull/25770

Differential Revision: D16437857

Pulled By: cpojer

fbshipit-source-id: ffeb4d6b175e341381352091134f7c97d78c679f
2019-07-23 03:24:00 -07:00
David Aurelio
8c0eed3c75 Add PhantomRef based YogaNode subclass
Summary: Adds a subclass of `YogaNodeJNIBase` that uses `PhantomReference` for deallocating native memory rather than `Object#finalize()`. This should help making garbage collection more efficient.

Reviewed By: amir-shalem

Differential Revision: D16182667

fbshipit-source-id: d310fdb6af184168c43462b24f5e18ab5d0d7ad0
2019-07-19 17:24:49 -07:00
David Aurelio
4e4ef06de1 Implement double measure experiment
Reviewed By: SidharthGuglani

Differential Revision: D16340462

fbshipit-source-id: b157d8137c72f83a3bea46f30d0f46f65055f9ef
2019-07-19 10:40:17 -07:00
David Aurelio
a53c14dc75 Add internal experiments API
Summary: Adds internal API that we can use to conduct experiments.

Reviewed By: SidharthGuglani

Differential Revision: D16340463

fbshipit-source-id: 07a8bb7dbc4a02c5c95f1ad29b18845ab43752cf
2019-07-19 10:40:16 -07:00
Sidharth Guglani
c99fc9c4da using enum struct for LayoutPassReason and LayoutType
Summary: Using enum struct for using enums in form ENUM_NAME::ENUM_VALUE for better code readablility

Reviewed By: davidaurelio

Differential Revision: D16356562

fbshipit-source-id: cbe7adadad78eb5d0756c44679c0e102b7d31ec6
2019-07-18 07:04:47 -07:00
Uladzislau Paulovich
2fb857d73d yoga | Fix error about implicit conversion to bit-field
Summary:
`YGStyle` puts Yoga enums (which are signed integers by default) into bitfields: https://fburl.com/7fowlunu

Mixing signed values and bit-fields can be error-prone and it also fails to build on Windows with `clang-cl` due to `-Wbitfield-constant-conversion` warning being treated as error:

```
stderr: In file included from xplat\yoga\yoga\YGLayout.cpp:8:
In file included from xplat\yoga\yoga/Utils.h:8:
In file included from xplat\yoga\yoga/YGNode.h:13:
xplat\yoga\yoga/YGStyle.h(110,9): error: implicit truncation from 'YGAlign' to bit-field changes value from 4 to -4 [-Werror,-Wbitfield-constant-conversion]
        alignItems_(YGAlignStretch),
```

This diff fixes the problem by making all enums unsigned integers. This change can be problematic only if values of the enums are serialized somewhere. CC: David Aurelio

Reviewed By: davidaurelio

Differential Revision: D16336729

fbshipit-source-id: ee4dabd7bd1ee429e644bd322b375ec2694cc742
2019-07-18 06:20:18 -07:00
Sidharth Guglani
e6dfe04388 Pass reason for measure pass along with measurecallbackend event (#566)
Summary:
Pull Request resolved: https://github.com/facebook/litho/pull/566

Pull Request resolved: https://github.com/facebook/react-native/pull/25702

Pass reason for each measure callback to the flipper plugin

Reviewed By: davidaurelio

Differential Revision: D16221771

fbshipit-source-id: 2e72e1ebb3c7e633d189e7a7a81d655ac9531e51
2019-07-18 05:21:11 -07:00
Sidharth Guglani
5e40e4b682 remove YGMarker code
Summary: Removes code for now unused marker based approach

Reviewed By: davidaurelio

Differential Revision: D16048800

fbshipit-source-id: 228e0e906252782ee0bed543728b666d1f9cc854
2019-07-17 08:11:38 -07:00
Sidharth Guglani
7c891db9af move YGMarkerMeasure and YGMarkerBaselineFn to event based system
Summary: Using yoga event listener for adding systrace sections for measure and baseline events

Reviewed By: davidaurelio

Differential Revision: D16048795

fbshipit-source-id: 3c2161328250184929ed1a3357b8c42ec8ca2e29
2019-07-17 08:11:37 -07:00
David Aurelio
6d916ab063 Do not depend on libfb
Reviewed By: SidharthGuglani

Differential Revision: D16220913

fbshipit-source-id: c6851d8dbda572aa50117b92353460f8a5b6df36
2019-07-17 06:57:18 -07:00
David Aurelio
59d680f4e9 Upgrade fbjni
Summary:
Upgrades Yoga’s copy of *fbjni* to the latest version.

This will enable us

- to move from `finalize()` to `PhantomReference` to deallocate native memory, with the potential of making GC more efficient.
- to remove the internal dependency to *libfb,* allowing apps without an own dependency to ship less code

Reviewed By: passy

Differential Revision: D16220924

fbshipit-source-id: e8233fe2b5403946ff51f43cb6def558ded52fda
2019-07-17 06:57:18 -07:00
Amir Shalem
be305b5d0f Rename fbjni shared library name to the standard soname
Summary:
Before we can upgrade to latest fbjni, we need to make sure our shared libraries are named the same.

Currently when we compile libfbjni it is named as `liblib_fb_fbjni.so`, where as the regular fbjni is expected to be named as `libfbjni.so`

Reviewed By: davidaurelio

Differential Revision: D16250801

fbshipit-source-id: 9a7f0f803d7e525985b40a49edcc0e660e9025f5
2019-07-17 03:35:31 -07:00
Sidharth Guglani
d676d917e3 moved all yoga node jni batching code to YogaNodeJNIBase and removed subclasses
Summary: Removed classes YogaNodeJNI and YogaNodeJNIBatching and all the logic have been moved to base class

Reviewed By: davidaurelio

Differential Revision: D16221484

fbshipit-source-id: 830819f5bc6010291b8bc0c6d90897cea991909f
2019-07-15 11:16:38 -07:00
Sidharth Guglani
838fc3f019 remove useBatchingForLayoutOutputs config param and start using batching for layout outputs
Summary: Removes config param useBatchingForLayoutOutputs and now we are using batching of layout outputs as float array while passing data from c++ to java

Reviewed By: davidaurelio

Differential Revision: D16221483

fbshipit-source-id: 326c668d4dfd13b2cf031f98a84bfa50b1440513
2019-07-15 11:16:38 -07:00
David Aurelio
296982a29e Enable events in OSS
Summary:
- Events are our new approach to instrumentation, and keeping debug code out of the core library
- This has run internally at FB for some time now
- Enabling for OSS, too, to make Java tests pass

Reviewed By: SidharthGuglani

Differential Revision: D16202541

fbshipit-source-id: c13f5270f04bba59f9f0a06d9c793da92b73d4ff
2019-07-12 01:43:49 -07:00
David Aurelio
1d0668692b Make tests runnable with Buck/OSS again
Summary:
Fixes test execution for open source:

- adds hamcrest jar and dependency, as required by buck (to not throw `"Unable to locate hamcrest on the classpath. Please add as a test dependency."`)
- enables events for OSS, to make tests pass

Reviewed By: SidharthGuglani

Differential Revision: D16202542

fbshipit-source-id: a56069de162f739b3b989961b5dc00f3d37f5849
2019-07-12 01:43:48 -07:00
Sidharth Guglani
39e512f691 Add tests for measure and baseline events
Summary: Add tests for measure and baseline events , same as we had in InstrumentationTests for marker based approach

Reviewed By: davidaurelio

Differential Revision: D16074402

fbshipit-source-id: 8b11cd6468420428701fd5be5c57700cbd913d23
2019-07-10 08:50:44 -07:00
Sidharth Guglani
0f250490d4 add baseline start and baseline end events
Summary: Adds Baseline start and end events to be handled later for instrumentation

Reviewed By: davidaurelio

Differential Revision: D16048790

fbshipit-source-id: 8409dbb633168753a7bf8fab20bc6551d113ddd6
2019-07-10 08:50:43 -07:00
Sidharth Guglani
eeae39d707 move YGMarkerLayout to event based system
Summary: Using layoutPassStart and LayoutPassEnd events instead of YGMarkerLayout for instrumentation

Reviewed By: davidaurelio

Differential Revision: D16048789

fbshipit-source-id: 041a35bc2cb1b7281ca83cf9d35041b4011cfeb9
2019-07-10 08:50:42 -07:00
Sidharth Guglani
ce517689ff add tests for layoutPassStart and layoutPassEnd
Summary: Add tests for layout pass start and end , same as what we had in InstrumentationTests for marker based approach

Reviewed By: davidaurelio

Differential Revision: D16073121

fbshipit-source-id: 838f01cb2a41d2d2764ba7ce2f317147f737b287
2019-07-10 08:50:42 -07:00
Sidharth Guglani
9c82ba783f Adds typed event test data for test cases
Summary: We are now using custom TypedEventTestData for test cases as we need to copy some data passed from the yoga event system

Reviewed By: davidaurelio

Differential Revision: D16090931

fbshipit-source-id: 4d11bdbdd73b67172ad4bba4b294c71f1c24cc10
2019-07-10 08:50:41 -07:00
James Burnett
1c8e8d3aec Compile Issues with Recent GCC (#895)
Summary:
GCC 8.3.0 (and possibly all gcc 7+) identified several warnings for signed unsigned integer comparison. With `-Werror` enabled this broke compiling tests. I suspect the warning is related to google/googletest#683. This diff updates those `ASSERT_EQ` calls that attempt to compare signed and unsigned errors by specifically declaring the literals to be unsigned.

There is also an issue with Buck where it will not link to pthreads. facebook/buck#1443. Adding a `prebuilt_cxx_library` for pthread fixes that issue and the tests will compile and run.

Finally, there was a warning about a missing return after a switch in `InstrumentationTest.cpp`. I added a `return ""` as a default, but it might be better to throw something. Thoughts?
Pull Request resolved: https://github.com/facebook/yoga/pull/895

Reviewed By: davidaurelio

Differential Revision: D15393082

Pulled By: davidaurelio

fbshipit-source-id: 4f13ec2f016af39537c08fb591b188a6a0ed55ce
2019-07-04 19:08:18 -07:00
Uladzislau Paulovich
cc27d85110 Remove incorrect constexpr specifier in YGLayout (#25430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/25430

Pull Request resolved: https://github.com/facebook/litho/pull/561

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

* According to C++ standard values which produce undefined behavior cannot be declared as `constexpr`.
* Expressions which evaluate to `nan, infinity, etc` are undefined behavior.

For more details you can checkout this Stackoverflow answer: https://stackoverflow.com/a/46373136

Reviewed By: davidaurelio

Differential Revision: D16055108

fbshipit-source-id: ee85ba63a714b18bfb8aa8c0770652e184454f74
2019-07-01 08:52:10 -07:00
David Aurelio
cd5324378d Move YG_ENABLE_EVENTS checks to event.h
Summary:
Instead of checking whether `YG_ENABLE_EVENTS` is defined for every publish, we simply wrap the body of the `publish` function macro that delegates to the method that actually publishes the event.

This way we get

1. easier to write code where we publish events
2. more type safety when editing, enabling editors/IDEs to show errors without knowing about `YG_ENABLE_EVENTS`

Reviewed By: SidharthGuglani

Differential Revision: D16049888

fbshipit-source-id: cbf362d6f7be5053c3f377125d303b7137d6a241
2019-06-28 09:58:57 -07:00
David Aurelio
c6ae314202 Stop recording measure callback duration
Summary: Removes time measurements for measure callbacks. This functionality should not be part of Yoga/core, and can now be done by event subscribers themselves, as we have two events per measure callback.

Reviewed By: SidharthGuglani

Differential Revision: D16049812

fbshipit-source-id: e16556f3854e42f4bada39a97a668e718719b22c
2019-06-28 09:58:57 -07:00
David Aurelio
73224c62b5 Publish two events for measure callbacks
Summary: Publishing two events will allow us to replace marker functionality completely with events. This also allows us to remove measuring time spent from Yoga itself.

Reviewed By: SidharthGuglani

Differential Revision: D16049810

fbshipit-source-id: 98628a92ed3c94d479e9fbcd53fac90c5f524087
2019-06-28 09:58:56 -07:00
David Aurelio
2c6a4485f5 Remove duplicate declaration of YGRoundValueToPixelGrid from Yoga-internal.h
Summary:
@public

Removes the declaration of `YGRoundValueToPixelGrid` from `Yoga-internal.h`, as it is already declared in `Yoga.h`. `Yoga.h` is included from `Yoga-internal.h`

Reviewed By: SidharthGuglani

Differential Revision: D16047832

fbshipit-source-id: 72d9d2510372c983eedacc5d7af406b9346f18e6
2019-06-28 05:17:06 -07:00
dattc2
cf005df828 make yoga threadsafe (#852)
Summary:
Continuing https://github.com/facebook/yoga/pull/791
nokia6686 is a former member of our team, so we are trying to pick up what he left and carry out the pull request.
# Solution
Improved from previous solution with jpap's suggestions.
2. Passing ```gDepth``` and ```gCurrentGenerationCount``` (renamed to **_depth_** and **_generationCount_** respectively) between function calls that stem from ```YGNodeCalculateLayout```.
In ```YGNodeCalculateLayout```, pass ```depth``` as value 0, to indicate the root depth.
Pull Request resolved: https://github.com/facebook/yoga/pull/852

Reviewed By: SidharthGuglani

Differential Revision: D15537450

Pulled By: davidaurelio

fbshipit-source-id: 338f51383591ba27702ebe759f6c47c2dede3530
2019-06-25 12:10:23 -07:00
Chris Hopman
f539d68049 Force ordering of :yoga/:yogaForDebug
Summary:
Due to testutil depending on :yoga, we are always linking against both
:yoga and :yogaForDebug in tests. This is only working right now due to luck in
how Buck orders the link line. Adding a dependency is silly but it enforces
that Buck maintain the ordering that we currently have even when it changes how
it does its traversal.

Reviewed By: philipjameson

Differential Revision: D15973581

fbshipit-source-id: 3d18aff578ee4d56175ce5efae52b56aeb2d9586
2019-06-24 17:10:45 -07:00
Sidharth Guglani
39996512fc pass cachedLayout and cachedMeasure measures to plugin
Summary: Passing whether layout cache or measure cache was used or not

Reviewed By: davidaurelio

Differential Revision: D15920937

fbshipit-source-id: a6728e7af07ea228a285f824fbdfddc8130c5990
2019-06-24 08:37:18 -07:00
Sidharth Guglani
2dc5a16d1f Move event NodeLayout to end of NodeLayout step
Summary:
Added event NodeLayoutEnd and this is being used now instead of NodeLayout
It will be used later to add more information about caches

Reviewed By: davidaurelio

Differential Revision: D15920935

fbshipit-source-id: c9f5e193bc8cc70d26ff5d84882d483c9b09f67d
2019-06-24 08:37:17 -07:00
David Aurelio
d667ebd66e Replace relative include
Summary: Replaces the relative include to `YGEnums.h` in `yoga/event/event.h` with `#include <yoga/YGEnums.h>

Reviewed By: SidharthGuglani

Differential Revision: D15778634

fbshipit-source-id: 2bceeb58f26c0d9d0df6c0e7ea20b8ddf68a1ee5
2019-06-21 04:11:36 -07:00
Sidharth Guglani
2b8217ce8d Send measure pass duration
Summary: Send measure callback duration time to yoga plugin

Reviewed By: davidaurelio

Differential Revision: D15917548

fbshipit-source-id: 2c947f14ddbc5932cedd0aab8622260478ec29a6
2019-06-21 02:38:57 -07:00
Stiopa Koltsov
9dac56e824 Migrate Yoga targets to raw_headers
Summary:
In "regular" header mode, Buck will symlink from `buck-out/` to the actual header file. This works fine with GCC and clang, but not with MSVC. Headers will be treated as different file, sidestepping `#pragma once` directives.

As a result, all kinds of symbols get declared twice, leading to compile errors.

Reviewed By: davidaurelio

Differential Revision: D15781947

fbshipit-source-id: a3b4e211b8b74b9ef44fc39471a3009b2cf47260
2019-06-15 12:07:14 -07:00
David Aurelio
a7e8aec3d9 Allow to end markers early
Summary:
Adds the ability to `MarkerSection` to end the marker before it goes out of scope.

This unlocks two scenarios:
- reuse the data associated with a marker after ending it.
- end markers in the middle of a function without adding arbitrary blocks.

Reviewed By: SidharthGuglani

Differential Revision: D15837840

fbshipit-source-id: c0afaeeabd169c65189b5028be54ea7dac3e3b84
2019-06-15 10:26:32 -07:00
David Aurelio
6b5bf570c8 Count the number measure callback invocations
Summary: Counts how many times measure callbacks have been invoked during a layout pass. This is made available via the marker and event APIs.

Reviewed By: SidharthGuglani

Differential Revision: D15836983

fbshipit-source-id: 3835bef94e497375821c9f2ad8209447b4f11518
2019-06-15 10:26:31 -07:00
Sidharth Guglani
a130ac2f9c pass measure callback data from c++ to java
Summary:
Passing Measure callback data - width, widthMeasureMode, height, heightMeasureMode, measuredWidth and measuredHeight along with NodeMeasure event
This data is then propagated to java layer in this diff

Reviewed By: davidaurelio

Differential Revision: D15697523

fbshipit-source-id: 615463da237175ff88abef3f6528b55333ccd915
2019-06-12 00:33:31 -07:00
David Aurelio
19fd066507 Pass layout context for Event::LayoutPassStart
Summary: Adds the layout context pointer when publishing `Event::LayoutPassStart`.

Reviewed By: SidharthGuglani

Differential Revision: D15754425

fbshipit-source-id: 6295ae1ebec9eab72a79c43bc1cb0e05a6d7ae68
2019-06-11 01:41:22 -07:00
David Aurelio
204e849218 rm YogaEventListener
Reviewed By: SidharthGuglani

Differential Revision: D15742456

fbshipit-source-id: b90a221e177e936e141c582500dccf0ac38027c2
2019-06-11 01:41:22 -07:00
Aditya Sharat
8ff13c922a Back out "[litho] Adds check to unset a YogaNode's parent during reconciliation."
Summary: Removes `unsetOwner` from Yoga. This was temporarily for patching a crash.

Reviewed By: colriot

Differential Revision: D15737613

fbshipit-source-id: 8ab93ecf7ffb913df6207fe5db47a8cc93eded2c
2019-06-10 06:57:05 -07:00
Sidharth Guglani
af219f8836 add node layout event and pass it java layer
Summary: Listen to NodeLayout event and passes this event callback to java layer along with the information whether layout or measure was done in this pass

Reviewed By: davidaurelio

Differential Revision: D15696021

fbshipit-source-id: 8c5ca69330a9baca26b77052d4965cc67fe97c75
2019-06-10 01:51:53 -07:00
Aditya Sharat
e33123f955 Adds check to unset a YogaNode's parent during reconciliation.
Summary: Adds check to unset a YogaNode's parent during reconciliation.

Reviewed By: davidaurelio

Differential Revision: D15714899

fbshipit-source-id: 6e2c2a28106574d062fec722c9a051acea87d0b6
2019-06-07 09:28:24 -07:00
Sidharth Guglani
755fa07b39 add node measure event and passing the callback to java layer
Summary: Adds measure event and its listener initial code structure

Reviewed By: davidaurelio

Differential Revision: D15600738

fbshipit-source-id: d15764e0b64edb170fcb15e0912ecce5f7e53595
2019-06-06 21:03:24 -07:00
Sidharth Guglani
2701d80078 passing layout context and getting local reference from it
Summary: We are passing layout context from yoga as event data for Layout Pass End event and it is being then used to get the local reference of node so that we can pass it as method parameter to java layer

Reviewed By: davidaurelio

Differential Revision: D15619640

fbshipit-source-id: 5f6c29d9e6acb73a8d87f8e0cb1577d35a271aeb
2019-06-06 21:03:24 -07:00
Sidharth Guglani
c393ed1381 moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga

Reviewed By: davidaurelio

Differential Revision: D15619629

fbshipit-source-id: 1bf213efd38ec7bcac6a38070f21fa837c5f17da
2019-06-06 21:03:23 -07:00
Rain ⁣
a4bdd9cd9b standardize C-like MIT copyright headers throughout fbsource
Summary:
`/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3

In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf.

Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too.

Reviewed By: zertosh

Differential Revision: D15640366

fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
2019-06-06 19:44:16 -07:00
Joshua Gross
4a4325afb6 Revert D15602627: [yoga] moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Differential Revision:
D15602627

Original commit changeset: bb5bd5bbf8dc

fbshipit-source-id: 5ae08826eb706c3794c36738cb9625f82b58641e
2019-06-03 19:57:53 -07:00
Joshua Gross
586eb6102a Revert D15602923: [yoga] passing layout context and getting local reference from it
Differential Revision:
D15602923

Original commit changeset: 54b25956af09

fbshipit-source-id: 8ce26a7f00d76bd5ade18f32ad14d943118a6f31
2019-06-03 19:57:53 -07:00
Sidharth Guglani
b1e6793460 passing layout context and getting local reference from it
Summary: We are passing layout context from yoga as event data for Layout Pass End event and it is being then used to get the local reference of node so that we can pass it as method parameter to java layer

Reviewed By: davidaurelio

Differential Revision: D15602923

fbshipit-source-id: 54b25956af098700cea25c4f7f8ffe0b9117432c
2019-06-03 16:01:51 -07:00
Sidharth Guglani
8b17459254 moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga

Reviewed By: davidaurelio

Differential Revision: D15602627

fbshipit-source-id: bb5bd5bbf8dcb279f5f87a4fd7287909d4e895d8
2019-06-03 16:01:50 -07:00
David Aurelio
195c166efe Back out "[Yoga] Remove comparison to YGUndefined *and* 0.0f"
Summary: Original commit changeset: 13c8f24e1bc8

Reviewed By: fabiomassimo

Differential Revision: D15583502

fbshipit-source-id: efc6175f6c4925a383fea723195c073f49e2eff1
2019-05-31 15:56:50 -07:00
David Aurelio
0908d3a173 Data structure for exclusive writing
Summary:
Adds a data structure that holds a series of values that can be *borrowed* for exclusive writing.
That means, that only a single consumer can write to any value owned by the data structure.

In addition, the data structure exposes read access via iteration over all contained values.

A typical use case would be a counter with thread-local values that are accumulated by readers in other parts of a programm. The design carefully avoids the use of atomics or locks for reading and writing. This approach avoids cache flushes and bus sync between cores.

Borrowing and returning a value go through a central lock to guarantee the consistency of the underlying data structure.

Values are allocated in a `std::forward_list`, which typically should avoid two values in the same cache line -- in that case, writing to one value would still cause cache flushing on other cores. An alternative approach would be to allocate values continuously on cache line boundaries (with padding between them). We can still change the code if the current approach turns out to be too naive (non-deterministic).

Reviewed By: SidharthGuglani

Differential Revision: D15535018

fbshipit-source-id: 212ac88bba9682a4c9d4326b46de0ee2fb5d9a7e
2019-05-31 09:43:43 -07:00
David Aurelio
f304990656 Use atomic list for event subscribers
Summary:
Replace the *copy on write* vector with an atomic pointer to a linked list.

This allows to publish without locking a mutex, at the cost of the slower traversal of a linked list (a vector has better locality).

At the moment, the typical use case is to have one subscriber, meaning that the afforementioned slower traversal is not a problem.

Adding subscribers is implemented as atomic *compare and swap.*

Reviewed By: SidharthGuglani

Differential Revision: D15546964

fbshipit-source-id: 41bfa41f1ac6be5c9b6bf4288ea3271ee995877e
2019-05-31 01:26:42 -07:00
David Aurelio
cea3865c74 Deprecate YGNode::setConfig
Summary:
We want to phase out usage of config pointers on nodes. Setting configs is no longer needed, as a config is unly used during construction.

Here we deprecate the setter, as it is no longer working as it used to (e.g. changing `useWebDefaults` after a node is constructed).

Reviewed By: SidharthGuglani

Differential Revision: D15416474

fbshipit-source-id: a2cc06cad0c5148cecce056ece5f141b3defe9a9
2019-05-29 07:50:11 -07:00
David Aurelio
b74c0d4766 Remove comparison to YGUndefined *and* 0.0f
Summary: Removes a check introduced in D6969537, comparing `totalFlexGrowFactors` and `resolveFlexGrow` to both `0.0` *and* undefined.

Reviewed By: SidharthGuglani

Differential Revision: D15431425

fbshipit-source-id: 13c8f24e1bc8c49496097a6aa78e20ee5d3964a7
2019-05-22 09:44:36 -07:00
David Aurelio
54e863cef2 Remove YGNode::setAndPropogateUseLegacyFlag
Summary:
`YGNode::setAndPropogateUseLegacyFlag` was only used for debugging purposes.
Here, we replace it with a free function in `Yoga.cpp`.

Now that we have events, the diffing functionality should go into a separate debugging package and be implemented in terms of an event listener. Let's do that as soon as we can support multiple listeners.

Reviewed By: SidharthGuglani

Differential Revision: D15316863

fbshipit-source-id: db929eba7c2de8aa1550e362dd2c175929c0070e
2019-05-21 06:06:37 -07:00
David Aurelio
1938792517 YGNode: Field for web defaults
Summary:
In order to remove the config pointer from nodes, we have to keep track of whether the node is using web defaults.
This information fits into one bit that we can place in padding (i.e. no extra memory needed).

This allows us to get rid of config usage withing `YGNode` with some exceptions:

- `iterChildrenAfterCloningIfNeeded` -- this function will simply receive the configuration, or the cloning callback.
- `setAndPropogateUseLegacyFlag` -- will be removed in D15316863
- in `YGNode::reset` -- will go away utomatically once we remove the config pointer

Reviewed By: SidharthGuglani

Differential Revision: D15391536

fbshipit-source-id: 0fa0d0805c6862bd741fe4a7d9b637ed534f56a4
2019-05-20 10:51:38 -07:00
Sidharth Guglani
aa71dbb5bd mutex lock while accessing event subscribers vector for thread safety
Summary: Using Mutex lock_guard mechanism when writing to subscribers and when accessing them in publish to make a copy

Reviewed By: davidaurelio

Differential Revision: D15391679

fbshipit-source-id: 16713ff28ce1762a5ca4c48c152897a92417e80b
2019-05-19 23:34:41 -07:00
David Aurelio
8dc46c0a87 YGNode: one byte of private storage
Summary:
Adds one byte of private storage to `YGNode`, intended to be used by Yoga itself.

This is in previously unused alignment space, and won’t cause more memory to be allocated.

Reviewed By: SidharthGuglani

Differential Revision: D15296732

fbshipit-source-id: 3caf0a3cd506e4e324e51c31869c69be5781d476
2019-05-16 11:47:30 -07:00
David Aurelio
1180afed9c Fix style property bits
Summary: Style bits had overlap, because `dimensionBit` was set with an incorrect increment.

Reviewed By: SidharthGuglani

Differential Revision: D15335134

fbshipit-source-id: 370e1a73547d76b0e26bc6ab67acb96d33ddf180
2019-05-16 11:47:30 -07:00
Sidharth Guglani
1562bce9b4 use shared_ptr for subscribers vector in event system
Summary:
using shared_ptr for vector of subscribers
Further changes in commit stack support the mutiple subscribers in event system

Reviewed By: davidaurelio

Differential Revision: D15352512

fbshipit-source-id: fac7f4268abf9ca4277734aca2f21cd711eb7d6e
2019-05-15 09:01:06 -07:00
Sidharth Guglani
a9514513a7 use vector for subscribers in event system
Summary:
Replaced global event subscriber with a vector of subscriber functions
Further changes in commit stack support the mutiple subscribers in event system

Reviewed By: davidaurelio

Differential Revision: D15352451

fbshipit-source-id: 7ca6f0943735bf1f76a906c23e15e14ae3c5f42c
2019-05-15 09:01:04 -07:00
Sidharth Guglani
cf809b8e8b added listener in flipper plugin for yoga
Summary:
Adds YogaEventListener interface and it's implementation which will be used in flipper for events coming from Yoga
After this diff , we will start getting layout calculate events in flipper listener

Reviewed By: davidaurelio

Differential Revision: D15316928

fbshipit-source-id: da3a53374a52386037b553d460038d988b0162c2
2019-05-15 01:18:11 -07:00
Yadong Wen
d7ff5c0689 Remove c++1y compiler flag
Reviewed By: meyering

Differential Revision: D15326600

fbshipit-source-id: 837f454ccf27299bc9360174bf54e48e4209bb52
2019-05-14 13:48:02 -07:00
David Aurelio
e3156279fc Travis: Fix C++ compilation
Summary:
@public

Removes the usage of C++14 features, and enforces C++11 via compiler flags.

Reviewed By: SidharthGuglani

Differential Revision: D15334938

fbshipit-source-id: 011764b5f226fef6a35e0c7c1dd170a39ae2261e
2019-05-14 07:45:31 -07:00
gengjiawen
0ce42d83e0 add missing gradle script for windows
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/885

Differential Revision: D15334309

Pulled By: davidaurelio

fbshipit-source-id: c594c0216a967c776606443a50f14e81da228d64
2019-05-14 06:24:18 -07:00
Shawn Presser
afc1108659 Fix cmake build / update CMakeLists.txt to use C++11 (#887)
Summary:
On MacOS, the following steps result in build errors:

```
mkdir build
cd build
cmake ..
make
```

The problem is that yogacore uses C++11 features (`constexpr`) but C++11 isn't specified in CMakeLists.txt.

This PR solves the poblem by adding the following code to the bottom of CMakeLists.txt:

```
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
```

This solution was derived from https://stackoverflow.com/questions/45688522/how-to-enable-c17-in-cmake
Pull Request resolved: https://github.com/facebook/yoga/pull/887

Differential Revision: D15334282

Pulled By: davidaurelio

fbshipit-source-id: a599d8a8f555f7f9cd8dc333e12dc2387d5b2d7a
2019-05-14 05:28:19 -07:00
David Aurelio
a15bf6e701 Publish events for layout pass
Summary:
Adds `LayoutPassStart` and `LayoutPassEnd` events.

The existing `NodeLayout` event in isolation is not as useful as it could be. Having events that mark start and end of a layout pass are a useful addition.

Differential Revision: D15305467

fbshipit-source-id: 14af6f65e698fb1e3112eb2ffd87a74d31df4840
2019-05-10 19:05:07 -07:00
Sidharth Guglani
74fc37efc8 move event files to yoga/events folder
Summary: Moved events files to yoga/events for better code structure

Reviewed By: davidaurelio

Differential Revision: D15198566

fbshipit-source-id: 74d451011841d59fae5a1c637f9c33a7d2d1f87e
2019-05-09 07:46:10 -07:00
David Aurelio
5824dbda66 Publish event when visiting nodes during layout
Summary:
@public

Publish an event when visiting nodes during layouts.

Reviewed By: SidharthGuglani

Differential Revision: D15206965

fbshipit-source-id: c201f084b1d4186bc64560b8033be965f2549236
2019-05-09 04:31:25 -07:00
David Aurelio
e96a09e5ff **breaking:** remove YGNodeGetInstanceCount
Summary:
@public

`YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments.

It was completely replaced with event-based counting for tests.

Here we remove public API around the counter, and the counter itself.

Reviewed By: SidharthGuglani

Differential Revision: D15174857

fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
2019-05-09 04:31:24 -07:00
David Aurelio
9e20dfeea1 Switch tests to test utility for counting nodes
Summary:
@public
replaces the global node counter with the event-based one for all tests.

Reviewed By: SidharthGuglani

Differential Revision: D15174856

fbshipit-source-id: f4401d502bdbaf3b6e4632a4d985aac260cb35a8
2019-05-09 04:31:24 -07:00
David Aurelio
6e04631862 Add test utilities for C++ and Java
Summary:
@public

Test utility on top of the new event system that maintains a counter of instantiated nodes. Meant to replace the global node counter.

Reviewed By: SidharthGuglani

Differential Revision: D15174855

fbshipit-source-id: 6998472f95a09b8da652257a26596164bdcf43d6
2019-05-09 04:31:23 -07:00
David Aurelio
88b23ebb3d Publish events for node allocation and deallocation
Summary:
@public

Publish two events, `NodeAllocation` and `NodeDeallocation`, in the same places where the global node counter is changed.

Reviewed By: SidharthGuglani

Differential Revision: D15174858

fbshipit-source-id: 6e4e9add88513b9e987189ca5035d76da2a1de55
2019-05-09 04:31:23 -07:00
David Aurelio
018916403e Reduce measure cache size to 8
Summary:
@public

Reduces measure cache size to a number that is enough for 95% of nodes, according to our (FB-internal) measurements.

Node size: 776b -> 584b

Reviewed By: SidharthGuglani

Differential Revision: D15183567

fbshipit-source-id: 9ae8cc78074271a015e7618b931ba0356de87a0c
2019-05-09 03:24:31 -07:00
Adrian Zgorzalek
af38fd31f8 Upgrade prettier to 1.17.0
Summary:
Run `js1 upgrade prettier 1.17.0` and `xplat/js/scripts/update-oss-yarn-lockfile.sh` and `hg revert -r .^ xplat/js/rome`

allow-large-files

Reviewed By: zackargyle, pvdz

Differential Revision: D15164375

fbshipit-source-id: 2fe68733dfa93ea64a67d170ba2f80c5af086917
2019-05-07 12:39:46 -07:00
David Aurelio
1e0ebdae2f Remove API to constrain measure cache size
Summary: We conducted an experiment with different measure cache sizes. This has now been deallocatedi (D15183473). Remove the necessary APIs.

Reviewed By: SidharthGuglani

Differential Revision: D15183486

fbshipit-source-id: a38fa5a3ab0321c2521265f7d1cd6b495efd76cf
2019-05-03 05:54:40 -07:00
David Aurelio
1adbafe950 Fix YGConfig constructors
Summary:
@public

`YGConfig::YGConfig(YGConfig*)` was not initializing the same fields as the default constructors.

Here, we make the default constructor delegate to the more specialized one to remove duplication.

Reviewed By: SidharthGuglani

Differential Revision: D15164599

fbshipit-source-id: 27247709091b7664386057d09ac67d481877871f
2019-05-03 05:01:32 -07:00
David Aurelio
e51ca95713 Add foundations for event system
Summary:
@public

We want to enable tooling, instrumentation, and statistics within Yoga without coupling these functionalities to our core code.

This commit introduces the foundations of a simple, global event system.
For the time being, we will only support a single subscriber. Should we require more than one, we can add support for it later.

Reviewed By: SidharthGuglani

Differential Revision: D15153678

fbshipit-source-id: 7d96f4c8def646a6a1b3908f946e7f81a6dba9c3
2019-05-01 17:08:02 -07:00
David Aurelio
a803421739 YGStyle: Make getters/setters template args of BitfieldRef
Summary:
@public

Makes bitfield getters/setters part of the bitfield ref template.
Since we introduced the tracking bit as template parameter in D14933022, every bitfield ref is an individual class anyway, and having function pointers doesn’t potentially lead to less code generation anyway.

Furthermore, this change can (in the absence of tracking bits) avoid less specialized templates dealing with refs, and to dynamic dispatch as a consequence.

Reviewed By: SidharthGuglani

Differential Revision: D15085495

fbshipit-source-id: 0dd70fa05e9d43a29e38a619cddb642c9ca3f7ab
2019-05-01 06:52:55 -07:00
David Aurelio
011c1964a0 Track which style properties have been set on YGStyle
Summary:
@public

In order to optimise property storage, we have to know how style properties are used in our apps.
Here, we add a bitmask that allows us to track which properties are set explicitely, and use that for our analysis.

Reviewed By: SidharthGuglani

Differential Revision: D14933022

fbshipit-source-id: 1ab8af562b14baba1d02057e527aa36d5c9a7823
2019-05-01 06:52:55 -07:00
David Aurelio
05d205cf89 Deduplicate updateStyle overloads
Summary:
@public

The extra overload of `updateStyle` introduced in D15078961 can also handle `BitfieldRef`.
That means that we can remove the more specific implementation previously introduced for `BitfieldRef`

Reviewed By: SidharthGuglani

Differential Revision: D15081069

fbshipit-source-id: 98f1f3478627974c5273c85d268ca07350f303d7
2019-05-01 06:52:54 -07:00
David Aurelio
0a4f7bd558 YGStyle: mutable accessors return Ref instances
Summary:
@public

Change style property accessors to return `Ref` instances instead of references to `CompactValue`.

This will allow to track assignments to properties later on, e.g. for instrumentation or dynamic property storage.

Reviewed By: SidharthGuglani

Differential Revision: D15078961

fbshipit-source-id: 259f05f7d30f093c04bf333c5bd4fb3601b8e933
2019-05-01 06:52:54 -07:00
David Aurelio
cea862a6bf Expose the value type used by YGStyle as ValueRepr
Summary:
@public

Adds `YGStyle::ValueRepr` to make code depending on the actual type easier to write.

So far, we have treated `yoga::detail::CompactValue` as an implementation detail, and that’s what it’s supposed to stay.

React Native Fabric has one value conversion overload that depends on that type, though, and used `decltype(YGStyle{}.margin()[0])` until now.
That’s problematic for two reasons:

- we want to constrain the parameter of `operator[](...)` to enum types, making the `0` unsuitable
- we want to return the non-const overload of the operator to return a custom `Ref` type, which is not the type needed by Fabric.

Making the storage type explicit allows to write more forward-compatible code.

Reviewed By: SidharthGuglani

Differential Revision: D15078960

fbshipit-source-id: 932c27ef2f2cdc6ce965b79894268170f0ccdce5
2019-04-29 09:23:18 -07:00
David Aurelio
cc02a20c9e More constness
Summary:
@public

Some `YGNode*` passed as `const YGNode*`, some const refs to sub-objects introduced.
This helps selecting the desired methods in more places, i.e. `const` overloads of accessors on `YGStyle`.

Reviewed By: SidharthGuglani

Differential Revision: D15078963

fbshipit-source-id: 5013721d6edcc68f42f4504f5c331da647a294bd
2019-04-29 09:23:17 -07:00
David Aurelio
98fda9c587 YGFloatOptional: Move binary operators to free functions
Summary:
@public

Having binary operators as member functions has disadvantages:

- the left hand side cannot be converted to `YGFloatOptional` implicitly (which we need for `YGStyle` refs)
- Operators are not necessarily commutative.

By moving these operators into free functions, and adding overloads for both variants if one operand is `float`, we get these properties.

Reviewed By: SidharthGuglani

Differential Revision: D15078962

fbshipit-source-id: 2e228a2ef90a8083c91788caa9eedfd4d140677f
2019-04-29 09:23:16 -07:00
David Aurelio
2eed95f3e4 YGNodeToString: take const ref to node style
Summary:
@public

Takes a const reference to the style of the printed node once, instead of using repeated calls to `node->getStyle()`.
Makes the code a bit shorter, and ensures that we are operating on `const YGStyle&`, which helps selecting the correct methods further up the stack.

Reviewed By: SidharthGuglani

Differential Revision: D14999094

fbshipit-source-id: 814f06b7e3179ac8cfb43d79fbec48ee4115d6e3
2019-04-26 02:15:06 -07:00
David Aurelio
e5d3baca81 Introduce YGNodeConstRef
Summary:
@public

Introduces `YGNodeConstRef` as `const YGNode*`, i.e. a pointer to a constant `YGNode`.
We also use it for all style getters, which will avoid casts to `const YGNode*` in diffs up the stack.

We should use this pointer type for all functions that do not modify the underlying node.

Reviewed By: SidharthGuglani

Differential Revision: D14999095

fbshipit-source-id: 61cc53bb35e787a12ae12e70438d84c0a4983752
2019-04-23 10:10:24 -07:00
David Aurelio
dee93017f7 YGStyle: wrap all fields into accessors
Summary:
@public

In order to encapsulate property access on `YGStyle`, as a first measure we wrap all fields with accessors.

This will e.g. enable dynamic property storage and instrumentation in the future.

All accessors have a `const` version that allows direct access via `const&`. For mutation, bit fields are wrapped with a custom reference object.

This style allows for the least amount of changes in client code. Property access simply needs appended parens, eg `style.direction` becomes `style.direction`.

Reviewed By: shergin

Differential Revision: D14999096

fbshipit-source-id: fbf29f7ddab520513d4618f5e70094c4f6330b30
2019-04-23 08:17:18 -07:00
David Aurelio
e167642672 Yoga.h: clean up const / extern
Summary:
@public

Remove unnecessary `const` and `extern` specifiers from `Yoga.h`.

- Function declarations are `extern` by default
- The removed `const` specifiers for pass-by-valye parameters are only meaningful for the *definition* of functions, not for the declaration.
In this specific case, I found `const YGNodeRef` particularly confusing, as it is a `typedef` for a pointer type. `const` does not refer to the pointed-to object, but to the parameter itself, i.e. `const YGNodeRef` is `YGNode * const`, and not `const YGNode *`.

Reviewed By: SidharthGuglani

Differential Revision: D14999097

fbshipit-source-id: 8350870cb67f4a34722f796c4f4a2fc7dde41b99
2019-04-23 08:17:16 -07:00
David Aurelio
e9bb1efb03 Code formatting: allow short inline methods on one line
Summary:
@public

This allows short methods defined in class declarations to occupy a single line.
The change makes class declarations more readable.

Reviewed By: SidharthGuglani

Differential Revision: D14950012

fbshipit-source-id: 1321949475184181c6cceb86613f730e430763e2
2019-04-16 07:12:58 -07:00
David Aurelio
3f7d03b443 Define all style getters/setters explicitely
Summary:
@public

For better grepping, we define all `YGNodeStyle...` accessors explicitely. This also replaces all macros with a set of templates that can easily be updated when we switch to style accessors on `YGNode`.

Transitioning to a consistent set of templates also allowed to end up with a single *needs update* / *do update* / *mark dirty* block.

The new template code also takes full advantage of the properties of `YGOptional` (constructor call with *not a number* creates an empty optional) and `detail::CompactValue` (conversions of *auto* and *undefined* are always well-formed) to get rid of some additional code:

Removed `NAN` check:
```
 _YGNodeStyleSetFlex:
 	pushq	%rbp
 	movq	%rsp, %rbp
 	movss	0x34(%rdi), %xmm1
 	ucomiss	%xmm0, %xmm1
 	jne	0x____
 	jnp	0x____
 	ucomiss	%xmm0, %xmm0
 	jnp	0x____
 	ucomiss	%xmm1, %xmm1
 	jnp	0x____
 	popq	%rbp
 	retq
-	ucomiss	%xmm0, %xmm0
-	movd	%xmm0, %eax
-	movl	$0x7fc00000, %ecx
-	cmovnpl	%eax, %ecx
-	movl	%ecx, 0x34(%rdi)
+	movss	%xmm0, 0x34(%rdi)
 	popq	%rbp
 	jmp	0x____
-	nopw	%cs:(%rax,%rax)
-	nop
+	nopw	(%rax,%rax)
```

Removed well-formedness check:
```
 _YGNodeStyleGetPosition:
 	pushq	%rbp
 	movq	%rsp, %rbp
 	movl	%esi, %eax
 	movl	0x68(%rdi,%rax,4), %ecx
+	xorl	%eax, %eax
 	movq	(%rip), %rcx
 	movl	(%rcx), %eax
 	movl	0x4(%rcx), %ecx
-	movq	%rcx, %rdx
-	shlq	$0x20, %rdx
+	shlq	$0x20, %rcx
 	movl	%eax, %eax
-	orq	%rdx, %rax
-	cmpl	$0x3, %ecx
-	je	0x____
-	testl	%ecx, %ecx
-	jne	0x____
-	movl	$0x7fc00000, %ecx
-	jmp	0x____
-	movq	%rax, %rcx
-	movabsq	$-0x100000000, %rdx
-	andq	%rax, %rdx
-	movl	%ecx, %eax
-	orq	%rdx, %rax
+	orq	%rcx, %rax
 	popq	%rbp
 	retq
 	nopw	(%rax,%rax)
```

Reviewed By: SidharthGuglani

Differential Revision: D14911973

fbshipit-source-id: db6eef65f8fdaf70875f7fe8799919ca88bd50ee
2019-04-15 10:51:44 -07:00
Sidharth Guglani
ffce716557 Use only 4 edges for margin, padding, border in YGLayout
Summary:
We were using four edges for margin, padding and border. This diff changes the array size in YGLayout for margin, padding, border to reduce YGNode size and corresponding changes while we are setting values in YGLayout.
Reduces the YGNode size by 24 bytes

Reviewed By: davidaurelio

Differential Revision: D14892666

fbshipit-source-id: 94013d5183ee869901267c4c9941fd94fa05d848
2019-04-15 05:41:59 -07:00
Andres Suarez
fcfb19e9cf Enable black for xplat/yoga
Summary:
This directory was excluded from Black formatting in D14888843 when Black
was turned on for all of `xplat/`. Since there aren't a lot of `.py` files in
this directory, the opt-out is being removed, and the outstanding issues fixed.

Reviewed By: d16r

Differential Revision: D14889104

fbshipit-source-id: 440077c1efcb4c653151bca1da5636212978add5
2019-04-11 05:24:34 -07:00
David Aurelio
c5f105a7b6 JNI: set language level to C++11
Summary:
@public

compiler flags were pushed to C++14, but we don’t currently have any code that requires it. Setting to `-std=c++11` in order to fix the OSS build.

Reviewed By: SidharthGuglani

Differential Revision: D14833737

fbshipit-source-id: df2cd7da8c7124e89863c90d7b77bcf86c495618
2019-04-09 03:12:32 -07:00
David Aurelio
b062d23947 Add -SNAPSHOT to gradle version
Summary:
@public

needed for snapshot releases off of master.

Reviewed By: colriot

Differential Revision: D14833415

fbshipit-source-id: f3b1fb1c41318a9b8f634cd16d37d5e2d050398f
2019-04-08 10:57:18 -07:00
David Aurelio
7fc6fcb38c v1.14.0
Summary:
@public

Push version to *1.14.0.*

This release contains some bug fixes around `align-content`.

Reviewed By: colriot

Differential Revision: D14833417

fbshipit-source-id: f653d5fbb36f307c92b14c091c3206290256f036
2019-04-08 10:57:17 -07:00
David Aurelio
bc7e504b29 Fix bugs around align-content
Summary:
@public

Regenerating the “golden master” tests with chrome surfaced different bugs around `align-content`:

- a misunderstanding that values in `align-content` only applied *if there is only one line.* In fact, it applies *every time* a container is set to `flex-wrap: wrap`. Chrome had this wrong, and as such our tests were generated with incorrect parameters.
- empty children growing to the cross axis size of the container, even when `align-content` is different from `stretch`. This was implemented incorrectly in Chrome as well. Here, we fix it with an extra check.

Reviewed By: SidharthGuglani

Differential Revision: D14725402

fbshipit-source-id: a45bebdadb9c694dc0eb7e27cb52b3d247f81c50
2019-04-08 03:20:27 -07:00
Daniel Büchele
3d8afa9e90 fixing playground links
Summary: Updating links to playgrounds

Reviewed By: davidaurelio

Differential Revision: D14775759

fbshipit-source-id: 8c5c30aa63f2ec2787c1a15a72d09f4e642dd672
2019-04-04 08:52:05 -07:00
Aditya Sharat
a1e47e37ae Add YogaNode.cloneWithoutChildren
Summary: Adding flat clone method back to YogaNode for reconciliation.

Reviewed By: davidaurelio

Differential Revision: D14683019

fbshipit-source-id: 08ed2ffbb16052cb11aa464f67a7ba9a64297985
2019-04-03 11:34:06 -07:00
David Aurelio
e0bc0ebe29 Move YGSetUsedCachedEntries to internal header
Summary:
@public

In order to get out of pre-releases again, we move `YGSetUsedCachedEntries` from `Yoga.h` to `Yoga-internal.h`.
This way, it’s obvious that the function is not public, and we can remove it from future versions without breaking semver contracts.

Reviewed By: SidharthGuglani

Differential Revision: D14726029

fbshipit-source-id: 8d7e747e843bf5c4b5e1d4cfbfa37ca9d240dffb
2019-04-03 08:44:14 -07:00
Pritesh Nandgaonkar
498c0ff4bf New yoga and yogakit pod released
Summary: I have released a new yoga and yogakit pod with 1.12.0-pre.2

Reviewed By: davidaurelio

Differential Revision: D14722676

fbshipit-source-id: 7b379ee41d04a15e25dcb2e992f361d9403269c4
2019-04-02 05:08:05 -07:00
Daniel Büchele
d42d43e90f use tinyURL
Summary: As of today, Google URL shortener is retired. Moving to tinyURL instead. However, tinyURL doesn't support CORS headers, therefore additionally adding a CORS proxy.

Reviewed By: davidaurelio

Differential Revision: D14722636

fbshipit-source-id: 2ec41bb43287102543f1ac31bb76df57d71ba134
2019-04-02 05:03:19 -07:00
Daniel Büchele
bfc6319daa use search instead of hash
Summary:
The state of the playground was stores in a hash appended to the URL. However, tinyURL ignores the hash part of the URL. For this reason, we are using the search part of the URL instead.

Before: `yogalayout.com/playground#ey...`
After: `yogalayout.com/playground?ey...`

Reviewed By: davidaurelio

Differential Revision: D14722638

fbshipit-source-id: ed135f60269e9136bb850c4c661bd88f8ee19323
2019-04-02 04:15:31 -07:00
Sidharth Guglani
74ce5afd9e added flag for useBatchingForLayoutOutputs experiment
Summary:
Using a config flag to switch between different implementations of transferring layout outputs
- YogaNodeJNI uses multiple access of java fields to pass all properties like width, height, margin etc...
- YogaNodeJNIBatching uses a float array to pass all the data in one java field access

Reviewed By: davidaurelio

Differential Revision: D14378301

fbshipit-source-id: 0da5b28e6a67ad8fd60eb7efe622d9b2deaf177f
2019-04-01 06:17:20 -07:00
Sidharth Guglani
c11faf2d56 Added implementation for YogaNodeJNIBatching and logic for passing array from c++ to java
Summary: This diff adds the logic to transfer layout outputs using a float array

Reviewed By: davidaurelio

Differential Revision: D14368120

fbshipit-source-id: d1f22283bcea051d15657f42c15b90edaa0a8a7a
2019-04-01 06:17:19 -07:00
Sidharth Guglani
5fad8008ab added test for reset method in YogaNodeJNI to verify all layout outputs are reset properly
Summary: This diff adds a test for reset method in YogaNodeJNI to verify all layout outputs are reset properly

Reviewed By: davidaurelio

Differential Revision: D14643926

fbshipit-source-id: fffbcd07ccb6d2df83fc0bf187d992ef194f3bd0
2019-04-01 06:17:19 -07:00
Sidharth Guglani
948ade4b1c moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14642995

fbshipit-source-id: 5d0bc7fa18c1985be7e216d7351f5eab2e03861d
2019-04-01 06:17:19 -07:00
David Aurelio
b1a7f2b4d9 gentest: Fix editing messup
Summary:
@public

Messed this one up when fixing the test generation script.

Reviewed By: SidharthGuglani

Differential Revision: D14684224

fbshipit-source-id: 2696ce9ff7d825d00c7ad1ab1627a5ffe56d123f
2019-03-29 10:22:31 -07:00
Pritesh Nandgaonkar
d44a6d936f Release a new version to cocoapods
Summary: Xcode 10.2 drops the support of swift version 3.0. Thus updated the swift version and also the yoga dependency.

Reviewed By: SidharthGuglani

Differential Revision: D14684332

fbshipit-source-id: d42e5979639c9fceec81627d4ac153566c2c0ab1
2019-03-29 10:08:10 -07:00
David Aurelio
1fc8472d35 gentest: allow for different default values
Summary:
@public

We use Chrome for generating test cases, which since v67 (or so) for `min-width` and `min-height` has a default value of either `0px` (CSS 2) or `auto` (CSS 3), depending on style properties.

Our setup only allowed for a single default value, and our test cases produce *both.*
This changes the test gen logic to allow for more than one value.

Reviewed By: SidharthGuglani

Differential Revision: D14682387

fbshipit-source-id: e76361f5cc0b88f9c2d74a5f3248c66abd6907a7
2019-03-29 06:32:21 -07:00
David Aurelio
c235301b52 gentest: remove empty line after license
Summary:
@public

This gets flagged by the linter. Remove it.

Reviewed By: SidharthGuglani

Differential Revision: D14682386

fbshipit-source-id: 612508b0906285e6420a553ac7a96d1024f1eac6
2019-03-29 06:32:20 -07:00
David Aurelio
2fb81500c1 gentest: adapt license
Summary:
@public

Adapts the license header text to the format we currently use.

Reviewed By: SidharthGuglani

Differential Revision: D14653591

fbshipit-source-id: f79446e4f85623326f770fe73482eab00edd9234
2019-03-28 04:47:56 -07:00
Alexander Vasyuk
68d9209dd9 Revert D14368107: [yoga] moved all the properties used for layout outputs to YogaNodeJNI
Differential Revision:
D14368107

Original commit changeset: 75ca330c1e7f

fbshipit-source-id: 9a9f5140bf8b1563c9ba85b3fe5f93fc6d8fdf41
2019-03-26 20:21:24 -07:00
Alexander Vasyuk
e91569cdad Revert D14368114: [yoga] removing unused const int
Differential Revision:
D14368114

Original commit changeset: f63b978813a0

fbshipit-source-id: 86a517b1483b0635f283702602712c42c3d51e20
2019-03-26 20:21:23 -07:00
Sidharth Guglani
f31917aa01 removing unused const int
Summary: Removed unused const int

Reviewed By: davidaurelio

Differential Revision: D14368114

fbshipit-source-id: f63b978813a01a37710fac299dc7ec9aff610844
2019-03-26 08:51:41 -07:00
Will Wilson
74202aecff Adds workspace for more efficient yoga development
Summary: This workspace should ease yoga development

Reviewed By: dinhviethoa

Differential Revision: D14600002

fbshipit-source-id: 49f6d36680acad5835fcf96e80bcd547b667c0c8
2019-03-26 07:43:30 -07:00
Sidharth Guglani
9c2108c69e moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368107

fbshipit-source-id: 75ca330c1e7f07adc0ab8e7a5927d93977088918
2019-03-26 07:35:17 -07:00
David Aurelio
3d2836a947 CompactValue overrides of YGResolveValue/YGValueEqual
Summary:
@public

I would like to get rid of implicit conversions between `YGValue` and `CompactValue`, because they don’t come for free.

That’s why I am adding `CompactValue` specific overrides for `YGResolveValue` and  `YGValueEqual`, that do explicit casts. Up the commit stack, we will be able mark both `CompactValue(const YGValue&)` and `CompactValue::operator YGValue()` as `explicit`.

Reviewed By: SidharthGuglani

Differential Revision: D14598447

fbshipit-source-id: 75dc15cefb2dddcf8def891c5fb37893cacd9d46
2019-03-26 05:21:35 -07:00
David Aurelio
e4856a2264 Remove duplicated function declaration
Summary:
@public

Just removes a duplicated function declaration.

Reviewed By: SidharthGuglani

Differential Revision: D14598446

fbshipit-source-id: b4d8fe192f9a07f512f6a346f27d9046bb3bae23
2019-03-26 05:21:35 -07:00
Sidharth Guglani
a2ee0f65bd fixed @Nullable missing infer errors
Summary: Fixed Nullable lint errors

Reviewed By: davidaurelio

Differential Revision: D14383930

fbshipit-source-id: 0847e19c50a0b8d4039199045b74aa86c96ac096
2019-03-25 06:36:28 -07:00
David Aurelio
85352c4e45 Automatic lint fixes
Summary:
@public
A round of automatic lint fixes.

Reviewed By: SidharthGuglani

Differential Revision: D14590396

fbshipit-source-id: f0b4a0ce503a1d9d46ea7ae788f9f2eac09c2ac7
2019-03-25 05:41:30 -07:00
David Aurelio
7d7b7b9e18 Sample workspace: remove XML comment
Summary:
@public

Xcode does not like it

Reviewed By: astreet

Differential Revision: D14580168

fbshipit-source-id: 6d26b3961b45a59ef9dc977b21493e60e3cf9396
2019-03-22 11:46:58 -07:00
David Aurelio
62d8a911ff Switch style getters to JNI fast calls
Summary:
@public

After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.

Reviewed By: pasqualeanatriello

Differential Revision: D14576815

fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
2019-03-22 10:36:56 -07:00
David Aurelio
ca46c67e9e Create YogaValue instances in Java, not C++
Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
2019-03-22 10:36:55 -07:00
David Aurelio
5bb2265083 Move native methods to a single class
Summary:
@public

Moving all native methods in a single class provides the benefit of not having to load native bindings eagerly when just creating config objects in the startup paths, or setting Java-only values on them.
Loading native bindings triggers additional class loads (`YogaConfig` / `YogaNode`), and can lead to problems in multi-dex scenarions.

Reviewed By: pasqualeanatriello

Differential Revision: D14560658

fbshipit-source-id: 14e31e3c3b560675b5a752a38ae75ab80a565ea1
2019-03-22 09:33:37 -07:00
David Aurelio
ab3bf40c7d Fix license headers
Summary:
@public

Yoga's Java license headers were not in the correct format.

Reviewed By: muraziz

Differential Revision: D14541087

fbshipit-source-id: 5b3cff398875bd59dadeaddbb43020700ef027e2
2019-03-21 04:56:49 -07:00
Sidharth Guglani
f273e80c77 created a new class YogaNodeJNI which extends YogaNodeJNIBase and using YogaNodeJNi for new object creation
Summary:
Added a child class of YogaNodeJNIBase which will be used to separate layout outputs transfer logic.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368098

fbshipit-source-id: e0f10fb61cd09ee47cf9ce41fb400f4cfb3dd795
2019-03-20 08:57:13 -07:00
David Aurelio
1471be54e3 JNI: Simplify node context
Summary:
@public
Contexts of nodes only hold a bit mask after we got rid of weak JNI refs.
We can simply store that data in a pointer-sized unsigned int.

Here, we replace all context heap allocations with usage of the node context (`void *`) as bitmask. We also add a couple of utility operators in order to keep the code comprehensible.

Reviewed By: fabiomassimo

Differential Revision: D14425742

fbshipit-source-id: f32c2184a1f09268c39dbb8cd09ac96517339674
2019-03-20 08:42:24 -07:00
Sidharth Guglani
f039835249 renamed YogaNodeJNI to YogaNodeJNIBase
Summary:
Renamed class from YogaNodeJNI to YogaNodeJNIBase.
This change set is for adding experiment for layout outputs batching using a float array where we will have two separate classes which will override how layout outputs are transferred to java YogaNode object.

We needed two separate classes because having everything in one class was causing memory issues as both the individual fields for width, height etc. and float array for batching needs to be present in code.

Reviewed By: davidaurelio

Differential Revision: D14368069

fbshipit-source-id: 0e98e28c8c7a9788345ccb92b2cd0f2cd4a53525
2019-03-20 07:53:48 -07:00
Yedidya Feldblum
f793ba2d6b Upgrade mobile BUCK and .bzl files to use C++14
Summary:
Upgrade mobile `BUCK` and `.bzl` files to use C++14.

Let's see what happens.

Reviewed By: mzlee

Differential Revision: D14223329

fbshipit-source-id: ff642ca017103d9415c4d7f5beaf5ded07ef7ff1
2019-03-16 02:25:21 -07:00
Peter van der Zee
9f72ad05ce Bump Prettier to 1.16.4
Summary:
@public
This bumps Prettier to v1.16.4
Only format source files were updated.

Reviewed By: mjesun

Differential Revision: D14454893

fbshipit-source-id: 72f9872fe764a79dbf0d9fab9bebb1456b039f2f
2019-03-14 07:00:56 -07:00
Eric Schlanger
14f3827491 Exclude logging functionality outside debug builds
Summary: Don't compile in YGNodePrint in production builds

Reviewed By: davidaurelio

Differential Revision: D14258269

fbshipit-source-id: 15b5e94d241a752fea74a45263aa343265071451
2019-03-13 07:52:26 -07:00
Sidharth Guglani
0d96098fd9 moved together the java object fields which are set always
Summary:
Moved all layout outputs fields which are set always on yoga node java object.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14355025

fbshipit-source-id: 371d9c49fcb631efa8a79b62f8051ba5a17c232c
2019-03-13 06:28:05 -07:00
Sidharth Guglani
42e3b78f04 change BOrder constant to 4 to set correct field bits
Summary: These constants are used for setting bit fields so they should be in power of 2

Reviewed By: davidaurelio

Differential Revision: D14384999

fbshipit-source-id: fa1f6994c874aff7a039ca98d5947cba317fa749
2019-03-13 03:20:25 -07:00
David Aurelio
3ad49d27d9 Remove configuration for avoiding JNI refs
Summary:
@public

Removes the configuration field to avoid weak JNI refs. It is no longer used.

Reviewed By: marco-cova

Differential Revision: D14424594

fbshipit-source-id: f0877022615a11ac5079354e0977c6893b7d58d7
2019-03-12 13:19:02 -07:00
David Aurelio
3331a9e480 No more weak JNI refs!
Summary:
@public

Completely removes the usage of weak JNI refs.

This is great, because node allocation and deallocation no longer go through a VM-global lock to access the weak reference table.
This is also great, because we can no longer overflow that ref table.
Performance is comparable to weak refs.

Reviewed By: marco-cova

Differential Revision: D14423068

fbshipit-source-id: 62003d2d6fd971e91460a26fb3477046f26e2ba5
2019-03-12 13:19:02 -07:00
David Aurelio
7890672ecc Fix Xcode Workspace
Summary: Turns out Xcode does not like document-level comments.

Reviewed By: SidharthGuglani

Differential Revision: D14301138

fbshipit-source-id: f515a1881daa109031963688c1556cb8ef42758f
2019-03-04 09:11:17 -08:00
Sidharth Guglani
d7bfbf3646 bump yoga version to 1.13.1-SNAPSHOT
Summary: Version bump to 1.13.1-SNAPSHOT

Reviewed By: davidaurelio

Differential Revision: D14300336

fbshipit-source-id: 2c0293d5eb95dc029d431133ce97e75fccd46897
2019-03-04 08:29:28 -08:00
Sidharth Guglani
6d271c05f6 update yoga version to 1.13.0
Summary: Bump yoga version to 1.13.0

Reviewed By: davidaurelio

Differential Revision: D14300306

fbshipit-source-id: 2865462731bcea7666ea14768dd6eb1a112944a9
2019-03-04 07:42:35 -08:00
David Aurelio
a9bddf87ff Fix problems with GCC < v8
Summary:
@public

GCC up until v7 flags our way of reading edges in `YGNodeSetStyleInputs` as unused variables. I managed to work around that by rearranging the casts a bit.

Reviewed By: SidharthGuglani

Differential Revision: D14299439

fbshipit-source-id: eec0266185504d1b790b9ef574bd4a83c0059d3a
2019-03-04 02:37:17 -08:00
David Aurelio
88994129ae 1.12.0-pre.1 (#865)
Summary:
Push version in podspec. We will use `-SNAPSHOT` for bintray
Pull Request resolved: https://github.com/facebook/yoga/pull/865

Differential Revision: D14299474

Pulled By: davidaurelio

fbshipit-source-id: e788479677e1b3c4155a24a336e625508e085f86
2019-03-04 01:34:36 -08:00
David Aurelio
888892885e Encapsulate all used java classes
Summary:
@public

Moves all Java classes used from C++ to their own header + implementation file. In `YGJNI.cpp`, we only call methods on these objects deriving from `jni::JavaClass`.

This is only a bit of cleanup, no functional change.

Reviewed By: SidharthGuglani

Differential Revision: D14261043

fbshipit-source-id: 2db1d81cb7f56a4cdc24b182b2166e1d7e24ba3c
2019-03-04 01:30:15 -08:00
David Aurelio
de79f2a1d4 for experimentation: configurable measure cache size
Summary:
@public

Allows to limit the number of measure cache entries used. This is purely for experimentation.

The measure cache uses about half of every `YGNode`. Reducing its size would allow us to reduce resident memory used by Yoga.

Reviewed By: SidharthGuglani

Differential Revision: D14279027

fbshipit-source-id: e0d22138230bee7fb129c193eb6e4085de02a36e
2019-03-02 12:43:01 -08:00
David Aurelio
6368416178 clean up config context
Summary: `YGConfigContext` was using `global_ref` instances for the config, leading to the config object never being freed. Since we no longer need it after getting rid of cloning, we can make the context a pointer to a `global_ref` to the logger.

Reviewed By: SidharthGuglani

Differential Revision: D14258571

fbshipit-source-id: cce632499839a680eef00a3854f61ab74ae2a87a
2019-03-01 05:45:15 -08:00
David Aurelio
a935a222b5 YGNode remove assignment operators
Summary:
@public

Having assignment operators for `YGNode` means that existing children on the node assigned to would have to be handled somehow.

Deallocating might be incorrect. Ignoring might leak.

Here, we `delete` copy assignment, and make move assignment private (it is used in `YGNode::reset()`).

Copy and move constructors *can* be implemented. The move constructor has to take ownership of the children, while the copy constructor leaves ownership untouched. Since children are copied lazily during layout, this does not expose true value semantics. We should consider removing the copy constructor, too.

Reviewed By: SidharthGuglani

Differential Revision: D14241663

fbshipit-source-id: 39ffdb07f1028bfcf2710c0674a06cdebf3bd650
2019-03-01 04:22:04 -08:00
Sidharth Guglani
7c4da0a341 added positive tests for all style inputs in batching API
Summary: Positive tests for all style input properties using JNI batching API

Reviewed By: davidaurelio

Differential Revision: D14207552

fbshipit-source-id: b7165c2115ace67bf131c76929d37df438921bf2
2019-02-28 12:52:01 -08:00
Sidharth Guglani
b047af25ca Setting flags for margin, padding, position and border
Summary:
We set flags to true when setting margin, padding, border, position individually
Doing the same for batching API

Reviewed By: davidaurelio

Differential Revision: D14207550

fbshipit-source-id: ddfdcd5056bea0dd76bd6762f47e90370e26c9e1
2019-02-28 12:52:01 -08:00
Sidharth Guglani
2abd9dd91b Added getters for flexWrap and flex style inputs in java bindings
Summary: Added getters fro flexWrap an flex style input properties in java bindings

Reviewed By: davidaurelio

Differential Revision: D14207517

fbshipit-source-id: e8d2ad17b5edbdf02e69011c6d95a4de076bd366
2019-02-28 12:52:01 -08:00
Sidharth Guglani
afadc5cf6b JNI batching API using float array
Summary:
Added a new API `YGNodeSetLayoutStyleInputs` to pass layout style inputs from java to native code.
All the style inputs are passed in a float array in [key1, key2, value2, key3, value3a, value3b .....] format over JNI layer.
There are three types of style inputs
- do not need any value to be passed along with them like WidthAuto, HeightAuto
- need one value to be passed like Width, Height
- need two values to be passed like Margin, Padding (edge value and actual margin, padding value)

Reviewed By: davidaurelio

Differential Revision: D14166948

fbshipit-source-id: 4bea64d6a429959c3962c87e337914dcd99199fd
2019-02-28 12:52:01 -08:00
Sidharth Guglani
8823cc357a added mEdgeSetFlags inside YogaNodeContext and using it YGJNI in getters/setters of margin, padding, border
Summary:
We have now create a yoga node context which consists of weak reference to java yoga node object and flag which tells us whether margin, padding , border are set or not.

This flag was initially in java layer and we have moved this to native layer as it will help us with enabling the bacthing API for setting style inputs.

Reviewed By: davidaurelio

Differential Revision: D14243378

fbshipit-source-id: fed935ef18c1abf2b07e5d69d9ca79ced51699f2
2019-02-28 12:52:01 -08:00
Sidharth Guglani
8b8d9a05b7 not setting flags when setting margin, padding, border and position on yoga node
Summary: We are now not setting flags when we set style inputs margin, padding, border and position on yoga node.

Reviewed By: davidaurelio

Differential Revision: D14224000

fbshipit-source-id: deef4c1ab1a60fbc4909183bc2aa59fa23939d43
2019-02-28 12:52:01 -08:00
David Aurelio
15668aceb6 Move reset logic to YGNode::reset()
Summary:
@public

Moving logic from free C functions to the C++ layer.

This will allow us to get rid of the dangerous copy / move assignment operators of `YGNode`.

Reviewed By: SidharthGuglani

Differential Revision: D14241564

fbshipit-source-id: aae9f2a7ffd23bb839f1747e4a0694578bae86ae
2019-02-28 06:31:34 -08:00
David Aurelio
e25fe994b3 Breaking remove YogaNode#clone
Summary:
@public

The cloning features of YogaNode don’t seem to be used. Let’s remove them.

Reviewed By: SidharthGuglani

Differential Revision: D14165624

fbshipit-source-id: 5b710964a4abf1b35f3bcc25b143ffc719a03cec
2019-02-27 04:43:34 -08:00
Chris Sarbora
47abe1c482 Rename makeCriticalNativeMethod to discourage over-use
Summary: "Critical" or "Fast" JNI methods are enticing by their name, but carry dangers that are not trivially visible.

Reviewed By: davidaurelio

Differential Revision: D14184560

fbshipit-source-id: 89ec70f53bb2cb89ff568d8b1fe222ede86c9824
2019-02-22 14:30:35 -08:00
David Aurelio
95169c3150 Don't call jni_YGNodeFree as fast native method
Summary:
@public

If `jni_YGNodeFree` is called while GC is running, the weak reference table lock is held by the GC, leading to deadlock.

Here, we revert the method to being a regular native method, solving that problem.

Reviewed By: SidharthGuglani

Differential Revision: D14184220

fbshipit-source-id: 2882fa10586617cea2df99550a7dd8885376d11e
2019-02-22 08:59:35 -08:00
David Aurelio
7331de78bd setBaseLine -> setBaseline
Summary:
@public

`setBaseLine` was the only place where we used a capitalised *L.* Fixed here.

Reviewed By: SidharthGuglani

Differential Revision: D14152320

fbshipit-source-id: abf54fe7d6088e03775968baa8421c4bf43d6a6e
2019-02-21 05:38:45 -08:00
David Aurelio
05f36a835a Allow to use JNI without global refs
Summary:
@public

Adds the ability to opt into avoiding global weak JNI refs via `YogaConfig`.

Note that only homogeneous trees are supported, i.e. **mixing weak-ref and non-weak-ref nodes will break!**

Not using JNI refs hopefully will help with avoiding JNI reference table overflows, and will help creating trees on multiple threads, as no lock has to be acquired at any time.

Reviewed By: SidharthGuglani

Differential Revision: D14151037

fbshipit-source-id: 56d94713d39aee080d54be4cb4cdf5e3eccb473a
2019-02-21 05:38:45 -08:00
Michael Lee
dcd9438488 Clean up unnecessary header glob
Reviewed By: davidaurelio

Differential Revision: D13509119

fbshipit-source-id: 35d32c82b4fbaf7529828982e69b15e1c61b9e25
2019-02-20 16:53:40 -08:00
David Aurelio
d38db1292c Use YGNodeRemoveAllChildren where appropriate
Summary:
@public

`YGNodeRemoveAllChildren` can be used instead of removing children of a yoga node in a loop.

Reviewed By: zats

Differential Revision: D14131679

fbshipit-source-id: 6ee31f1e288b9b161c641b5bca4f2c1156d58c38
2019-02-20 12:35:27 -08:00
David Aurelio
4463fe0856 Add config for avoiding JNI refs
Summary:
@public

Adds `YogaConfig#avoidGlobalJNIRefs` to control whether nodes created with a config will use weak global JNI refs. Used for experimentation.

Reviewed By: SidharthGuglani

Differential Revision: D14149982

fbshipit-source-id: c777c8b3af2167d96154db5aa6afec1476dac35b
2019-02-20 12:01:15 -08:00
David Aurelio
2156de5fb5 Add support for context-aware cloning functions
Summary:
@public

Context-aware cloning functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to cloning functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14149470

fbshipit-source-id: 1d11106e65f9d872d10f191763da001f8d158a61
2019-02-20 12:01:14 -08:00
David Aurelio
b1c749075d Clone children only during layout, allow mixing shared + owned children
Summary:
@public

Limit child cloning to layout calculation. This also allows for mixing shared and owned children.

Rationale:
We do allow for shared children if the caller manages themselves. The single known use case is React Native.

So far, we have cloned children eagerly whenever child lists are mutated, or layout is run. This was to allow for a quick check of the owner of any first child, assuming that either *all* or *no* child of a node are shared.

For Yoga/Java, we want to get rid of global weak JNI refs, and these are also used to invoke clone callbacks. We can achieve that goal by switching to an alternative approach, passing additional data to the layout pass. This additional data has to be passed to any configured cloning callback. Therefore, it is desirable to **only call cloning functions during the layout pass.**

The obvious solution seems to be to not uphold the invariant of the first child determining shared/owned state of all siblings, and allow for a mix of shared and own children.

Reviewed By: shergin

Differential Revision: D14136223

fbshipit-source-id: 34490cfeeb2170c99d6ed1b9bdcbcedb316813af
2019-02-20 12:01:14 -08:00
David Aurelio
367a93de88 Move node cloning to YGConfig
Summary:
@public

Encapsulates node cloning within `YGConfig`.
This is necessary for allowing for context-aware cloning functions, which will ultimately allow for removal of weak global JNI references.

Reviewed By: shergin

Differential Revision: D14132608

fbshipit-source-id: 0dec114c8e172b1e34a4b7fd146c43f13c151ade
2019-02-20 12:01:14 -08:00
David Aurelio
2643b96589 Extract abstract class YogaNode
Summary:
@public

Here, we extract an abstract class from `YogaNode`, in order to allow for experimentation with different implementations.

The reason for not choosing an interface is to keep ABI compatibility for `YogaNode.create()`.

Reviewed By: pasqualeanatriello

Differential Revision: D14044990

fbshipit-source-id: f8eb246338b55f34f0401198c0655abfcb7c9f37
2019-02-19 11:19:10 -08:00
David Aurelio
016a10df26 Switch to YogaNode.create()
Summary:
@public

Switches instance creation from `new YogaNode()` to `YogaNode.create()`.

This allows for experimentation with different implementations, while maintaining API + ABI compatibility internally at FB, as well as for dependent projects in open source and elsewhere.

Reviewed By: amir-shalem

Differential Revision: D14122975

fbshipit-source-id: f194b146b7cd693dba1a7dafdf92d350e54cb179
2019-02-19 11:19:10 -08:00
David Aurelio
cbcf07f08a Add support for context-aware print functions
Summary:
@public

Context-aware print functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14131098

fbshipit-source-id: 7a9da307274ceccba9f7debba581b70c1ebf2c98
2019-02-19 09:58:43 -08:00
David Aurelio
59bcac3289 Make node printing private
Summary:
@public

Removes `YGNodeGetPrintFunc`, and encapsulates node printing within `YGNode`.
This is necessary for allowing for context-aware callback functions, which will ultimately allow for removal of weak global JNI references.

On a side node, the printing logic does not seem to be well thought through: print functions print as a side effect to whatever output they choose. Printing that uses callbacks is printing to different output streams or strings, though.

We need to consolidate Yoga debugging, and make it all more stringent.

Reviewed By: SidharthGuglani

Differential Revision: D14131024

fbshipit-source-id: 68704682dab3e7dfba61930bb03003d7d4723b80
2019-02-19 09:58:43 -08:00
David Aurelio
bd90192df9 Allow to calculate layout with context
Summary:
publc

Adds the ability to calculate layout with a context pointer set.

The context is passed through to measure and baseline functions of individual nodes.

This will be used to remove the necessity of holding weak global JNI references for each node.

Reviewed By: SidharthGuglani

Differential Revision: D14101426

fbshipit-source-id: 25047e1e44af48feb22ea686285d70803e8961bb
2019-02-19 09:58:42 -08:00
David Aurelio
e7fcf1ee65 Add support for context-aware measure and baseline functions
Summary:
@public

Context-aware measure and baseline functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14100509

fbshipit-source-id: acf4a030549b2e38d5ce0cd5dbe837864e5ffd81
2019-02-19 09:58:42 -08:00
David Aurelio
f86c74ce7e Call measure and baseline fns within YGNode
Summary:
@public

Stricter encapsulation of baseline and measure callbacks withing `YGNode`.

Instead of invoking these callbacks directly (`node->getBaseline()(...)`), they are invoked via methods on `YGNode` (`node->baseline(...)`).

This change will allow us to add the concept of a *Layout Context,* where measure and baseline functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows.

Changed API:

- `YGNodeGetMeasureFunc()` -> `YGNodeHasMeasureFunc()`
- `YGNodeGetBaselineFunc()` -> `YGNodeHasBaselineFunc()`
- `YGNode::getMeasure()` -> `YGNode::hasMeasureFunc()` + `YGNode::measure()`
- `YGNpde::getBaseline()` -> `YGNode::hasBaselineFunc()` + `YGNode::baseline()`

Reviewed By: SidharthGuglani

Differential Revision: D14099550

fbshipit-source-id: 2653ab36acc252a9747986bc88d21dac22d8c91b
2019-02-19 09:58:42 -08:00
David Aurelio
d5ad51bccc Add support for context-aware logging functions
Summary:
@public

Context-aware logging functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14123482

fbshipit-source-id: 8ba3b6c493bf79fe09831f22d2b6da44f09e3d95
2019-02-19 09:58:42 -08:00
David Aurelio
0bdf36f5d1 Call logger from within YGConfig
Summary:
@public

Stricter encapsulation of logging callbacks within `YGConfig`.

Instead of invoking the logging callback directly (`node->logger(...)`), callers now have to go through `YGConfig::log()`.

This change will allow us to add the concept of a *Layout Context,* where logging functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows.

Changed API:

- `YGConfig::logger()` -> `YGConfig::log()`

Reviewed By: SidharthGuglani

Differential Revision: D14123483

fbshipit-source-id: 87b8bb7de0e4346b6a41e57a70ac4eb8d79b24af
2019-02-19 09:58:42 -08:00
David Aurelio
1b9053bc5d Make logging private
Summary:
@public

Makes logging implementation internal to Yoga.

Breaking changes: removed  `YGLog` and `YGLogWithConfig`.

The upcoming changes to the JNI layer (removal of weak global refs for each node) requires adding additional parameters to the logging functions that will only be available when calculating layout.

Reviewed By: SidharthGuglani

Differential Revision: D14123390

fbshipit-source-id: 468e4a240c190342868ffbb5f8beb92324cdfdd6
2019-02-19 09:58:42 -08:00
Yuichi ONO
446101a168 flexWrap should be kebab-case inside inline-style (#761)
Summary:
Inside css inline style, it should be spelled as `flex-wrap`.
Pull Request resolved: https://github.com/facebook/yoga/pull/761

Reviewed By: davidaurelio

Differential Revision: D14100508

Pulled By: SidharthGuglani

fbshipit-source-id: 65ebc984d959555107d58ad16ca27b2b8b4d0874
2019-02-19 04:56:36 -08:00
Leandro Ostera
f0324035bf Fix small typos (#784)
Summary:
Hello! Just found some typos on the docs. Fixing them here :)
Pull Request resolved: https://github.com/facebook/yoga/pull/784

Reviewed By: davidaurelio

Differential Revision: D14100968

Pulled By: SidharthGuglani

fbshipit-source-id: 1462216a0d5315075871f2fb11b6b1279ae0097a
2019-02-19 04:48:35 -08:00
David Aurelio
a2f94cbf9a Add -SNAPSHOT to version
Summary: Adds the `-SNAPSHOT` specifier back to the version number in `gradle.properties`

Reviewed By: SidharthGuglani

Differential Revision: D14123308

fbshipit-source-id: e5d4c4dd9552557dc42440f0892c1452dd0195a5
2019-02-18 05:35:54 -08:00
David Aurelio
d21fa68033 Bump version to 1.12.0
Summary:
@public

For `YogaNode.create()`

Reviewed By: amir-shalem

Differential Revision: D14122976

fbshipit-source-id: 5e2fe4f2039d700be6eefff2401b4333fdca3dd2
2019-02-18 03:08:14 -08:00
David Aurelio
5a6d84abc9 Add YogaNode.create()
Summary:
Adds a factory method to `YogaNode`.

While this is purely redundant at the moment, it will allow experimentation in follow-up diffs. We will have concrete implementations deriving from `YogaNode` (which will be abstract).

Going through `YogaNode.create()` means that we can maintain ABI compatibility.

Reviewed By: amir-shalem

Differential Revision: D14122974

fbshipit-source-id: 15d92f296d91cc8bbd79a196f370d2dbb69b3f92
2019-02-18 03:08:14 -08:00
Sidharth Guglani
61ae484316 Pin cmake version to 3.6
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/861

Reviewed By: davidaurelio

Differential Revision: D14081865

Pulled By: SidharthGuglani

fbshipit-source-id: 98bce25cfdd397f48beee64f114c85460b6d81fe
2019-02-14 09:35:02 -08:00
Sidharth Guglani
42657017bd bump version to 1.11.1-SNAPSHOT
Summary: bump version 1.11.1-SNAPSHOT

Reviewed By: davidaurelio

Differential Revision: D14042030

fbshipit-source-id: 0d9ef91013454311d038c23124571d1093471c9b
2019-02-12 06:17:36 -08:00
Sidharth Guglani
9b9a344934 updated gradle build tool version to 3.1.0 and gradle to 4.6
Summary: Upgraded gradle build tool version to 3.1.0 to solve issue "No toolchains found in the NDK toolchains folder for ABI with prefix: mips-linux-android"

Reviewed By: davidaurelio

Differential Revision: D14042022

fbshipit-source-id: c615127fa296f30f589b183bffc8f2a95f7b943b
2019-02-12 05:35:32 -08:00
Sidharth Guglani
5f92ba49a7 yoga bump version 1.11.0
Summary: Yoga release 1.11.0

Reviewed By: davidaurelio

Differential Revision: D14025465

fbshipit-source-id: e76c79898ed212ad8450f261822ed0d84a6ca14b
2019-02-12 04:39:22 -08:00
Pritesh Nandgaonkar
2e564c21cd Fixed the build issue for oss
Summary:
Our OSS build was failing with the latest version of cocoapods(1.6.0). The reason was that the `post_install` script of adding a `SWIFT_VERSION` was not getting applied while building the project. So I added a `swift_version` in the YogaKit pod itself. So with this change we no longer need the `post_install` script to add `SWIFT_VERSION`.

I have also released a new version of YogaKit(1.10.0) on the CocoaPods. Usually the swift pods should specify the swift_version which is being used to develop it.Due to unknown reason, it was never mentioned in the podspec.

Reviewed By: jknoxville

Differential Revision: D13990363

fbshipit-source-id: 3c2f814765c03683fbedd17b3607ff0e6cdef566
2019-02-07 12:52:34 -08:00
David Aurelio
ca7d4d1633 Change compiler flag to -O2
Summary:
@public

Changes compiler flag from `-O3` to `-O2`

Saves 5.3 KiB compressed / 12 KiB uncompressed on 32bit Android.

Java on-device benchmarks show a slight improvement.

Reviewed By: astreet

Differential Revision: D13916987

fbshipit-source-id: e6bc474889e24a90ec473c8ae8c5029224c97eba
2019-02-04 12:52:57 -08:00
David Aurelio
3645f43cea Make == operator for YGStyle free function
Summary:
@public

Makes it work nicely with gtest.

Also allows rhs *and* lhs to offer `operator(YGStyle)()`.

Reviewed By: SidharthGuglani

Differential Revision: D13942573

fbshipit-source-id: ff8b3a9aa6f05ca1b0572eb97d0ad23b09d77871
2019-02-04 10:25:18 -08:00
David Aurelio
9378a7a439 User-defined literals for YGValue
Summary:
@public

Adds `_pt` and `_percent` user defined literals to create `YGValue` instances.

This allows to create `YGValue`s in the following form:

```
use namespace facebook::yoga::literals;

auto a = 123_pt; // == YGValue{123.0f, YGUnitPoint}
auto b = -12.5_percent; // == YGValue{-12.5f, YGUnitPercent}
```

Reviewed By: SidharthGuglani

Differential Revision: D13942100

fbshipit-source-id: ce1e2f9431c3e2a99c6e11896a712539cc535e0d
2019-02-04 10:25:18 -08:00
David Aurelio
d3e02b15fa Compile JNI bindings with -Os
Summary:
@public

Compiles Yoga’s JNI bindings with `-Os`. This doesn’t have perf implications. Compressed APK size ~ -4KB, uncompressed ~ -40KB

Reviewed By: astreet

Differential Revision: D13862404

fbshipit-source-id: 43402478ab2b932f0ca79711c35dfb507bab818b
2019-02-01 10:45:26 -08:00
Pablo Sichert
80d527814e Allow Yoga Pod to be built on any platform (#821)
Summary:
Currently the CocoaPod for Yoga explicitly states platform requirements.

Since the Yoga implementation doesn't depend on any platform features, it would be safe to build it on any platform.

That can be configured by omitting the `platform`/`platforms` key:

> The platform on which this Pod is supported. Leaving this blank means the Pod is supported on all platforms.
>
> http://guides.cocoapods.org/syntax/podspec.html#platform

Among others, that would allow to use the pod in macOS projects
Pull Request resolved: https://github.com/facebook/yoga/pull/821

Reviewed By: passy

Differential Revision: D13848153

Pulled By: davidaurelio

fbshipit-source-id: 5a3e81d81ca97b120f2711bafd3c8b9e0c3f8088
2019-02-01 05:10:13 -08:00
David Aurelio
5121fef5d8 Marker for baseline callbacks
Summary:
@public

Wraps baseline callbacks with a marker.

Reviewed By: SidharthGuglani

Differential Revision: D13896861

fbshipit-source-id: 848ec697977a0a68b9943f1159f6562d54724f89
2019-02-01 03:34:11 -08:00
David Aurelio
0d026bd1a0 Marker for measure callbacks
Summary:
@public

Wraps measure callbacks with a marker.

Reviewed By: SidharthGuglani

Differential Revision: D13896745

fbshipit-source-id: d6e14fe93f666b06516be1aef7f8e1bfe45440a7
2019-02-01 03:34:11 -08:00
Diego Muracciole
719fa3cca3 Add react-pdf to open source adoption list
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/857

Reviewed By: SidharthGuglani

Differential Revision: D13915577

Pulled By: davidaurelio

fbshipit-source-id: 55a9cbe96712c4fe7475665c907f650b4b2a8fb3
2019-02-01 02:55:24 -08:00
Eric Rozell
307cf09434 Adds fixes for react-native-windows UWP (#848)
Summary:
Specifically, updates the UWP .vcxproj for MSBuild and also exposes the UseLegacyStretchBehaviour API for use with react-native-windows.
Pull Request resolved: https://github.com/facebook/yoga/pull/848

Reviewed By: SidharthGuglani

Differential Revision: D13848609

Pulled By: davidaurelio

fbshipit-source-id: eab046ff3c47e49706f515e209d8aaf750c2198f
2019-01-31 16:50:38 -08:00
Reinier Hartog
8691cdaed6 Expose dirtied func in Javascript bindings (#842)
Summary:
Yoga currently has the concept of a 'dirtied func', which is called when a Node becomes dirty, which can be useful to trigger a repaint. This PR exposes that functionality in the Javascript bindings.
Pull Request resolved: https://github.com/facebook/yoga/pull/842

Reviewed By: SidharthGuglani

Differential Revision: D13847093

Pulled By: davidaurelio

fbshipit-source-id: 41913abd6eedc46ee7d66929140e08a084f23972
2019-01-31 16:50:38 -08:00
David Aurelio
4a6b1e19b8 InstrumentationTest: allow to record multiple markers
Summary:
@public

Extends `InstrumentationTest` with the ability to record more than one marker.
Instead of overwriting any previously recorder marker, we collect them in a `std::deque`.

`std::deque` was chosen, because it keeps pointers to elements stable.

Reviewed By: SidharthGuglani

Differential Revision: D13880777

fbshipit-source-id: f6f6606ac8625bdd90c06459fdb967c3478265e7
2019-01-31 16:50:38 -08:00
David Aurelio
31ce3ab866 Add license header to fb_native_wrapper.bzl
Summary:
Github and fbsource got out of sync, we have a PR to fix this: https://github.com/facebook/yoga/pull/843

This updates the internal-only file to match the PR, so that we can merge it without hassle.

Reviewed By: cuva

Differential Revision: D13879526

fbshipit-source-id: f83115617e580e118a5f4e0f37e877db38a8fcac
2019-01-31 16:50:38 -08:00
David Aurelio
0846439c8e Bring github and internal back in sync 2019-01-31 22:59:19 +01:00
David Aurelio
000d1436b4 Merge pull request #843 from rmhartog/add_fb_native_wrapper
Add fb_native_wrapper.bzl to fix Travis CI
2019-01-30 16:40:08 +00:00
David Aurelio
1bc97a5e48 Track how much measure cache entries are used
Summary:
@public

Adds the maximum number of measure cache entries in use to the metrics for `YGMarkerLayout`

Reviewed By: SidharthGuglani

Differential Revision: D13844731

fbshipit-source-id: fa66dbf1b7a1799494f72ecc17dfaef04d0b56e4
2019-01-29 15:53:32 -08:00
CangZhu
68f7001ed4 feat: expose flex prop to YogaKit (#844)
Summary:
This exposes `yoga` property to `YogaKit`
Pull Request resolved: https://github.com/facebook/yoga/pull/844

Reviewed By: SidharthGuglani

Differential Revision: D13849076

Pulled By: davidaurelio

fbshipit-source-id: 560986c2235dfd28d287f61b2e784c9eef6c5eda
2019-01-29 13:06:12 -08:00
David Aurelio
59446294b3 count cache hits
Summary:
@public

Adds cache hit counts to layout stats.

Reviewed By: SidharthGuglani

Differential Revision: D13844022

fbshipit-source-id: 906b4ec5fe3314287911cee2c37d77c4aac76455
2019-01-29 11:42:37 -08:00
David Aurelio
460370b7d3 More readable instrumentation test
Summary:
@public

Evolves setup and helpers in `InstrumentationTest` to avoid repetition across test cases, and allow for more readable test by hiding default values where they don’t matter.

Reviewed By: SidharthGuglani

Differential Revision: D13839521

fbshipit-source-id: 7f7ad49fec84e0bbb09ad746dd8c28bd34de25b2
2019-01-29 11:42:37 -08:00
David Aurelio
cbea5d44b8 Layout marker metadata
Summary:
@public

Adds marker meta data to `YGMarkerLayout`: the number of measures, and the numbers of layouts for all nodes in the tree.

Reviewed By: SidharthGuglani

Differential Revision: D13838975

fbshipit-source-id: d575c26a3d5a4f0b66834eb6bedecadc3f3ca265
2019-01-29 11:42:37 -08:00
David Aurelio
b4b009c2d8 Pass layout marker data along
Summary:
pubic

Passes layout marker data through the recursive calls of the layout algorithm, in order to allow for collecting metrics.

Reviewed By: SidharthGuglani

Differential Revision: D13819444

fbshipit-source-id: cdca04964fba6a03ca3eeaca4d169107019ba457
2019-01-29 11:42:37 -08:00
David Aurelio
74dd627495 Introduce first marker
Summary: @public Adds a marker section for a complete layout pass

Reviewed By: SidharthGuglani

Differential Revision: D13819447

fbshipit-source-id: 21a80f0fe3d325d804a968508761d115c50d3dc1
2019-01-29 11:42:37 -08:00
David Aurelio
58f0cca7c7 Add MarkerSection
Summary:
@public

Adds a class for triggering markers.

This calls `startMarker()` on construction, and `endMarker()` on destruction, thus being usable like a "scope guard": the object is instantiated, and automatically destroyed when going out of scope.

Reviewed By: SidharthGuglani

Differential Revision: D13817589

fbshipit-source-id: fd88884af970c1c0933d9ca6843f3f8f5d28b9e6
2019-01-29 11:42:36 -08:00
David Aurelio
3de3575ac4 Remove unused constexpr
Summary:
@public

Removes unused constexpr variables from YGStyle. Not polluting the global namespace is a good thing.

Reviewed By: SidharthGuglani

Differential Revision: D13816817

fbshipit-source-id: e4c27a8f2de466ccb759bbe52cdaea6fe451b961
2019-01-29 04:11:15 -08:00
David Aurelio
390fade8c0 Add function to set marker callbacks
Summary:
@public

Adds a function to allow to configure markers. The function is declared in `YGMarker.h`

Reviewed By: SidharthGuglani

Differential Revision: D13819111

fbshipit-source-id: f9158b3d4e5727da4e151c84b523c7c7e8158620
2019-01-29 03:51:16 -08:00
David Aurelio
96dfe068ee Add YGMarkerLayout
Summary: @public adds a first `YGMarker`, and the accompanying data type.

Reviewed By: SidharthGuglani

Differential Revision: D13817588

fbshipit-source-id: 6007eb09d19cf4021989bad5b5e880adb16364a0
2019-01-29 03:51:16 -08:00
David Aurelio
e0eb37fce0 Rename YGMarkerType to YGMarker
Summary:
@public

this will lead to nicer enum member names.

Reviewed By: SidharthGuglani

Differential Revision: D13817587

fbshipit-source-id: 85355328f7977b4fb29a9474532f2d578a3cbf79
2019-01-29 03:51:16 -08:00
Cameron Rollheiser
79355ab72d Spelling Fix (#851)
Summary:
Corrects the spelling of `corss-compiled` to `cross-compiled`.
Pull Request resolved: https://github.com/facebook/yoga/pull/851

Reviewed By: SidharthGuglani

Differential Revision: D13848545

Pulled By: davidaurelio

fbshipit-source-id: 84b7d2a738f0faf863717818e8784acd5b5c8156
2019-01-29 03:14:15 -08:00
David Aurelio
5a9f29debb Delete functionality for shared childen
Summary:
@public

Removes `YGNodeInsertSharedChild` / `addSharedChildAt`.

This functionality is unused, and can cause memory leaks.

Reviewed By: SidharthGuglani

Differential Revision: D13711105

fbshipit-source-id: 86206c05393b3f1a497e6b046006f94ead88c6ce
2019-01-24 06:33:06 -08:00
Amir Shalem
8b8932811e Make Yoga's libfb code to be gcc7 compatible
Summary: Make the libfb jni code to be compatible with gcc7 compiler

Reviewed By: davidaurelio

Differential Revision: D13711390

fbshipit-source-id: 9a378a3ee4feb7e928dd97dae7d79a41f0658992
2019-01-17 07:36:09 -08:00
Eduardo Roman
604a9a98a9 guard against INF values in CompactValue
Summary:
After this diff D13403925 that got rid of `-ffast-math` we started to have a very odd behavior on Yoga when using release builds.

After digging a while we found that certain set of conditions on O2 and O3 optimization levels was causing Origami to set some `INFINITE` values on Yoga.

We found the root of the problem and fix it on Origami side. But I'm wondering if guarding agains `INFINITE` on Yoga side would be good too. Since now Yoga it's not using `-ffast-math` anymore, and I think infinite is not a a valid value anywhere on Yoga side, it seems to support the reason to guard against it.

I'm happy to abandon this diff if you guys think this is not a good solution.

Reviewed By: davidaurelio

Differential Revision: D13679319

fbshipit-source-id: 061448fea9d1a8496362ff07dc46b546e7f1ffa3
2019-01-16 12:28:51 -08:00
David Aurelio
71321f763a Reflow comments
Summary:
@public

Repeated application and alternation of Clang Format rules has lead to unfortunate block comment formatting.

Here, we reflow comments

Reviewed By: SidharthGuglani

Differential Revision: D13677242

fbshipit-source-id: 3f1f5e38693eb15e9705f24fd363fc1618c78974
2019-01-16 08:47:48 -08:00
David Aurelio
7fa0816d81 Fix URLs to CSS spec in comments
Summary:
@public

These URLs probably have been changed when CSSLayout was renamed to Yoga by search & replacing

Reviewed By: SidharthGuglani

Differential Revision: D13690829

fbshipit-source-id: 44dbd8fe256fc286006d164390609a7c3de6c4e6
2019-01-16 08:47:48 -08:00
David Aurelio
4840495d3f Remove enum count macros
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.

Same as D13597449, working around a defect in clang < 3.9

Reviewed By: amir-shalem

Differential Revision: D13634622

fbshipit-source-id: 344dc70e167b0caf746fe396cedd200f54e52219
2019-01-11 03:11:33 -08:00
Amir Shalem
866bf101b2 Revert D13597449: [Yoga][cleanup] Remove enum count macros
Differential Revision:
D13597449

Original commit changeset: edcee225ada4

fbshipit-source-id: 1afc24833c8657a8a198bc4529d98c8f605b7fbd
2019-01-10 23:51:03 -08:00
Taras Tsugrii
3467308874 Reformat xplat build files according to new formatting rules.
Summary: drop-conflicts

Reviewed By: zertosh

Differential Revision: D13610808

fbshipit-source-id: 52c2a90bba3d9b0ac383f6e4a76b4fb3e60bf382
2019-01-10 20:01:02 -08:00
David Aurelio
ef2c693b05 Remove enum count macros
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.

Reviewed By: shergin

Differential Revision: D13597449

fbshipit-source-id: edcee225ada4058e94f3a727246763e3cc45873d
2019-01-10 07:38:43 -08:00
Marko Novakovic
efac22a508 Using ENUM_BITFIELDS_NOT_SUPPORTED for enum bitfields
Reviewed By: davidaurelio

Differential Revision: D13556160

fbshipit-source-id: e6d373a4e1dd702509b5d63606c08fae9cdb5498
2019-01-08 16:22:28 -08:00
David Aurelio
4b97375524 Remove repetition in YGEnums.h
Summary:
@public

Wraps enum definition in a single macro.

Down the line, this will allow us to add more functionality:
- Replace manual counts with `yoga::enums::count<YG...>()`
- `yoga::enums::max<YG...>()`
- A bitfield implementation with known memory layout using `max<>()`

Reviewed By: SidharthGuglani

Differential Revision: D13597259

fbshipit-source-id: 543a11a53090bedf1474d00328565ed57d059e23
2019-01-08 12:50:41 -08:00
David Aurelio
ab9d06abf5 Apply clang-format rules
Summary:
@public

Formats Yoga's source according to our clang-format configuration

Reviewed By: SidharthGuglani

Differential Revision: D13596650

fbshipit-source-id: c3722d4eafd63b7596a8b1e85c0197e9d2d6cb7d
2019-01-08 12:50:41 -08:00
David Aurelio
5ee32fbefc Add .clang-format
Summary:
@public

Add `.clang-format` for automatic formatting of our C++ code.

Reviewed By: SidharthGuglani

Differential Revision: D13596651

fbshipit-source-id: c3f866ad552cd7a1d5824f43b093f45842a2142e
2019-01-08 12:50:41 -08:00
David Aurelio
899664dddd Remove stray file
Summary:
@public

Remove accidental copy of `Yoga-internal.h`

Reviewed By: SidharthGuglani

Differential Revision: D13596615

fbshipit-source-id: c137b45caa9c55f75f9bd199be535f1b08977249
2019-01-08 09:47:05 -08:00
Sidharth Guglani
b66642cb86 fixed a csharp test case
Summary: Using default logger in test case

Reviewed By: davidaurelio

Differential Revision: D13565071

fbshipit-source-id: 93cee223a7f366e3e965fde2d5cdc7d4b27e310f
2019-01-04 06:08:24 -08:00
Reinier Hartog
b9ae948ce9 Add fb_native_wrapper.bzl to fix CI 2018-12-31 13:36:31 +01:00
David Aurelio
138521ccc2 Test YogaNode#getLayoutDirection()
Summary:
@public

Previously untested. Allows us to ship with more confidence

Reviewed By: SidharthGuglani

Differential Revision: D13534350

fbshipit-source-id: a2e7577befdeeb7a27148e16624eeb7a347efd87
2018-12-21 04:25:52 -08:00
David Aurelio
5514722ce2 Add tests for YogaNode#hasNewLayout() / #markLayoutSeen()
Summary:
@public

Adds test for the `hasNewLayout()` and `markLayoutSeen()` methods of `YogaNode`. The behavior of these methods wasn't previously covered by a test. This will allow us to change the implementation with confidence.

Reviewed By: SidharthGuglani

Differential Revision: D13534351

fbshipit-source-id: 23a9f9b70df18fd7c34023fd77b9df9fbd733f61
2018-12-21 04:25:51 -08:00
Taras Tsugrii
56e133ab4c Do not use glob for static paths.
Summary:
```
>>> Lint for xplat/yoga/csharp/BUCK:

   Warning  (BUILDIFIERLINT2) constant-glob
    Glob pattern `Yoga/YGInterop.cpp` has no wildcard ('*'). Constant
    patterns can be error-prone, move the file outside the glob.
    (https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#constant-glob)

              30
              31 yoga_cxx_library(
              32     name = "yoganet",
    >>>       33     srcs = glob(["Yoga/YGInterop.cpp"]),
              34     compiler_flags = COMPILER_FLAGS,
              35     link_style = "static",
              36     link_whole = True,
```

Differential Revision: D13521382

fbshipit-source-id: 744368e7818370c8ec68f332caaf766cad635e7a
2018-12-19 15:17:07 -08:00
David Aurelio
f6415889ca Use bitfields for YGLayout and YGNode
Summary:
@public

Further heap size reductions by using bitfields in `YGLayout` and `YGNode`.

Reviewed By: SidharthGuglani

Differential Revision: D13466325

fbshipit-source-id: ddcef0a1b3822e7449fe485d99c920d54139c893
2018-12-18 08:27:12 -08:00
David Aurelio
885b4cbdfb Switch storage in YGStyle to CompactValue
Summary:
@public

Switches the storage in `facebook::yoga::detail::Values` from `YGValue` to `facebook::yoga::detail::CompactValue`.
This cuts heap size for arrays of values in half.

Reviewed By: SidharthGuglani

Differential Revision: D13465586

fbshipit-source-id: 49a4d6d29a73bdd44843b1f3c57bf746050c94d6
2018-12-18 08:27:12 -08:00
David Aurelio
8461aeaef0 Remove cast from detail::Values to std::array<YGValue
Summary:
@public

When switching to `CompactValue`, casting edges or dimensions to `std::array<YGValue, ...>` will do actual work.
In order to avoid that from happening implicitely, we remove the casting operator.

Reviewed By: SidharthGuglani

Differential Revision: D13464292

fbshipit-source-id: 217065b001a63cfa8adde715063682c583007a4d
2018-12-14 09:22:53 -08:00
David Aurelio
3df41aefdb Encapsulate arrays of YGValue within YGStyle
Summary:
@public

Enforce more encapsulation of arrays of `YGValue` in `YGSty;e`.
This will allow us to use `CompactValue` in `YGStyle` while (mostly) retaining API compatibility.

Reviewed By: SidharthGuglani

Differential Revision: D13452042

fbshipit-source-id: 382b1c7245c4bea4280126ab1413e7e931b62eaa
2018-12-14 09:22:53 -08:00
David Aurelio
8bc89651d6 Introduce CompactValue
Summary:
@public

`CompactValue` represents a `YGValue` in 32bits instead of 64. This comes at the cost of a range limitation, as one exponent bit is borrowed for the unit.

*Undefined* and *Auto* have no magnitude, and are represented as *NaN* values.

The data structure is meant to be used as a field type on `YGStyle` to save memory.

This is header-only for efficient inlining.

Reviewed By: jackerghan, aCorrado

Differential Revision: D13187211

fbshipit-source-id: 16e3ffad592e38e2493e4f7c8b952d372e449846
2018-12-14 09:22:52 -08:00
David Aurelio
c5f2444048 Don't use default in exhaustive switch
Summary:
@public
removes the `default` case from an already exhaustive switch.

Reviewed By: SidharthGuglani

Differential Revision: D13451869

fbshipit-source-id: 32727330c7fce013963f5c83c95a73b230d5c938
2018-12-13 10:42:16 -08:00
David Aurelio
130a9a2aa2 Don't pass std::string by pointer
Summary:
@public

Pass strings by mutable ref rather than pointer.

Reviewed By: SidharthGuglani

Differential Revision: D13439613

fbshipit-source-id: ea889abe0fe8ec44ae02f13c1d9a10c0dbfdbcf1
2018-12-13 07:16:56 -08:00
David Aurelio
dd97fcc968 Use bitfields for enum members of YGStyle
Summary:
@public

Puts all enum fields of `YGStyle` into bitfields. This saves 36 bytes (> 3%) per node.

Reviewed By: SidharthGuglani

Differential Revision: D13439606

fbshipit-source-id: b60a5444762041bc6f8cc5e04757034cb6893b30
2018-12-13 07:16:55 -08:00
David Aurelio
4f51871fa8 Remove templates for setting/getting style properties
Summary:
@public

Replaces the `StyleProp` template with a simple setter macro / inlined getter code.

The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.

Reviewed By: SidharthGuglani

Differential Revision: D13439612

fbshipit-source-id: 36f6a86917d035be6891cb736d1f288d8e02f5cf
2018-12-13 07:16:55 -08:00
David Aurelio
e96d14395c YGNodeBoundAxisWithinMinAndMax accepts YGFloatOptional
Summary:
@public

Saves some calls to `.unwrap()`

Reviewed By: SidharthGuglani

Differential Revision: D13439600

fbshipit-source-id: ce0f6bad9a0709e9d64e23d8349bc2423b9b2ad4
2018-12-13 07:16:55 -08:00
David Aurelio
852db1d885 Remove unnecessary static keyword
Summary:
@public

Header-declared inline functions shouldn’t be decleared `static`

Reviewed By: SidharthGuglani

Differential Revision: D13439607

fbshipit-source-id: 89555bb19a3fff6e29ca4afc10fe15fecca8fa17
2018-12-13 07:16:55 -08:00
David Aurelio
3f79439718 Get rid of static_cast in YGResolveValue
Summary:
@public

Removes `static_cast` from `YGResolveValue`

Reviewed By: SidharthGuglani

Differential Revision: D13439605

fbshipit-source-id: 8736541c8e1d43fd698d368cb4f3211ffd929364
2018-12-13 07:16:54 -08:00
David Aurelio
96d93f2982 Inline YGFloatOptional completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13439609

fbshipit-source-id: 3f3c6c3a15e05ac55da2af30eb629f786ecb90a9
2018-12-13 07:16:54 -08:00
David Aurelio
236bcc1a39 Pass YGFloatOptional by value, not reference
Summary:
@public

`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.

Reviewed By: SidharthGuglani

Differential Revision: D13439603

fbshipit-source-id: e12539ad5b3cccbd5bc27869866ca66c023b24a7
2018-12-13 07:16:54 -08:00
David Aurelio
4b5ae211da Eliminate YGFloatOptional::getValue()
Summary:
@public

Replace `YGFloatOptional::getValue()` with `YGFloatOptional::unwrap()`.

`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.

Here, we eliminate the method, and just call `.unwrap()` everywhere.

Reviewed By: shergin

Differential Revision: D13439608

fbshipit-source-id: 5ae82b170537d0a10c301412567a7a66fd50bab4
2018-12-13 07:16:54 -08:00
David Aurelio
aaa018bbea Remove YGUnwrapFloatOptional
Summary:
Replaces `YGUnwrapFloatOptional` with `YGFloatOptional::unwrap`.

This leads to more idiomatic C++, and to less function call nesting, thus increasing readability.

Reviewed By: SidharthGuglani

Differential Revision: D13439604

fbshipit-source-id: 33b43c08d725c253c359959e7cbbd83fd6bd9ba4
2018-12-13 07:16:53 -08:00
David Aurelio
6bdd39d0ed Store YGFloatOptional in 32 bits
Summary:
@public

After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.

Reviewed By: SidharthGuglani

Differential Revision: D13439611

fbshipit-source-id: 93e90f72f0415edb228b4e7d145e1fae35cc6b43
2018-12-13 07:16:53 -08:00
David Aurelio
da678ef971 Add tests for YGFloatOptional
Summary:
@public

Adds tests for `YGFloatOptional`, to ease refactorings.

Reviewed By: SidharthGuglani

Differential Revision: D13439610

fbshipit-source-id: e29da7f85ccedc46520b59f6c893bad521d35417
2018-12-13 07:16:53 -08:00
David Aurelio
e9078374c9 Make equality operator for YGValue inlineable
Summary:
@public

Makes `operator==` for `YGValue` an inline function.

Reviewed By: SidharthGuglani

Differential Revision: D13439601

fbshipit-source-id: c5dd1f35c40f0ffa8224ee2f40ac7cc3cd8e3cf9
2018-12-13 07:16:53 -08:00
David Aurelio
f23a669ed0 Move out YGValue
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13439602

fbshipit-source-id: 68eef2c391b6c9810f3c995b86fff7204ebe6511
2018-12-13 07:16:53 -08:00
David Aurelio
9ddda3c630 Roll back -ffast-math
Summary:
@public

`-ffast-math` does not have measurable performance benefits.

By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.

Reviewed By: astreet

Differential Revision: D13403925

fbshipit-source-id: b13d026bf556f24ab4699e65fb450af13a70961b
2018-12-13 07:16:52 -08:00
David Aurelio
8ab01fde6e Back out "[yoga][PR] Fix aspect ratio when stretching with main axis margin"
Summary: Original commit changeset: 6970e6072e79

Reviewed By: mdvacca

Differential Revision: D13437552

fbshipit-source-id: 65a55d716da6b6582e38efa906d3f540e58418bf
2018-12-12 16:18:56 -08:00
Sidharth Guglani
440c719190 added baseline and setIsReferenceBaseline doc in yoga website
Summary: Added docs for align-items BASELINE property and yoga node setIsReferenceBaseline property in yoga website

Reviewed By: davidaurelio

Differential Revision: D13359436

fbshipit-source-id: 34cbb1087c70d44ec6462048cc2a819daf5951e0
2018-12-12 05:58:11 -08:00
Emil Sjölander
e522b2dee4 Fix aspect ratio when stretching with main axis margin (#834)
Summary:
I've noticed that when a child's size is determined by `align-items: stretch` in combination with `aspect-ratio` its size is wrongly calculated to account for margin in the main axis when there is more than enough space.

See playground: https://goo.gl/tgW6cD

I've yet to figure out exactly how to solve this but i've started by writing a failing test when can be seen in the first commit here.

I assumed I had found the bug here https://github.com/facebook/yoga/blob/master/yoga/Yoga.cpp#L1838 where margin is being subtracted from the desired width even though the measure mode tells it to measure to exactly that size. However, if we don't remove this margin from the available width then 15 tests fail (including the one I just added) not quite figured out why yet. I'm also a bit confused at to why this would only happen for nodes with `aspect-ratio` and not for nodes where an explicit height and width is set.
Pull Request resolved: https://github.com/facebook/yoga/pull/834

Reviewed By: astreet

Differential Revision: D13223579

Pulled By: davidaurelio

fbshipit-source-id: 6970e6072e79f3bb6f9097355ab6e441441bfd88
2018-12-10 09:23:03 -08:00
David Aurelio
b26e637c81 Back out Stack D13119110..D13236159
Summary: backout, causes failures

Reviewed By: adityasharat

Differential Revision: D13376210

fbshipit-source-id: 1fa8823f2dce601c47738f34ddb2674288197e79
2018-12-07 13:01:06 -08:00
David Aurelio
6b7f6980f9 Don't pass std::string by pointer
Summary:
@public

Pass strings by mutable ref rather than pointer.

Reviewed By: SidharthGuglani

Differential Revision: D13236159

fbshipit-source-id: 04fd35e8a9e106ba8cdd71cfab31e8d90edaac9e
2018-12-06 07:46:25 -08:00
David Aurelio
4248fd9d4c Use bitfields for enum members of YGStyle
Summary:
@public

Puts all enum fields of `YGStyle` into bitfields. This saves 36 bytes (> 3%) per node.

Reviewed By: SidharthGuglani

Differential Revision: D13233686

fbshipit-source-id: 3ef7e0d6913f0254806acb942d9a9f5b78a5af9c
2018-12-06 07:46:25 -08:00
David Aurelio
5a65261a55 Remove templates for setting/getting style properties
Summary:
@public

Replaces the `StyleProp` template with a simple setter macro / inlined getter code.

The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.

Reviewed By: SidharthGuglani

Differential Revision: D13233687

fbshipit-source-id: 218a7d5edb489b43a66c8c9d6156f74feefd2227
2018-12-06 07:46:25 -08:00
David Aurelio
5719132f58 YGNodeBoundAxisWithinMinAndMax accepts YGFloatOptional
Summary:
@public

Saves some calls to `.unwrap()`

Reviewed By: SidharthGuglani

Differential Revision: D13209153

fbshipit-source-id: 5658586e91496085f39b3522db6364aaeafcfe2f
2018-12-06 07:46:24 -08:00
David Aurelio
10b316f315 inline YGUnwrapFloatOptional
Summary:
@public
Replaces C-style function call with C++ method invokation.

Reviewed By: SidharthGuglani

Differential Revision: D13209154

fbshipit-source-id: 14e650af4655efb3a659f3cd949a11df773aabcf
2018-12-06 07:46:24 -08:00
David Aurelio
b6498987fa Remove unnecessary static keyword
Summary:
@public

Header-declared inline functions shouldn’t be decleared `static`

Reviewed By: SidharthGuglani

Differential Revision: D13209156

fbshipit-source-id: e2d643a67e6f6c33c96dc71b0a90d00bd9b6f36f
2018-12-06 07:46:24 -08:00
David Aurelio
9680ae98a6 Get rid of static_cast in YGResolveValue
Summary:
@public

Removes `static_cast` from `YGResolveValue`

Reviewed By: SidharthGuglani

Differential Revision: D13209155

fbshipit-source-id: 76c27c89f6217af9dfef9e2620d639c9f3e212f5
2018-12-06 07:46:24 -08:00
David Aurelio
59755d2874 Inline YGFloatOptional completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13209151

fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
2018-12-06 07:46:24 -08:00
David Aurelio
64c37767c2 Pass YGFloatOptional by value, not reference
Summary:
@public

`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.

Reviewed By: SidharthGuglani

Differential Revision: D13209150

fbshipit-source-id: c7b937a640258256c97e082ba2f832754e191b9a
2018-12-06 07:46:24 -08:00
David Aurelio
50ec35575f Eliminate YGFloatOptional::getValue()
Summary:
@public

`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.
That forces `x.isUndefined() ? fallback : x.getValue()` as access pattern.

Here, we replace that by introducing `YGFloatOptional::orElse(float)` which encapsulates that pattern. Other additions are `orElseGet([] { … })` and some extra operators.

Reviewed By: SidharthGuglani

Differential Revision: D13209152

fbshipit-source-id: 4e5deceaaaaf8eaed44846a8c152cc8b235e815c
2018-12-06 07:46:24 -08:00
David Aurelio
ed3b54b603 Store YGFloatOptional in 32 bits
Summary:
@public

After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.

Reviewed By: SidharthGuglani

Differential Revision: D13209157

fbshipit-source-id: 21b83c837a78f924a4ec23a9236ca2440b3c8606
2018-12-06 07:46:24 -08:00
David Aurelio
ed5c5a799f Make equality operator for YGValue inlineable
Summary:
@public

Makes `operator==` for `YGValue` an inline function.

Reviewed By: SidharthGuglani

Differential Revision: D13189356

fbshipit-source-id: 7fe61035acf635e22ebb1a1071925d6b3dad0616
2018-12-06 07:46:23 -08:00
David Aurelio
d19da9e528 Move out YGValue
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13172444

fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
2018-12-06 07:46:23 -08:00
David Aurelio
0962c5220c Roll back -ffast-math
Summary:
@public

`-ffast-math` does not have measurable performance benefits.

By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.

Reviewed By: SidharthGuglani

Differential Revision: D13119110

fbshipit-source-id: 4e6964240bf74ebc22d8783107b89d536a1a0842
2018-12-06 07:46:23 -08:00
David Aurelio
b9972cee6e Adjust yearless format for MIT license
Summary:
@public

Adjust license headers throughout the project

Reviewed By: SidharthGuglani

Differential Revision: D13255691

fbshipit-source-id: 98be2aa372a94e7a54a65e3d64e5c6a436b18083
2018-11-29 11:37:52 -08:00
David Aurelio
98c1c180af Remove extraneous file
Summary:
@public

This file shouldn’t be here

Reviewed By: SidharthGuglani

Differential Revision: D13255658

fbshipit-source-id: 1b40ab674bbf451d04797516a24c3bd2fef7222d
2018-11-29 11:37:52 -08:00
Eddie Zhang
6f6e0ce339 Fix typo in Yoga Layout documentation
Summary: Found and fixed typo on https://yogalayout.com/docs/justify-content/

Reviewed By: danielbuechele

Differential Revision: D13199988

fbshipit-source-id: 029cf812f09c48822ec11b054bf0c987f718191d
2018-11-29 11:17:20 -08:00
Taras Tsugrii
bdae838516 Sort build file loads.
Summary: drop-conflicts

Reviewed By: passy

Differential Revision: D13176350

fbshipit-source-id: 0f875a6c0f1eca2f992026bb2b2d0851f90f5d2f
2018-11-27 15:16:12 -08:00
Tnarita0000
6d8ee77791 Fix typo 'laid our' to 'laid out' (#833)
Summary:
I've fixed typo `laid our` to `laid out` in [`website/contents/properties/layout-direction.md`].
Pull Request resolved: https://github.com/facebook/yoga/pull/833

Differential Revision: D13196468

Pulled By: passy

fbshipit-source-id: 8b51e0d93fd0b6b131b7ea9446fff28ffeca9764
2018-11-27 03:42:00 -08:00
Tomas Reimers
9725d5b21b Create a recursive free with cleanup function
Reviewed By: davidaurelio

Differential Revision: D13119307

fbshipit-source-id: 162bb4fd6d7620f61cbac010d0dc236d81738b71
2018-11-26 16:04:16 -08:00
Sidharth Guglani
8e48edaa0b calling markDirtyAndPropogate when setting isReferenceBaseline value
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed

Reviewed By: davidaurelio

Differential Revision: D13147742

fbshipit-source-id: 3bbff1cfceeadfbf77380519e4638f2984fc2009
2018-11-26 07:28:37 -08:00
David Aurelio
89394a2dd6 Data types for marker API
Summary:
@public

Adds types for a marker API in Yoga.

This will allow us to register callbacks that Yoga can use to log performance data without hard-coding the backend system for that.

Reviewed By: SidharthGuglani

Differential Revision: D13118830

fbshipit-source-id: b42a42c609f0cf66212186f7f20ee572522d59e3
2018-11-24 16:28:49 -08:00
David Aurelio
02a2309b2a YGNodeComputeFlexBasisForChildren: remove output param
Summary:
@public

`YGNodeComputeFlexBasisForChildren` was using an output parameter (`float&`) that is always initialised to `0.0f`.
Here, we move the initialisation inside `YGNodeComputeFlexBasisForChildren`, and simply return the result.

Reviewed By: astreet

Differential Revision: D13167509

fbshipit-source-id: cbea20e2deb82ec75a1c158b16c94f4a3e5e4c99
2018-11-22 08:08:30 -08:00
David Aurelio
8f181c7259 Pass enums by value
Summary:
@public

passes all enum values by value, not by reference.

Reviewed By: astreet

Differential Revision: D13156390

fbshipit-source-id: 56aea66c16ab3325594f67b9017afa18a678d281
2018-11-22 08:08:29 -08:00
David Aurelio
339c5574b8 Dealloc JNI implementation experiment
Summary:
@public

Remove ability to configure Yoga to run with/without JNI fast calls on dalvik / art.
This switches to always run with fast calls.

Reviewed By: astreet

Differential Revision: D13144652

fbshipit-source-id: 091aab0cd1290d46346323d3e26a11dd0bb17187
2018-11-22 04:01:06 -08:00
David Aurelio
8d5bbecd3d Pass primitives by value
Summary:
@public

Passes all `float`, `bool`, etc. by value, not by reference.

Reviewed By: astreet

Differential Revision: D13153500

fbshipit-source-id: 95529bc2efcff144044e2c25087915b2b7ede179
2018-11-22 03:50:02 -08:00
Amir Shalem
dd12907632 Add getUndefined() method to obtain the undefined value
Summary:
Add getUndefined() method to obtain the undefined value.
This would allow to obtain the Yoga undefined value in runtime, and not just in compile time

Reviewed By: davidaurelio

Differential Revision: D13136972

fbshipit-source-id: aa198aa1ea65bb6b7302abeba6f9f5d483a45ff3
2018-11-22 02:37:05 -08:00
David Aurelio
7d7d9a7ef0 Back to yearless format for MIT license
Summary:
@public

Restores the yearless format of the MIT license.

Reviewed By: SidharthGuglani

Differential Revision: D13082510

fbshipit-source-id: f5a849b06652cedf68547d4a7963398b2627915f
2018-11-15 08:28:16 -08:00
Sidharth Guglani
63570613d3 added basic java, csharp and javascript tests for reference baseline feature
Summary:
@public
We added a functionality using which child node can tell parent node to use it as a reference baseline.
Added some tests for java, csharp, javascript language bindings.

Reviewed By: davidaurelio

Differential Revision: D12997442

fbshipit-source-id: 4717167d2b3862bf2af87b663bda82f9c1eae33e
2018-11-14 04:02:31 -08:00
Sidharth Guglani
4e2011c381 added functionality using which child node can tell parent node to use it as a reference baseline
Summary:
@public
Currently only parent can tell the layout to align its children based on baseline. But if one of the children is a column or row then basealign does not work as expected.

We have added an api setReferenceBaseline which when set to true would mean that it's baseline would be considered as the reference baseline for parent amongst its siblings. If there are more than one siblings with referenceBaseline set, the first one would be considered.

Reviewed By: davidaurelio

Differential Revision: D12883323

fbshipit-source-id: 19beccfc47d98bb38f81f5b66ba764e83680f821
2018-11-14 02:52:20 -08:00
David Aurelio
7a60399b2b Add Yoga JNI bindings to libcoldstart
Summary:
Yoga's JNI bindings are usually loaded during class loading, and can stall the UI thread.

Here, we try to mitigate the problem by adding the bindings to libcoldstart.

Reviewed By: michalgr

Differential Revision: D12956818

fbshipit-source-id: 9dda5cb6d26c2bae64606bc2d7c98ab8f7c05a30
2018-11-07 09:35:32 -08:00
Daniel Hood
a0b3586fb3 Fix build error caused by -Werror=class-memaccess (#823)
Summary:
OS: Arch Linux
GCC Version: gcc (GCC) 8.2.1 20180831
Clang Version: 6.0.1 (tags/RELEASE_601/final)

Build Log Before Fix:

command: `buck build //:yoga`
```
Not using buckd because watchman isn't installed.
yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’:
yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess]
   memset(&(node->getLayout()), 0, sizeof(YGLayout));
                                                   ^
In file included from yoga/YGNode.h:11,
                 from yoga/Utils.h:9,
                 from yoga/Yoga.cpp:13:
yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here
 struct YGLayout {
        ^~~~~~~~
cc1plus: all warnings being treated as errors
Build failed: Command failed with exit code 1.
stderr: yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’:
yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess]
   memset(&(node->getLayout()), 0, sizeof(YGLayout));
                                                   ^
In file included from yoga/YGNode.h:11,
                 from yoga/Utils.h:9,
                 from yoga/Yoga.cpp:13:
yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here
 struct YGLayout {
        ^~~~~~~~
cc1plus: all warnings being treated as errors
    When running <c++ preprocess_and_compile>.
    When building rule //:yoga#compile-Yoga.cpp.o9b5477b5,default.
Parsing buck files: finished in 0.8 sec (100%)
Building: finished in 2.2 sec (100%) 10/10 jobs, 1 updated
  Total time: 3.3 sec
```

Build Log After Fix

command: `buck build //:yoga`
```
Not using buckd because watchman isn't installed.
Parsing buck files: finished in 0.8 sec (100%)
Building: finished in 0.6 sec (100%) 1/1 jobs, 0 updated
  Total time: 1.6 sec
```

All tests are passing
Pull Request resolved: https://github.com/facebook/yoga/pull/823

Reviewed By: davidaurelio

Differential Revision: D10486023

Pulled By: passy

fbshipit-source-id: e9de734c3ce6c45ea4a8edd5d78206901d85ca84
2018-11-07 08:53:41 -08:00
Sidharth Guglani
a2ef8978cd flex_shrink_flex_grow_row and flex_shrink_flex_grow_child_flex_shrink_other_child tests were directly added in YGFlexTest.cpp, Added these in YGFlexTest.html so that they can generated accordingly in all different langauges via gentest ruby script
Summary:
@public
`flex_shrink_flex_grow_row` and `flex_shrink_flex_grow_child_flex_shrink_other_child` tests were present in YGFlexTest.cpp.

When running ruby script to generate tests, these were getting removed since they were not added in YGFlexTest.html using which tests are generated.
This diff adds tests in YGFlexTest.html and contains corresponding generated test cases for different languages.

Reviewed By: priteshrnandgaonkar

Differential Revision: D12838701

fbshipit-source-id: 5e92716d94fa392230db2c0ec3b8c131a089c55a
2018-10-31 13:12:00 -07:00
Scott Rice
d02f4a94de Use fb_native_wrapper for all targets
Differential Revision: D12868694

fbshipit-source-id: 0dfc7d05cc0ee6b15a2534f17260e340038a1041
2018-10-31 12:05:41 -07:00
Sidharth Guglani
b7890fa2a8 adding missing generated test cases in csharp, java, js
Summary:
@public
gentest.rb script generates tests in different languages cpp, java, csharp, js from html files.
Some tests were missing from csharp, java and js test files. This diff adds those in all the test files

Reviewed By: priteshrnandgaonkar

Differential Revision: D10853971

fbshipit-source-id: 11d7cee5889dd1f5a7440f6802fca78cea17aa4d
2018-10-31 10:16:47 -07:00
Sidharth Guglani
1e4d0abc66 using TestParametrization.NodeFactory in gentest-java.js to generate java tests
Summary:
@public

Our tests were manually parametrized, without adding the necessary code to the test case generation script.

This commit makes the necessary changes so that test generation won’t overwrite the parametrization.

Reviewed By: davidaurelio

Differential Revision: D10853163

fbshipit-source-id: b5e41755df16a6a296cf2061fbb89c3f27f8574d
2018-10-29 04:30:20 -07:00
Sidharth Guglani
eb2aeb3adb corrected copyright header in gentest.js
Summary:
@public

We have changed Yoga’s license to a yearless format, but this was not reflected in the test generation script.
This commit changes the corresponding template/.

Reviewed By: davidaurelio

Differential Revision: D10852787

fbshipit-source-id: 0b79e253be6174a218f9dc8de942fc2496a425c8
2018-10-29 03:09:30 -07:00
Sidharth Guglani
fad2ee1a64 Replaced default constructors with member assignments
Reviewed By: davidaurelio

Differential Revision: D10466125

fbshipit-source-id: ed92d1e054a8b5b9a6c8c09035173b11da45c368
2018-10-25 08:03:48 -07:00
Sidharth Guglani
ba9bd4eae3 Added Copyright Header
Reviewed By: davidaurelio

Differential Revision: D10462700

fbshipit-source-id: edef1f6f5825835bbdb613a1934bf7bfe86d0ee6
2018-10-24 03:11:40 -07:00
Pascal Hartig
e12b78f99b Fix Android snapshot version
Summary:
The current snapshot version is not in line with the standard versioning
scheme.

Tried to export this as PR first, but GitHub is having a day.

Reviewed By: muraziz

Differential Revision: D10486037

fbshipit-source-id: d5b08bd5dd2a7d382681ee198e040451a1c2aa11
2018-10-22 06:41:59 -07:00
Alexey Kozhevnikov
5d1cee2bf0 Exclude cpp equality operators from extern "C"
Summary:
`extern "C"` disables name mangling, hence input parameter types does not influence the name. That makes it impossible to have several equality operators with `extern "C"` linkage (for different types).

One such operator is defined in Windows SDK, in `guiddef.h`. It in turn is included in `winnt.h` inside `extern "C" { ... }` block. Trying to compile file which both is dependent both on `winnt.h` and `Yoga.h` results in:
```
Yoga.h(50): error C2733: 'operator ==': second C linkage of overloaded function not allowed
guiddef.h(192): note: see declaration of 'operator =='
```

In general it doesn't make much sense to have cpp specific operator to have `extern "C"` linkage, so the change doesn't introduce any controlling flag (mangling on/off).

Note that it's breaking binary compatibility and yoga library should be rebuilt if those operators are used.

Reviewed By: milend

Differential Revision: D10418395

fbshipit-source-id: 2f1cccff26165e638b9a07eece07d94fccfa5e5a
2018-10-18 08:47:16 -07:00
Adam Comella
5c711a7076 When paddingStart is 0, it should override paddingHorizontal (#816)
Summary:
Fixes #815

Imagine a node with this style: `{ paddingHorizontal: 10, paddingStart: 0 }`.

After running layout on this node, we expect its computed `paddingStart` to be `0`. However, it is actually `10`.

Consider the expression `paddingEdgeStart.getValue() > 0.0f` in [`getLeadingPadding`](328ec7dc4d/yoga/YGNode.cpp (L461)). Why is `0` handled like a negative number rather than a positive number? I suspect this should be `>=` so `0` is handled like the positive numbers (this is how `getTrailingPadding` works).

It looks like 3a82d2b1a8 (diff-07b4949bf42749fde386e769ff08a124) changed the operator from `>=` to `>` in `getLeadingPadding`. I suspect it was a mistake. `getTrailingPadding` still uses `>=`.

I manually verified this using the code in #815 and added some unit tests to catch this bug and other similar issues.

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/816

Reviewed By: priteshrnandgaonkar

Differential Revision: D10282617

Pulled By: shergin

fbshipit-source-id: 2ab2874ae39d9454308a020a960ace85573fe777
2018-10-12 15:08:18 -07:00
Pavel Mazurin
838ef47847 Fixes #606 (#610)
Summary:
Fixes #606.

If there are no subviews in `UIView`, yoga assumes that `sizeThatFits:` returns `CGSizeZero`. However, according to [the documentation](https://developer.apple.com/documentation/uikit/uiview/1622625-sizethatfits), `UIView` returns current size if there are no subviews.

This diff adds a check - if there are no subviews, `sizeThatFits:` doesn't get called, and CGSizeZero is returned.
Pull Request resolved: https://github.com/facebook/yoga/pull/610

Reviewed By: davidaurelio

Differential Revision: D6807406

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 9189cf14c393f840122bc365d3827881bf03548c
2018-10-12 14:09:32 -07:00
Adam Comella
786ccddd7b Fix rounding of negative numbers (#825)
Summary:
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example:

```
YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0
```

However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`.

There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works.

A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see https://github.com/facebook/yoga/issues/824.

Fixes #824

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/825

Reviewed By: priteshrnandgaonkar

Differential Revision: D10282064

Pulled By: shergin

fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
2018-10-11 18:21:49 -07:00
Adam Comella
b747286c1d Fix C# unit tests (#818)
Summary:
This consists of several fixes:
  - Some of the C++ functions called by the tests were missing `WIN_EXPORT`
  - It looks like Yoga was changed to round up after `TestMeasureFuncWithFloat` was written. Here's the function call that results in the rounding: 357ca78f9f/yoga/Yoga.cpp (L4019-L4026)
  - The format of the result of the `Print` method was changed after `TestPrint` was written.
Pull Request resolved: https://github.com/facebook/yoga/pull/818

Differential Revision: D10282902

Pulled By: shergin

fbshipit-source-id: a5fd732a7dbff1a704cbafbfc95ae3e0c0a0cdd8
2018-10-09 18:14:43 -07:00
Adam Comella
bb3c2b2498 C#: Change NaN with large number (#817)
Summary:
This PR is the C# version of 3a82d2b1a8

The above change moved Yoga away from NaN to facilitate usage of the `-ffast-math` compiler flag. However, that commit forgot to update the C# implementation.
Pull Request resolved: https://github.com/facebook/yoga/pull/817

Differential Revision: D10282642

Pulled By: shergin

fbshipit-source-id: 51681ce12344bc421f346ccc30e2950f4f39dbc6
2018-10-09 17:33:43 -07:00
Emily Janzer
36e732aabd Update copyright for yoga files
Summary: Appeasing lint

Reviewed By: hramos

Differential Revision: D9819535

fbshipit-source-id: 0080f17a62291291a0ea90942af4b38588e9057f
2018-10-05 18:46:14 -07:00
Pritesh Nandgaonkar
d6517ae288 Update version name with snapshot as a suffix
Summary: Adds snapshot as a suffix

Reviewed By: passy

Differential Revision: D10217480

fbshipit-source-id: 0208663b55ff2e403ff94adb98c374cdadefe2ba
2018-10-05 13:15:52 -07:00
Pritesh Nandgaonkar
93d327acfb Yoga Release v1.10.0
Summary:
Updated the build number.
Removed armeabi from build.gradle, as gradle was complaining that it doesn't support armeabi.

Reviewed By: passy

Differential Revision: D10145261

fbshipit-source-id: ab04e2d709cb6faf8bce02a53b7c865c342edefe
2018-10-05 08:39:17 -07:00
Pritesh Nandgaonkar
01c6c79efb Remove armeabi target
Summary: While releasing android yoga release, gradle compained that armeabi is not supported, thus removing it

Reviewed By: passy

Differential Revision: D10194155

fbshipit-source-id: ddb03ae0fe41d5b338c9207ac066090f7e7748a9
2018-10-05 08:39:15 -07:00
David Aurelio
357ca78f9f Set up Yoga experiment
Reviewed By: priteshrnandgaonkar

Differential Revision: D9943869

fbshipit-source-id: 6b6550f453ab4e0ab8305401b299f2d0ed415f72
2018-09-25 16:03:16 -07:00
David Aurelio
6e46eec58f Adapt methods for fast calls
Summary:
Changes all possible native JNI methods to critical methods.

For now, this only changes Android up and including v7. In order to be prepared for the `CriticalNative` annotation in Android v8, the following restrictions apply:

- Qualifying methods must be static (this is also enforced for Dalvik / Android v4)
- Method implementations can only consume primitive JNI types (`boolean`, jchar`, etc.)

Reviewed By: priteshrnandgaonkar

Differential Revision: D9943868

fbshipit-source-id: 728817eb37822b717fd3daf94cd9f02b42c17db6
2018-09-25 16:03:16 -07:00
David Aurelio
554d8cdf76 Make native method binding configurable
Summary:
Moves binding of native methods into a separate native method that can be parameterized.

This will be used to experiment with JNI-related technology.

Reviewed By: priteshrnandgaonkar

Differential Revision: D9943870

fbshipit-source-id: 661f15537d5bbf7a3eef7717e3d99fed2de23904
2018-09-25 16:03:15 -07:00
David Aurelio
328ec7dc4d Support !-style fast calls for Android
Summary:
Adds support for `!`-style fast calls in Android versions < 8.

For now, this comes with the following restrictions:

- has to be enabled with a macro
- only supports native functions that return and accept primitive Java types (`jint`, `jdouble`, etc.), and `void`
- this is supposed to map to `CriticalNative` as described in https://source.android.com/devices/tech/dalvik/improvements#faster-native-methods.

Inline documentation in art: http://androidxref.com/6.0.1_r10/xref/art/runtime/jni_internal.cc#2110

Possible follow ups:
- don’t prefix when the Android runtime is too new (to avoid the warning, and future error, see http://androidxref.com/8.1.0_r33/xref/art/runtime/jni_internal.cc#2355)
- shim `CriticalNative` (see https://android.googlesource.com/platform/libcore/+/master/dalvik/src/main/java/dalvik/annotation/optimization/CriticalNative.java)
- test whether we can use `CriticalNative` at all (docs claim classes must be on bootclasspath)
- suppport `FastNative`, i.e. instance methods that can also receive and return `jobject`

Reviewed By: cjhopman

Differential Revision: D9630538

fbshipit-source-id: 0ae86c909b192429d60f8eddb15528cc38610379
2018-09-19 18:04:09 -07:00
Philip Jameson
2e66f8d828 Format bzl files with new buildifier
Summary: Build file formatting

Reviewed By: ttsugriy

Differential Revision: D9778749

fbshipit-source-id: 4ee3743fabdbb9202b1fe1334fd255e9734352e2
2018-09-11 17:13:12 -07:00
Héctor Ramos
e224a29d1c Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:53:35 -07:00
Taras Tsugrii
238d7ba98f Remove unused loads from build files.
Summary: Unused loads hurt readability and take time to process.

Reviewed By: hramos

Differential Revision: D9494120

fbshipit-source-id: 455b56efadab1cb976344cffcb427772bfda2f71
2018-08-31 17:59:37 -07:00
Pritesh Nandgaonkar
d6ba8326d1 Expose printTree property of YGConfig to jni
Summary: Exposes printTree property of YGConfig to jni

Reviewed By: IanChilds

Differential Revision: D9561097

fbshipit-source-id: 1bf86a63ad5e9baa107e36d429209b9061e6676d
2018-08-30 04:45:23 -07:00
Pritesh Nandgaonkar
f7df575746 Expose logging capablities in Yoga header
Summary: Exposes a bool in the config which will help log the yoga hierarchy. Also added a test case

Reviewed By: IanChilds

Differential Revision: D9560577

fbshipit-source-id: ef4998107ed51ea374853bab7cbe09e3232caa0c
2018-08-30 04:45:23 -07:00
Jonathan Kim
2b52c73d70 Move yoga_defs.bzl
Reviewed By: mzlee

Differential Revision: D9546736

fbshipit-source-id: ff0c19a33cc72a330bac1e266ad0bb6d7c440e60
2018-08-28 22:06:45 -07:00
Pritesh Nandgaonkar
7a45fb39bf Solve the bug related to baseline height
Summary:
This diff fixes the height calculation logic for the nodes with baseline. Before height calculation for baseline was done at wrong place.

The task was created due to the regression caused by D9219678.

Reviewed By: IanChilds

Differential Revision: D9421551

fbshipit-source-id: 3fbb738314130b346c4186ec45d00c9ea63bc9f4
2018-08-21 17:29:43 -07:00
Pritesh Nandgaonkar
1080cf22e3 Solve width bug when the size is less than min
Summary:
This diff updates the logic which reassigns `remainingFreeSpace` when the node's calculated dimension falls below min width of the node.

So we will have to update the `remainingFreeSpace` as there is more available space since the calculated nodes width is less than the min width.

I have also added comments at relevant places in the code so that it is clearer.

This diff solves the issue raised in litho support grp. The details can be found here T32199608. This diff also makes sure that it doesn't break fblite, as the earlier version broke it, details of which can be found here T32881750.

Reviewed By: IanChilds

Differential Revision: D9359026

fbshipit-source-id: 4168e385e962c168a9de9370220c75f14a6726a7
2018-08-20 06:29:38 -07:00
David Aurelio
1d09227374 Inline YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro
Reviewed By: astreet

Differential Revision: D8874733

fbshipit-source-id: 75c24b508f287f405fad09605f64d2bfb3ffa0a5
2018-08-17 03:59:46 -07:00
David Aurelio
85031baaf2 Replace percent setter in YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro with template code
Reviewed By: astreet

Differential Revision: D8874732

fbshipit-source-id: 46fdf851f19f16def0c7e2ab4c5f17a349dc7aee
2018-08-17 03:59:46 -07:00
David Aurelio
7f71cac3b0 Replace point setter in YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro with template code
Reviewed By: astreet

Differential Revision: D8874735

fbshipit-source-id: 77fa1ceb2eaff6a0e415ef939e55aa22bc3d6099
2018-08-17 03:59:45 -07:00
David Aurelio
48a8f883ba Replace getter in YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro with template code
Reviewed By: astreet

Differential Revision: D8874734

fbshipit-source-id: ba94b4d0fd31e8344c7836b66a269d5f1f69e225
2018-08-17 03:59:45 -07:00
David Aurelio
6132a59772 Type alias for dimensions
Summary:
Aliases `std::array<YGValue, 2>` as `YGStyle::Dimensions` for increased readability.

This prepares a follow up, where the alias is used in `Yoga.cpp`.

Reviewed By: astreet

Differential Revision: D8874566

fbshipit-source-id: a7a7a1b02bff547d7d6b800c522c4785a62ad611
2018-08-17 03:59:45 -07:00
Pritesh Nandgaonkar
8309cfc976 Fix parent height calculation in case of baseline alignment
Summary:
Prior to this diff, if parents height was not set then the height of parent was deduced as max of childrens height(considering  line ht, padding, margin etc. ), but it didn't consider the baseline scenario where the previous logic will fail as then the parents height will be determined by the space taken by children above and below the reference baseline. I added a test case for the same.

Look at the diff D9088051 which shows the screenshot of the bug.
It is solved to https://pxl.cl/gvVk

Reviewed By: dsyang

Differential Revision: D9219678

fbshipit-source-id: f4a0b9f1452c33e78bd8c6cf39f6fcf538a04074
2018-08-16 06:28:37 -07:00
Roman Kushnarenko
abc9fdb37c Revert D9286928: [yoga] Solve width bug when the size is less than min
Differential Revision:
D9286928

Original commit changeset: 915269602cda

fbshipit-source-id: a4c23bf335b82fbbf3928a524a61374a6cf6ffb1
2018-08-16 03:14:16 -07:00
Pritesh Nandgaonkar
b872751d68 Solve width bug when the size is less than min
Summary:
Removed the faulty calculation of `remainingFreeSpace` from the code. `remainingFreeSpace` already had the correct value that special condition was not required.

Also added a test case for this issue

Reviewed By: IanChilds

Differential Revision: D9286928

fbshipit-source-id: 915269602cda2cc4515e6eab8184b2ea98d3e6d4
2018-08-15 14:29:37 -07:00
David Aurelio
8368338c93 Eliminate remaining YGStyle& locals
Summary:
@public

Replaces local references to `YGStyle` objects, and assignment to `YGValue` members with direct assignment from temporaries.

This should increase readability, and eliminate duplicated checks for *undefined* values.

Reviewed By: astreet

Differential Revision: D9083531

fbshipit-source-id: 11386be465352f5cb167b8195b7da432d0055d6f
2018-08-15 06:30:43 -07:00
David Aurelio
45c44d293c Eliminate unnecessary copies of node style objects
Summary:
@public

`YGNode.getStyle()` returns a reference to the enclosed `YGStyle` member. Assigning to a local copies unnecessarily.

Having eliminated the copy, we can also safely remove calls to `YGNode.setStyle()`, eliminating another copy.

Reviewed By: astreet

Differential Revision: D9083336

fbshipit-source-id: df8b603b5cc0b974cf5dd434c71956be4548e583
2018-08-15 06:30:43 -07:00
Amir Livneh
b4a889553c Fix typo
Summary:
Fix typo

Created from Diffusion's 'Open in Editor' feature.

Reviewed By: dshahidehpour

Differential Revision: D9295603

fbshipit-source-id: 0a105284592de4962acc672712cca14e157074f4
2018-08-13 15:31:08 -07:00
David Aurelio
78cdf3cadc Back to JNI storage
Summary:
@public

This reverts the Yoga/Java storage experiment. I will follow up with any learnings.

Reviewed By: pasqualeanatriello

Differential Revision: D9168405

fbshipit-source-id: fb227fb9353bd4c4e3bebbe9b04eec1132e532e8
2018-08-06 02:12:40 -07:00
David Aurelio
be78bfbd8c Add Unsafe based storage backend
Summary:
@public

Adds another version of property storage for `YogaNode`, using `sun.misc.Unsafe`.

Adopts the stub concept from Litho for `Unsafe`, as it is hidden by the Android SDK.

Reviewed By: pasqualeanatriello

Differential Revision: D9140103

fbshipit-source-id: a4b376eca341b724a00f873467ae8bf8eaac69f4
2018-08-05 16:45:31 -07:00
Pascal Hartig
c5d4485db3 Fix Travis build (#800)
Summary:
Fix the `Werror` failures and update JUnit to 4.12 as we're making use of `Parameterized` features which aren't available in whichever version we have here.
Pull Request resolved: https://github.com/facebook/yoga/pull/800

Reviewed By: jknoxville

Differential Revision: D9132106

Pulled By: passy

fbshipit-source-id: 5e6a130ba65e4a1ebd1d9ec506fdb126ecd0e44a
2018-08-02 10:43:03 -07:00
David Aurelio
71f1d99494 Fix behaviour of freeNatives()
Summary:
@public

Prevents repeated deallocation of weak references.

Reviewed By: pasqualeanatriello

Differential Revision: D9131551

fbshipit-source-id: bc79596e056ae0657a55146ad786422fd0f5badc
2018-08-02 04:00:50 -07:00
David Aurelio
0e99980206 Adapt micro benchmark
Summary:
- adds more property assignments
- reduces the number of layout roots that exist simultanously

Reviewed By: pasqualeanatriello

Differential Revision: D8989389

fbshipit-source-id: 6a0ac800a4caad61a2f4bf98caa314855b70875f
2018-08-02 04:00:50 -07:00
Pascal Hartig
292bfed102 Update CoC for various projects
Summary: The old link 404s. This is the new canonical location.

Reviewed By: IanChilds

Differential Revision: D9131447

fbshipit-source-id: 77b82a4184fff89faf1da76e922a5f1ce3de3314
2018-08-02 03:12:17 -07:00
David Aurelio
78d6988461 Add YogaNodeProperties implementation with ByteBuffer based setters
Summary:
@public
Adds an implementation of `YogaNodeProperties` that sets style properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.

Reviewed By: pasqualeanatriello

Differential Revision: D9042225

fbshipit-source-id: c7f2b24eaeddd1190755bec85a5034079bd2f492
2018-07-30 09:43:37 -07:00
David Aurelio
3499e2e0ef Add YogaNodeProperties implementation based on ByteBuffer
Summary:
@public
Adds an implementation of `YogaNodeProperties` that accesses style and layout properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.

This needs further cleanup after experimenting, e.g. to codegen the offsets.

Reviewed By: pasqualeanatriello

Differential Revision: D8911723

fbshipit-source-id: 3c24b57eb545155878896ebb5d64d4553eb6bedc
2018-07-30 09:43:37 -07:00
David Aurelio
b1821ab4cd move property storage into sub-object
Summary:
Here we introduce an abstraction over node property storage, in order to experiment with different approaches for Java/C integration.

- interface `YogaNodeProperties` as abstraction
- current JNI code factored into `YogaNodePropertiesJNI.java`
- `YogaNode` delegates all calls, no API changes

Reviewed By: astreet

Differential Revision: D8769448

fbshipit-source-id: e67327ce41fa047a51a986c652b3d59992a510e2
2018-07-30 09:43:37 -07:00
Amir Shalem
006f6460a9 Deallocate the YogaConfig memory with correct method
Summary: We've mistakenly used `free()` to free the memory, where `delete` should have been used

Reviewed By: davidaurelio

Differential Revision: D9042347

fbshipit-source-id: e15cec0f498409066521a6de1e3fe4b7404ec46c
2018-07-29 14:12:00 -07:00
Zhaojun Zhang
db5bc092aa Remove clang compiler warnings for Android: -Wno-unused-parameter
Summary: att

Reviewed By: gkmhub

Differential Revision: D8972835

fbshipit-source-id: c8b893eefec6ccb5d8506c959bcf5c3f43701e81
2018-07-27 10:59:16 -07:00
Nate Stedman
9fe20fd2fc Also ban +new on YGLayout
Summary: `-init` is marked unavailable, but `+new` does the same thing and is not.

Reviewed By: dshahidehpour

Differential Revision: D8957391

fbshipit-source-id: 42fcfe845db79726d8724efd9f6a4d37c19938ad
2018-07-24 06:59:03 -07:00
David Aurelio
7b87ded288 Add tests for style properties
Summary:
@public

The existing test suite does not check every single style property settable in Java for defaults, reads, and effect on layout.

Here, we add these test, in order to make evolving the Java/C++ bridge as safe as possible.

Reviewed By: pasqualeanatriello

Differential Revision: D8952470

fbshipit-source-id: a94933adff01c313b3f440eb5207d2cb6a54a85d
2018-07-23 14:58:36 -07:00
Valentin Shergin
eaaf0fdfe2 Implementation of operator== for YGValue
Summary:
@public
It's very useful sometimes for product code to compare `YGValue`s (e.g. in Fabric).

Reviewed By: priteshrnandgaonkar

Differential Revision: D8937594

fbshipit-source-id: b93e1ab4a6419ada6746f233b587e8c9cb32c6d4
2018-07-23 13:27:50 -07:00
David Aurelio
4caed8feb5 Replace YG_NODE_STYLE_PROPERTY_IMPL macro with template
Summary:
@public

Replacing the `YG_NODE_STYLE_PROPERTY_IMPL` macro with template code, in order to make code easier to edit and grep.

Reviewed By: astreet

Differential Revision: D8868184

fbshipit-source-id: f52537376fa8d4dd53aa98bb43e93279699dbdd5
2018-07-19 09:58:25 -07:00
David Aurelio
4be229059c Yoga.h: inline function declaring macros
Summary:
@public

Inlines macros used for declarations of `YGNodeStyle*` and `YGNodeLayout*` functions.
Benefits easier grepping and code base navigation.

Reviewed By: astreet

Differential Revision: D8868168

fbshipit-source-id: d6b1b70981a59a2214dc7d166435a1d1a844e1b7
2018-07-19 09:58:24 -07:00
David Aurelio
389f2fd85d Run lint on Yoga.cpp/Yoga.h
Summary:
@public

auto-fixes formatting for `Yoga.cpp`/`Yoga.h`.
Submitted separately to keep other diffs cleaner.

Reviewed By: astreet

Differential Revision: D8868179

fbshipit-source-id: d0667f8bb909bb5ada1263aac6e22b0a8f8875ad
2018-07-19 09:58:24 -07:00
David Aurelio
f95e3b49e9 inline trivial constructors / methods
Summary:
@public

inlines some trivial constructors, destructors, and methods.

Reviewed By: astreet

Differential Revision: D8912691

fbshipit-source-id: 79840ef3322676deebed99391390d6c1796963b5
2018-07-19 09:58:24 -07:00
David Aurelio
f172d5d41c auto-lint YGLayout.h YGNode.h YGStyle.cpp YGStyle.h
Summary:
@public

automatically applies lint fixes to  YGLayout.h YGNode.h YGStyle.cpp YGStyle.h

Reviewed By: astreet

Differential Revision: D8913432

fbshipit-source-id: 488bf25db041ddb527565c26c1762c6ee4cae736
2018-07-19 09:58:24 -07:00
Pascal Hartig
7be9fd1a79 1.9.1-SNAPSHOT
Summary: Reenable snapshot releases.

Reviewed By: muraziz

Differential Revision: D8914105

fbshipit-source-id: f9fcd74912f3ef2f9fb94ec832c41353e3f890bb
2018-07-19 09:14:45 -07:00
Pascal Hartig
5e1796505d v1.9.0
Summary: New release against soloader ~0.5.0.

Reviewed By: muraziz

Differential Revision: D8914103

fbshipit-source-id: b1eb3f608ac7cf3791fefe88e596383483ae3474
2018-07-19 09:14:45 -07:00
Pascal Hartig
51a4601e18 Update soloader to 0.5.1
Summary:
There's been a breaking change in 0.5 and old versions
are ABI-incompatible with new ones.

Reviewed By: muraziz

Differential Revision: D8913456

fbshipit-source-id: 89221c5ac95c7c2197083a5390403c72e7e33af1
2018-07-19 06:58:13 -07:00
Scott Wolchok
0bc4d23e2e Explicitly default YGNode copy ctor
Summary: No need to type out the old version. This is exactly equivalent (unless I've misread and the old version did something other than memberwise copy).

Reviewed By: davidaurelio

Differential Revision: D8842326

fbshipit-source-id: c575ea4cee6caef9ea15aaf5967597385ed26ec3
2018-07-18 15:59:02 -07:00
Scott Wolchok
4c47dcbd0f Delete YGNode ctor w/arg per member
Summary: It doesn't seem to be used internally, it hurts greppability, and there are setters for these properties as needed anyway.

Reviewed By: davidaurelio

Differential Revision: D8842084

fbshipit-source-id: f0275b490e585ea94df341c97c34b441ed91c4fb
2018-07-18 15:59:02 -07:00
David Aurelio
c1a9f6120a Make YGFloatIsUndefined inlineable
Summary:
@public

Makes `YGFloatIsUndefined` inlineable

Reviewed By: swolchok

Differential Revision: D8875520

fbshipit-source-id: 7ac653e002512b1a8d5f9c04e0a21381aeb02e67
2018-07-18 02:27:05 -07:00
David Aurelio
1b32c4f054 Lint Utils.cpp YGLayout.cpp YGNode.cpp Yoga-internal.h
Summary:
@public

Auto-fixes formatting of YGLayout.cpp YGNode.cpp Yoga-internal.h

Reviewed By: astreet

Differential Revision: D8875514

fbshipit-source-id: 38d709831349c4ad015f20451421aea89fc6f007
2018-07-18 01:17:22 -07:00
Taras Tsugrii
896cfbdfde Skylarkify yoga build defs.
Summary:
Top-level `if` statements are not allowed in a new Buck parser - Skylark.
https://buckbuild.com/concept/skylark.html

Reviewed By: grzmiel

Differential Revision: D8849590

fbshipit-source-id: 6648135f23e058adfeddf574932f8a98c7831fee
2018-07-14 00:27:17 -07:00
Scott Wolchok
910aa77c01 Remove some unnecessary const float & uses
Summary: Holding floats by reference is unnecessary at best and may be detrimental to performance.

Reviewed By: davidaurelio

Differential Revision: D8826496

fbshipit-source-id: 2391f8aa26ebfbb440f6e4b7d57975be688f791c
2018-07-13 12:43:19 -07:00
Scott Wolchok
2562c029b1 Tidy up YGFloatOptional further
Summary: I missed these two things: inline default ctor, getValue() should return a float.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8826640

fbshipit-source-id: e6324dea0268ef276e6fa1722e72dffb5241e676
2018-07-13 12:43:19 -07:00
Scott Wolchok
0b1780a081 YGNode::getChildren() should return const ref
Summary:
It's wasteful to do it by value. I'm fairly sure this is
safe, especially because
fbd332dee8 (diff-ade2a4bbd6582e2898cbd9e0fa142ab5R215)
shows that we did access by reference before.

Reviewed By: priteshrnandgaonkar, davidaurelio

Differential Revision: D8822697

fbshipit-source-id: 791bcf0fa37453f67795af727c85c8adce3b0f69
2018-07-13 12:43:18 -07:00
573 changed files with 32053 additions and 13398 deletions

56
.clang-format Normal file
View File

@@ -0,0 +1,56 @@
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyReturnTypeOnItsOwnLine: 2000
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
Standard: Cpp11
UseTab: Never

1
.clang-format-ignore Normal file
View File

@@ -0,0 +1 @@
^lib/.*

58
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,58 @@
name: CI
on: [push, pull_request]
jobs:
website:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 8.x
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
working-directory: website
- name: Build
run: yarn build
working-directory: website
- name: Deploy
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: website/public
cname: yogalayout.com
keep_files: true
user_name: 'Yoga-bot'
user_email: 'yogabot@fb.com'
android:
runs-on: ubuntu-latest
steps:
- 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
run: |
if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then
openssl aes-256-cbc -K ${{ secrets.encrypted_d27e803291ff_key }} -iv {{ secrets.encrypted_d27e803291ff_iv }} -in scripts/setup-keys.enc -d >> gradle.properties;
fi
sudo apt-get update
sudo apt-get install -y ninja-build
pushd $HOME
git clone --depth 1 https://github.com/facebook/buck.git
cd buck
ant
popd
echo "$HOME/buck/bin" >> $GITHUB_PATH
export PATH=$PATH:$HOME/buck/bin/
buck --version
- name: Build
# 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
/gentest/test.html
.buckversion
.cxx
.idea
/local.properties
# Jekyll
/.sass-cache/

View File

@@ -1 +0,0 @@
3.0

View File

@@ -1,68 +0,0 @@
language: java
env:
- TARGET: website
- TARGET: android
install:
- cd website
- yarn --ignore-scripts
- cd ..
cache:
directories:
- $HOME/buck
- $HOME/.gradle
before_install:
- |
if [[ -n "$encrypted_d27e803291ff_iv" ]]; then
openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties;
fi
# Android
- |
if [[ $TARGET = "android" ]]; then
pushd $HOME
git clone --depth 1 https://github.com/facebook/buck.git
cd buck
ant
popd
export PATH=$PATH:$HOME/buck/bin/
buck --version
export TERMINAL=dumb
source scripts/android-setup.sh && installAndroidSDK
export ANDROID_SDK=$ANDROID_HOME
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
export ANDROID_NDK_HOME=$ANDROID_NDK_REPOSITORY/android-ndk-r15c
fi
# Website
- |
if [[ $TARGET = "website" ]]; then
nvm install 8
nvm use 8
fi
script:
- |
if [[ $TARGET = "android" ]]; then
./gradlew testDebugUnit && scripts/publish-snapshot.sh
fi
- |
if [[ $TARGET = "website" ]]; then
pushd website
yarn build
popd
fi
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
fqdn: yogalayout.com
local-dir: website/public
email: yogabot@fb.com
name: Yoga-bot
keep-history: true
on:
branch: master
condition: $TARGET = website

65
BUCK
View File

@@ -1,44 +1,83 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep")
load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "YOGA_ROOTS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep", "yoga_prebuilt_cxx_library")
GMOCK_OVERRIDE_FLAGS = [
# gmock does not mark mocked methods as override, ignore the warnings in tests
"-Wno-inconsistent-missing-override",
]
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
"-std=c++1y",
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
"-DDEBUG",
"-DYG_ENABLE_EVENTS",
]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
"-std=c++1y",
]
yoga_prebuilt_cxx_library(
name = "ndklog",
exported_platform_linker_flags = [
(
"^android.*",
["-llog"],
),
],
header_only = True,
visibility = YOGA_ROOTS,
)
yoga_cxx_library(
name = "yoga",
srcs = glob(["yoga/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = COMPILER_FLAGS,
srcs = glob(["yoga/**/*.cpp"]),
compiler_flags = LIBRARY_COMPILER_FLAGS,
public_include_directories = ["."],
raw_headers = glob(["yoga/**/*.h"]),
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
yoga_dep("lib/fb:ndklog"),
":ndklog",
],
)
yoga_cxx_library(
name = "yoga-static",
srcs = glob(["yoga/**/*.cpp"]),
compiler_flags = LIBRARY_COMPILER_FLAGS,
preferred_linkage = "static",
public_include_directories = ["."],
raw_headers = glob(["yoga/**/*.h"]),
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
":ndklog",
],
)
yoga_cxx_library(
name = "yogaForDebug",
srcs = glob(["yoga/**/*.cpp"]),
compiler_flags = TEST_COMPILER_FLAGS,
public_include_directories = ["."],
raw_headers = glob(["yoga/**/*.h"]),
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
":yoga",
],
)
yoga_cxx_test(
name = "YogaTests",
srcs = glob(["tests/*.cpp"]),
headers = subdir_glob([("", "yoga/**/*.h")]),
compiler_flags = TEST_COMPILER_FLAGS,
contacts = ["emilsj@fb.com"],
visibility = ["PUBLIC"],
deps = [
":yoga",
":yogaForDebug",
yoga_dep("testutil:testutil"),
GTEST_TARGET,
],
)

View File

@@ -1,15 +1,24 @@
#
# Copyright (c) 2014-present, Facebook, Inc.
# 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.
#
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB yogacore_SRC yoga/*.cpp)
add_compile_options(
-fno-omit-frame-pointer
-fexceptions
-fvisibility=hidden
-ffunction-sections
-fdata-sections
-Wall
-std=c++11)
file(GLOB_RECURSE yogacore_SRC yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC})
target_include_directories(yogacore PUBLIC .)
target_link_libraries(yogacore android log)
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)

View File

@@ -1,3 +1,77 @@
# Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <opensource-conduct@fb.com>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@@ -4,7 +4,7 @@ possible.
## Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
## Pull Requests
We actively welcome your pull requests.

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2014-present, Facebook, Inc.
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,14 +1,14 @@
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg)](http://cocoapods.org/pods/YogaKit) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![bintray](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga:yoga.svg)](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [![NuGet](https://img.shields.io/nuget/v/Facebook.Yoga.svg)](https://www.nuget.org/packages/Facebook.Yoga)
## Building
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C++, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
## Testing
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generate a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
```html
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
@@ -46,3 +46,29 @@ This will now only run the standalone webpack build upon install.
| node | Builds node js version. |
| standalone | Runs webpack. |
| 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!

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,11 @@
# 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.
Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '1.9.0'
spec.version = '1.14.0'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://yogalayout.com/docs'
@@ -13,7 +18,7 @@ Pod::Spec.new do |spec|
:git => 'https://github.com/facebook/yoga.git',
:tag => spec.version.to_s,
}
spec.platforms = { :ios => "8.0", :tvos => "10.0" }
spec.platforms = { :ios => "8.0", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
spec.module_name = 'yoga'
spec.requires_arc = false
spec.pod_target_xcconfig = {
@@ -28,6 +33,6 @@ Pod::Spec.new do |spec|
'-fPIC'
]
spec.source_files = 'yoga/**/*.{c,h,cpp}'
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros}.h'
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGNode,YGStyle,YGValue}.h'
end

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:YogaDev/YogaDev.xcodeproj">
</FileRef>
<FileRef
location = "group:ReactYoga.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,350 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F892249476700CBB1EC /* YGMarker.cpp */; };
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F8B2249476700CBB1EC /* YGValue.cpp */; };
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F902249476700CBB1EC /* YGLayout.cpp */; };
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */; };
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F992249476800CBB1EC /* YGStyle.cpp */; };
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9A2249476800CBB1EC /* log.cpp */; };
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9B2249476800CBB1EC /* YGNode.cpp */; };
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9C2249476800CBB1EC /* Yoga.cpp */; };
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9D2249476800CBB1EC /* Utils.cpp */; };
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */; };
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7FA32249476800CBB1EC /* YGConfig.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
6D4C7F76224945B200CBB1EC /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
6D4C7F78224945B200CBB1EC /* libYogaDev.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libYogaDev.a; sourceTree = BUILT_PRODUCTS_DIR; };
6D4C7F892249476700CBB1EC /* YGMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGMarker.cpp; path = ../yoga/YGMarker.cpp; sourceTree = "<group>"; };
6D4C7F8A2249476700CBB1EC /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../yoga/Utils.h; sourceTree = "<group>"; };
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGValue.cpp; path = ../yoga/YGValue.cpp; sourceTree = "<group>"; };
6D4C7F8C2249476700CBB1EC /* instrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = instrumentation.h; path = ../yoga/instrumentation.h; sourceTree = "<group>"; };
6D4C7F8D2249476700CBB1EC /* YGStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGStyle.h; path = ../yoga/YGStyle.h; sourceTree = "<group>"; };
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNodePrint.h; path = ../yoga/YGNodePrint.h; sourceTree = "<group>"; };
6D4C7F8F2249476700CBB1EC /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMarker.h; path = ../yoga/YGMarker.h; sourceTree = "<group>"; };
6D4C7F902249476700CBB1EC /* YGLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGLayout.cpp; path = ../yoga/YGLayout.cpp; sourceTree = "<group>"; };
6D4C7F912249476700CBB1EC /* YGEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGEnums.h; path = ../yoga/YGEnums.h; sourceTree = "<group>"; };
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNodePrint.cpp; path = ../yoga/YGNodePrint.cpp; sourceTree = "<group>"; };
6D4C7F932249476700CBB1EC /* YGMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMacros.h; path = ../yoga/YGMacros.h; sourceTree = "<group>"; };
6D4C7F942249476700CBB1EC /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = log.h; path = ../yoga/log.h; sourceTree = "<group>"; };
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGFloatOptional.h; path = ../yoga/YGFloatOptional.h; sourceTree = "<group>"; };
6D4C7F962249476800CBB1EC /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNode.h; path = ../yoga/YGNode.h; sourceTree = "<group>"; };
6D4C7F972249476800CBB1EC /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGLayout.h; path = ../yoga/YGLayout.h; sourceTree = "<group>"; };
6D4C7F982249476800CBB1EC /* CompactValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactValue.h; path = ../yoga/CompactValue.h; sourceTree = "<group>"; };
6D4C7F992249476800CBB1EC /* YGStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGStyle.cpp; path = ../yoga/YGStyle.cpp; sourceTree = "<group>"; };
6D4C7F9A2249476800CBB1EC /* log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = log.cpp; path = ../yoga/log.cpp; sourceTree = "<group>"; };
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNode.cpp; path = ../yoga/YGNode.cpp; sourceTree = "<group>"; };
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Yoga.cpp; path = ../yoga/Yoga.cpp; sourceTree = "<group>"; };
6D4C7F9D2249476800CBB1EC /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Utils.cpp; path = ../yoga/Utils.cpp; sourceTree = "<group>"; };
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGEnums.cpp; path = ../yoga/YGEnums.cpp; sourceTree = "<group>"; };
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Yoga-internal.h"; path = "../yoga/Yoga-internal.h"; sourceTree = "<group>"; };
6D4C7FA02249476800CBB1EC /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGValue.h; path = ../yoga/YGValue.h; sourceTree = "<group>"; };
6D4C7FA12249476800CBB1EC /* Yoga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Yoga.h; path = ../yoga/Yoga.h; sourceTree = "<group>"; };
6D4C7FA22249476800CBB1EC /* YGConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGConfig.h; path = ../yoga/YGConfig.h; sourceTree = "<group>"; };
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGConfig.cpp; path = ../yoga/YGConfig.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
6D4C7F75224945B200CBB1EC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
6D4C7F6F224945B200CBB1EC = {
isa = PBXGroup;
children = (
6D4C7F982249476800CBB1EC /* CompactValue.h */,
6D4C7F8C2249476700CBB1EC /* instrumentation.h */,
6D4C7F9A2249476800CBB1EC /* log.cpp */,
6D4C7F942249476700CBB1EC /* log.h */,
6D4C7F9D2249476800CBB1EC /* Utils.cpp */,
6D4C7F8A2249476700CBB1EC /* Utils.h */,
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */,
6D4C7FA22249476800CBB1EC /* YGConfig.h */,
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */,
6D4C7F912249476700CBB1EC /* YGEnums.h */,
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */,
6D4C7F902249476700CBB1EC /* YGLayout.cpp */,
6D4C7F972249476800CBB1EC /* YGLayout.h */,
6D4C7F932249476700CBB1EC /* YGMacros.h */,
6D4C7F892249476700CBB1EC /* YGMarker.cpp */,
6D4C7F8F2249476700CBB1EC /* YGMarker.h */,
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */,
6D4C7F962249476800CBB1EC /* YGNode.h */,
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */,
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */,
6D4C7F992249476800CBB1EC /* YGStyle.cpp */,
6D4C7F8D2249476700CBB1EC /* YGStyle.h */,
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */,
6D4C7FA02249476800CBB1EC /* YGValue.h */,
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */,
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */,
6D4C7FA12249476800CBB1EC /* Yoga.h */,
6D4C7F79224945B200CBB1EC /* Products */,
);
sourceTree = "<group>";
};
6D4C7F79224945B200CBB1EC /* Products */ = {
isa = PBXGroup;
children = (
6D4C7F78224945B200CBB1EC /* libYogaDev.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
6D4C7F77224945B200CBB1EC /* YogaDev */ = {
isa = PBXNativeTarget;
buildConfigurationList = 6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */;
buildPhases = (
6D4C7F74224945B200CBB1EC /* Sources */,
6D4C7F75224945B200CBB1EC /* Frameworks */,
6D4C7F76224945B200CBB1EC /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = YogaDev;
productName = YogaDev;
productReference = 6D4C7F78224945B200CBB1EC /* libYogaDev.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
6D4C7F70224945B200CBB1EC /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Will Wilson";
TargetAttributes = {
6D4C7F77224945B200CBB1EC = {
CreatedOnToolsVersion = 10.1;
};
};
};
buildConfigurationList = 6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 6D4C7F6F224945B200CBB1EC;
productRefGroup = 6D4C7F79224945B200CBB1EC /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
6D4C7F77224945B200CBB1EC /* YogaDev */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
6D4C7F74224945B200CBB1EC /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */,
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */,
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */,
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */,
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */,
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */,
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */,
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */,
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */,
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */,
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
6D4C7F7F224945B200CBB1EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
6D4C7F80224945B200CBB1EC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
6D4C7F82224945B200CBB1EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
6D4C7F83224945B200CBB1EC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6D4C7F7F224945B200CBB1EC /* Debug */,
6D4C7F80224945B200CBB1EC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6D4C7F82224945B200CBB1EC /* Debug */,
6D4C7F83224945B200CBB1EC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 6D4C7F70224945B200CBB1EC /* Project object */;
}

View File

@@ -1,9 +1,14 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit'
spec.version = '1.9.0'
spec.version = '1.18.1'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/'
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
@@ -11,17 +16,22 @@ podspec = Pod::Spec.new do |spec|
spec.authors = 'Facebook'
spec.source = {
:git => 'https://github.com/facebook/yoga.git',
:tag => spec.version.to_s,
:tag => "1.18.0",
}
spec.platform = :ios
spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'UIKit'
spec.dependency 'Yoga', '~> 1.9'
spec.module_name = 'YogaKit'
spec.dependency 'Yoga', '~> 1.14'
# Fixes the bug related the xcode 11 not able to find swift related frameworks.
# https://github.com/Carthage/Carthage/issues/2825
# https://twitter.com/krzyzanowskim/status/1151549874653081601?s=21
spec.pod_target_xcconfig = {"LD_VERIFY_BITCODE": "NO"}
spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
spec.swift_version = '5.1'
end
# See https://github.com/facebook/yoga/pull/366

View File

@@ -1,8 +1,8 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
COMPILER_FLAGS = [
"-fobjc-arc",
@@ -37,11 +37,14 @@ yoga_apple_library(
),
compiler_flags = COMPILER_FLAGS,
frameworks = [
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
],
header_path_prefix = "",
link_whole = True,
modular = True,
module_name = "YogaKit",
visibility = ["PUBLIC"],
deps = [
yoga_dep(":yoga"),

View File

@@ -1,32 +1,33 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout.h"
#import <UIKit/UIKit.h>
#import "YGLayout.h"
NS_ASSUME_NONNULL_BEGIN
typedef void (^YGLayoutConfigurationBlock)(YGLayout *layout);
typedef void (^YGLayoutConfigurationBlock)(YGLayout* layout);
@interface UIView (Yoga)
/**
The YGLayout that is attached to this view. It is lazily created.
*/
@property (nonatomic, readonly, strong) YGLayout *yoga;
@property(nonatomic, readonly, strong) YGLayout* yoga;
/**
Indicates whether or not Yoga is enabled
*/
@property (nonatomic, readonly, assign) BOOL isYogaEnabled;
@property(nonatomic, readonly, assign) BOOL isYogaEnabled;
/**
In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend`
to your code. If you plan on making multiple changes to YGLayout, it's more performant
to use this method, which uses a single objc_msgSend call.
In ObjC land, every time you access `view.yoga.*` you are adding another
`objc_msgSend` to your code. If you plan on making multiple changes to
YGLayout, it's more performant to use this method, which uses a single
objc_msgSend call.
*/
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
NS_SWIFT_NAME(configureLayout(block:));

View File

@@ -1,36 +1,34 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <objc/runtime.h>
#import "UIView+Yoga.h"
#import "YGLayout+Private.h"
#import <objc/runtime.h>
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
static const void* kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
@implementation UIView (YogaKit)
- (YGLayout *)yoga
{
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
- (YGLayout*)yoga {
YGLayout* yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
if (!yoga) {
yoga = [[YGLayout alloc] initWithView:self];
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
objc_setAssociatedObject(
self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return yoga;
}
- (BOOL)isYogaEnabled
{
- (BOOL)isYogaEnabled {
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
}
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
{
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block {
if (block != nil) {
block(self.yoga);
}

View File

@@ -1,17 +1,17 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout.h"
#import <yoga/Yoga.h>
#import "YGLayout.h"
@interface YGLayout ()
@property (nonatomic, assign, readonly) YGNodeRef node;
@property(nonatomic, assign, readonly) YGNodeRef node;
- (instancetype)initWithView:(UIView *)view;
- (instancetype)initWithView:(UIView*)view;
@end

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -7,15 +7,15 @@
#import <UIKit/UIKit.h>
#import <yoga/YGEnums.h>
#import <yoga/Yoga.h>
#import <yoga/YGMacros.h>
#import <yoga/Yoga.h>
YG_EXTERN_C_BEGIN
extern YGValue YGPointValue(CGFloat value)
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
extern YGValue YGPercentValue(CGFloat value)
NS_SWIFT_UNAVAILABLE("Use the swift Int and FloatingPoint extensions instead");
extern YGValue YGPointValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
"Use the swift Int and FloatingPoint extensions instead");
extern YGValue YGPercentValue(CGFloat value) NS_SWIFT_UNAVAILABLE(
"Use the swift Int and FloatingPoint extensions instead");
YG_EXTERN_C_END
@@ -33,106 +33,118 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
- (instancetype)init
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
Make default init unavailable, as it will not initialise YGNode which is
required for the setters and getters of YGLayout's properties to work properly.
*/
+ (instancetype)new
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
The property that decides if we should include this view when calculating
layout. Defaults to YES.
*/
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
@property(nonatomic, readwrite, assign, setter=setIncludedInLayout:)
BOOL isIncludedInLayout;
/**
The property that decides during layout/sizing whether or not styling properties should be applied.
Defaults to NO.
The property that decides during layout/sizing whether or not styling
properties should be applied. Defaults to NO.
*/
@property (nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
@property(nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
@property (nonatomic, readwrite, assign) YGDirection direction;
@property (nonatomic, readwrite, assign) YGFlexDirection flexDirection;
@property (nonatomic, readwrite, assign) YGJustify justifyContent;
@property (nonatomic, readwrite, assign) YGAlign alignContent;
@property (nonatomic, readwrite, assign) YGAlign alignItems;
@property (nonatomic, readwrite, assign) YGAlign alignSelf;
@property (nonatomic, readwrite, assign) YGPositionType position;
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
@property (nonatomic, readwrite, assign) YGOverflow overflow;
@property (nonatomic, readwrite, assign) YGDisplay display;
@property(nonatomic, readwrite, assign) YGDirection direction;
@property(nonatomic, readwrite, assign) YGFlexDirection flexDirection;
@property(nonatomic, readwrite, assign) YGJustify justifyContent;
@property(nonatomic, readwrite, assign) YGAlign alignContent;
@property(nonatomic, readwrite, assign) YGAlign alignItems;
@property(nonatomic, readwrite, assign) YGAlign alignSelf;
@property(nonatomic, readwrite, assign) YGPositionType position;
@property(nonatomic, readwrite, assign) YGWrap flexWrap;
@property(nonatomic, readwrite, assign) YGOverflow overflow;
@property(nonatomic, readwrite, assign) YGDisplay display;
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
@property (nonatomic, readwrite, assign) YGValue flexBasis;
@property(nonatomic, readwrite, assign) CGFloat flex;
@property(nonatomic, readwrite, assign) CGFloat flexGrow;
@property(nonatomic, readwrite, assign) CGFloat flexShrink;
@property(nonatomic, readwrite, assign) YGValue flexBasis;
@property (nonatomic, readwrite, assign) YGValue left;
@property (nonatomic, readwrite, assign) YGValue top;
@property (nonatomic, readwrite, assign) YGValue right;
@property (nonatomic, readwrite, assign) YGValue bottom;
@property (nonatomic, readwrite, assign) YGValue start;
@property (nonatomic, readwrite, assign) YGValue end;
@property(nonatomic, readwrite, assign) YGValue left;
@property(nonatomic, readwrite, assign) YGValue top;
@property(nonatomic, readwrite, assign) YGValue right;
@property(nonatomic, readwrite, assign) YGValue bottom;
@property(nonatomic, readwrite, assign) YGValue start;
@property(nonatomic, readwrite, assign) YGValue end;
@property (nonatomic, readwrite, assign) YGValue marginLeft;
@property (nonatomic, readwrite, assign) YGValue marginTop;
@property (nonatomic, readwrite, assign) YGValue marginRight;
@property (nonatomic, readwrite, assign) YGValue marginBottom;
@property (nonatomic, readwrite, assign) YGValue marginStart;
@property (nonatomic, readwrite, assign) YGValue marginEnd;
@property (nonatomic, readwrite, assign) YGValue marginHorizontal;
@property (nonatomic, readwrite, assign) YGValue marginVertical;
@property (nonatomic, readwrite, assign) YGValue margin;
@property(nonatomic, readwrite, assign) YGValue marginLeft;
@property(nonatomic, readwrite, assign) YGValue marginTop;
@property(nonatomic, readwrite, assign) YGValue marginRight;
@property(nonatomic, readwrite, assign) YGValue marginBottom;
@property(nonatomic, readwrite, assign) YGValue marginStart;
@property(nonatomic, readwrite, assign) YGValue marginEnd;
@property(nonatomic, readwrite, assign) YGValue marginHorizontal;
@property(nonatomic, readwrite, assign) YGValue marginVertical;
@property(nonatomic, readwrite, assign) YGValue margin;
@property (nonatomic, readwrite, assign) YGValue paddingLeft;
@property (nonatomic, readwrite, assign) YGValue paddingTop;
@property (nonatomic, readwrite, assign) YGValue paddingRight;
@property (nonatomic, readwrite, assign) YGValue paddingBottom;
@property (nonatomic, readwrite, assign) YGValue paddingStart;
@property (nonatomic, readwrite, assign) YGValue paddingEnd;
@property (nonatomic, readwrite, assign) YGValue paddingHorizontal;
@property (nonatomic, readwrite, assign) YGValue paddingVertical;
@property (nonatomic, readwrite, assign) YGValue padding;
@property(nonatomic, readwrite, assign) YGValue paddingLeft;
@property(nonatomic, readwrite, assign) YGValue paddingTop;
@property(nonatomic, readwrite, assign) YGValue paddingRight;
@property(nonatomic, readwrite, assign) YGValue paddingBottom;
@property(nonatomic, readwrite, assign) YGValue paddingStart;
@property(nonatomic, readwrite, assign) YGValue paddingEnd;
@property(nonatomic, readwrite, assign) YGValue paddingHorizontal;
@property(nonatomic, readwrite, assign) YGValue paddingVertical;
@property(nonatomic, readwrite, assign) YGValue padding;
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
@property (nonatomic, readwrite, assign) CGFloat borderRightWidth;
@property (nonatomic, readwrite, assign) CGFloat borderBottomWidth;
@property (nonatomic, readwrite, assign) CGFloat borderStartWidth;
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
@property(nonatomic, readwrite, assign) CGFloat borderLeftWidth;
@property(nonatomic, readwrite, assign) CGFloat borderTopWidth;
@property(nonatomic, readwrite, assign) CGFloat borderRightWidth;
@property(nonatomic, readwrite, assign) CGFloat borderBottomWidth;
@property(nonatomic, readwrite, assign) CGFloat borderStartWidth;
@property(nonatomic, readwrite, assign) CGFloat borderEndWidth;
@property(nonatomic, readwrite, assign) CGFloat borderWidth;
@property (nonatomic, readwrite, assign) YGValue width;
@property (nonatomic, readwrite, assign) YGValue height;
@property (nonatomic, readwrite, assign) YGValue minWidth;
@property (nonatomic, readwrite, assign) YGValue minHeight;
@property (nonatomic, readwrite, assign) YGValue maxWidth;
@property (nonatomic, readwrite, assign) YGValue maxHeight;
@property(nonatomic, readwrite, assign) YGValue width;
@property(nonatomic, readwrite, assign) YGValue height;
@property(nonatomic, readwrite, assign) YGValue minWidth;
@property(nonatomic, readwrite, assign) YGValue minHeight;
@property(nonatomic, readwrite, assign) YGValue maxWidth;
@property(nonatomic, readwrite, assign) YGValue maxHeight;
// Yoga specific properties, not compatible with flexbox specification
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
@property(nonatomic, readwrite, assign) CGFloat aspectRatio;
/**
Get the resolved direction of this node. This won't be YGDirectionInherit
*/
@property (nonatomic, readonly, assign) YGDirection resolvedDirection;
@property(nonatomic, readonly, assign) YGDirection resolvedDirection;
/**
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
If the origin is not preserved, the root view's layout results will applied from {0,0}.
Perform a layout calculation and update the frames of the views in the
hierarchy with the results. If the origin is not preserved, the root view's
layout results will applied from {0,0}.
*/
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
NS_SWIFT_NAME(applyLayout(preservingOrigin:));
/**
Perform a layout calculation and update the frames of the views in the hierarchy with the results.
If the origin is not preserved, the root view's layout results will applied from {0,0}.
Perform a layout calculation and update the frames of the views in the
hierarchy with the results. If the origin is not preserved, the root view's
layout results will applied from {0,0}.
*/
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
NS_SWIFT_NAME(applyLayout(preservingOrigin:dimensionFlexibility:));
/**
Returns the size of the view if no constraints were given. This could equivalent to calling [self
sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
Returns the size of the view if no constraints were given. This could
equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
*/
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
@property(nonatomic, readonly, assign) CGSize intrinsicSize;
/**
Returns the size of the view based on provided constraints. Pass NaN for an unconstrained dimension.
Returns the size of the view based on provided constraints. Pass NaN for an
unconstrained dimension.
*/
- (CGSize)calculateLayoutWithSize:(CGSize)size
NS_SWIFT_NAME(calculateLayout(with:));
@@ -140,19 +152,19 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
/**
Returns the number of children that are using Flexbox.
*/
@property (nonatomic, readonly, assign) NSUInteger numberOfChildren;
@property(nonatomic, readonly, assign) NSUInteger numberOfChildren;
/**
Return a BOOL indiciating whether or not we this node contains any subviews that are included in
Yoga's layout.
Return a BOOL indiciating whether or not we this node contains any subviews
that are included in Yoga's layout.
*/
@property (nonatomic, readonly, assign) BOOL isLeaf;
@property(nonatomic, readonly, assign) BOOL isLeaf;
/**
Return's a BOOL indicating if a view is dirty. When a node is dirty
it usually indicates that it will be remeasured on the next layout pass.
*/
@property (nonatomic, readonly, assign) BOOL isDirty;
@property(nonatomic, readonly, assign) BOOL isDirty;
/**
Mark that a view's layout needs to be recalculated. Only works for leaf views.

View File

@@ -1,175 +1,205 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "YGLayout+Private.h"
#import "UIView+Yoga.h"
#import "YGLayout+Private.h"
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
- (type)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(type)lowercased_name \
{ \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
-(type)lowercased_name { \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
-(void)set##capitalized_name : (type)lowercased_name { \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
}
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
-(YGValue)lowercased_name { \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
-(void)set##capitalized_name : (YGValue)lowercased_name { \
switch (lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent( \
self.node, lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
-(YGValue)lowercased_name { \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
-(void)set##capitalized_name : (YGValue)lowercased_name { \
switch (lowercased_name.unit) { \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent( \
self.node, lowercased_name.value); \
break; \
case YGUnitAuto: \
YGNodeStyleSet##capitalized_name##Auto(self.node); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_EDGE_PROPERTY_GETTER( \
type, lowercased_name, capitalized_name, property, edge) \
-(type)lowercased_name { \
return YGNodeStyleGet##property(self.node, edge); \
}
#define YG_EDGE_PROPERTY_SETTER( \
lowercased_name, capitalized_name, property, edge) \
-(void)set##capitalized_name : (CGFloat)lowercased_name { \
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
}
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER( \
CGFloat, lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGE_PROPERTY_SETTER( \
objc_lowercased_name, objc_capitalized_name, c_name, edge) \
-(void)set##objc_capitalized_name : (YGValue)objc_lowercased_name { \
switch (objc_lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##c_name##Percent( \
self.node, edge, objc_lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_VALUE_EDGE_PROPERTY( \
lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER( \
YGValue, lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_SETTER( \
lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Left, \
capitalized_name##Left, \
capitalized_name, \
YGEdgeLeft) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Top, \
capitalized_name##Top, \
capitalized_name, \
YGEdgeTop) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Right, \
capitalized_name##Right, \
capitalized_name, \
YGEdgeRight) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Bottom, \
capitalized_name##Bottom, \
capitalized_name, \
YGEdgeBottom) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Start, \
capitalized_name##Start, \
capitalized_name, \
YGEdgeStart) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##End, \
capitalized_name##End, \
capitalized_name, \
YGEdgeEnd) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Horizontal, \
capitalized_name##Horizontal, \
capitalized_name, \
YGEdgeHorizontal) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name##Vertical, \
capitalized_name##Vertical, \
capitalized_name, \
YGEdgeVertical) \
YG_VALUE_EDGE_PROPERTY( \
lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
YGValue YGPointValue(CGFloat value) {
return (YGValue){.value = value, .unit = YGUnitPoint};
}
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
case YGUnitAuto: \
YGNodeStyleSet##capitalized_name##Auto(self.node); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
- (type)lowercased_name \
{ \
return YGNodeStyleGet##property(self.node, edge); \
}
#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \
- (void)set##capitalized_name:(CGFloat)lowercased_name \
{ \
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
}
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(CGFloat, lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
{ \
switch (objc_lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPoint: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##c_name##Percent(self.node, edge, objc_lowercased_name.value); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(YGValue, lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
YGValue YGPointValue(CGFloat value)
{
return (YGValue) { .value = value, .unit = YGUnitPoint };
}
YGValue YGPercentValue(CGFloat value)
{
return (YGValue) { .value = value, .unit = YGUnitPercent };
YGValue YGPercentValue(CGFloat value) {
return (YGValue){.value = value, .unit = YGUnitPercent};
}
static YGConfigRef globalConfig;
@interface YGLayout ()
@property (nonatomic, weak, readonly) UIView *view;
@property(nonatomic, weak, readonly) UIView* view;
@property(nonatomic, assign, readonly) BOOL isUIView;
@end
@implementation YGLayout
@synthesize isEnabled=_isEnabled;
@synthesize isIncludedInLayout=_isIncludedInLayout;
@synthesize node=_node;
@synthesize isEnabled = _isEnabled;
@synthesize isIncludedInLayout = _isIncludedInLayout;
@synthesize node = _node;
+ (void)initialize
{
+ (void)initialize {
globalConfig = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(globalConfig, YGExperimentalFeatureWebFlexBasis, true);
YGConfigSetExperimentalFeatureEnabled(
globalConfig, YGExperimentalFeatureWebFlexBasis, true);
YGConfigSetPointScaleFactor(globalConfig, [UIScreen mainScreen].scale);
}
- (instancetype)initWithView:(UIView*)view
{
- (instancetype)initWithView:(UIView*)view {
if (self = [super init]) {
_view = view;
_node = YGNodeNewWithConfig(globalConfig);
YGNodeSetContext(_node, (__bridge void *) view);
YGNodeSetContext(_node, (__bridge void*)view);
_isEnabled = NO;
_isIncludedInLayout = YES;
_isUIView = [view isMemberOfClass:[UIView class]];
}
return self;
}
- (void)dealloc
{
- (void)dealloc {
YGNodeFree(self.node);
}
- (BOOL)isDirty
{
- (BOOL)isDirty {
return YGNodeIsDirty(self.node);
}
- (void)markDirty
{
- (void)markDirty {
if (self.isDirty || !self.isLeaf) {
return;
}
@@ -178,24 +208,24 @@ static YGConfigRef globalConfig;
// the measure function. Since we already know that this is a leaf,
// this *should* be fine. Forgive me Hack Gods.
const YGNodeRef node = self.node;
if (YGNodeGetMeasureFunc(node) == NULL) {
if (!YGNodeHasMeasureFunc(node)) {
YGNodeSetMeasureFunc(node, YGMeasureView);
}
YGNodeMarkDirty(node);
}
- (NSUInteger)numberOfChildren
{
- (NSUInteger)numberOfChildren {
return YGNodeGetChildCount(self.node);
}
- (BOOL)isLeaf
{
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
- (BOOL)isLeaf {
NSAssert(
[NSThread isMainThread],
@"This method must be called on the main thread.");
if (self.isEnabled) {
for (UIView *subview in self.view.subviews) {
YGLayout *const yoga = subview.yoga;
for (UIView* subview in self.view.subviews) {
YGLayout* const yoga = subview.yoga;
if (yoga.isEnabled && yoga.isIncludedInLayout) {
return NO;
}
@@ -207,13 +237,11 @@ static YGConfigRef globalConfig;
#pragma mark - Style
- (YGPositionType)position
{
- (YGPositionType)position {
return YGNodeStyleGetPositionType(self.node);
}
- (void)setPosition:(YGPositionType)position
{
- (void)setPosition:(YGPositionType)position {
YGNodeStyleSetPositionType(self.node, position);
}
@@ -227,6 +255,7 @@ YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
YG_PROPERTY(YGOverflow, overflow, Overflow)
YG_PROPERTY(YGDisplay, display, Display)
YG_PROPERTY(CGFloat, flex, Flex)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
@@ -258,25 +287,23 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
#pragma mark - Layout and Sizing
- (YGDirection)resolvedDirection
{
- (YGDirection)resolvedDirection {
return YGNodeLayoutGetDirection(self.node);
}
- (void)applyLayout
{
- (void)applyLayout {
[self calculateLayoutWithSize:self.view.bounds.size];
YGApplyLayoutToViewHierarchy(self.view, NO);
}
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
{
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin {
[self calculateLayoutWithSize:self.view.bounds.size];
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
}
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin dimensionFlexibility:(YGDimensionFlexibility)dimensionFlexibility
{
- (void)applyLayoutPreservingOrigin:(BOOL)preserveOrigin
dimensionFlexibility:
(YGDimensionFlexibility)dimensionFlexibility {
CGSize size = self.view.bounds.size;
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
size.width = YGUndefined;
@@ -288,18 +315,15 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
YGApplyLayoutToViewHierarchy(self.view, preserveOrigin);
}
- (CGSize)intrinsicSize
{
- (CGSize)intrinsicSize {
const CGSize constrainedSize = {
.width = YGUndefined,
.height = YGUndefined,
.width = YGUndefined,
.height = YGUndefined,
};
return [self calculateLayoutWithSize:constrainedSize];
}
- (CGSize)calculateLayoutWithSize:(CGSize)size
{
- (CGSize)calculateLayoutWithSize:(CGSize)size {
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
@@ -307,46 +331,55 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
const YGNodeRef node = self.node;
YGNodeCalculateLayout(
node,
size.width,
size.height,
YGNodeStyleGetDirection(node));
node, size.width, size.height, YGNodeStyleGetDirection(node));
return (CGSize) {
.width = YGNodeLayoutGetWidth(node),
.height = YGNodeLayoutGetHeight(node),
return (CGSize){
.width = YGNodeLayoutGetWidth(node),
.height = YGNodeLayoutGetHeight(node),
};
}
#pragma mark - Private
static YGSize YGMeasureView(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode)
{
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
const CGFloat constrainedWidth =
(widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
const CGFloat constrainedHeight =
(heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : height;
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
.width = constrainedWidth,
.height = constrainedHeight,
}];
UIView* view = (__bridge UIView*)YGNodeGetContext(node);
CGSize sizeThatFits = CGSizeZero;
return (YGSize) {
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
// The default implementation of sizeThatFits: returns the existing size of
// the view. That means that if we want to layout an empty UIView, which
// already has got a frame set, its measured size should be CGSizeZero, but
// UIKit returns the existing size.
//
// See https://github.com/facebook/yoga/issues/606 for more information.
if (!view.yoga.isUIView || [view.subviews count] > 0) {
sizeThatFits = [view sizeThatFits:(CGSize){
.width = constrainedWidth,
.height = constrainedHeight,
}];
}
return (YGSize){
.width = YGSanitizeMeasurement(
constrainedWidth, sizeThatFits.width, widthMode),
.height = YGSanitizeMeasurement(
constrainedHeight, sizeThatFits.height, heightMode),
};
}
static CGFloat YGSanitizeMeasurement(
CGFloat constrainedSize,
CGFloat measuredSize,
YGMeasureMode measureMode)
{
CGFloat constrainedSize,
CGFloat measuredSize,
YGMeasureMode measureMode) {
CGFloat result;
if (measureMode == YGMeasureModeExactly) {
result = constrainedSize;
@@ -359,13 +392,14 @@ static CGFloat YGSanitizeMeasurement(
return result;
}
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
{
static BOOL YGNodeHasExactSameChildren(
const YGNodeRef node,
NSArray<UIView*>* subviews) {
if (YGNodeGetChildCount(node) != subviews.count) {
return NO;
}
for (int i=0; i<subviews.count; i++) {
for (int i = 0; i < subviews.count; i++) {
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
return NO;
}
@@ -374,9 +408,8 @@ static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *
return YES;
}
static void YGAttachNodesFromViewHierachy(UIView *const view)
{
YGLayout *const yoga = view.yoga;
static void YGAttachNodesFromViewHierachy(UIView* const view) {
YGLayout* const yoga = view.yoga;
const YGNodeRef node = yoga.node;
// Only leaf nodes should have a measure function
@@ -386,8 +419,9 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
} else {
YGNodeSetMeasureFunc(node, NULL);
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView *subview in view.subviews) {
NSMutableArray<UIView*>* subviewsToInclude =
[[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView* subview in view.subviews) {
if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
[subviewsToInclude addObject:subview];
}
@@ -395,74 +429,75 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
YGRemoveAllChildren(node);
for (int i=0; i<subviewsToInclude.count; i++) {
for (int i = 0; i < subviewsToInclude.count; i++) {
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
}
}
for (UIView *const subview in subviewsToInclude) {
for (UIView* const subview in subviewsToInclude) {
YGAttachNodesFromViewHierachy(subview);
}
}
}
static void YGRemoveAllChildren(const YGNodeRef node)
{
static void YGRemoveAllChildren(const YGNodeRef node) {
if (node == NULL) {
return;
}
while (YGNodeGetChildCount(node) > 0) {
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
}
YGNodeRemoveAllChildren(node);
}
static CGFloat YGRoundPixelValue(CGFloat value)
{
static CGFloat YGRoundPixelValue(CGFloat value) {
static CGFloat scale;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^(){
dispatch_once(&onceToken, ^() {
scale = [UIScreen mainScreen].scale;
});
return roundf(value * scale) / scale;
}
static void YGApplyLayoutToViewHierarchy(UIView *view, BOOL preserveOrigin)
{
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
NSCAssert(
[NSThread isMainThread],
@"Framesetting should only be done on the main thread.");
const YGLayout *yoga = view.yoga;
const YGLayout* yoga = view.yoga;
if (!yoga.isIncludedInLayout) {
return;
return;
}
YGNodeRef node = yoga.node;
const CGPoint topLeft = {
YGNodeLayoutGetLeft(node),
YGNodeLayoutGetTop(node),
YGNodeLayoutGetLeft(node),
YGNodeLayoutGetTop(node),
};
const CGPoint bottomRight = {
topLeft.x + YGNodeLayoutGetWidth(node),
topLeft.y + YGNodeLayoutGetHeight(node),
topLeft.x + YGNodeLayoutGetWidth(node),
topLeft.y + YGNodeLayoutGetHeight(node),
};
const CGPoint origin = preserveOrigin ? view.frame.origin : CGPointZero;
view.frame = (CGRect) {
.origin = {
.x = YGRoundPixelValue(topLeft.x + origin.x),
.y = YGRoundPixelValue(topLeft.y + origin.y),
},
.size = {
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
},
view.frame = (CGRect){
.origin =
{
.x = YGRoundPixelValue(topLeft.x + origin.x),
.y = YGRoundPixelValue(topLeft.y + origin.y),
},
.size =
{
.width = YGRoundPixelValue(bottomRight.x) -
YGRoundPixelValue(topLeft.x),
.height = YGRoundPixelValue(bottomRight.y) -
YGRoundPixelValue(topLeft.y),
},
};
if (!yoga.isLeaf) {
for (NSUInteger i=0; i<view.subviews.count; i++) {
for (NSUInteger i = 0; i < view.subviews.count; i++) {
YGApplyLayoutToViewHierarchy(view.subviews[i], NO);
}
}

View File

@@ -1,10 +1,11 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import yoga;
postfix operator %
extension Int {
@@ -29,15 +30,15 @@ extension YGValue : ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral {
public init(integerLiteral value: Int) {
self = YGValue(value: Float(value), unit: .point)
}
public init(floatLiteral value: Float) {
self = YGValue(value: value, unit: .point)
}
public init(_ value: Float) {
self = YGValue(value: value, unit: .point)
}
public init(_ value: CGFloat) {
self = YGValue(value: Float(value), unit: .point)
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -16,17 +16,15 @@
@implementation YogaKitTests
- (void)testConfigureLayoutIsNoOpWithNilBlock
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testConfigureLayoutIsNoOpWithNilBlock {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
id block = nil;
XCTAssertNoThrow([view configureLayoutWithBlock:block]);
}
- (void)testConfigureLayoutBlockWorksWithValidBlock
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view configureLayoutWithBlock:^(YGLayout *layout){
- (void)testConfigureLayoutBlockWorksWithValidBlock {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
[view configureLayoutWithBlock:^(YGLayout* layout) {
XCTAssertNotNil(layout);
layout.isEnabled = YES;
layout.width = YGPointValue(25);
@@ -36,12 +34,11 @@
XCTAssertEqual(view.yoga.width.value, 25);
}
- (void)testNodesAreDeallocedWithSingleView
{
__weak YGLayout *layoutRef = nil;
- (void)testNodesAreDeallocedWithSingleView {
__weak YGLayout* layoutRef = nil;
@autoreleasepool {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.flexBasis = YGPointValue(1);
layoutRef = view.yoga;
@@ -53,17 +50,16 @@
XCTAssertNil(layoutRef);
}
- (void)testNodesAreDeallocedCascade
{
__weak YGLayout *topLayout = nil;
__weak YGLayout *subviewLayout = nil;
- (void)testNodesAreDeallocedCascade {
__weak YGLayout* topLayout = nil;
__weak YGLayout* subviewLayout = nil;
@autoreleasepool {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
topLayout = view.yoga;
topLayout.flexBasis = YGPointValue(1);
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
subviewLayout = subview.yoga;
subviewLayout.flexBasis = YGPointValue(1);
@@ -74,9 +70,8 @@
XCTAssertNil(subviewLayout);
}
- (void)testIsEnabled
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testIsEnabled {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertFalse(view.yoga.isEnabled);
view.yoga.isEnabled = YES;
@@ -86,30 +81,31 @@
XCTAssertFalse(view.yoga.isEnabled);
}
- (void)testSizeThatFitsAsserts
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){
XCTAssertThrows(view.yoga.intrinsicSize);
});
- (void)testSizeThatFitsAsserts {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
dispatch_sync(
dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL),
^(void) {
XCTAssertThrows(view.yoga.intrinsicSize);
});
}
- (void)testSizeThatFitsSmoke
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testSizeThatFitsSmoke {
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
container.yoga.alignItems = YGAlignFlexStart;
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
UILabel* longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
longTextLabel.text =
@"This is a very very very very very very very very long piece of text.";
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
longTextLabel.numberOfLines = 1;
longTextLabel.yoga.isEnabled = YES;
longTextLabel.yoga.flexShrink = 1;
[container addSubview:longTextLabel];
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
UIView* textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
textBadgeView.yoga.isEnabled = YES;
textBadgeView.yoga.margin = YGPointValue(0);
textBadgeView.yoga.width = YGPointValue(10);
@@ -124,21 +120,31 @@
const CGSize longTextLabelSize = longTextLabel.yoga.intrinsicSize;
XCTAssertEqual(longTextLabelSize.height, containerSize.height);
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
XCTAssertEqual(
longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width,
containerSize.width);
}
- (void)testPreservingOrigin
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
- (void)testSizeThatFitsEmptyView {
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
view.yoga.isEnabled = YES;
const CGSize viewSize = view.yoga.intrinsicSize;
XCTAssertEqual(viewSize.height, 0);
XCTAssertEqual(viewSize.width, 0);
}
- (void)testPreservingOrigin {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 75)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.isEnabled = YES;
view.yoga.flexBasis = YGPointValue(0);
view.yoga.flexGrow = 1;
[container addSubview:view];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* view2 = [[UIView alloc] initWithFrame:CGRectZero];
view2.yoga.isEnabled = YES;
view2.yoga.marginTop = YGPointValue(25);
view2.yoga.flexBasis = YGPointValue(0);
@@ -152,28 +158,28 @@
XCTAssertEqual(25, view2.frame.origin.y);
}
- (void)testContainerWithFlexibleWidthGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
- (void)testContainerWithFlexibleWidthGetsCorrectlySized {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
[container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
[container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth];
XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(200, container.frame.size.height);
}
- (void)testContainerWithFlexibleHeightGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
- (void)testContainerWithFlexibleHeightGetsCorrectlySized {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
@@ -186,12 +192,11 @@
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
- (void)testContainerWithFlexibleWidthAndHeightGetsCorrectlySized {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
container.yoga.isEnabled = YES;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.yoga.isEnabled = YES;
view.yoga.width = YGPointValue(100);
view.yoga.height = YGPointValue(100);
@@ -205,12 +210,11 @@
XCTAssertEqual(100, container.frame.size.height);
}
- (void)testMarkingDirtyOnlyWorksOnLeafNodes
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testMarkingDirtyOnlyWorksOnLeafNodes {
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
subview.yoga.isEnabled = YES;
[container addSubview:subview];
@@ -223,14 +227,13 @@
XCTAssertTrue(subview.yoga.isDirty);
}
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
container.yoga.alignItems = YGAlignFlexStart;
UILabel *view = [[UILabel alloc] initWithFrame:CGRectZero];
UILabel* view = [[UILabel alloc] initWithFrame:CGRectZero];
view.text = @"This is a short text.";
view.numberOfLines = 1;
view.yoga.isEnabled = YES;
@@ -248,61 +251,70 @@
XCTAssertFalse(CGSizeEqualToSize(view.frame.size, viewSizeAfterFirstPass));
}
- (void)testFrameAndOriginPlacement
{
- (void)testFrameAndOriginPlacement {
const CGSize containerSize = CGSizeMake(320, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
UIView* container = [[UIView alloc]
initWithFrame:CGRectMake(
0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqualWithAccuracy(subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
XCTAssertEqualWithAccuracy(subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
XCTAssertEqualWithAccuracy(
subview2.frame.origin.x, CGRectGetMaxX(subview1.frame), FLT_EPSILON);
XCTAssertEqualWithAccuracy(
subview3.frame.origin.x, CGRectGetMaxX(subview2.frame), FLT_EPSILON);
CGFloat totalWidth = 0;
for (UIView *view in container.subviews) {
for (UIView* view in container.subviews) {
totalWidth += view.bounds.size.width;
}
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
XCTAssertEqual(
containerSize.width,
totalWidth,
@"The container's width is %.6f, the subviews take up %.6f",
containerSize.width,
totalWidth);
}
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
{
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder {
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
UIView* container = [[UIView alloc]
initWithFrame:CGRectMake(
0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
@@ -324,32 +336,33 @@
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
}
- (void)testThatWeRespectIncludeInLayoutFlag
{
- (void)testThatWeRespectIncludeInLayoutFlag {
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
UIView* container = [[UIView alloc]
initWithFrame:CGRectMake(
0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayoutPreservingOrigin:YES];
for (UIView *subview in container.subviews) {
for (UIView* subview in container.subviews) {
XCTAssertEqual(subview.bounds.size.width, 100);
}
@@ -359,27 +372,27 @@
XCTAssertEqual(subview1.bounds.size.width, 150);
XCTAssertEqual(subview2.bounds.size.width, 150);
// We don't set the frame to zero, so, it should be set to what it was previously at.
// We don't set the frame to zero, so, it should be set to what it was
// previously at.
XCTAssertEqual(subview3.bounds.size.width, 100);
}
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews {
UIView* container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.isIncludedInLayout = NO;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.isIncludedInLayout = NO;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.isIncludedInLayout = YES;
[container addSubview:subview3];
@@ -392,23 +405,22 @@
XCTAssertEqual(container.yoga.numberOfChildren, 2);
}
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
UIView* subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
subview3.yoga.isIncludedInLayout = NO;
@@ -428,13 +440,12 @@
XCTAssertEqual(subview3.bounds.size.width, 100);
}
- (void)testIsLeafFlag
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testIsLeafFlag {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertTrue(view.yoga.isLeaf);
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
for (int i = 0; i < 10; i++) {
UIView* subview = [[UIView alloc] initWithFrame:CGRectZero];
[view addSubview:subview];
}
XCTAssertTrue(view.yoga.isLeaf);
@@ -443,99 +454,95 @@
view.yoga.width = YGPointValue(50);
XCTAssertTrue(view.yoga.isLeaf);
UIView *const subview = view.subviews[0];
UIView* const subview = view.subviews[0];
subview.yoga.isEnabled = YES;
subview.yoga.width = YGPointValue(50);
XCTAssertFalse(view.yoga.isLeaf);
}
- (void)testThatWeCorrectlyAttachNestedViews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionColumn;
- (void)testThatWeCorrectlyAttachNestedViews {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionColumn;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.width = YGPointValue(100);
subview1.yoga.flexGrow = 1;
subview1.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview1];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.width = YGPointValue(100);
subview1.yoga.flexGrow = 1;
subview1.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.width = YGPointValue(150);
subview2.yoga.flexGrow = 1;
subview2.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview2];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.width = YGPointValue(150);
subview2.yoga.flexGrow = 1;
subview2.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview2];
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayoutPreservingOrigin:YES];
for (UIView* view in @[ subview1, subview2 ]) {
UIView* someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayoutPreservingOrigin:YES];
// Add the same amount of new views, reapply layout.
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayoutPreservingOrigin:YES];
// Add the same amount of new views, reapply layout.
for (UIView* view in @[ subview1, subview2 ]) {
UIView* someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayoutPreservingOrigin:YES];
XCTAssertEqual(subview1.bounds.size.width, 100);
XCTAssertEqual(subview1.bounds.size.height, 25);
for (UIView *subview in subview1.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertNotEqual(subviewSize.width, 0);
XCTAssertNotEqual(subviewSize.height, 0);
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
XCTAssertEqual(subview1.bounds.size.width, 100);
XCTAssertEqual(subview1.bounds.size.height, 25);
for (UIView* subview in subview1.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertNotEqual(subviewSize.width, 0);
XCTAssertNotEqual(subviewSize.height, 0);
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
XCTAssertEqual(subview2.bounds.size.width, 150);
XCTAssertEqual(subview2.bounds.size.height, 25);
for (UIView *subview in subview2.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertNotEqual(subviewSize.width, 0);
XCTAssertNotEqual(subviewSize.height, 0);
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
XCTAssertEqual(subview2.bounds.size.width, 150);
XCTAssertEqual(subview2.bounds.size.height, 25);
for (UIView* subview in subview2.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertNotEqual(subviewSize.width, 0);
XCTAssertNotEqual(subviewSize.height, 0);
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
}
- (void)testThatANonLeafNodeCanBecomeALeafNode
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
- (void)testThatANonLeafNodeCanBecomeALeafNode {
UIView* container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
[container addSubview:subview1];
UIView* subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
[subview1 addSubview:subview2];
UIView* subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
[subview1 addSubview:subview2];
[container.yoga applyLayoutPreservingOrigin:YES];
[subview2 removeFromSuperview];
[container.yoga applyLayoutPreservingOrigin:YES];
[container.yoga applyLayoutPreservingOrigin:YES];
[subview2 removeFromSuperview];
[container.yoga applyLayoutPreservingOrigin:YES];
}
- (void)testPointPercent
{
- (void)testPointPercent {
XCTAssertEqual(YGPointValue(1).value, 1);
XCTAssertEqual(YGPointValue(1).unit, YGUnitPoint);
XCTAssertEqual(YGPercentValue(2).value, 2);
XCTAssertEqual(YGPercentValue(2).unit, YGUnitPercent);
}
- (void)testPositionalPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testPositionalPropertiesWork {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.left = YGPointValue(1);
XCTAssertEqual(view.yoga.left.value, 1);
@@ -580,9 +587,8 @@
XCTAssertEqual(view.yoga.end.unit, YGUnitPercent);
}
- (void)testMarginPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testMarginPropertiesWork {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.margin = YGPointValue(1);
XCTAssertEqual(view.yoga.margin.value, 1);
@@ -648,9 +654,8 @@
XCTAssertEqual(view.yoga.marginEnd.unit, YGUnitPercent);
}
- (void)testPaddingPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testPaddingPropertiesWork {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.padding = YGPointValue(1);
XCTAssertEqual(view.yoga.padding.value, 1);
@@ -716,9 +721,8 @@
XCTAssertEqual(view.yoga.paddingEnd.unit, YGUnitPercent);
}
- (void)testBorderWidthPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
- (void)testBorderWidthPropertiesWork {
UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.borderWidth = 1;
XCTAssertEqual(view.yoga.borderWidth, 1);

View File

@@ -1,3 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// !$*UTF8*$!
{
archiveVersion = 1;

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import Foundation

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "ViewController.h"
@@ -12,45 +11,41 @@
@implementation ViewController
- (void)viewDidLoad
{
UIView *root = self.view;
root.backgroundColor = [UIColor redColor];
root.yoga.isEnabled = YES;
root.yoga.width = YGPointValue(self.view.bounds.size.width);
root.yoga.height = YGPointValue(self.view.bounds.size.height);
root.yoga.alignItems = YGAlignCenter;
root.yoga.justifyContent = YGJustifyCenter;
- (void)viewDidLoad {
UIView* root = self.view;
root.backgroundColor = [UIColor redColor];
root.yoga.isEnabled = YES;
root.yoga.width = YGPointValue(self.view.bounds.size.width);
root.yoga.height = YGPointValue(self.view.bounds.size.height);
root.yoga.alignItems = YGAlignCenter;
root.yoga.justifyContent = YGJustifyCenter;
UIView *child1 = [UIView new];
child1.backgroundColor = [UIColor blueColor];
child1.yoga.isEnabled = YES;
child1.yoga.width = YGPointValue(100);
child1.yoga.height = YGPointValue(100);
UIView* child1 = [UIView new];
child1.backgroundColor = [UIColor blueColor];
child1.yoga.isEnabled = YES;
child1.yoga.width = YGPointValue(100);
child1.yoga.height = YGPointValue(100);
UIView *child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor];
child2.frame = (CGRect) {
.size = {
.width = 200,
.height = 100,
}
};
UIView* child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor];
child2.frame = (CGRect){
.size = {
.width = 200,
.height = 100,
}};
UIView *child3 = [UIView new];
child3.backgroundColor = [UIColor yellowColor];
child3.frame = (CGRect) {
.size = {
.width = 100,
.height = 100,
}
};
UIView* child3 = [UIView new];
child3.backgroundColor = [UIColor yellowColor];
child3.frame = (CGRect){
.size = {
.width = 100,
.height = 100,
}};
[child2 addSubview:child3];
[root addSubview:child1];
[root addSubview:child2];
[root.yoga applyLayoutPreservingOrigin:NO];
[child2 addSubview:child3];
[root addSubview:child1];
[root addSubview:child2];
[root.yoga applyLayoutPreservingOrigin:NO];
}
@end

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import UIKit

View File

@@ -1,12 +1,13 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "JAVA_TARGET", "PROGUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
yoga_android_aar(
name = "android",
enable_relinker = True,
manifest_skeleton = "src/main/AndroidManifest.xml",
visibility = [
"PUBLIC",
@@ -14,9 +15,8 @@ yoga_android_aar(
deps = [
ANDROID_JAVA_TARGET,
ANDROID_RES_TARGET,
INFER_ANNOTATIONS_TARGET,
JAVA_TARGET,
PROGRUARD_ANNOTATIONS_TARGET,
PROGUARD_ANNOTATIONS_TARGET,
],
)

View File

@@ -1,14 +1,16 @@
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
/*
* 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.
*/
version = VERSION_NAME
group = GROUP
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
ndkVersion rootProject.ndkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
@@ -25,21 +27,10 @@ dependencies {
api project(':yoga')
}
task sourcesJar(type: Jar) {
classifier = 'source'
from android.sourceSets.main.java.srcDirs
// We don't build Javadoc at this time as we can't disable "BUCK" files
// from mistakenly getting parsed as Java.
tasks.withType(Javadoc).all {
enabled = false
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
apply from: rootProject.file('gradle/release.gradle')
apply plugin: 'com.vanniktech.maven.publish'

View File

@@ -1,3 +1,10 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
GROUP=com.facebook.yoga.android
POM_NAME=YogaLayout
POM_DESCRIPTION=YogaLayout

View File

@@ -4,7 +4,8 @@
# This source code is licensed under the license found in the
# LICENSE-examples file in the root directory of this source tree.
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
yoga_android_binary(
name = "sample",
@@ -28,7 +29,7 @@ yoga_android_resource(
],
)
keystore(
fb_native.keystore(
name = "debug_keystore",
properties = "debug.keystore.properties",
store = "debug.keystore",

View File

@@ -1,13 +1,14 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the license found in the
# LICENSE-examples file in the root directory of this source tree.
load("//:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
yoga_android_library(
name = "yoga",
srcs = glob(["**/*.java"]),
autoglob = False,
visibility = [
"PUBLIC",
],

View File

@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/*
* 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.samples.yoga;

View File

@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/*
* 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.samples.yoga;

View File

@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/*
* 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.samples.yoga;

View File

@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/*
* 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.samples.yoga;

View File

@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/*
* 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.samples.yoga;

View File

@@ -1,4 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/*
* 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.samples.yoga;

View File

@@ -1,9 +1,8 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
* 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.samples.yoga;

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-present, Facebook, Inc.
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.

View File

@@ -1,13 +1,14 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
yoga_android_library(
name = "android",
srcs = glob(["**/*.java"]),
autoglob = False,
visibility = [
"PUBLIC",
],

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -18,6 +18,7 @@ import android.view.View;
import android.view.ViewGroup;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaNodeFactory;
/**
* Much like a {@link YogaLayout}, except this class does not render itself (the container) to the
@@ -33,7 +34,7 @@ public class VirtualYogaLayout extends ViewGroup {
final private List<View> mChildren = new LinkedList<>();
final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
final private YogaNode mYogaNode = new YogaNode();
final private YogaNode mYogaNode = YogaNodeFactory.create();
public VirtualYogaLayout(Context context) {
super(context);
@@ -73,7 +74,7 @@ public class VirtualYogaLayout extends ViewGroup {
return;
}
YogaNode node = new YogaNode();
YogaNode node = YogaNodeFactory.create();
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
YogaLayout.applyLayoutParams(lp, node, child);
node.setData(child);

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -29,6 +29,7 @@ import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaNodeFactory;
import com.facebook.yoga.YogaOverflow;
import com.facebook.yoga.YogaPositionType;
import com.facebook.yoga.YogaWrap;
@@ -78,7 +79,7 @@ public class YogaLayout extends ViewGroup {
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mYogaNode = new YogaNode();
mYogaNode = YogaNodeFactory.create();
mYogaNodes = new HashMap<>();
mYogaNode.setData(this);
@@ -155,7 +156,7 @@ public class YogaLayout extends ViewGroup {
if(mYogaNodes.containsKey(child)) {
childNode = mYogaNodes.get(child);
} else {
childNode = new YogaNode();
childNode = YogaNodeFactory.create();
}
childNode.setData(child);

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright (c) 2014-present, Facebook, Inc.
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.

View File

@@ -1,8 +1,8 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//:yoga_defs.bzl", "subdir_glob", "yoga_cxx_binary", "yoga_dep")
load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_cxx_binary", "yoga_dep")
yoga_cxx_binary(
name = "benchmark",

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -16,7 +16,7 @@
#define NUM_REPETITIONS 1000
#define YGBENCHMARKS(BLOCK) \
int main(int argc, char const *argv[]) { \
int main(int argc, char const* argv[]) { \
clock_t __start; \
clock_t __endTimes[NUM_REPETITIONS]; \
{ BLOCK } \
@@ -26,14 +26,13 @@
#define YGBENCHMARK(NAME, BLOCK) \
__start = clock(); \
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
{ BLOCK } \
__endTimes[__i] = clock(); \
{BLOCK} __endTimes[__i] = clock(); \
} \
__printBenchmarkResult(NAME, __start, __endTimes);
static int __compareDoubles(const void *a, const void *b) {
double arg1 = *(const double *) a;
double arg2 = *(const double *) b;
static int __compareDoubles(const void* a, const void* b) {
double arg1 = *(const double*) a;
double arg2 = *(const double*) b;
if (arg1 < arg2) {
return -1;
@@ -46,7 +45,10 @@ static int __compareDoubles(const void *a, const void *b) {
return 0;
}
static void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
static void __printBenchmarkResult(
char* name,
clock_t start,
clock_t* endTimes) {
double timesInMs[NUM_REPETITIONS];
double mean = 0;
clock_t lastEnd = start;
@@ -70,12 +72,12 @@ static void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes)
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
}
static YGSize _measure(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
static YGSize _measure(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return (YGSize){
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
@@ -83,7 +85,6 @@ static YGSize _measure(YGNodeRef node,
}
YGBENCHMARKS({
YGBENCHMARK("Stack with flex", {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
@@ -161,7 +162,8 @@ YGBENCHMARKS({
for (uint32_t iiii = 0; iiii < 10; iiii++) {
const YGNodeRef grandGrandGrandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexDirection(
grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandGrandChild, 10);
@@ -174,5 +176,4 @@ YGBENCHMARKS({
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
});

View File

@@ -1,15 +1,20 @@
/*
* 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.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com/' }
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@@ -17,15 +22,17 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}
ext {
minSdkVersion = 14
targetSdkVersion = 25
compileSdkVersion = 26
buildToolsVersion = '26.0.2'
targetSdkVersion = 29
compileSdkVersion = 29
buildToolsVersion = '30.0.2'
ndkVersion = '21.3.6528147'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,20 +1,27 @@
# Copyright (c) 2014-present, Facebook, Inc.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
load("//:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "is_apple_platform", "yoga_cxx_library", "yoga_dep")
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load(
"//tools/build_defs/oss:yoga_defs.bzl",
"BASE_COMPILER_FLAGS",
"yoga_apple_binary",
"yoga_cxx_library",
"yoga_dep",
)
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"]
csharp_library(
fb_native.csharp_library(
name = "yogalibnet46",
srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll",
framework_ver = "net46",
)
csharp_library(
fb_native.csharp_library(
name = "yogalibnet45",
srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll",
@@ -23,7 +30,7 @@ csharp_library(
yoga_cxx_library(
name = "yoganet",
srcs = glob(["Yoga/YGInterop.cpp"]),
srcs = ["Yoga/YGInterop.cpp"],
compiler_flags = COMPILER_FLAGS,
link_style = "static",
link_whole = True,
@@ -32,41 +39,4 @@ yoga_cxx_library(
deps = [yoga_dep(":yoga")],
)
if is_apple_platform():
yoganet_ios_srcs = []
for arch in [
"iphonesimulator-x86_64",
"iphoneos-arm64",
]:
name = "yoganet-" + arch
yoganet_ios_srcs.append(":" + name)
genrule(
name = name,
srcs = [
yoga_dep(":yogaApple#%s,static" % arch),
yoga_dep("YogaKit:YogaKitApple#%s,static" % arch),
yoga_dep("csharp:yoganetApple#%s,static" % arch),
],
out = "libyoga-%s.a" % arch,
cmd = "libtool -static -o $OUT $SRCS",
visibility = [yoga_dep("csharp:yoganet-ios")],
)
genrule(
name = "yoganet-ios",
srcs = yoganet_ios_srcs,
out = "libyoga.a",
cmd = "lipo $SRCS -create -output $OUT",
visibility = ["PUBLIC"],
)
yoganet_macosx_target = "csharp:yoganetAppleMac#macosx-%s,dynamic"
genrule(
name = "yoganet-macosx",
srcs = [
yoga_dep(yoganet_macosx_target % "x86_64"),
],
out = "libyoga.dylib",
cmd = "lipo $SRCS -create -output $OUT",
visibility = ["PUBLIC"],
)
yoga_apple_binary()

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -10,12 +10,6 @@ using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
#if WINDOWS_UWP_ARM
using YogaValueType = IntPtr;
#else
using YogaValueType = YogaValue;
#endif
internal static class Native
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
@@ -49,9 +43,6 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigFree(IntPtr node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGNodeGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGConfigGetInstanceCount();
@@ -74,6 +65,14 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetUseLegacyStretchBehaviour(
YGConfigHandle config,
bool useLegacyStretchBehavior);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetPointScaleFactor(
YGConfigHandle config,
@@ -88,6 +87,14 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetIsReferenceBaseline(
YGNodeHandle node,
bool isReferenceBaseline);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGNodeIsReferenceBaseline(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeCalculateLayout(
YGNodeHandle node,
@@ -218,7 +225,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
@@ -230,7 +237,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
@@ -242,7 +249,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
@@ -251,7 +258,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
@@ -260,7 +267,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
@@ -269,7 +276,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
@@ -278,7 +285,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node);
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -297,7 +304,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
@@ -309,7 +316,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
@@ -318,7 +325,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -117,6 +117,19 @@ namespace Facebook.Yoga
}
}
public bool UseLegacyStretchBehaviour
{
get
{
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
}
set
{
Native.YGConfigSetUseLegacyStretchBehaviour(_ygConfig, value);
}
}
public float PointScaleFactor
{
set

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -13,7 +13,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
}
set
@@ -26,7 +26,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
}
set
@@ -39,7 +39,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
}
set
@@ -52,7 +52,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
}
set
@@ -65,7 +65,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
}
set
@@ -78,7 +78,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End));
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
}
set
@@ -103,7 +103,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
}
set
@@ -116,7 +116,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
}
set
@@ -129,7 +129,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
}
set
@@ -142,7 +142,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
}
set
@@ -155,7 +155,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
}
set
@@ -168,7 +168,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
}
set
@@ -181,7 +181,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
}
set
@@ -194,7 +194,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
}
set
@@ -207,7 +207,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All));
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
}
set
@@ -236,7 +236,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
}
set
@@ -249,7 +249,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
}
set
@@ -262,7 +262,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
}
set
@@ -275,7 +275,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
}
set
@@ -288,7 +288,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
}
set
@@ -301,7 +301,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
}
set
@@ -314,7 +314,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
}
set
@@ -327,7 +327,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
}
set
@@ -340,7 +340,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All));
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
}
set

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -271,7 +271,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode));
return Native.YGNodeStyleGetFlexBasis(_ygNode);
}
set
@@ -295,7 +295,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode));
return Native.YGNodeStyleGetWidth(_ygNode);
}
set
@@ -319,7 +319,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode));
return Native.YGNodeStyleGetHeight(_ygNode);
}
set
@@ -343,7 +343,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode));
return Native.YGNodeStyleGetMaxWidth(_ygNode);
}
set
@@ -363,7 +363,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode));
return Native.YGNodeStyleGetMaxHeight(_ygNode);
}
set
@@ -383,7 +383,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode));
return Native.YGNodeStyleGetMinWidth(_ygNode);
}
set
@@ -403,7 +403,7 @@ namespace Facebook.Yoga
{
get
{
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode));
return Native.YGNodeStyleGetMinHeight(_ygNode);
}
set
@@ -519,6 +519,19 @@ namespace Facebook.Yoga
Native.YGNodeSetHasNewLayout(_ygNode, false);
}
public bool IsReferenceBaseline
{
get
{
return Native.YGNodeIsReferenceBaseline(_ygNode);
}
set
{
Native.YGNodeSetIsReferenceBaseline(_ygNode, value);
}
}
public bool ValuesEqual(float f1, float f2)
{
if (float.IsNaN(f1) || float.IsNaN(f2))
@@ -594,7 +607,7 @@ namespace Facebook.Yoga
}
public void CalculateLayout(
float width = YogaConstants.Undefined,
float width = YogaConstants.Undefined,
float height = YogaConstants.Undefined)
{
Native.YGNodeCalculateLayout(
@@ -660,10 +673,5 @@ namespace Facebook.Yoga
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
}
public static int GetInstanceCount()
{
return Native.YGNodeGetInstanceCount();
}
}
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -91,17 +91,5 @@ namespace Facebook.Yoga
{
return Point(pointValue);
}
#if WINDOWS_UWP_ARM
internal static YogaValue MarshalValue(IntPtr ptr)
{
return Marshal.PtrToStructure<YogaValue>(ptr);
}
#else
internal static YogaValue MarshalValue(YogaValue value)
{
return value;
}
#endif
}
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,2 +1,7 @@
#!/bin/sh
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests
# 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.
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2014-present, Facebook, Inc.
# 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,4 +1,11 @@
using System;
/*
* 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.
*/
using System;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Facebook.Yoga;
@@ -206,8 +213,8 @@ namespace Facebook.Yoga.Universal.Tests
return MeasureOutput.Make(123.4f, 81.7f);
});
node.CalculateLayout();
Assert.AreEqual(123, node.LayoutWidth);
Assert.AreEqual(81, node.LayoutHeight);
Assert.AreEqual(124, node.LayoutWidth);
Assert.AreEqual(82, node.LayoutHeight);
}
[TestMethod]
@@ -268,7 +275,12 @@ namespace Facebook.Yoga.Universal.Tests
parent.Insert(0, child0);
parent.Insert(0, child1);
parent.CalculateLayout();
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
Assert.AreEqual(parent.Print(),
"<div layout=\"width: 100; height: 120; top: 0; left: 0;\" style=\"width: 100px; height: 120px; \" >\n" +
" <div layout=\"width: 35; height: 45; top: 0; left: 0;\" style=\"width: 35px; height: 45px; \" ></div>\n" +
" <div layout=\"width: 30; height: 40; top: 45; left: 0;\" style=\"width: 30px; height: 40px; \" ></div>\n" +
"</div>"
);
}
[TestMethod]
@@ -414,4 +426,4 @@ namespace Facebook.Yoga.Universal.Tests
}
#endif
}
}
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* 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.

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -9,11 +9,12 @@
static YGInteropLogger gManagedLogger;
static int unmanagedLogger(const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
const char *format,
va_list args) {
static int unmanagedLogger(
const YGConfigRef config,
const YGNodeRef node,
YGLogLevel level,
const char* format,
va_list args) {
int result = 0;
if (gManagedLogger) {
char message[8192];

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* 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.
@@ -11,10 +11,11 @@
YG_EXTERN_C_BEGIN
typedef int (*YGInteropLogger)(const void *unmanagedConfigPtr,
const void *unmanagedNodePtr,
YGLogLevel level,
const char *message);
typedef int (*YGInteropLogger)(
const void* unmanagedConfigPtr,
const void* unmanagedNodePtr,
YGLogLevel level,
const char* message);
WIN_EXPORT YGConfigRef YGConfigGetDefault();

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