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
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
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
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
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
Summary: Yoga set as a static library also for debug+release builds in x64
Reviewed By: SidharthGuglani
Differential Revision: D27230019
fbshipit-source-id: d77e2c4130cd8303d1585723bfad927b9ddba23e
Summary: We are linking yoga as a static library in most of the places
Reviewed By: SidharthGuglani
Differential Revision: D27228933
fbshipit-source-id: 725d6551198c96925ae80b3a62ef9737ee7e3052
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
Summary: Yoga Visual Studio project file was outdated. Made it back working/compilable
Reviewed By: Andrey-Mishanin
Differential Revision: D27138942
fbshipit-source-id: 5d57e61dbb415db54e255e148739c2e670f3bd23
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
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
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
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/18415https://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
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
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
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
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
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
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
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
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
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
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
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
Summary: Disable Starlark in several files which are not trivial to fix.
Reviewed By: scottrice
Differential Revision: D22202463
fbshipit-source-id: a3ff717f0f4b9cd7f492b8fcebdb91f232207222
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary:
## Changelog:
[Internal][Yoga] Add YogaJniException class to be used later for jni exceptions
Reviewed By: astreet
Differential Revision: D18745609
fbshipit-source-id: 53503b54dbc59e9fe47f599dee6be9cb68134cb2
Summary: Use BitUtils for testing bit operations
Reviewed By: astreet
Differential Revision: D18596312
fbshipit-source-id: 83f93cd7f1f056b3f64070debbc452877b44ac7a
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
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
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
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
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
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
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
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
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/2825https://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
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
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
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
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
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
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
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
Summary: UseVanillaJNI flag was missing for measure and baseline functions
Reviewed By: amir-shalem
Differential Revision: D17868201
fbshipit-source-id: 95d6843d643e90157a51550d6efbf059f0ca2c39
Summary: We can use getCurrentEnv() instead of passing environment variable around
Reviewed By: amir-shalem
Differential Revision: D17842042
fbshipit-source-id: 185b174ae7c08e746bc76c0600c2e326b15c4993
Summary: We can use getCurrentEnv() , no need to pass env around methods
Reviewed By: amir-shalem
Differential Revision: D17841281
fbshipit-source-id: a4a58292e70ac05b0f0b9eb962a82a8501ad0226
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
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
Summary: Use TestParametrization to test both fbjni and vanilla jni versions
Reviewed By: amir-shalem
Differential Revision: D17788718
fbshipit-source-id: 0f3317b7403cadca7b7ccd9140f1933d746bf433
Summary: Add ScopedLocalRef, ScopedGlobalRef and some common methods to be used later.
Reviewed By: amir-shalem
Differential Revision: D17711284
fbshipit-source-id: be43d5e246bc2406765057783be11854877c41f1
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
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
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
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
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
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
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
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
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
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
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
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
Summary: Bump version to 1.16.0-SNAPSHOT for new yoga release
Reviewed By: amir-shalem
Differential Revision: D17396540
fbshipit-source-id: ddd01454752d88548ae7490cfd9fccfb8c591ec9
Summary: Bump version to 1.16.0 for new yoga release
Reviewed By: amir-shalem
Differential Revision: D17395785
fbshipit-source-id: b01b31d58b5b1a2a9532e9cce0892c08960ec31c
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
Summary: Bumping version to 1.15.0 for new yoga release
Reviewed By: amir-shalem
Differential Revision: D17394805
fbshipit-source-id: de43e97a0c155f332ecbe4e98b78c2f7c9ffe771
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
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
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
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
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
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
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
Summary: The artifacts generated otherwise can cause issues in Android projects.
Reviewed By: SidharthGuglani
Differential Revision: D16803253
fbshipit-source-id: db139560dfbddb917c27bdfd80e1bf5747e4a74b
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
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
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
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
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
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
Summary: Replaces the usage of C++ bitfields with our portable `Bitfield` class.
Reviewed By: SidharthGuglani
Differential Revision: D16656361
fbshipit-source-id: 05f679e2e994e109b2bd1090c879d6850fabdc40
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
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
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
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
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
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
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
Summary: Update build file to include subdirectories of yoga also in sources
Reviewed By: davidaurelio
Differential Revision: D16560253
fbshipit-source-id: 5dee4379912e003d4a1fa611882fbf736321615c
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
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
Summary: Adds internal API that we can use to conduct experiments.
Reviewed By: SidharthGuglani
Differential Revision: D16340463
fbshipit-source-id: 07a8bb7dbc4a02c5c95f1ad29b18845ab43752cf
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
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
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
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
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
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
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
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
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
Summary: Adds Baseline start and end events to be handled later for instrumentation
Reviewed By: davidaurelio
Differential Revision: D16048790
fbshipit-source-id: 8409dbb633168753a7bf8fab20bc6551d113ddd6
Summary: Using layoutPassStart and LayoutPassEnd events instead of YGMarkerLayout for instrumentation
Reviewed By: davidaurelio
Differential Revision: D16048789
fbshipit-source-id: 041a35bc2cb1b7281ca83cf9d35041b4011cfeb9
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
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
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
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
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
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
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
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
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
Summary: Passing whether layout cache or measure cache was used or not
Reviewed By: davidaurelio
Differential Revision: D15920937
fbshipit-source-id: a6728e7af07ea228a285f824fbdfddc8130c5990
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
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
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
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
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
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
Summary: Removes `unsetOwner` from Yoga. This was temporarily for patching a crash.
Reviewed By: colriot
Differential Revision: D15737613
fbshipit-source-id: 8ab93ecf7ffb913df6207fe5db47a8cc93eded2c
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: Style bits had overlap, because `dimensionBit` was set with an incorrect increment.
Reviewed By: SidharthGuglani
Differential Revision: D15335134
fbshipit-source-id: 370e1a73547d76b0e26bc6ab67acb96d33ddf180
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: This diff adds the logic to transfer layout outputs using a float array
Reviewed By: davidaurelio
Differential Revision: D14368120
fbshipit-source-id: d1f22283bcea051d15657f42c15b90edaa0a8a7a
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
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
Summary:
@public
Messed this one up when fixing the test generation script.
Reviewed By: SidharthGuglani
Differential Revision: D14684224
fbshipit-source-id: 2696ce9ff7d825d00c7ad1ab1627a5ffe56d123f
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
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
Summary:
@public
This gets flagged by the linter. Remove it.
Reviewed By: SidharthGuglani
Differential Revision: D14682386
fbshipit-source-id: 612508b0906285e6420a553ac7a96d1024f1eac6
Summary:
@public
Adapts the license header text to the format we currently use.
Reviewed By: SidharthGuglani
Differential Revision: D14653591
fbshipit-source-id: f79446e4f85623326f770fe73482eab00edd9234
Summary: This workspace should ease yoga development
Reviewed By: dinhviethoa
Differential Revision: D14600002
fbshipit-source-id: 49f6d36680acad5835fcf96e80bcd547b667c0c8
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
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
Summary:
@public
Xcode does not like it
Reviewed By: astreet
Differential Revision: D14580168
fbshipit-source-id: 6d26b3961b45a59ef9dc977b21493e60e3cf9396
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
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
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
Summary:
@public
Yoga's Java license headers were not in the correct format.
Reviewed By: muraziz
Differential Revision: D14541087
fbshipit-source-id: 5b3cff398875bd59dadeaddbb43020700ef027e2
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
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
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
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
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
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
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
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
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
Summary: Turns out Xcode does not like document-level comments.
Reviewed By: SidharthGuglani
Differential Revision: D14301138
fbshipit-source-id: f515a1881daa109031963688c1556cb8ef42758f
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
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
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
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
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
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
Summary: Positive tests for all style input properties using JNI batching API
Reviewed By: davidaurelio
Differential Revision: D14207552
fbshipit-source-id: b7165c2115ace67bf131c76929d37df438921bf2
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: Adds the `-SNAPSHOT` specifier back to the version number in `gradle.properties`
Reviewed By: SidharthGuglani
Differential Revision: D14123308
fbshipit-source-id: e5d4c4dd9552557dc42440f0892c1452dd0195a5
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: @public adds a first `YGMarker`, and the accompanying data type.
Reviewed By: SidharthGuglani
Differential Revision: D13817588
fbshipit-source-id: 6007eb09d19cf4021989bad5b5e880adb16364a0
Summary:
@public
this will lead to nicer enum member names.
Reviewed By: SidharthGuglani
Differential Revision: D13817587
fbshipit-source-id: 85355328f7977b4fb29a9474532f2d578a3cbf79
Summary:
@public
Removes `YGNodeInsertSharedChild` / `addSharedChildAt`.
This functionality is unused, and can cause memory leaks.
Reviewed By: SidharthGuglani
Differential Revision: D13711105
fbshipit-source-id: 86206c05393b3f1a497e6b046006f94ead88c6ce
Summary: Make the libfb jni code to be compatible with gcc7 compiler
Reviewed By: davidaurelio
Differential Revision: D13711390
fbshipit-source-id: 9a378a3ee4feb7e928dd97dae7d79a41f0658992
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
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
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
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
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
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
Summary: Using default logger in test case
Reviewed By: davidaurelio
Differential Revision: D13565071
fbshipit-source-id: 93cee223a7f366e3e965fde2d5cdc7d4b27e310f
Summary:
@public
Previously untested. Allows us to ship with more confidence
Reviewed By: SidharthGuglani
Differential Revision: D13534350
fbshipit-source-id: a2e7577befdeeb7a27148e16624eeb7a347efd87
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
Summary:
@public
Further heap size reductions by using bitfields in `YGLayout` and `YGNode`.
Reviewed By: SidharthGuglani
Differential Revision: D13466325
fbshipit-source-id: ddcef0a1b3822e7449fe485d99c920d54139c893
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
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
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
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
Summary:
@public
removes the `default` case from an already exhaustive switch.
Reviewed By: SidharthGuglani
Differential Revision: D13451869
fbshipit-source-id: 32727330c7fce013963f5c83c95a73b230d5c938
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary:
@public
This file shouldn’t be here
Reviewed By: SidharthGuglani
Differential Revision: D13255658
fbshipit-source-id: 1b40ab674bbf451d04797516a24c3bd2fef7222d
Summary: Found and fixed typo on https://yogalayout.com/docs/justify-content/
Reviewed By: danielbuechele
Differential Revision: D13199988
fbshipit-source-id: 029cf812f09c48822ec11b054bf0c987f718191d
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed
Reviewed By: davidaurelio
Differential Revision: D13147742
fbshipit-source-id: 3bbff1cfceeadfbf77380519e4638f2984fc2009
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
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
Summary:
@public
passes all enum values by value, not by reference.
Reviewed By: astreet
Differential Revision: D13156390
fbshipit-source-id: 56aea66c16ab3325594f67b9017afa18a678d281
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
Summary:
@public
Passes all `float`, `bool`, etc. by value, not by reference.
Reviewed By: astreet
Differential Revision: D13153500
fbshipit-source-id: 95529bc2efcff144044e2c25087915b2b7ede179
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
Summary:
@public
Restores the yearless format of the MIT license.
Reviewed By: SidharthGuglani
Differential Revision: D13082510
fbshipit-source-id: f5a849b06652cedf68547d4a7963398b2627915f
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: This change drops the year from the copyright headers and the LICENSE file.
Reviewed By: yungsters
Differential Revision: D9727774
fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
Summary: Unused loads hurt readability and take time to process.
Reviewed By: hramos
Differential Revision: D9494120
fbshipit-source-id: 455b56efadab1cb976344cffcb427772bfda2f71
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
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
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
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
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
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
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
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
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
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
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
Summary:
- adds more property assignments
- reduces the number of layout roots that exist simultanously
Reviewed By: pasqualeanatriello
Differential Revision: D8989389
fbshipit-source-id: 6a0ac800a4caad61a2f4bf98caa314855b70875f
Summary: The old link 404s. This is the new canonical location.
Reviewed By: IanChilds
Differential Revision: D9131447
fbshipit-source-id: 77b82a4184fff89faf1da76e922a5f1ce3de3314
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
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
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
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
Summary: `-init` is marked unavailable, but `+new` does the same thing and is not.
Reviewed By: dshahidehpour
Differential Revision: D8957391
fbshipit-source-id: 42fcfe845db79726d8724efd9f6a4d37c19938ad
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
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
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
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
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
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
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
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
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
Summary: I missed these two things: inline default ctor, getValue() should return a float.
Reviewed By: priteshrnandgaonkar
Differential Revision: D8826640
fbshipit-source-id: e6324dea0268ef276e6fa1722e72dffb5241e676
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
Summary: Just some convention/weird style things. `float` should be passed by value, weird use of ?: operator instead of ||.
Reviewed By: priteshrnandgaonkar
Differential Revision: D8804407
fbshipit-source-id: e0d67363ccde36ec5bccec7497ed0ffd364b3fcf
Summary:
This PR adds support for using Yoga Swift dependents when Yoga is pulled as a static library.
Currently swift projects trying to pull static libraries are unable to import the module. The reason for that is because the `DEFINES_MODULES` build setting is set to`NO`. If a Swift Framework is trying to `pod spec lint --use-libraries` with `Yoga` as a dependency, the validation will fail. With the `DEFINES_MODULE` enabled, the product will be treated as defining its own module. This enables automatic production of LLVM module map files when appropriate, and allows the product to be imported as a module.
A workaround to this issue would be passing the `:modular_headers` flag to the `Podfile`, but that would not fix the `pod spec lint` validation for framework/library dependencies, it would just allow consuming applications to build and run.
An example of this issue would be [SonarKit](https://github.com/facebook/Sonar/blob/master/iOS/SonarKit.podspec). `SonarKit` wasn't able to validate its podspec due to `YogaKit` (Swift Framework) depending on `Yoga` and SonarKit validating with the `--use-libraries` flag due to the c++ dependencies. We had to create a new version of [Yoga 1.9 podspec](https://github.com/facebook/Sonar/blob/master/Specs/Yoga/1.9/Yoga.podspec.json) and make sure to set the `DEFINES_MODULE` flag of the pod target. After that, we were able to `pod spec lint` `SonarKit.podspec` successfully.
After merging a new `tag` should be created and the new podspec should be pushed to cocoapods master repository.
Pull Request resolved: https://github.com/facebook/yoga/pull/793
Reviewed By: passy
Differential Revision: D8820126
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 98eae3c31ec67a03c0fe97e05ab9e79446fa9f78
Summary: This linked list was never used, and YGNodeDeepClone was doing scary things to maintain it.
Reviewed By: davidaurelio
Differential Revision: D8792864
fbshipit-source-id: c578fabe65c837f0791aa9ac3e18f31d93691abd
Summary: There were a few missing prototypes and a -Wshadow violation. Merged YGBenchmark.h into YGBenchmark.c, added static where needed, fixed shadow violation.
Reviewed By: davidaurelio
Differential Revision: D8793124
fbshipit-source-id: c4b2dd348c38aa599169b5e9bea543c172439432
Summary:
Fixes the improper `singleFlexChild` optimization. In the case when all the childs have `flex-grow:0 flex-grow:0` except one child with `flex-grow:1 flex-shrink:1`, then one can simply measure all the non-flexing children and then give the flexing child all the remaining space.
Also added a test case which reproduced the bug
Reviewed By: IanChilds
Differential Revision: D8782684
fbshipit-source-id: ffd4d35b6122f82111b987540efb23bd2a8da5a2
Summary:
Replaces two nested if-blocks with guards. This is intended to help with restructuring this function in follow-ups.
@public
Reviewed By: priteshrnandgaonkar
Differential Revision: D8785659
fbshipit-source-id: 7b9d63e9814b83b999397c016ad67ad348bb0f72
Summary:
Updates all dependencies of the website to their latest version. This is made due to CVE-2018-3728 and a vunerable version of `hoek` used in s transitive dependency of the website. This updates `hoek` to v 4.2.1 which is not affected.
allow-large-files
Reviewed By: astreet
Differential Revision: D8734272
fbshipit-source-id: 3e96ea5890190f7d7b83cc4c18121fc925411f69
Summary:
On the first render the landing page was missing a CSS class. This ls probably related to https://github.com/gatsbyjs/gatsby/issues/5136
It is fixed by wrapping the page in a <div>
Reviewed By: priteshrnandgaonkar
Differential Revision: D8660801
fbshipit-source-id: dd1ac4145831f2556e2c7ceeaddb2a423447f833
Summary:
This diff refactors the cloning mechanism for YogaNode used from Fabric UI renderer and RN iOS graphs.
Previously, we were cleaning the owner of the child's cloned node inside the C++ implementation of YogaNode. This was a mistake because this modified the last commited YogaTree, causing side effect in RN iOS graphs.
Reviewed By: shergin
Differential Revision: D8672627
fbshipit-source-id: c9902d00690e0361fd58aed84b506c42258bd995
Summary:
Sync fbjni with `libaries/fbjni`.
This includes a hack to fix a deadlock we found for cmake-debug variants only. This still gets us back in sync with other fbjni consumers which is going to save us trouble in the future if Yoga ever wants to make use of a newer feature.
Manual changes made in addition to the hand-crafted CMakeLists and cxx buck rules:
- `jni::isObjectRefType` has SDK lookup disabled.
- `fbjni/` path is changed back to `fb/` to retain compatibility with Yoga.
Reviewed By: priteshrnandgaonkar
Differential Revision: D8531991
fbshipit-source-id: 776f519e2e5f9bea37f55990348f7ed81c4860b4
Summary: This diff cleans up the parent / owner references for children of ReactShadowNode / YogaNode during cloning. The reason of this behavior is to avoid retaining every generation of trees during cloning. This fixes a memory leak detected when running the ProgressBarExample.android.js in catalyst app
Reviewed By: fkgozali
Differential Revision: D8019894
fbshipit-source-id: b0d38f0c836ffec534f64fa1adbd7511ecf3473d
Summary:
Might be the smallest PR in the world, but it caught my eye reading the
docs so I figured I should fix it.
Closes https://github.com/facebook/yoga/pull/782
Reviewed By: emilsjolander
Differential Revision: D8351525
Pulled By: jknoxville
fbshipit-source-id: fc7a881f062e07d2e28b5ca2da8c52f20bad53be
Summary:
I'm not totally sure what I'm doing so if this needs changes let me know.
Closes https://github.com/facebook/yoga/pull/775
Reviewed By: emilsjolander
Differential Revision: D8331892
Pulled By: passy
fbshipit-source-id: eb1023e666322d2472e4081fd4a4e72a7b43d049
Summary:
@public
Bump Prettier to use version 1.13.4
All code changes are caused by running Prettier and should only affect files that have an `format` header.
All other changes caused by yarn.
Reviewed By: ryanmce
Differential Revision: D8251255
fbshipit-source-id: 0b4445c35f1269d72730f2000002a27c1bc35914
Summary:
The "copy share URL" button only works in the standalone playground, not the ones embedded on the landing page or the documentation, because, we don't want people to share a link to a modified documentation page.
This diff replaces the share URL button with a link to a standalone playground which then can be shared.
Reviewed By: astreet
Differential Revision: D8125135
fbshipit-source-id: 8b69b69caeadf5d598ed89b0abd9b742f5f07a9c
Summary:
This uses the latest version of `buildifier` that supports many
more Skylark syntax features.
Reviewed By: yfeldblum
Differential Revision: D8073585
fbshipit-source-id: 12322aebc09b89d5af9cc257b16c1bc0fbb066c1
Summary:
This is to make them `buildifier` compatible in order to start using
`buildifier` for all .bzl files.
Differential Revision: D8069457
fbshipit-source-id: f5bce02a3e6ba8dc4ccbf5bae70de224c30cbd64
Summary: Fix yoga podspec issue. The newly released versiong of Yoga i.e 1.8.0 was not building on iOS. So fixing the bug. Want to use this pod in SonarKitLayout
Reviewed By: emilsjolander
Differential Revision: D8024641
fbshipit-source-id: c8d7279e654145199fbee6655909e1c10d8b2114
Summary: The error message saying the playground is only available on bigger screens also was shown on big screens.
Reviewed By: emilsjolander
Differential Revision: D7989482
fbshipit-source-id: f444ca2d6608b868c4ff4d38fa6798d80b57c047
Summary:
Updates Prettier to v1.12.1, using `xplat/js/scripts/prettier-bump.js` based on the playbook by https://our.intern.facebook.com/intern/wiki/Prettier/upgrade-guide/
All changes related to upgrading or running Prettier
allow-many-files
allow-large-files
bypass-lint
drop-conflicts
ignore-conflict-markers
ignore-signed-source
ignore-nocommit
Reviewed By: benjaffe, ryanmce, yungsters
Differential Revision: D7652946
fbshipit-source-id: 396d45c675e93f2298cd2920d927630c81867447
Summary:
External partners have asked us to provide an easier way to migrate and this was
a breaking change in the most recent release.
Reviewed By: emilsjolander
Differential Revision: D7654526
fbshipit-source-id: efe44807caa97f495c5e5691dedcf281760fa23e
Summary: Several of dependencies and tests in repository are missing (e.g. because we don't support building certain library for MacOSX). Clean up those mistakes.
Differential Revision: D7625433
fbshipit-source-id: 332b7ff7eaed82cb52f459921f1ae67b702a1636
Summary: Several of dependencies and tests in repository are missing (e.g. because we don't support building certain library for MacOSX). Clean up those mistakes.
Differential Revision: D7618360
fbshipit-source-id: 421834892519998ad088a138b3fc3d96afe34d79
Summary:
Change the travis platform to Java and install Node via nvm instead. This
manually reinstalls buck and then publishes a snapshot if it builds and tests
correctly.
Reviewed By: emilsjolander, danielbuechele
Differential Revision: D7567862
fbshipit-source-id: fabdbbb13117ab8ead4eb9f10402a71d30f29c12
Summary: this diff re-add the assertion to check for owner reference before adding child that was removed by mistake in previous diff
Reviewed By: emilsjolander
Differential Revision: D7495417
fbshipit-source-id: b81174aeea3f2796d76ccdae4a8eddd0beace0aa
Summary:
This PR fixes the compilation on MSVC. I moved the `YGConfig` creation to a C++ constructor.
Addionally it removes the "dot" notation on `YGValue`, I didn't want to change that type to a C++ constructor, because I think this will break the ABI.
Closes https://github.com/facebook/yoga/pull/746
Differential Revision: D7498141
Pulled By: emilsjolander
fbshipit-source-id: 5f5308ff838dcd803065785ddc08b2404524acb9
Summary: Remove experimental setup of fast-math and add `-ffast-math` as a compiler flag for yoga.
Reviewed By: emilsjolander
Differential Revision: D7414228
fbshipit-source-id: 320e1b1953f6af867b13e617af7872eb8999160e
Summary: Change the return type of getMarginForAxis to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7350337
fbshipit-source-id: dd1ee2fcd295ccd14f7d414ab0c24090b24e91e0
Summary: Change the return type of getTrailingMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7350221
fbshipit-source-id: 61a67364c1975ec6dd1883bc2cb4968b830c73df
Summary: Changed the return type of getLeadingMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7349907
fbshipit-source-id: b20894fbc33fd5b29a28f3c9174d1b5f406774ab
Summary: Change the type of getTrailingPosition to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7344710
fbshipit-source-id: eb4c422b6e0f55d90b083221aa8ff1ab797d58a8
Summary: Changed the type of return value of getLeadingPosition to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7344367
fbshipit-source-id: 0f5a667ca357b2ce056c86763aa3e9e4c54b82f0
Summary: Changed the type of computedFlexBasis to YGFloatOptional in YGLayout
Reviewed By: emilsjolander
Differential Revision: D7340413
fbshipit-source-id: 39247b2b582a682e602f49f58b4bbd2bf0c995af
Summary: Changed the return type of trailing padding to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7339712
fbshipit-source-id: 483c5886838c14b17cb731c81abb9fc80f519956
Summary: Changed the arguments for the getter of leading padding to avoid copies. Added an assetion in getter of leading padding, as padding would always be defined even in the case when the user has not explicitly defined the value. In these cases it would take the default value of 0. So changing the type of `getLayoutPadding` to `YGFloatOptional`, doesn't make sense.
Reviewed By: emilsjolander
Differential Revision: D7336690
fbshipit-source-id: b2a2f010026f26fc2cc9fb35ad921da8f7017c9f
Summary: Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7323382
fbshipit-source-id: 8e3eb4f3744b5f3f9e2b353f56184905f7557191
Summary: Remove the use of YGUnwrapOptional from YGConstrainedMaxSizeForMode
Reviewed By: emilsjolander
Differential Revision: D7322743
fbshipit-source-id: d825c60bcdc9ecdc0c784a215dc6b1b8a7a7860e
Summary:
This PR fixes a type mismatch on `endOfLineIndex` where it should be of type `uint32_t` while it is of type `float`
Additonally it fixes some `double` casting in the rounding methods.
Closes https://github.com/facebook/yoga/pull/745
Differential Revision: D7494519
Pulled By: emilsjolander
fbshipit-source-id: 30a86574ce163458a6888f61a902d0640c1874fb
Summary: Changed the return type of YGResolveValueMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7304090
fbshipit-source-id: cbec03a9367cf34976d083ad475d4da0b736e6d2
Summary: Move equaltiy function from utils to an operator on YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7303460
fbshipit-source-id: 41ec0076ace621ec1a5bdbab00b72eea57780fff
Summary: Change the type of aspect Ratio to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7302651
fbshipit-source-id: 53e3b4c9627207a379f927b1f3485e36a9c70601
Summary: Removes the use of YGUndefined from kYGValueAuto. Also fixed the setter and getter of dimensions. This diff also fixes a typo
Reviewed By: emilsjolander
Differential Revision: D7302453
fbshipit-source-id: e002a1ddd75bfc6fe142a7275e7913c064972e16
Summary:
This diff includes the following changes:
1 ) I extended the Java implementation of YogaNode to be able to get a full copy of a YogaNode object without copying the List of children of the original YogaNode. In other words, the new copy of the YogaNode will have the same data of the original YogaNode, but with an empty list of children.
2 ) We created a new method in Yoga.cpp called YGNodeInsertSharedChild. This new method is going to be used by Fabric in order to temporarily share a YogaNode between two "Yoga Trees" (the "current Yoga" tree and a partial "clone of the current Yoga tree"). We exposed this new functionality in the java implementation of Yoga (method addSharedChildAt)
I'm including sebmarkbage for more context.
Reviewed By: emilsjolander
Differential Revision: D7245421
fbshipit-source-id: 72578c8261f29e4a12fc6c72a91f2f891cd58d48
Summary:
In the persistent version of Yoga, a YogaNode can be shared between two YogaTrees, that means that a YogaNode could have more than one Parent at one point in time. That's why the concept of Parent of a YogaNode is not a 1-1 relationship anymore.
This diff changes the semantic of Parent of a YogaNode to Owner of a Yoga Node. CC sebmarkbage and priteshrnandgaonkar for more context.
Technically this diff renames the field YogaNode.parent to YogaNode.owner (and every internal field, Getter and Setter that is related to parent)
Note that as part of this diff I also modified the CSSLayoutDEPRECATED version of Yoga in order to keep compatibility with the C++ implementation.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7352778
fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
Summary:
We had functions for inserting/removing a specific child, but not for simply replacing the child set with another list.
`YGNodeSetChildren()` will unhook child nodes from the parent that don't appear in the new set. We set the disconnected child node layouts to `YGLayout()` b/c that's what the rest of the code does.
`YGTraversePreOrder()` walks the tree and calls a labmda for each node. We could very easily add a post-order traversal and the ability to stop traversal if we ever want, but for now this is an MVP.
Reviewed By: Woody17
Differential Revision: D7360203
fbshipit-source-id: 32df8e1213ead03bc0a026ec4bf453bc799bb9ce
Summary:
Podspec to push yoga 1.8.0 to cocoapods. There is an issue with cocoapods and it fails to lint those projects with C++ in its header, which is the case with yoga too.
Follow this thread https://github.com/CocoaPods/CocoaPods/issues/5152. To make the lint pass, one would have to change `app_target_helper.rb` cocoapod source file in the local machine. Follow my [gist](https://gist.github.com/priteshrnandgaonkar/dcca9639a3bc0a3b9adecae3a2b3b0c4).
I am able to pass the lint, but not able to push the pod in cocoapods as I am not the admin. @[759512522:emilsj], please push it on Cocoapods or give me permission.
Podspec now also exposes public header explicitly.
Reviewed By: gkassabli
Differential Revision: D7375018
fbshipit-source-id: 4e82e1c0b6340c3f8d3b8a96ecadbcb711d4bcd8
Summary: Adds an example of how to use yoga from JavaScript to the documentation pages.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7354390
fbshipit-source-id: 0dbc08e5341c06b621acd99bfb9ce7e789b67a45
Summary: These don't need to be copied twice.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291363
fbshipit-source-id: 22e606d0b3fa1133d7e0334c8cf9f5f1f32fe64b
Summary: These shouldn't be copying the arguments when they pass by value. Instead these only get copied when assigning the value to the member.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291096
fbshipit-source-id: 7a4025831811d622050adbb5f86608855b94d68e
Summary:
Earlier `YGfloatOptional` was plain struct with no privacy around the variables. This diff adds privacy and also enforces checks when one tries to access value of an undefined `YGFloatOptional`
This diff also adds a behaviour in which when a value of an undefined YGFloatOptional is accessed, it will normally terminate(Several cleanup steps are performed).
Reviewed By: emilsjolander
Differential Revision: D7288555
fbshipit-source-id: f61cc92c8fd0d48d2fc1f4d0e6fcef155f19ff8a
Summary: Fixed a typo of flexshrink and added a test case
Reviewed By: emilsjolander
Differential Revision: D7289221
fbshipit-source-id: 48ee9ccfac4adee51d515a366b5a11790f7236fc
Summary: Fix getters and setters of min and max Dimension to behave exactly the same way as it was before fast math changes
Reviewed By: emilsjolander
Differential Revision: D7274807
fbshipit-source-id: 7c1a4c19e8d0552b089a410c3330392cb26a6a47
Summary:
This diff fixes the setter and getter of margin, position, border and padding to the previous behaviour of yoga, before floatoptional change
This diff also removes the unrequired `#define`
Reviewed By: emilsjolander
Differential Revision: D7274115
fbshipit-source-id: 942a91e6562ef789ae79102a828f397889468fa7
Summary:
Earlier YGUndefined was NAN, but recently it was replaced with 10E20 and the check for `isUndefined` is as follows
```
public static boolean isUndefined(float value) {
return (Float.compare(value, (float) 10E8) >= 0 || Float.compare(value, (float) -10E8) <= 0);
}
```
If the number is in (-inf, -10E8] and [10E8, inf) then it is considered as undefined. Failing test passed values in this range, so thats why the test was failing. Current diff fixes this issue, and passes a big number which is outside the range as the result of measure function.
Reviewed By: emilsjolander
Differential Revision: D7272325
fbshipit-source-id: 81a77117c65c5dc0cec920f50f0735ec0a7433d1
Summary:
This diff exposes `shouldDiffLayoutWithoutLegacyStretchBehaviour` from YGConfig and `doesLegacyStretchFlagAffectsLayout` from YGLayout to YogaConfig and YogaNode respectively
Also added a positive test case. Didn't find the negative test case example. @[508947467:ianc] or @[759512522:emilsj], can you suggest a negative test case example.
Reviewed By: emilsjolander
Differential Revision: D7272067
fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
Summary: Remove the use of YGUndefined for default flex-basis value
Reviewed By: emilsjolander
Differential Revision: D7243924
fbshipit-source-id: 2bfaca1a5e3da40d5292a273cabf705f59c9d666
Summary: Change the type of flexShrink to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7232171
fbshipit-source-id: 3111119d3d74a7035c01132bff61b30cf44e120a
Summary: Change the type of flexGrow to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7215355
fbshipit-source-id: 1298ee332551d44e4d070169a1e4103d005c4f43
Summary: Change the type of flex to YGFloatOptional internally, but keeping the public facing API the same as before
Reviewed By: emilsjolander
Differential Revision: D7211327
fbshipit-source-id: 0d979b6ba00317317b98bbc6e63979c7f1feb2da
Summary: Changed the return type of YGResolveValue
Reviewed By: emilsjolander
Differential Revision: D7195099
fbshipit-source-id: 72c4163cd08691cf6e40df05394cc52e83b0de14
Summary: Remove the usage of YGUndefined in the default values of Border in YGStyle. In the getter of Border function, YGUndefined is used just to keep it logically consistent. The proper solution would be to change the api in `Yoga.h` to accept `YGFloatOptional`, but that would require to change lot of the code in client of this library. Will make a separate diff for that.
Reviewed By: emilsjolander
Differential Revision: D7195115
fbshipit-source-id: e635cf55ac94d8a90caef6cafce281579da2cbfc
Summary:
emilsjolander hi,
this PR solves the following common and probable layout pixel scenario:
the older code is presented for reference:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutWidth()),
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
Math.round(xOffset + node.getLayoutX()),
Math.round(yOffset + node.getLayoutY()),
Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
suppose now the following:
- `xOffset + node.getLayoutX() = 2.2`
- `node.getLayoutWidth() = 0.4` ==> `Math.round(node.getLayoutWidth()) = 0`
- `Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()) = Math.round(2.2 + 0.4) = 3`
this induces, the following measurements:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
0,
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
2,
Math.round(yOffset + node.getLayoutY()),
3,
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
the width measurement of the view is 0, while the layout is `(3 - 2 = 1)`.
my proposed solution is to measure the view the way it is now, but when layouting
I use the `#getMeasuredWidth/Height()` methods, this will stop this problem
from happening.
I also want to note that this bug happens with high probability.
Closes https://github.com/facebook/yoga/pull/712
Reviewed By: emilsjolander
Differential Revision: D7231798
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 171da519639dbecd75416a574bccc4456aa22f31
Summary: When we don't explicitly set header_namespace, we can get differing behavior between Android and iOS. Even when it is not explicitly necessary, we are going to try to enforce this properly.
Reviewed By: scottrice
Differential Revision: D7141155
fbshipit-source-id: 74d1488c3909f89ad9d6d0ee0de335b789dc2ccd
Summary:
Some files have crept into the repo with the old license header. These are usually from PRs that were opened prior to the re-licensing of the project.
Let the script run, prior to fixing the errant files. The script outputs the following:
```
PATENTS crept into some new files?
--- /dev/fd/63 2018-03-01 01:42:48.250153746 +0000
+++ /dev/fd/62 2018-03-01 01:42:48.250153746 +0000
@@ -1 +1,9 @@
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.h
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.m
+ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+ReactAndroid/src/main/java/com/facebook/react/views/text/CustomLetterSpacingSpan.java
+ReactCommon/yoga/yoga/YGLayout.cpp
+ReactCommon/yoga/yoga/YGLayout.h
+ReactCommon/yoga/yoga/YGStyle.cpp
+ReactCommon/yoga/yoga/YGStyle.h
scripts/circleci/check_license.sh
Exited with code 1
```
Fix the headers in these files and run the script again. No output, exit code 0.
Closes https://github.com/facebook/react-native/pull/18143
Reviewed By: sophiebits
Differential Revision: D7119356
Pulled By: hramos
fbshipit-source-id: d238e4d4a3ae320a2c8e625c2fa29690057a4814
Summary:
Changed NaN with large number to support `-ffast-math` compiler flag.For `-ffast-math` to work, all floating point numbers should be finite. Reason for not going with `FLT_MAX`, is that, it may cause number overflow during math operations. So thats why I opted for big number smaller than `FLT_MAX`. Earlier we used NaN, while NaN is involved in comparision the comparision operator behaves differently, it always returns false. Also operators like, fmaxf,fminf etc. have wierd beahviours. This diff takes care of those things as far as possible, and all tests are passing.
Running ./instrumentation_tests/run instrumentation_tests/com/facebook/feed/ctacoalescing:ctacoalescing --class AttachmentCallToActionSelectorBenchmarkTest --benchmark --extra-arg iterations=100 shows the perf gain of 13-15%
Reviewed By: emilsjolander
Differential Revision: D6969537
fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
Summary: removing the old `docs` folder as we are switching to `gh-pages` branch.
Reviewed By: emilsjolander
Differential Revision: D7110147
fbshipit-source-id: a27e6fc3a115f2f62b8a0dd5833d872e24698021
Summary: Tracks a Google Analytics event once the code generator is opened.
Reviewed By: emilsjolander
Differential Revision: D7097182
fbshipit-source-id: 637a96db981f5e90c9f7ce155ba8669b8dac98fa
Summary: Travis builds for the website were failing. The problem was due to `yoga-layout` not compiling. However, we don't need to compile `yoga-layout` at all, because we are only using the asm.js version. This adds the `--ignore-scripts` flag to the `yarn` command, to ignore the post-install script which tries to compile yoga.
Reviewed By: emilsjolander
Differential Revision: D7097154
fbshipit-source-id: 3bf9efda0e2ae6166181dad66621cf6fc9586e88
Summary: Travis defaults to node version 0.10 (!). Explicitly setting the node version to 8.
Reviewed By: emilsjolander
Differential Revision: D7056888
fbshipit-source-id: f6e31cc75009dc4f322c1750c2ce540afdd641ce
Summary: Removes travis build as they were currently not in use and prevented website from being deployed.
Reviewed By: emilsjolander
Differential Revision: D7055369
fbshipit-source-id: f227b1da1fea748c526b9faeedef063f9eeff61f
Summary: Adds a deploy step to travis.yml file to depoly the docs to github pages.
Reviewed By: emilsjolander
Differential Revision: D7028804
fbshipit-source-id: bb91c6b1ad2a306a6957a48679f164128c5b1be1
Summary:
"feature" should be "features" but it's already used twice in that paragraph so
I replaced it with "showcases" instead.
Reviewed By: emilsjolander
Differential Revision: D7042770
fbshipit-source-id: 0287f8746feca5c9f651950c8e9c24d2e86d55e9
Summary: Specify that the jni rule is really for android
Reviewed By: emilsjolander
Differential Revision: D7015911
fbshipit-source-id: 5fbff4bb15d2d1256261b13417653b68bb6dc5aa
Summary: Added default constructor for YGCachedMeasurement. This diff uses the default initialiser to get rid off the older designated initializer syntax. This diff also addresses https://github.com/facebook/yoga/pull/700
Reviewed By: emilsjolander
Differential Revision: D7020337
fbshipit-source-id: e084e234bf6a2ae22e53e739959683abca169b88
Summary: Add default constructor in YGLayout and moved to separate file. This diff also addresses https://github.com/facebook/yoga/pull/700
Reviewed By: emilsjolander
Differential Revision: D7019653
fbshipit-source-id: 5a2655626db0915fcebe7d4517e2d0b2e2484460
Summary: Moved YGStyle to separate file and added default constructor to it. This diff also gets rid off of the default values, which were earlier declared in Yoga-interna.h and instead uses default constructor. This diff also addresses https://github.com/facebook/yoga/pull/700
Reviewed By: emilsjolander
Differential Revision: D7016575
fbshipit-source-id: eb28df0ffb4cc813b23edaff80d7d4ebc56ce6af
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
Summary: Yoga logo was hotlinked from the old pages. This adds the logo to the sources
Reviewed By: emilsjolander
Differential Revision: D7009804
fbshipit-source-id: d913223e042b1bd9cf2ddab7c74d864e482d94b3
Summary: The position record defaulted to 0, which was wrong. No it defaults to NaN, which is the same as not having a value at all.
Reviewed By: emilsjolander
Differential Revision: D7009783
fbshipit-source-id: 83810da87e983f8d4d3e428f1f5fab0928bce58d
Summary: select the value of any input element once the field gets focus.
Reviewed By: emilsjolander
Differential Revision: D7009723
fbshipit-source-id: e1bc0f4b219958d8bdb79ef1a583cad86157b050
Summary: This is now possible with the changes to centering the content
Reviewed By: danielbuechele
Differential Revision: D7009506
fbshipit-source-id: e2ff11d25dd6c388c82983d615e2a4c50b992583
Summary: Generated code modal now has a copy to clipboard button
Reviewed By: emilsjolander
Differential Revision: D7009716
fbshipit-source-id: 7a9b083d7067aa66ffa5b9d9c23741321547c4f6
Summary: Code generators now can handle percentage and auto values as well as numeric values (DIP)
Reviewed By: emilsjolander
Differential Revision: D7009344
fbshipit-source-id: 64ddcb61a2dce01e68e38a16e4d5865d8e4c6d5b
Summary:
- fixes a but where `auto` was passed to properties that don't support auto as a value
- fixes errors in flow typing
- Re-adds accidentally removed scripts to package.json
Reviewed By: emilsjolander, arcanis
Differential Revision: D6999447
fbshipit-source-id: df66976c74c4af082a1ca0527e3e1ce54bdeb732
Summary: This is an older version of the standalone playground which is outdated and not used anymore
Reviewed By: emilsjolander
Differential Revision: D6998970
fbshipit-source-id: a27bee81b6f85f70c35a8d3e7ea7b06486c52626
Summary: root node is now centerwed between edge and editor
Reviewed By: emilsjolander
Differential Revision: D6989159
fbshipit-source-id: ce2621402d380843125fabc43452c64ea3b563dd
Summary:
When the following conditions are met, the main size become smaller by the margins in the main axis.
* The aspect ratio is defined
* The main size is not defined
* The cross size is defined
* The main margin is defined
This is because the main margin size is not included when calculating the main size from the aspect ratio.
Closes https://github.com/facebook/yoga/pull/715
Reviewed By: emilsjolander
Differential Revision: D6998988
Pulled By: priteshrnandgaonkar
fbshipit-source-id: f6f69c47ece17bd7c5e41517b96032bf0c149356
Summary:
This diff exposes the YogaNode clone operation to JNI in order to be able to clone Java YogaNode objects.
The clone method performs a shallow copy of the java YogaNode.
I made YogaNode to implement Cloneable, I know that this might not be a good idea but in this case it simplifies the cloning mechanism. I am open to suggestions.
IMPORTANT NOTES:
- The current implementation IS NOT making a deep copy of the mData instance variable.
- The mParent Java instance variable will reference the parent of the original Java YogaNode, is that ok sebmarkbage?
Reviewed By: priteshrnandgaonkar
Differential Revision: D6935971
fbshipit-source-id: a2008f1eb849b5074585b48699b7de56d5ac90d4
Summary: This diff extends the JNI version of yoga in order to allow Java instances of the YogaConfig class to receive a callback when a Yoga node is cloned.
Reviewed By: priteshrnandgaonkar
Differential Revision: D6918605
fbshipit-source-id: e424c78680c04e21154ebe21405671c4e90f6529
Summary: editing numerical values didn't work. this fixes it and cleans up the API of the playground
Reviewed By: emilsjolander
Differential Revision: D6976128
fbshipit-source-id: 9b1ace9d93ba8e597bdfb4842ed6adcaf8b77fd9
Summary: Inserting or deleting nodes threw an error, due to some changes I made earlier. This fixes the error.
Reviewed By: emilsjolander
Differential Revision: D6975950
fbshipit-source-id: d04df08260ab8ab248726809329e69f4d264decd
Summary: The bundling of gatsby is done in node. This caused the node-libs from yoga being loaded. This directly imports the browser version.
Reviewed By: emilsjolander
Differential Revision: D6975779
fbshipit-source-id: 0257a86733c5552259b171309e59cc676786621e
Summary:
Sets up a skeleton for the new yoga website using gatsby static site generator
allow-large-files
Reviewed By: emilsjolander
Differential Revision: D6952326
fbshipit-source-id: 7579bc80bec21552689da5b78f3d960910ff13bb
Summary:
YGConfig isn't owned by the YGNode, and thus isn't freed when freeing the node (`YGNodeFreeRecursive`)
This fixes a memory leak caused by D6856812
Reviewed By: emilsjolander
Differential Revision: D6945022
fbshipit-source-id: 5fd3c3e2ac1cd94d459d5aa06e0daa8f107779ac
Summary: Expose a function which marks all descendants dirty
Reviewed By: emilsjolander
Differential Revision: D6911869
fbshipit-source-id: e0a3abcf5653f921297edfdca473d83b947cc627
Summary: While moving a function as a method in YGNode, there was an error in which I mistakenly called a method on node, whereas I had to call it on child.
Reviewed By: emilsjolander
Differential Revision: D6918367
fbshipit-source-id: cee90e015f9e45a717a7307f59fd3b9ef6f399b6
Summary: There was a slight error in main axis justification which caused the regression
Reviewed By: emilsjolander
Differential Revision: D6923178
fbshipit-source-id: d8f81b06d9127c75daecffb73b5e6c5abbad8ade
Summary: Moved margin axis function as a method in YGNode
Reviewed By: emilsjolander
Differential Revision: D6900003
fbshipit-source-id: a42da3bcd3126bf8c432c6740987b5ec0b572172
Summary: Moved trailing padding and border function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6899571
fbshipit-source-id: 7f686e8771d5a94aae502191516557b20c557d7c
Summary: Moved out main axis justification logic to seperate function
Reviewed By: emilsjolander
Differential Revision: D6845997
fbshipit-source-id: fdb64e00de39427ce1d66d4fbfd06c23c0d32bcf
Summary:
This adds a web-based playground to try out Yoga. The playground uses yogas javascript bindings to use yoga within the browser. The layout tree can be modified and shared. Code generators for litho, ComponentKit and React Native allow the layout to be copied into any app.
allow-large-files
Reviewed By: emilsjolander
Differential Revision: D6871601
fbshipit-source-id: 3b97c87e91d6bafe8e1c38b8b7eca8d372324c0b
Summary: Made a separate function for resolving flexible length
Reviewed By: emilsjolander
Differential Revision: D6834269
fbshipit-source-id: 954bc7fe8eb9256d353cdda27e5c64c076808e25
Summary: Added a separate function which does the second pass to distribute the free space amongst the views which can be flexed.
Reviewed By: emilsjolander
Differential Revision: D6833635
fbshipit-source-id: 7680a67db8bfe22f8fb86407159888882f3a3353
Summary: Added a function which does the first pass to determine the free space based on flex items whose min and max constraints are triggered
Reviewed By: emilsjolander
Differential Revision: D6819719
fbshipit-source-id: e5e77c21d1dca2255433da3388887d9db3f7b642
Summary: Moved out logic to calculate size consumed on a line into seperate function
Reviewed By: emilsjolander
Differential Revision: D6797640
fbshipit-source-id: ad9757e7d603c0ce57f452b1e5c404037605bed9
Summary: Check if the layout tree is different if we do not use legacy flags. If they are different then report to the client
Reviewed By: emilsjolander
Differential Revision: D6856812
fbshipit-source-id: e4724d80702cc75c1894e348e137b24e663573d2
Summary: Since a `YGNodeRef` is created with `new`, it needs to be deleted using `delete` instead of `free`.
Reviewed By: richardjrossiii
Differential Revision: D6866064
fbshipit-source-id: a44828cedb5045b6c97179fb30ffd8c8dafcbfbe
Summary: Previously the logging logic assumed fixed number of characters in the string to be logged. With this diff the logging logic is made dynamic, catering to variable length of the string to be logged
Reviewed By: emilsjolander
Differential Revision: D6784491
fbshipit-source-id: 26e4520a84be355ff992b808297ce7a95b3d09e3
Summary: Added a benchmark tests along with the usual gentest in yoga for a complex yoga android news feed view.
Reviewed By: emilsjolander
Differential Revision: D6753544
fbshipit-source-id: 23b8da9785990a86248ff4708ac61e12411eb489
Summary: These are already considered immutable, but not marked in their class.
Reviewed By: emilsjolander
Differential Revision: D6759564
fbshipit-source-id: 810dc8a9730fb330760d2aedecafcea81cf25cb1
Summary: Package is already published via NPM. This is just the version bump.
Reviewed By: emilsjolander
Differential Revision: D6750224
fbshipit-source-id: 6add1ce71714e58e4afacd095265b3e770bc558e
Summary: Currently in the flexbox algorithm we were using linked list for maintaining the nodes which had relative/absolute position types, this diff uses STL vector instead of linked list.
Reviewed By: emilsjolander
Differential Revision: D6722959
fbshipit-source-id: 4e81176802b9a9319bc5f385c824a06be14a83a2
Summary:
@public
Trivial. Those lines were lost during rebasing of the original commit.
Reviewed By: priteshrnandgaonkar
Differential Revision: D6717696
fbshipit-source-id: a5dce25427c8977352b3ae7ea01e546a540e0c13
Summary: Moved leadingpaddingnandborder function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711991
fbshipit-source-id: 41ad7191bf8df6fe3131106436dc0c87e9dee297
Summary: Move trailing padding function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711897
fbshipit-source-id: fa2e1a8e31242358a6e94aef51368e2c2c58b79d
Summary: Moved leading padding function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711830
fbshipit-source-id: d2f6f55ec23b007bb51f8a91385e02236f46dc7b
Summary: Resolve direction function is now as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711755
fbshipit-source-id: a0e80596e10f0c7fb7a31b75377da4db846c4bbb
Summary: Move trailing border function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711666
fbshipit-source-id: fe4fdfc2db59d03beb763317e1a6f9de52f851d4
Summary: Move leading border function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711523
fbshipit-source-id: 76e90083a9dd0728dc9557cc3b0a1f431f3afd5d
Summary: Moved YGNodeIsFlex as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6711536
fbshipit-source-id: e60be7da55e3e8d254eb253c141d219a37a76087
Summary: Previously flexbasis calculation was doing more than one task of accumulating absolutelypositioned child and flexbasis calculation. So this diff refactors the logic and moves out absolutely positioned child calculation to our step 1(which is calculating the variables which are required for rest of the algorithm). This diff also moves the flexbasis logic into separate function
Reviewed By: emilsjolander
Differential Revision: D6702749
fbshipit-source-id: 15dcc94ae30ac185e4d1c7d6e3744a40cfa47317
Summary: Refactored the logic to calculate available main and cross dimensions
Reviewed By: emilsjolander
Differential Revision: D6693777
fbshipit-source-id: d6c87670e74bdc22b32916c2d77fe423d831b378
Summary: Moved setPosition as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6683387
fbshipit-source-id: 83f64101faa700933771c69b222056ec2a6b8d1e
Summary: Moved trailingmargin function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6683313
fbshipit-source-id: 5ee458c2f4698768724901df0e3f5d8805c7c8f5
Summary: Moved getLeadingMargin as a function on YGNode
Reviewed By: emilsjolander
Differential Revision: D6683270
fbshipit-source-id: a26663006419e13cb783e9849183e3c665f59b3c
Summary: Moved getTrailingPosition function as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6683205
fbshipit-source-id: d30003d90d634c644d92c833e58165b073d4d13e
Summary: Moved is isTrailingPos defined as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6683190
fbshipit-source-id: c37e57d02cc4475eb8181a2bb003c555bdb0aaea
Summary: Moved isLeadingPos defined as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6682956
fbshipit-source-id: 31c60e0eae906e1434a6969f3cd786fcaf9097a5
Summary: Moved YGNodeLeading position as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6682929
fbshipit-source-id: 3607aab1544b62b1126c5d75b2f6fb8f5ca2d45f
Summary:
@public
Currently, we can dirty leaf nodes with `measure` function, we also can get `dirty` status for any node, but we cannot handle a moment when this change happen. This diff introduces a new call-back-manner handler for it.
We need this to plug Yoga inside and outside other layout systems without maintaining own dirty propagation infrastructure.
Consider using Yoga for flex-box layout in React Native where we can have deeply nested layout like `<View><Text><View><Text/></View></Text></View>` where all content of all <Text> nodes are laid out using native text/inline (not flex-box!) layout system. In this case, when some change dirties some deeply nested Yoga node, we have to propagate the dirty state down to outer one. Having this handler makes possible to wire up `on-dirty` handler on the root node and `setDirtied` for the leaf node.
Removing custom dirting mechanism from React Native should drastically simplify rendering layer and bring a huge performance win.
Reviewed By: emilsjolander
Differential Revision: D6597856
fbshipit-source-id: 6588cd712f9c1dede4af32f3d326f90103e48ff0
Summary: There were warnings of castings and null pointer handling in yoga.cpp. This diff fixes the warnings. The issue was brought up here https://github.com/facebook/react-native/issues/17274
Reviewed By: emilsjolander
Differential Revision: D6675111
fbshipit-source-id: 884659fabb05033b4d43d3aa6629e22481d39b7e
Summary: Moved YGResolveFlexGrow as a method on YGNode
Reviewed By: emilsjolander
Differential Revision: D6611385
fbshipit-source-id: 71660946c469fac77c5ffa0284c793e6adc9db7b
Summary: Moved YGNodeMarkDirtyInternal as a method in YGNode
Reviewed By: emilsjolander
Differential Revision: D6611287
fbshipit-source-id: 54402145d51ea717553ea136be739b9880a79817
Summary:
- Removed the default() static method, instead of this, its zero argument initialiser is used
- Moved `YGCloneChildrenIfNeeded` to `cloneChildrenIfNeeded` as a method on `YGNode`.
Reviewed By: emilsjolander
Differential Revision: D6611155
fbshipit-source-id: 463723a363e0fbd2c7686f65226eca73236bd07e
Summary: With this flag the the workflow successfully passed.
Reviewed By: emilsjolander
Differential Revision: D6619293
fbshipit-source-id: c1632efd97f47696b7f8bb1b3e763de92c707287
Summary: Currently whenever `Yoga.h` is imported by someone we set `FB_ASSERTION_ENABLED`. The use case of this flag is to use assert calls of `FBAssert.h`, since we do not use it anymore, there is no need to set this flag.
Reviewed By: emilsjolander
Differential Revision: D6611904
fbshipit-source-id: f01ac144159c1b333d8deb8cbb5ba0288e4bf7a4
Summary: Moved c implementation of `YGNode` to C++ struct. Not moving to C++ class as the React Classes dependent on `Yoga.h` assume it to be C. Thats why keeping `Yoga.h` C compatible. Sorry for the long diff, didn't thought that it will turn out to be this much big.Will keep an eye on number of lines next time 😉
Reviewed By: emilsjolander
Differential Revision: D6592257
fbshipit-source-id: 641e8b9462ad00731a094511f9f5608b23a6bb21
Summary:
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. In setters and getters we call the corresponding `YGNode`'s setters and getters. Thus the following code will crash
```
let layout = YGLayout()
layout.flexDirection = .row
```
Reviewed By: emilsjolander
Differential Revision: D6597796
fbshipit-source-id: 653d275d7314bfdd7a1106884fa3fbc0a13e1be7
Summary:
Disable assert code in release builds (define DNDEBUG).
This disables assertions in Facebook JNI library - which checks that our references to Yoga JNI objects are correct.
This saves CPU time, since those checks are costly.
Reviewed By: emilsjolander
Differential Revision: D6592023
fbshipit-source-id: eaf869c7990cab3a72ae2bbdc67e709153f5020c
Summary:
Currently we have `-O3` hardcoded inside our BUCK target files, this will allow us afterwards to remove that.
Follow up commit will also add `-DNDEBUG` which will disable `assert` in release builds.
Reviewed By: emilsjolander
Differential Revision: D6592024
fbshipit-source-id: f541ee8728ff44db8e31885f2085dc036a400f70
Summary:
GCC internally aliases isnan and a dozen other math.h primitives to their `__builtin_` counterparts, which compile straight to assembler. Clang does not do this, so calls to `isnan` compile to a function call. The Android libc does not define `isnan` because it assumes all application code compiled `__builtin_isnan` and has no need for the function `isnan`.
This is a temporary kludge: Starting with NDK r16, the math.h header has appropriate `#defines` to alias primitives to their `__builtin_` counterparts. Upon upgrade to NDK r16, this can be reverted.
Reviewed By: passy
Differential Revision: D6527499
fbshipit-source-id: 65d9e43c7e7d973a6c92e9863ebe469b35a24ac8
Summary:
Use clang-5.0 -Oz as default NDK compiler for android.
It does 3 good things:
* brings us into compliance with deprecation of gcc for android NDKs since r13
* yields slightly smaller native code, on the order of many-10s-to-small-100s of KB
* slight improvement in startup performance, on the order of 10s of ms
Reviewed By: mzlee
Differential Revision: D6155682
fbshipit-source-id: 2f64e742f4dc44be171274c2ad0a41fb1e7079d7
Summary:
ComponentKit requires all size geometry provided to be rounded to pixel grid. This ensures
that layout will not truncate provided sizes.
Reviewed By: cuva
Differential Revision: D6466875
fbshipit-source-id: 62a480411e7d2354a6879917c42bbf0ee96cdadd
Summary:
Changes so we are able to reset properties to their initial value.
This is required to reset these properties.
Add the support of YGUnitUndefined to many properties:
* minWidth
* maxWidth
* minHeight
* maxHeight
Also, these properties must be reset to YGUnitAuto.
* width
* height
* flexBasis
This now matches completely how these properties are initialized in Yoga.cpp
Closes https://github.com/facebook/yoga/pull/672
Reviewed By: dshahidehpour
Differential Revision: D6407908
Pulled By: emilsjolander
fbshipit-source-id: ac20c7b2c06349115aea7d31240204d17e2f1b44
Summary:
👋 Hello! Thanks for react-native, it’s a great project.
I was digging into the Android implementation in _ReactAndroid_ and noticed a couple typos in the documentation. I went through and tried to fix all the typos I could find using [aspell](http://aspell.net).
Not applicable: these changes are only to comments, and CI should be skipped.
[ANDROID][ENHANCEMENT][*] - Correct comment and docblock typos
Closes https://github.com/facebook/react-native/pull/17049
Differential Revision: D6472182
Pulled By: shergin
fbshipit-source-id: 7e62cab118609596b483d1cf16c3abf651d6753b
Summary:
Fix min/max percentage constraints on measured nodes. Currently we passed in the available size instead of the parent size.
Fixes#611
Closes https://github.com/facebook/yoga/pull/649
Reviewed By: priteshrnandgaonkar
Differential Revision: D6408019
Pulled By: emilsjolander
fbshipit-source-id: 18be5056dbc0dc179970ec231ab8b4e2cdba65c5
Summary: We were using a very out-dated version of watir which did not run with latest ruby
Reviewed By: priteshrnandgaonkar
Differential Revision: D6447029
fbshipit-source-id: ff4ccb8c96947811ff09f7e87cb504e3e7cb834e
Summary:
Because the source files are *.cpp, not *.c. This fixes building issue with gradle.
Closes https://github.com/facebook/yoga/pull/676
Reviewed By: emilsjolander
Differential Revision: D6446545
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 809229057db26665b2d97b3002ade73632dd9117
Summary:
Suppresses the unused warnings on ```YGDefaultLog```. It uses a more generic macro which simply casts the variable to ```(void)```. This is the simples approach to make mutiple different compilers happy. Fixes#650
Closes https://github.com/facebook/yoga/pull/651
Differential Revision: D6407999
Pulled By: emilsjolander
fbshipit-source-id: 19fd78dd8b84eafdbb48875dd003d506a98c4807
Summary:
If you have a measurable node and set ```marign-left: auto``` + ```align-item:stretch``` on it, it won't get measured and they get a width/height of ```-(nan)```. This change fixes that behaviour. Fixes#644.
Closes https://github.com/facebook/yoga/pull/645
Differential Revision: D6413512
Pulled By: emilsjolander
fbshipit-source-id: 755febeb33bb0d4520ca6b3c28d56ac333e4a14d
Summary:
`!Object.prototype.hasOwnProperty.call(methods, unit))` doesn't correctly return `true` when an unsupported value is passed into `setMaxWidth` within an Automator (macOS) javascript/cocoascript environment.
This PR fixes the issue and also adds the `value` information to the returned error to help with debugging
Closes https://github.com/facebook/yoga/pull/643
Differential Revision: D6413569
Pulled By: emilsjolander
fbshipit-source-id: a42a66710a3ca578b5c25ecef8722f9c3f082b73
Summary:
Needed for a project I'm working on to properly render on high dpi screens. I've manually tested against my project to confirm it works.
Closes https://github.com/facebook/yoga/pull/612
Differential Revision: D6413517
Pulled By: emilsjolander
fbshipit-source-id: c298d7f6b58dc45aaaede2bb995df8615911a4a9
Summary:
Adds new ```space-evenly``` for ```justify-content```.
Also adds a typofix in one of the other justify-content tests.
Fixes#657
Closes https://github.com/facebook/yoga/pull/658
Differential Revision: D6407996
Pulled By: emilsjolander
fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
Summary:
This fixes shrinking of elements which are in a non stretch alignment, but keeps the legacy stretch behaviour in place. Additionally this adds a testcase for ```useLegacyStretchBehaviour```
Fixes#633
Closes https://github.com/facebook/yoga/pull/635
Differential Revision: D6408037
Pulled By: emilsjolander
fbshipit-source-id: 377ab0308dd3a75a148a0af31ab5eb3ffb5b5d83
Summary:
If we have a values already set to undefined and set it to undefined again, we invalidate the layout. This change takes this case into account and keeps the layout valid.
Fixes#630
Closes https://github.com/facebook/yoga/pull/648
Differential Revision: D6408013
Pulled By: emilsjolander
fbshipit-source-id: dc2a848d84d3de9f4650fac9e41d7c8169446406
Summary:
Expected to be able to call `YGNodeLayoutGetMargin(node, YGEdgeEnd)`, but instead, the program aborts with `"Cannot get layout properties of multi-edge shorthands"`.
This bug seems to incorrectly prevent properties from YGEdgeEnd for all Layout properties.
Closes https://github.com/facebook/yoga/pull/632
Differential Revision: D6408060
Pulled By: emilsjolander
fbshipit-source-id: 4ab3b2ffb2f1bb6fd3a27f780caf0123abcdb230
Summary:
It is very inconvenient to enter block attribute name for each view in Objective-C.
Closes https://github.com/facebook/yoga/pull/618
Differential Revision: D6408138
Pulled By: emilsjolander
fbshipit-source-id: 71fe8eadda7233e5055560667d0fc3840ab7259b
Summary:
The min/max inner width shouldn't take the margins into account.
Adds a test for both cases.
Fixes#664
Closes https://github.com/facebook/yoga/pull/665
Differential Revision: D6407982
Pulled By: emilsjolander
fbshipit-source-id: ffa549a06f802263e3b8488e90756aa3f722d52d
Summary:
If you run ```enums.py``` it will revert the changes from 835b2bb . This changes the license header for java to not be a javadocs comment.
Closes https://github.com/facebook/yoga/pull/660
Differential Revision: D6407985
Pulled By: emilsjolander
fbshipit-source-id: 49efe555fecb8d740675c6b4631dce2a64f10417
Summary: Refactored the `YGNodeToString` function from c to c++.
Reviewed By: emilsjolander
Differential Revision: D6397372
fbshipit-source-id: 79e701efe7f19db6dac1aea6328ebf0ac84a7ac3
Summary: Changed the extensions of c files to cpp and made the project build successfully
Reviewed By: gkassabli
Differential Revision: D6271299
fbshipit-source-id: 66c0e54ccf019d72d1fd0b4d117826e4e84fdc89
Summary:
**what is the change?:**
Adding a document linking to the Facebook Open Source Code of Conduct,
for visibility and to meet Github community standards.
**why make this change?:**
Facebook Open Source provides a Code of Conduct statement for all
projects to follow.
Exposing the COC via a separate markdown file is a standard being
promoted by Github via the Community Profile in order to meet their Open
Source Guide's recommended community standards.
As you can see, adding this file will complete [Yoga's Community Profile](https://github.com/facebook/yoga/community)
checklist and increase the visibility of our COC.
We also added a link to the COC in the CONTRIBUTING doc because folks may miss the separate CODE_OF_CONDUCT document.
**test plan:**
Viewing it on my branch -


**issue:**
internal task t23481323
Closes https://github.com/facebook/yoga/pull/670
Reviewed By: emilsjolander
Differential Revision: D6384655
Pulled By: flarnie
fbshipit-source-id: 6c5557094719cc8f1b08deb4d477ab56603caf39
Summary: Removed YGSetMemoryFuncs, as it is not used internally and barely externally.
Reviewed By: emilsjolander
Differential Revision: D6374147
fbshipit-source-id: 8c896dce23571268a1a52df5cc72486af9d66df7
Summary: Use internal linting rules instead of the custom once.
Differential Revision: D6284667
fbshipit-source-id: 65aae336f1d7f14dfefed7391b0f5b89b333495e
Summary: For our -objc efforts we'll be excluding vendorlibs from these changes for now and then working on getting them to not have to be fully linked as a second effort. The way -objc flag works is its an all or nothing flag for the app and thus for any library we still want to link completely we'll have to add a link_whole = True to the BUCK file. (Otherwise we'll have crashes in these libraries :P).
Reviewed By: kastiglione
Differential Revision: D6252740
fbshipit-source-id: fe074977a11b70c4aa63a4c69cb7518906c98eb9
Summary: We'll need these libraries for rainbow, and none of them exist in fbcode.
Reviewed By: mzlee
Differential Revision: D5897801
fbshipit-source-id: c379b76fef2ab204555ceded0834efc6ba932f90
Summary: YGRoundValueToPixelGrid does not handle float point values correctly. It causes layout bugs in arm 32 devices. The way values are rounded to pixel grid is the following: if value is close to the left pixel - discard error and set it equal to left pixel. If value is close to right pixel - set it equal to the right pixel. Otherwise if value is closer to the left - set it equal to the left, closer to the right - set it equal to the right. The problem is when values are close to the middle. Old implementation could produce either left or right boundaries. This patch moves all values that are close to the middle to right boundary. This way results are consistent.
Reviewed By: emilsjolander
Differential Revision: D6202484
fbshipit-source-id: bb80235452208caec388775574cc4f07bfd649c4
Summary: Yoga has an edge case that cause layout to return NaN. This happened when we used absolute position with percentage and infinite constraint in that dimension. This diff fixes that case to default to border+padding
Reviewed By: emilsjolander
Differential Revision: D6199731
fbshipit-source-id: f40ddf00614b2f507848fb35f348a9dfef14b323
Summary:
More fine grained dirty marking
Currently a node's dirty flag propagates to the root of the tree ensuring that when any node is invalidated its whole subtree will be re-calculated. This is often times not needed. There are many properties which only effects a node's children and would not need to propagate all the way to the root such as align-items. Also in cases where the style does change layout it may not need to propagate all the way to the root but can often stop at the nearest position: absolute parent.
This change has the potential of greatly improving performance of re-calculating a tree.
This might require adding a second dirty flag named hasDirtyDescendants ensuring that traversal still works even though a parent is not marked as dirty.
Reviewed By: emilsjolander
Differential Revision: D6134754
fbshipit-source-id: bbcfee14058140b946401de756a3f130de0f51cd
Summary:
Source-only ABIs are a new feature of Buck that allows massive parallelism
by generating ABI jars from just the source code (without looking at most
dependencies). Because dependencies are not available, the generator
makes assumptions about how we write Java code. This commit updates
Instagram's code to conform to those assumptions.
These changes were generated by Buck's automatic migration script.
Reviewed By: dreiss
Differential Revision: D6168048
fbshipit-source-id: 0e51319d93fd697db01ea3933f48cd06a6ffac12
Summary:
This is meant to show a possible route format for a persistent form of Yoga. Where previous layouts can remain intact while still taking advantage of incremental layout by reusing previous subtrees.
```c
YGNodeRef YGNodeClone(const YGNodeRef node);
```
The core of this functionality is a new API to clone an existing node. This makes a new detached node with all the same values as the previous one. Conceptually this makes the original node "frozen" from that point on. It's now immutable. (This is not yet enforced at runtime in this PR but something we should add.)
Since the original is frozen, we reuse the children set from the original node. Their parent pointers still point back to the original tree though.
The cloned node is still mutable. It can have its styles updated, and nodes can be inserted or deleted. If an insertion/deletion happens on a cloned node whose children were reused, it'll first shallow clone its children automatically.
As a convenience I also added an API to clear all children:
```c
void YGNodeRemoveAllChildren(const YGNodeRef node);
```
During insert/delete, or as a result of layout a set of reused children may need to be first cloned. A kind of copy-on-write. When that happens, the host may want to respond. E.g. by updating the `context` such as by cloning any wrapper objects and attaching them to the new node.
```c
typedef void (*YGNodeClonedFunc)(YGNodeRef oldNode,
YGNodeRef newNode,
YGNodeRef parent,
int childIndex);
void YGConfigSetNodeClonedFunc(YGConfigRef config,
YGNodeClonedFunc callback);
```
This PR doesn't change any existing semantics for trees that are not first cloned.
It's possible for a single node to exist in two trees at once and be used by multiple threads. Therefore it's not safe to recursively free a whole tree when you use persistence. To solve this, any user of the library has to manually manage ref counting or tracing GC. E.g. by replicating the tree structure in a wrapper.
In a follow up we could consider moving ref counting into Yoga.
Closes https://github.com/facebook/yoga/pull/636
Reviewed By: emilsjolander
Differential Revision: D5941921
Pulled By: sebmarkbage
fbshipit-source-id: c8e93421824c112d09c4773bed4e3141b6491ccf
Summary:
After about 500MB, Travis seems to kill the TLS connection. Could be a traffic
limit, could be a timeout. I've only seen this for their MacOS boxes. We're now
retrying a few times with curl, which seems to work.
Reviewed By: emilsjolander
Differential Revision: D6051024
fbshipit-source-id: feb73bfb9fd81b2a8b9b4d33d4e9f230a9899a66
Summary: This seems to have changed upstream.
Reviewed By: emilsjolander
Differential Revision: D6050471
fbshipit-source-id: b453831c1d5a5974572265a78da40b0612b1d1f2
Summary:
The native-dependencies plugin seems unused. Upgrade to the latest
gradle-bintray-plugin version that's supported for the current Gradle version.
I'll hold back the upgrade to Gradle 4 until the Gradle Android Plugin for the
version hits stable.
Reviewed By: IanChilds
Differential Revision: D5986549
fbshipit-source-id: d26aa19e9eba40a2b30b20d5ffa9d2b006450f95
Summary:
Use the `deprecated_prebuilt_cxx_library` wrapper instead of the deprecated
API of `prebuilt_cxx_library`.
Reviewed By: ttsugriy
Differential Revision: D5878523
fbshipit-source-id: 2c8c1fd1d19597ff7459bbd527c89573520db74b
Summary:
The Android logger adds newline automatically, which makes the log ugly on Android.
To avoid that, wrap the android logger, print to a memory buffer. Call __android_log_write() when '\n' is detected.
Reviewed By: emilsjolander
Differential Revision: D5842889
fbshipit-source-id: 8ecc829dc43614934c47fd3a68317259e403325a
Summary:
This fixes shrinking of elements which are in a non stretch alignment
Fixes#633
Closes https://github.com/facebook/yoga/pull/634
Differential Revision: D5874862
Pulled By: emilsjolander
fbshipit-source-id: 1426aa6b60f6ba42c2be702e6f24cea935ab7acb
Summary:
Add a new test named YGZeroOutLayoutRecursivlyTest, which verifies that padding and margin of a child node should be set to 0 when the display is set to none.
Modify YGZeroOutLayoutRecursivly function, use memset to clear the layout struct of the node.
Reviewed By: emilsjolander
Differential Revision: D5842351
fbshipit-source-id: d2c2b6f829588a200525b7ccbdb63003cb4dcc4e
Summary:
Only add UIView nodes to Yoga where they are enabled.
We check for it in `isLeaf` but I think we should also check for them in the check for sub views.
Closes https://github.com/facebook/yoga/pull/609
Reviewed By: emilsjolander
Differential Revision: D5643387
Pulled By: dshahidehpour
fbshipit-source-id: a85c62b6b2e0120b2913e7f2df8b094d43ca49a6
Summary:
This PR fixes a declaration mismatch for `YGNodeCanUseCachedMeasurement` where the last argument is declared non `const` in `.h` and `const` in `.c`.
Additionally it uses explicit `float` for fraction calculation do avoid usage of `double` assignment.
Closes https://github.com/facebook/yoga/pull/607
Differential Revision: D5677931
Pulled By: emilsjolander
fbshipit-source-id: 502da957089e4439ed956987ff8dec10bd033ba3
Summary: At least one compiler seems to care about it.
Reviewed By: emilsjolander
Differential Revision: D5675518
fbshipit-source-id: 72a6e208263dde0b6bb46a78fedb2796d0e0a600
Summary:
@public
== Before ==
- Aspect ratio would do its best to fit within it's parent constraints
- Aspect ratio would prioritize `alignItems: stretch` over other sizing properties.
== After ==
- Aspect ratio is allowed to make a node grow past its parent constraints. This matches many other aspects of flexbox where parent constraints are not treated as hard constraints but rather as suggestions.
- Aspect ratio only takes `alignItems: stretch` into account if no other size definition is defined. This matches the interaction of other properties with `alignItems: stretch`.
== Updating your code ==
**You probably don't need to do anything** but in case something does break in your product it should be as easy as adding `{width: '100%', height: '100%', flexShrink: 1}` to the style declaring the `aspectRatio`.
Reviewed By: gkassabli
Differential Revision: D5639187
fbshipit-source-id: 603e8fcc3373f0b7f2461da2dad1625ab59dcb19
Summary: There was an uncovered edge case where number close to the whole was forced to round down because it was considered non-whole and had forced flooring. This diff covers that + adds a bunch of test cases to cover rounding function
Reviewed By: emilsjolander
Differential Revision: D5465632
fbshipit-source-id: 57e11092a97eba5dd76daad15fa8619535ff9c1b
Summary:
There was one incorrect path and some caching problems. I hope this will take
care of it for good.
Reviewed By: emilsjolander
Differential Revision: D5470120
fbshipit-source-id: 17c9e783c952c92fa5c2ccfb18107a59d8a80e3d
Summary:
Phew, this took a while. Buck had some changes in how it picks up SDK/NDK
configs.
In order to satisfy the new demands, I'm now installing the NDK manually and no
longer through the SDK manager. I'm also trying to cache as much as possible to
reduce the flakiness here.
Reviewed By: emilsjolander
Differential Revision: D5465206
fbshipit-source-id: 61a4b9006fe96fc9a99fb9d75b822589064a9d1a
Summary:
Set to the next snapshot version so automatic snapshot publishing is reenabled.
We need those to keep in sync with the Litho snapshots.
Reviewed By: emilsjolander
Differential Revision: D5442493
fbshipit-source-id: ecb92071ec8edb9c3c6b625c08f5aad20368d0a3
Summary: Yoga had a bug in Rounding calculation that caused text nodes dimensions to be rounded up even when the dimensions didn't need rounding
Reviewed By: emilsjolander
Differential Revision: D5406211
fbshipit-source-id: df1d54ed0805dfc3abbd8f0ceae30f6d8c26d61a
Summary:
Currently the nbind asm.js output generates boilerplate code which can conditionally load node's `fs` and `path` modules. If this output is run directly in the browser there are no issues but if you run it through a bundler the build step will fail trying to resolve the node builtins.
Workarounds currently exist for bundlers like webpack (mentioned in #444) but this is not a safe assumption to make (for example such workarounds don't exist for `metro-bundler`).
I am by no means suggesting that this is the perfect solution but this might provide a stop-gap fix for people who are currently blocked by this issue (like I am).
Closes https://github.com/facebook/yoga/pull/585
Differential Revision: D5388660
Pulled By: emilsjolander
fbshipit-source-id: d3a51eb852df35e3d0610158fe7d9f5754e4e684
Summary:
This fixes the case where we change the layout, so that it doesn't overflow anymore.
This also improves the readability by using `|=` instead of referencing the value twice.
Closes https://github.com/facebook/yoga/pull/587
Differential Revision: D5388657
Pulled By: emilsjolander
fbshipit-source-id: ce1b1ded1feed7314a2c16bf695f62b866c19ea0
Summary:
If we have a fractional measure output which matches the subpixel rounding factor, we still should round both dimension into the same direction.
Fixesfacebook/yoga#580.
Closes https://github.com/facebook/yoga/pull/583
Reviewed By: marco-cova
Differential Revision: D5274212
Pulled By: emilsjolander
fbshipit-source-id: 1febf9194210437ab77f91319d10d4da9b284b79
Summary:
We need to provide Yoga clients with means of detecting overflow in flexbox layout. This information can be used later to identify a non-overflowing layout variant among others.
Flexbox layout considered overflown if (this is *not* an exhaustive list):
- if any child node overflows
- [no-wrap] total flex basis of all child nodes is greater than available space in parent and there are no flexible children
- [no-wrap] after flexing there is still not enough space to layout all child nodes
Reviewed By: gkassabli
Differential Revision: D5336645
fbshipit-source-id: c4f87d1754d7bac848e8d347b31d619393b94d2c
Summary: We don't bundle this library with the yoga source, and it isn't needed.
Reviewed By: emilsjolander
Differential Revision: D5274172
fbshipit-source-id: fec47d2700da86498410fe445d2980f31a563551
Summary:
This is an easy diff to wrap YGPointValue() in an extern "C" block to make sure it compiles
when we are using inside of Objective-C++ classes.
Reviewed By: emilsjolander
Differential Revision: D5242366
fbshipit-source-id: 772aaac056b3a20041926d5f35128716848a271a
Summary:
The only thing I found in the spec for this change is the following. Not exactly sure if this is the thing this PR is about:
> For each flex item, subtract its outer flex base size from its max-content contribution size. If that result is not zero, divide it by (if the result was positive) its **flex grow factor floored at 1** or (if the result was negative) by its scaled flex shrink factor, having **floored the flex shrink factor at 1**. This is the item’s max-content flex fraction.
But at least it seems a required change.
Fixesfacebook/yoga#566
Closes https://github.com/facebook/yoga/pull/572
Differential Revision: D5264388
Pulled By: emilsjolander
fbshipit-source-id: 0004d1c3b9bad070a98cd6766c1adc06a54475f8
Summary:
The library(yoga) has no dependency on android framework. As a matter of
fact this version can change to a lower number which will make yoga
support more old systems.
According to I/O 17, support library has change its minimum SDK version
to 14, so I think 14 is a reasonable min support version for yoga as well.
See
https://developer.android.com/topic/libraries/support-library/revisions.html
Closes https://github.com/facebook/yoga/pull/573
Differential Revision: D5264385
Pulled By: emilsjolander
fbshipit-source-id: cb813a3b643a3f4e2034c6c0ab8b488f94d6a7d0
Summary:
They were set up as javadocs (double-asterisk at the start) but should be normal
block headers.
Reviewed By: IanChilds
Differential Revision: D5255424
fbshipit-source-id: 23439ac035f74f2fd1c756b8185e39199e748e33
Summary:
Same as litho, just for compat with Android Studio. Shouldn't affect the
project.
Reviewed By: emilsjolander
Differential Revision: D5217956
fbshipit-source-id: 32cfec0bf4ab4e51f5e4116149ee091cf1245e95
Summary: If the width has an exact dimension, while the left and right edges have a decimal part, that means the decimal part is equal and we can round both down instead of rounding left down and right up. Same for top and bottom.
Reviewed By: emilsjolander
Differential Revision:
D5209073
Tags: accept2ship
fbshipit-source-id: a3a6a43767aa707ebfa5eee62a83adcdd88d7ce6
Summary:
This is a fix on top of 56b10fc. It takes the case into account were you have `wrap-reverse` and `align-items: flex-end` set.
Closes https://github.com/facebook/yoga/pull/568
Differential Revision: D5155521
Pulled By: emilsjolander
fbshipit-source-id: 7e5fcfa2fbb48b6c6279da46cc648a071ff2b079
We want to make contributing to this project as easy and transparent as
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.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
## Pull Requests
We actively welcome your pull requests.
1. Fork the repo and create your branch from `master`.
@@ -25,9 +29,6 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.
## Coding Style
* format.sh
## License
By contributing to yoga, you agree that your contributions will be licensed
[]()
[]()
## 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.
@@ -33,13 +23,10 @@ You may need to install the latest watir-webdriver gem (`gem install watir-webdr
### .NET
.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.Yoga/test_macos.sh`.
## Code style
For the main C implementation of Yoga clang-format is used to ensure a consistent code style. Please run `bash format.sh` before submitting a pull request. For other languages just try to follow the current code style.
## Benchmarks
Benchmarks are located in `benchmark/YGBenchmark.c` and can be run with `buck run //benchmark:benchmark`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.
### Javascript
### JavaScript
Installing through NPM
```sh
npm install yoga-layout
@@ -60,4 +47,28 @@ This will now only run the standalone webpack build upon install.
| 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.
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
spec.summary = '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 => '1.5.0',
:tag => "1.18.0",
}
spec.platform = :ios
spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'UIKit'
spec.dependency 'Yoga', '~> 1.5'
spec.module_name = 'YogaKit'
spec.dependency 'Yoga', '~> 1.14'
# Fixes the bug related the xcode 11 not able to find swift related frameworks.
* 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.
*/
usingSystem;
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.