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
Summary: Variable name suggest it does not constrain to min dimension but it did indeed. Changing that to match variable name. This required updating code to use fully constraint value again. gkassabli this seems wrong, do you know what is going on?
Reviewed By: gkassabli
Differential Revision: D5144146
fbshipit-source-id: a5d711f8ad7049b0d96ee0f0f3eef1165ab3b4e8
Summary: Previously pointScaleFactor was stored as a divider that opened way to accumulating difference. For instance in ScreenScale=3, pointScaleFactor = 0.3333343 (0.000001 error). When used for width = 300 that error was multiplied by the number of times pointScale contained in width (300 *3 = 900) and we had almost 0.001 error accumulated. With this change Yoga will avoid such issue
Reviewed By: shergin
Differential Revision: D5137923
fbshipit-source-id: 652b59bc3da3f35ee93ffa3695936f623298a023
Summary:
Travis doesn't set encrypted variables in pull requests (for very good reasons),
but openssl fails rather loudly if it doesn't get them. Our artifact publishing
script happily skips PRs anyway, so we don't need these variables in that case.
Reviewed By: emilsjolander
Differential Revision:
D5137092
Tags: accept2ship
fbshipit-source-id: b14d61feba0bb98a1705b2f8232f52ba59a2c734
Summary: Implement the inverse of toString. This allows us to parse a YogaValue from a string inputted from the user in debugging tools.
Reviewed By: kittens
Differential Revision: D5120456
fbshipit-source-id: 6ac7cff2a040778e63a953070e1bd7e768fedaa7
Summary: To fix builds where `sdks =` is not supported.
Reviewed By: splhack
Differential Revision: D5113020
fbshipit-source-id: b716acd6fb88ccb55c72b24f9fcdf20a2ea3693e
Summary: There is a case when measure() function will be called with negative width/height because of margin/padding. This diff fixes that scenario
Reviewed By: emilsjolander
Differential Revision: D5111534
fbshipit-source-id: 99f09b85f0c6a0e5dec89a26baba8f9d560100da
Summary: This makes the output less messy.
Reviewed By: emilsjolander
Differential Revision: D5111279
fbshipit-source-id: c65c7f275e57312fb56c2edfec429cc3d2373e3f
Summary:
Make sure that the gradle tests pass before publishing the snapshot. Also makes
sure that we don't break the gradle build.
Reviewed By: emilsjolander
Differential Revision: D5020044
fbshipit-source-id: dfebd829701717eac3ed078a807cd10f489f4348
Summary:
calculateLayoutWithSize: can be useful when calculating table/collection view sizes before the views are fully laid out by UIKit.
Closes https://github.com/facebook/yoga/pull/558
Differential Revision: D5104863
Pulled By: emilsjolander
fbshipit-source-id: e0e0c6d502f6745be8d84de8c1b6e24cc25a0352
Summary:
This adds the same logic that we have in place with Litho for Yoga, allowing
unit tests to run with Gradle for Yoga. It'll still shell out to Buck to build
the native library, but that's hopefully only until we have found a way to reuse
the NDK build. For CI this shouldn't matter as we want to run `buck build`
anyway and the build step should be a no-op.
FB-Only:
This should unlock D5020044.
Reviewed By: emilsjolander
Differential Revision: D5104154
fbshipit-source-id: 48732fff6c1d100a155452f675de343aaf06427b
Summary:
1, Change bottom to be based� on height of parent.
2, Respect margin value when layout with right/bottom.
Closes https://github.com/facebook/yoga/pull/552
Differential Revision: D5102090
Pulled By: emilsjolander
fbshipit-source-id: dca291413ffc2027d7628f4c8b8eeeb0b4823bc2
Summary:
This is used in a stack where I'm using YogaKit on tvOS. fb_apple_library needs `sdks = ` to get buck to do its thing for tvOS.
This seems like it should be OK since apple_library is a nop on non apple platforms (which makes sense since this is ObjC only) - I think that makes sense anyway?
Reviewed By: emilsjolander
Differential Revision: D5080261
fbshipit-source-id: f08d7e6d2599b9af25fb964ade485aef552f306b
Summary: We should always try to make root node as small as possible, while previously this wasn't functioning this way
Reviewed By: emilsjolander
Differential Revision: D5071164
fbshipit-source-id: b8afef42477d0ed87d0c9fcfd26349e0a0babd6e
Summary: When config was added to YGNodeCanUseCachedMeasurement we didn't account for default 0 scale factor. This diff fixes that
Reviewed By: emilsjolander
Differential Revision: D5061016
fbshipit-source-id: 907ef987bd0ead29cf02f6945a3f03d4ffb58a2e
Summary: We want to be able to use YGConfig to account for possible rounding of width/height
Reviewed By: emilsjolander
Differential Revision: D5059560
fbshipit-source-id: d729e991758a8c668a4b373105b71337961875cd
Summary: Include margin when calculating if children overflow
Reviewed By: passy
Differential Revision: D5044471
fbshipit-source-id: e7c1eb694445ffb898bcf375d9deefc558c49f11
Summary: Fix flex basis not being constraint to the max size in the main direction. Previously this caused the added test to fail due to NaN in child dimensions.
Reviewed By: gkassabli
Differential Revision: D5044314
fbshipit-source-id: d9f9db832e4943a57a89c9d162ff6077b709795a
Summary: This adds very little (no?) new features and mostly just refactors code to live in a singular place. Instead of users having to worry about DebugComponent as well as the DebugInfo object and attaching it correctly to a tree now user's of the DebugComponent API only need to worry about a single class, greatly simplifying its usage.
Reviewed By: passy
Differential Revision: D5027780
fbshipit-source-id: 95a95b3572747aa2088f8f9b35a160257eb59269
Summary: This diff adds node type definition to Yoga and moves rounding to rely on the node type. If the node has measure function we consider that node to be text node, otherwise we have default behavior.
Reviewed By: emilsjolander
Differential Revision: D5025107
fbshipit-source-id: a8d66e2f9c5d02ab080784cc474be583a09b92e2
Summary: Also bumped the version number for the existing dependency examples.
Reviewed By: emilsjolander
Differential Revision: D5044190
fbshipit-source-id: 4199ab114450a256efaa30a811822923beafb378
Summary:
Fix some long-standing issues with the android build on Travis (and elsewhere)
and enable automatic publishing of snapshots.
Reviewed By: emilsjolander
Differential Revision: D5044001
fbshipit-source-id: f00be07f33c8018573af0b98233068ebd93360b4
Summary: The appcompat library was way outdated and failed CI: https://travis-ci.org/facebook/yoga/builds/231065300
Reviewed By: emilsjolander
Differential Revision: D5043967
fbshipit-source-id: a5bb02110cf016972d983f511cf8c31dd9d667e1
Summary: So I can use them from JSBigString whose methods are marked const.
Reviewed By: emilsjolander
Differential Revision: D5020648
fbshipit-source-id: 6e60b80cb3d4718bab25dd6ca9627aee862117db
Summary:
Gets all the pieces in place to automatically publish snapshot artifacts after
successful travis build.
I'll test the actual publishing in a separate branch and then flip the switch in
a separate diff when it's ready.
Reviewed By: emilsjolander
Differential Revision: D5028239
fbshipit-source-id: c57d02a1dee41c84001bd17821b050c8c9aa4134
Summary:
Reuse the gradle setup we've built for Litho which allows for parallel publishing to Bintray and Maven Central in addition to Sonatype Snapshots.
This appears not to break the existing jcenter deploy script which is pretty great.
Reviewed By: emilsjolander
Differential Revision: D5020576
fbshipit-source-id: 3ef163ccbfe91c6858b051d39dcf237ca388e18d
Summary:
fbjni was previously dependency-free but now requires some annotations and
soloader. This unbreaks the gradle build.
Reviewed By: emilsjolander
Differential Revision: D5020069
fbshipit-source-id: b8bde83ce6a70b06e04491f1d70c2a6b568bc99c
Summary:
Moves the `YGLogger` into `YGConfig` and pass the `YGNodeRef` into the logger to be able to associate the log messages and assertions with the specific node.
Tackles facebook/yoga#530 and facebook/yoga#446
Closes https://github.com/facebook/yoga/pull/531
Reviewed By: astreet
Differential Revision: D4970149
Pulled By: emilsjolander
fbshipit-source-id: b7fcdaa273143ea2fa35861620b2e4d79f04f0af
Summary:
ActionBarActivity has been deprecated for 2+ years now.
Closes https://github.com/facebook/yoga/pull/538
Differential Revision: D4985973
Pulled By: emilsjolander
fbshipit-source-id: 09f2a8a12943c9b3ccdaee9cac684276b42ff843
Summary:
ActionBarActivity has been deprecated for 2+ years now.
Closes https://github.com/facebook/yoga/pull/539
Differential Revision: D4985970
Pulled By: emilsjolander
fbshipit-source-id: 2e2fcc5188c08ef1cd78f7e1be71917f0395ff2c
Summary: See blame revision. we are still passing all the added tests from that pull request but with much simpler logic.
Reviewed By: gkassabli
Differential Revision: D4977923
fbshipit-source-id: cb488e63c7c2e15e4c0f0133a16df36580c646fd
Summary: We need to treat measurements from nodes with measure functions as minimum values as to not truncate text.
Reviewed By: shergin
Differential Revision: D4972290
fbshipit-source-id: 0a7bcc7f47b3e5acb8745da5286abcb9c4e44a38
Summary:
We still need to wait for the `YGUnitPoint` PR to be merged :) But please let me know what you think. One caveat: because of a limitation of Swift, a literal value can be automatically understood as a point-based `YGValue`, but variables have to be explicitly cast. I haven't found a way around it yet:
```
view.yoga.width = 10 // value == 10, unit == YGUnitPixel
let a: CGFloat = 100
view.yoga.height = a // Compiler error
view.yoga.height = YGValue(a) // works, not great
```
Closes https://github.com/facebook/yoga/pull/390
Reviewed By: emilsjolander
Differential Revision: D4954021
Pulled By: maxoll
fbshipit-source-id: 5eff6aeb6dd969d0d5dc557b149bb5819b0e31de
Summary:
Fixes the sizing of items so that under most scenarios it calcultes its height by it's content for non exact measurings. This introduces a new useLegacyStretchBehaviour flag on the config to opt out of this change as it is breaking.
See facebook/yoga#505
Closes https://github.com/facebook/yoga/pull/506
Reviewed By: astreet
Differential Revision: D4954016
Pulled By: emilsjolander
fbshipit-source-id: d28bd5d174cd76951fb94df85e3b0cfab7f81ff7
Summary:
Hi! After merging 3db38f2a80 the rounding algorithm become broken in YogaKit because it doesn't configure scale factor.
Closes https://github.com/facebook/yoga/pull/534
Differential Revision: D4969481
Pulled By: emilsjolander
fbshipit-source-id: 57ea42a3b1f37007b2392cda724d509e0b28c4cb
Summary: Rounding has been successfully adopted by multiple products and frameworks. Time to move it out of experimental mode. Rounding can still be turned of by setting the point scale factor to 0 on the config.
Reviewed By: gkassabli
Differential Revision: D4953838
fbshipit-source-id: 3ee5f27d92f95b3ed4a01c98bc35e9157f2e91c5
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fixfacebook/yoga#488
Closes https://github.com/facebook/yoga/pull/499
Reviewed By: astreet
Differential Revision: D4954008
Pulled By: emilsjolander
fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
Summary:
Fixes `flex-wrap` with a max constraint and `justify-content`. Fixesfacebook/yoga#514.
Closes https://github.com/facebook/yoga/pull/519
Differential Revision: D4953727
Pulled By: emilsjolander
fbshipit-source-id: 32dec48220be1392ea8dac5f34871d407eb8d49b
Summary: Update yoga's copy of fbjni to include some missing java files.
Reviewed By: IanChilds
Differential Revision: D4953841
fbshipit-source-id: 74d5c617a6fcd11e82c86f03e61448b14a34b86b
Summary:
Fixes#507 . The attribute name format got changed and the docs were left behind.
Closes https://github.com/facebook/yoga/pull/510
Differential Revision: D4953733
Pulled By: emilsjolander
fbshipit-source-id: 6eb02d6745d08fdd8cce669c691794351bd6fbc7
Summary:
Hey there, lets downgrade deployment target of YogaKit pod to iOS7. This days there is a lot of apps that still have support of ios7 (and i'm working on one of them :)). And I didnt't find any reason why it couldn't be done.
Thanks
Closes https://github.com/facebook/yoga/pull/524
Differential Revision: D4953726
Pulled By: emilsjolander
fbshipit-source-id: 9e17a40caaa0a3ae26779c0d08acb59f71df2b23
Summary:
This diff introduces new, little bit sophisticated round-to-pixel-grid algorithm.
**Motivation:**
Previous simple and straightforward solution works in most cases but sometimes produce the not-so-great result. A while ago Nick Lockwood described this problem and proposed the solution in RN's RCTShadowView class:
For example, say you have the following structure:
// +--------+---------+--------+
// | |+-------+| |
// | || || |
// | |+-------+| |
// +--------+---------+--------+
Say the screen width is 320 pts so the three big views will get the following x bounds from our layout system:
{0, 106.667}, {106.667, 213.333}, {213.333, 320}
Assuming screen scale is 2, these numbers must be rounded to the nearest 0.5 to fit the pixel grid:
{0, 106.5}, {106.5, 213.5}, {213.5, 320}
You'll notice that the three widths are 106.5, 107, 106.5.
This is great for the parent views but it gets trickier when we consider rounding for the subview. When we go to round the bounds for the subview in the middle, it's relative bounds are {0, 106.667} which gets rounded to {0, 106.5}. This will cause the subview to be one pixel smaller than it should be. This is why we need to pass in the absolute position in order to do the rounding relative to the screen's grid rather than the view's grid. After passing in the absolutePosition of {106.667, y}, we do the following calculations:
absoluteLeft = round(absolutePosition.x + viewPosition.left) = round(106.667 + 0) = 106.5
absoluteRight = round(absolutePosition.x + viewPosition.left + viewSize.width) + round(106.667 + 0 + 106.667) = 213.5
width = 213.5 - 106.5 = 107
You'll notice that this is the same width we calculated for the parent view because we've taken its position into account.
I believe this is awesome. I also believe that we have to decouple this logic from RN and put it into awesome Yoga. So I did it in this diff.
**Fun fact:**
The original implementation of this algorithm in RN had (and still have) a bug, which was found by Dustin dshahidehpour and fixed in D4133643. Therefore that diff was unlanded because it broke something unrelated inside RN text engine. I will fix that problem in RN later.
**Why do we need to change test methodology?**
Because the way we receive layout metrics from Chrome browser actually directly related to rounding problem. Previously we used `offsetHeight` and `offsetWidth` properties of the DOM node, which contain naively rounded values from `computedStyle` or `getBoundingClientRect`. (Which is we are trying to fix!) So, I added the new function that computes node size using two-step-rounding approach, conceptually similar to one that implemented in Yoga. Note: Chrome browser performs rounding layout as part of rendering process and actual values that can ve computed by counting actual pixel are different from these natively rounded ones.
**Why do some tests now have different desired values?**
These changes actually prove that my approach is correct and more useful for actual view rendering goals. So, let's take a look at test with changed values `rounding_fractial_input_3`:
Previously: 64+25+24=114 (Incorrect!)
Now: 65+24+25=114 (Correct!)
Previously: 64+25+24=114 (Incorrect!)
Now: 65+24+25=114 (Correct!)
Reviewed By: emilsjolander
Differential Revision: D4941266
fbshipit-source-id: 07500f5cc93c628219500e9e07291438e9d5d36c
Summary:
Mark some fields as readonly and reuse index value in RemoveChild.
Closes https://github.com/facebook/yoga/pull/516
Reviewed By: emilsjolander
Differential Revision: D4921809
Pulled By: splhack
fbshipit-source-id: 261a7910675d93be165c16ee53a83c02b15925f1
Summary:
Marks enum with ```[Flags]``` attribute, where they are used as flags.
Closes https://github.com/facebook/yoga/pull/515
Reviewed By: emilsjolander
Differential Revision: D4921807
Pulled By: splhack
fbshipit-source-id: f056189b76ee6e6c042417a7998bfd20a610c27f
Summary:
These only exist to support a deprecated form of project generation which is
about to be removed.
Reviewed By: marcinkosiba
Differential Revision: D4945841
fbshipit-source-id: 3d35b8f8cd902572995ee4f55f9b5930efa186ec
Summary: We don't need to set overflow from litho any more because overflow hidden / visible no longer effects layout.
Reviewed By: marco-cova
Differential Revision: D4938759
fbshipit-source-id: 4cd6bc478dd1f56340f23e8bfe95fe7bb1b5db2d
Summary:
The main container that gets called `applyLayoutPreservingOrigin:` is using its size as a fixed bounding box.
In some cases it's preferrable to let it accomodate its contents.
This diffs extends `applyLayoutPreservingOrigin:` by adding an additional parameter which can be used to sepecify whether width and/or height are fixed or flexible.
Feel free to suggest better names than `YGDimensionFlexibility` & co.
Let me know if you prefet to kill the API without flexiblity specifier - I'll codemod everything then.
Reviewed By: dshahidehpour
Differential Revision: D4929702
fbshipit-source-id: f128f244140b4a54d8ce3b3f4edddbb9756f8fdf
Summary: The `block` paramenter is marked as nonnull, so we can't pass `nil` directly in.
Reviewed By: dshahidehpour
Differential Revision: D4929692
fbshipit-source-id: a35ef2940d6986f4ff55444d8a99ba17eb7c677e
Summary: This diff corrects the fix to be limited only to cases when either element itself or all of it's children can't be flexed
Reviewed By: emilsjolander
Differential Revision: D4915189
fbshipit-source-id: efccee2fe39ed0f474a41dc3250d24c546f3f5d9
Summary:
I'm actually quite excited about this one!
No more buck shelling out for building the Yoga AARs/JARs via Gradle. It's now
all done via Gradle.
This commit is the only one that should actually change anything about the entry
points to the gradle builds and release process. **So if anything goes wrong
with the next release, reverting this one here should be enough!**
Reviewed By: emilsjolander
Differential Revision: D4913600
fbshipit-source-id: 4a54562ad5be69f62a7781d43fddad211f99ab25
Summary:
I put the CMake file in the root directory to avoid moving the actual `yoga/`
dir around, but created a directory for the Android library manifest nonsense
so it works as its own module you can depend on.
Reviewed By: emilsjolander
Differential Revision: D4913601
fbshipit-source-id: 582064264cf0b6b69c03d0e72ed9dd22d217dd16
Summary:
This enables using gradle for building libfb using the NDK. This is 1/3 of what
we need to do. We also need to build yoga itself (which is the easiest as it's
just a static library without external dependencies) and yogajni which relies on
the other two.
Hopefully, this should also make it more obvious why the previous moves were
necessary.
Reviewed By: emilsjolander
Differential Revision: D4913360
fbshipit-source-id: 47658328532fd1ec15f10f8e31ea04691c481011
Summary:
This way we can more easily build it with Gradle. The CMake build for this comes
with the next Diff.
Reviewed By: emilsjolander
Differential Revision: D4913361
fbshipit-source-id: b7958e204a8a4a97a1f60043788d826dd2a4c080
Summary:
Adds two methods ```AddChild``` and ```RemoveChild``` to be able to add/remove children without the need to know there position.
Closes https://github.com/facebook/yoga/pull/513
Reviewed By: emilsjolander
Differential Revision: D4914242
Pulled By: splhack
fbshipit-source-id: df187ba71a1bae0b3b0649624f3c29401d5f8804
Summary:
Rename ```StyleAspectRatio``` to ```AspectRatio``` to be consistent with the other getters and setters.
Closes https://github.com/facebook/yoga/pull/512
Reviewed By: emilsjolander
Differential Revision: D4914236
Pulled By: splhack
fbshipit-source-id: 7b9ebdbf8945c4a8570c61de16d71c8d9d96bf9f
Summary:
As stated in 152074935 by rmarinho the Visual Studio solution didn't compile as ```YGEnums.c/YGEnums.h``` hasn't been added to them. This fixes this problem.
Closes https://github.com/facebook/yoga/pull/511
Reviewed By: emilsjolander
Differential Revision: D4914234
Pulled By: splhack
fbshipit-source-id: 473b6169bfb6576ca8848d4a5079f81692766897
Summary:
We need to use the most recent Android SDK to leverage the cmake-based NDK build
system. Also, since everything seems to be still working - why not?
I also changed the dependency of `yoga-layout` to be the project, not the
pre-published artifact as it no longer compiled due to the changed measure API
signature. I'm not sure if there was a reason to keep the two separate.
By relying on Maven-published artifacts, we generate better POMs when publishing
and people can override dependencies and see them more easily.
A few more cleanups based on what we did with Litho.
Reviewed By: emilsjolander
Differential Revision: D4913208
fbshipit-source-id: 053deb444ce91106afb3b66c3be28d6fcbdea450
Summary:
By declaring the properties first, before using them in the scripts, you no
longer get an exception if you fail to specify them.
You can now build artifacts or run tests without specifying your bintray
password, which is probably what you want.
Reviewed By: emilsjolander
Differential Revision: D4913103
fbshipit-source-id: 8787af8973cebb84cd59e18c63a3a9f28e0ec348
Summary:
I'm trying to get an NDK build set up for Yoga and clean up some of the Gradle
things along the way.
Having a wrapper is not only the preferred way of setting up Android
repositories and more convenient than asking users to install Gradle on their
machines themselves, but also allows for version pinning, which is important
when dealing with Android plugins which usually expect one very specific version
of Gradle.
Reviewed By: emilsjolander
Differential Revision: D4913104
fbshipit-source-id: b14964025271cd16c3c5c05a2fb6dab213227346
Summary: Can we just bump this here?
Reviewed By: emilsjolander
Differential Revision: D4905930
fbshipit-source-id: ea0bd51e32700556ecd1527d2b7fad67d4645366
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fixfacebook/yoga#488
Closes https://github.com/facebook/yoga/pull/499
Differential Revision: D4850458
Pulled By: emilsjolander
fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
Summary:
Fixes the sizing of items so that under most scenarios it calcultes its height by it's content for non exact measurings. See facebook/yoga#505
Closes https://github.com/facebook/yoga/pull/506
Differential Revision: D4878875
Pulled By: emilsjolander
fbshipit-source-id: ab1174ac7a76dcf20aae7b29a3bc396e11077c4d
Summary: Fix some issues with the deploy script and deploy a new version for android
Reviewed By: passy
Differential Revision: D4876006
fbshipit-source-id: ddafb8349e1c77ab5afd9a823103fb6a1dfabb1d
Summary: Bump version of android things
Reviewed By: passy
Differential Revision: D4875213
fbshipit-source-id: 2b229a0dade521ef745852c0096545e7e9fe2c1e
Summary:
If a min constraint exists. It incorrectly reduces the available space by that amount. This adds a test and fix for this.
Closes https://github.com/facebook/yoga/pull/501
Differential Revision: D4867146
Pulled By: emilsjolander
fbshipit-source-id: ceafe070bfe7f501929d316656ac44c4e1753059
Summary:
If the root node has a position and we have a RTL layout, that position must be like LTR direction. See #477.
Closes https://github.com/facebook/yoga/pull/502
Differential Revision: D4867144
Pulled By: emilsjolander
fbshipit-source-id: b5ad3d87e7054090da12d7665a3d1abe8496a548
Summary:
- depends on #496
- For memory leak unit test
- Expose the API for C#
Closes https://github.com/facebook/yoga/pull/497
Reviewed By: emilsjolander
Differential Revision: D4796190
Pulled By: splhack
fbshipit-source-id: 99e4e78e8dfb3d459cf6cd7103ab252c3748e5a6
Summary:
See facebook/yoga#453. Optimizes the node log print by generating some enum text via ```enum.py``` and moving printing to new functions to reduce boilerplate code.
Changes the log output to format the nodes in html to be able to copy paste it into browsers for quick debugging.
Hides all default values.
Closes https://github.com/facebook/yoga/pull/479
Reviewed By: gkassabli
Differential Revision: D4802184
Pulled By: emilsjolander
fbshipit-source-id: 143bd63cbc31fb0755d711062cb4e6a448049ba3
Summary:
See facebook/yoga#483. We should not transfer the layout if the layout didn't change. (using ```hasNewLayout```). This also changes that the lock on the java node is only aquired if needed, and it holds the lock only for the time the values are set and not for the time all it's children are set.
Closes https://github.com/facebook/yoga/pull/484
Reviewed By: astreet
Differential Revision: D4802966
Pulled By: emilsjolander
fbshipit-source-id: e8a8f2280ad6b25b98fc68b07eac68e0ec80fe3e
Summary:
Fix xmlns import for yoga library by using `apk` instead of `lib` in the comment.
Closes https://github.com/facebook/yoga/pull/495
Reviewed By: emilsjolander
Differential Revision: D4802918
Pulled By: rspencer01
fbshipit-source-id: 9cef7709606e30e8e30af6e396866ac4900168bf
Summary:
As suggested in facebook/yoga#484. This is the PR which only adds the part of using a local bool field for storing the hasLayoutFlag, to be able to pass the layout only if it has really changed.
Closes https://github.com/facebook/yoga/pull/492
Reviewed By: astreet
Differential Revision: D4786961
Pulled By: emilsjolander
fbshipit-source-id: cf3d354b93f6dcc3ef817ef73a47bd29e37d1848
Summary: The native build script didn't make the directories it needed, and thus only worked if you'd run it before :O
Reviewed By: emilsjolander
Differential Revision: D4794861
fbshipit-source-id: 69764ef1ddadf63333ce5d91dfa85bc943479fef
Summary: Version bump as we have introduced `setUseWebDefaults`.
Reviewed By: emilsjolander
Differential Revision: D4794772
fbshipit-source-id: 0a42def3bec3f4f76caf6da01e3b9ab3679ebcb0
Summary: Set web defaults when resetting
Reviewed By: astreet
Differential Revision: D4779742
fbshipit-source-id: 5b8c5d7bd432a12984e4ebfd3187da3d680272cd
Summary: Mark nodes as having a new layout when changing display to none recursively.
Reviewed By: astreet
Differential Revision: D4786615
fbshipit-source-id: 2f3a16661d37bc37939e8e7a551445886a06524e
Summary:
The following PR fixes the tests used in the javascript port (it modifies gentest.rb).
These changes don't yet pass, it seems something is segfaulting somewhere. I have to check if it comes from nbind, the yoga library, or the node bridge itself. There's also some fails on the browser build, but it might be the same issue.
Closes https://github.com/facebook/yoga/pull/487
Reviewed By: emilsjolander
Differential Revision: D4778870
Pulled By: astreet
fbshipit-source-id: 936fbca564ec89738c78e50c4402c53eb6867dec
Summary:
- Unity IL2CPP (ENABLE_IL2CPP) requires the same code path with AOT compile.
- Clean up unneeded code in YGConfigHandle.
- YogaNode.Reset makes YGNodeHandle stale. Unmanaged side was reset by YGNodeReset, but YGNodeHandle keeps to retain the old managed handle. Release it.
Closes https://github.com/facebook/yoga/pull/491
Reviewed By: astreet
Differential Revision: D4765683
Pulled By: splhack
fbshipit-source-id: 83bfe19feb0e6ec45dc504e42b0c6c34e10af8e2
Summary:
Move -fPIC from BUCK to YOGA_DEFS, so that it can be overridden when
building yoga inside another build tree (since the larger build tree
may need its own configuration for -fPIC). No change when building yoga
standalone.
Reviewed By: emilsjolander
Differential Revision: D4714782
fbshipit-source-id: c706336cda72b36045e744e4fcaea4c0899bcf38
Summary: Don't transfer layout outputs to java if the layout was cached as this means that it has already been transfered
Reviewed By: astreet
Differential Revision: D4716024
fbshipit-source-id: c30763a6fc7426d653c7a6ca129615cddb4140e9
Summary: The layout of a node is invalid once it leaves the tree. Let's reset it for safety in case it is added to another tree.
Reviewed By: astreet
Differential Revision: D4716022
fbshipit-source-id: 399cc64a4b3f5fd3fc469ea37bdd31abe474dc6c
Summary:
This changes the `YOGA_ROOT` to `YOGA_ROOTS` in `YOGA_DEFS`. This allows the
inclusion of Yoga in the exported Components libraries directory and
back-references to the nested dependencies within it.
Reviewed By: rspencer01
Differential Revision: D4721745
fbshipit-source-id: 2dc9d4a730076510aed02027cb6713f6326c588d
Summary: We would like to know some numbers on benchmarking `YogaLayout` against other layouts, particularly `LinearLayout`. This implements a `BenchmarkActivity` to fill that need.
Reviewed By: emilsjolander
Differential Revision: D4565531
fbshipit-source-id: fe1c558beb603c3116ac3d0dd6654b0376dd6b8a
Summary:
This fixes ```align-content: center``` and ```align-content: flex-end``` when the child exceeds the parents size. See #476. It also fixes those layouts if the child has ```margin: auto``` set.
Closes https://github.com/facebook/yoga/pull/477
Differential Revision: D4697833
Pulled By: emilsjolander
fbshipit-source-id: d081ec7ea559a5f2bd3271c3a4dc272960beddfa
Summary: Using the newer/recommended API in the sample project. #accept2ship
Reviewed By: emilsjolander
Differential Revision: D4698936
fbshipit-source-id: 07b61df897524cd38390ba48dfa2a2e10942329b
Summary:
We have some resolve functions with ```YG**Resolve``` and others named ```YGResolve**```. This changes both to be named like the later one, as I think this is the grammatically better readable one.
Closes https://github.com/facebook/yoga/pull/471
Differential Revision: D4688997
Pulled By: emilsjolander
fbshipit-source-id: 38b5f84d4d39ed3effedf08188085b9efd96b4ce
Summary:
Once measure and baseline functions are set, C# layer never calls YGNodeSetMeasure/BaselineFunc with NULL. This diff will fix the issue.
Closes https://github.com/facebook/yoga/pull/468
Reviewed By: emilsjolander
Differential Revision: D4676753
Pulled By: splhack
fbshipit-source-id: da34de2fc28adf320a18de2addffe9671cf1ecf9
Summary:
This adds some improvements to the new ```YGConfig```, it tackles #452 and moves the scalefactor into the config.
Closes https://github.com/facebook/yoga/pull/457
Differential Revision: D4675088
Pulled By: emilsjolander
fbshipit-source-id: 99b2c734d6c5139fe1dc8bdeb014bb038f0e337d
Summary: The android standard is `prefix_camelCase` such as `layout_marginLeft`. This changes attributes like `yg_margin_left` to `yg_marginLeft`.
Reviewed By: emilsjolander
Differential Revision: D4681514
fbshipit-source-id: 76a80c24f19f3ee52329a2a254fe1f5fbcb40b9c
Summary:
We need to take the margin into account if we clip on max dimension. Fixes#466.
Closes https://github.com/facebook/yoga/pull/467
Differential Revision: D4681342
Pulled By: emilsjolander
fbshipit-source-id: 56311df9864a284d553c31f1c6db382f337f1fad
Summary:
Fixes a typo in the test class to use the same name as the other tests.
Closes https://github.com/facebook/yoga/pull/469
Differential Revision: D4681340
Pulled By: emilsjolander
fbshipit-source-id: a5e60b5e2aa74dc25e677a5579bb853492708c16
Summary: Until now we've been building only arm-v7 and x86 libraries. This builds 64 bit versions too, and sets up the gradle script to publish them. We also bump up the NDK version, and increase the min API to 21, as this is the first API supporting 64 bit NDK tools.
Reviewed By: emilsjolander
Differential Revision: D4674049
fbshipit-source-id: fbc87541fcaf72b83d376646c7aab70c317125e1
Summary:
For some reason this Universal.csproj wasn't pulled from rozele PR.. i added the missing files.
Added badges for build and nuget for more exposure.
Ignore a failing unit test on MacOS for a green build.
Closes https://github.com/facebook/yoga/pull/464
Reviewed By: emilsjolander
Differential Revision: D4670392
Pulled By: splhack
fbshipit-source-id: 9ea3150b92039cab87ce8696db983fdf373c5388
Summary:
Before:
There was a broken link in ./docs/README.md
CONTRIBUTING didn't render markup on Github
After:
All links to CONTRIBUTING.md are not broken anymore
CONTRIBUTING.md renders markup on Github
Closes https://github.com/facebook/yoga/pull/458
Differential Revision: D4673746
Pulled By: emilsjolander
fbshipit-source-id: 151c1f38789a96b61dfbb544fd11996098dc456d
Summary:
With the current setup, the final aar contains `com.facebook.proguard.annotation.DoNotStrip`. This is not needed (it is only used for proguard), and thus should not get published.
We move proguard annotations into its own project for this, and place it into `java/proguard-annotations`. Here we adopt the gradle convention of `src/main` to make for a nice, clean (one line!) gradle script. As a different subproject, we can include this to `:yoga` as a `provided` dependency now, which doesn't include it in the output artifact.
Reviewed By: emilsjolander
Differential Revision: D4666572
fbshipit-source-id: a0cb26cb6c264065a0bd355b7d72ba02e3759560
Summary: I accidentally used pngs for the bintray badges. This renders ugly sometimes. This corrects that.
Reviewed By: emilsjolander
Differential Revision: D4666641
fbshipit-source-id: df53f08a77be3067804d7671d673146f208a24fd
Summary: This adds bintray badges to the readme, and creates a readme for the android code.
Reviewed By: emilsjolander
Differential Revision: D4666314
fbshipit-source-id: a2549374f3e9c39c260160d1e32fb37801ff4208
Summary: The gists in the docs have large margins to fit with the front page. This diff specialises that margin setting and sets it to something smaller for other gists.
Reviewed By: emilsjolander
Differential Revision: D4666016
fbshipit-source-id: 5121849a153e78d523b33e10b96641426e794f8d
Summary: This improves the quality of the published POM files, adding dependencies and marking the object as an 'aar'. It also bumps the version to 1.2.0 for JCenter.
Reviewed By: emilsjolander
Differential Revision: D4620150
fbshipit-source-id: 968f1cea21af4b2f19aeff3f32ad575b185fa1bb
Summary:
The issue is on ARM builds for Windows UWP. For the C# P/Invoke API wrapper, any native method that returns the YogaValue struct throws the AccessViolationException. The issue is not with structs in general, as returning the YogaSize / YGSize struct works fine. The issue seems to be limited to structs that have an enum member.
I tried a number of things to resolve the issue without changing the underlying native API for Windows. I read the ARM documentation and saw reference to variable enum sizes based on the number of enum members, so I tried to use a number of different UnmanagedType values in a [MarsalAs()] attribute on the enum member of the C# struct declaration.
What ultimately worked was to return a pointer to the location of the struct, and use the System.Runtime.InteropServices.PtrToStructure API to read the struct data from that pointer. I added a few new macros that will return the struct address on Windows only, other builds are not affected.
Note, I have not tested the impact of this ch
Closes https://github.com/facebook/yoga/pull/459
Reviewed By: emilsjolander
Differential Revision: D4652278
Pulled By: splhack
fbshipit-source-id: bf7ada4da1781e3f813b3ba331974b7bded476d9
Summary:
If we set ```display:none``` all children are set with layout sizes/values of 0. We need do mark all those children as dirty to force a relayout if we toggle the display on a higher parent node. This fixes#443
Closes https://github.com/facebook/yoga/pull/448
Reviewed By: astreet
Differential Revision: D4642273
Pulled By: emilsjolander
fbshipit-source-id: dfdb920e2049952bd6c7f48cfa53b1448e1f3e8f
Summary:
This sets the new ```YGExperimentalFeatureMinFlexFix``` explicitly to false in the config.
It also a changes a stretch reason to reflect that it is the strech in a multiline.
Closes https://github.com/facebook/yoga/pull/447
Reviewed By: astreet
Differential Revision: D4642275
Pulled By: emilsjolander
fbshipit-source-id: 26777db7008ff6ee86da72ca9ea19e979b916cc9
Summary:
Use ```float``` for calculation, as we would calculate with ```double``` and cast to float afterwards otherwise. So this removes the warning.
Closes https://github.com/facebook/yoga/pull/450
Reviewed By: astreet
Differential Revision: D4642267
Pulled By: emilsjolander
fbshipit-source-id: 184ef24474f2b8a42654a71a8e98839296648b2b
Summary: Add test covering a nested percentage container inside of a unconstraint container. This is something we ran into recently and want to make sure to cover in tests.
Reviewed By: astreet
Differential Revision: D4637519
fbshipit-source-id: a8fe3c7702c2ea0ad954cce80fbdf953bb23c997
Summary: Some of the tests were not generated correctly. most likely due to a rebase.
Reviewed By: astreet
Differential Revision: D4637539
fbshipit-source-id: 196478d7e5197519af9ab05e5134e6fb7d22b992
Summary: To avoid clashes in the `app:` namespace, we prefix all yoga attributes with `yg_`.
Reviewed By: emilsjolander
Differential Revision: D4643080
fbshipit-source-id: 3e9265fd57e56a1df2f687a5d17c5bc66b8befa3
Summary: When some drawing attributes of a view changes how it measures, we need to be able to relayout it correctly. This adds method `invalidate(View)` to `YogaLayout` which will flag the corresponding node as dirty and requiring layout again.
Reviewed By: emilsjolander
Differential Revision: D4634563
fbshipit-source-id: af7f47dce00a31414d0987a58307c5d44c1bcf20
Summary:
Move configuration to new ```YGConfig``` and pass them down to CalculateLayout. See #418 .
Adds ```YGConfigNew()``` + ```YGConfigFree```, and changed ```YGSetExperimentalFeatureEnabled``` to use the config.
New function for calculation is ```YGNodeCalculateLayoutWithConfig```.
Closes https://github.com/facebook/yoga/pull/432
Reviewed By: astreet
Differential Revision: D4611359
Pulled By: emilsjolander
fbshipit-source-id: a1332f0e1b21cec02129dd021ee57408449e10b0
Summary: This is a follow up on a recent change which made the constraints passed into conculateLayout describe the parent constraints and not the root node constraints. This broke some assumptions and was not very inuitive if no size was set on the root. Therefor this diff ensure that if the root node does not have any size set then it will adopt the size of the parent constraints.
Reviewed By: dshahidehpour
Differential Revision: D4634616
fbshipit-source-id: 089eb4313c5bb810a6ff56f158cd19cec71808ec
Summary: This diff updates the NDK version from 10 to 12
Reviewed By: emilsjolander
Differential Revision: D4634938
fbshipit-source-id: 6a9cbc48dbcbda4674d6460120c7a0d8abd626ab
Summary: [This commit](1146013e9e) (or diff D4501142) adds an `auto` option for margins. This diff allows you to leverage that in android via attribute `yoga:margin_all="auto"` (and as expected for the other edges).
Reviewed By: emilsjolander
Differential Revision: D4634684
fbshipit-source-id: 158f70ec975b5bb3a666e590b76eb52daeb38f49
Summary: Test fails when we have flexible child and min/max layout dimension. Yoga should flex the child to minimal size, while in reality Yoga flexes it to maximal size
Reviewed By: emilsjolander
Differential Revision: D4558653
fbshipit-source-id: 06b38d7ed43aee063cc881f38b84558641f043f3
Summary:
Changed the flex getters to return the values they were actually set. See #421 .
Closes https://github.com/facebook/yoga/pull/431
Reviewed By: astreet
Differential Revision: D4604744
Pulled By: emilsjolander
fbshipit-source-id: 02d79100ef22be866db1c3bd9d53e4447186811f
Summary: The size of the node is already set on the node however there was no way to set the size of the parent to the root so that the root could use percentages. This change fixes this by making the width and height passed to calculate layout be the width and height of the hypothetical parent.
Reviewed By: astreet
Differential Revision: D4611417
fbshipit-source-id: 2fb0eedffa17f0ec89b601722a1717a72e216b9e
Summary: Diff D4501141 added display attributes for Yoga. This exposes them in the android library.
Reviewed By: emilsjolander
Differential Revision: D4605574
fbshipit-source-id: dbad3d6fe924682c6b81f65bbba9727085de2d81
Summary: The android sdk and api installation seems to be timing out on Travis. This should extend the 10 minute limit to 20 minutes. Hopefully this will be enough to download it all. If not, we must just extend the timeout.
Reviewed By: emilsjolander
Differential Revision: D4588245
fbshipit-source-id: fef25c54b081ba4d96d1e0435c6c1f643ff49b66
Summary: This diff adds rounding to the pixel grid feature to Yoga and appropriate property
Reviewed By: emilsjolander
Differential Revision: D4565980
fbshipit-source-id: 9700f6d6ed147f82b19f230fbff2e9ccbd625b25
Summary:
Fix for #413. This was a hangover from a previous attept to fix other align-content problems.
Closes https://github.com/facebook/yoga/pull/417
Reviewed By: astreet
Differential Revision: D4604727
Pulled By: emilsjolander
fbshipit-source-id: 92fd31a385d8182c6b201c891d5ae478372d525d
Summary: Adds a buildscript for gradle as well as bintray upload capabilities for the YogaLayout library
Reviewed By: emilsjolander
Differential Revision: D4604712
fbshipit-source-id: bacbcc20b7ed6ee8689130287a48bd5d3826298c
Summary: This builds the java bindings with gradle, and adds a script for Facebook employees to upload the generated artifacts to JCenter.
Reviewed By: emilsjolander
Differential Revision: D4597335
fbshipit-source-id: 4c01695a8638000a417bfb49deba4b9b9b4e114b
Summary:
Since my new main work maschine is a hdpi device, all the gentests with rounding are producing different outputs.
This PR force the scalefactor=1 for gentest to fix issues with generation on hdpi devices.
Closes https://github.com/facebook/yoga/pull/434
Differential Revision: D4604724
Pulled By: emilsjolander
fbshipit-source-id: ce4036ae71a45775280e0504f20c06a4622ccceb
Summary: The attribute for height was incorrectly assumed to be type `float` which led to it not being explicitly defined. It is actually a dimension.
Reviewed By: emilsjolander
Differential Revision: D4588629
fbshipit-source-id: 56c7e460d27528823944852d682e7f26bf908292
Summary: When a container's children wrap the container should match the parent size and not wrap to the new size of the children. This is confirmed behavior in chrome.
Reviewed By: astreet
Differential Revision: D4578614
fbshipit-source-id: 5d22a3a673735587384d775189158a87bb1d457d
Summary:
Travis android build is failing with
BUILD FAILED: Google APIs not found in /usr/local/opt/android-sdk/add-ons/addon-google_apis-google-19/libs.
Please run '/usr/local/opt/android-sdk/tools/android sdk' and select both 'SDK Platform' and 'Google APIs' under Android (API 19)
This should fix that error
Reviewed By: emilsjolander
Differential Revision: D4588053
fbshipit-source-id: e57d635141e8aede5803b919ee5a28a60c5e667c
Summary:
You must measure children before you lay them out, and YogaLayout didn't do this. This fixes that.
We also only recompute the yoga tree if the YogaLayout is laid out with a different size to what it's been measured as.
Reviewed By: emilsjolander
Differential Revision: D4572237
fbshipit-source-id: 6e86dbf939b06338c1dc2a37b7dafafd548dd390
Summary:
For now i setup the CI using VSTS (Visual Studio Team Services) , i m using my own account, but i want to move this to a Travis setup so it would be easy ported to Facebook own build system. We can also take a look on how buck can help with this.
Here's a overview of my dashboard for the build and release process on VSTS:
<img width="1084" alt="screen shot 2017-02-16 at 23 52 07" src="https://cloud.githubusercontent.com/assets/1235097/23046869/ff4dcada-f4a3-11e6-8d09-fb8974fb58d4.png">
The all process is pretty simple, there's a few tricks here and there, but the basic steps are:
<img width="1036" alt="builds" src="https://cloud.githubusercontent.com/assets/1235097/23046874/0cb95fc2-f4a4-11e6-8fd8-3048be7ffd9d.png">
These run for every commit and publish the artifacts, then the release lane takes that artifacts and builds a nuget, after that (and it's not implemented yet) we run UI Tests on devices Android , iOS for the nuget created and run tests on UWP and .net45 on both windows and OS X so
Closes https://github.com/facebook/yoga/pull/408
Reviewed By: emilsjolander
Differential Revision: D4576542
Pulled By: splhack
fbshipit-source-id: 66e0e4c1cb3721ed7aa7118e4e226b6ec575fea8
Summary:
The existing Yoga.vcxproj works great for Desktop apps, but breaks when you try to use the resulting DLL on mobile, Xbox, etc. This change compiles the DLL for the UWP and the Windows Store.
Closes https://github.com/facebook/yoga/pull/401
Reviewed By: emilsjolander
Differential Revision: D4561354
Pulled By: splhack
fbshipit-source-id: 643ad4ed1ffc73719d35974e2d357c37d5b1d1c4
Summary:
Based on the idea of #386 by rmarinho
Closes https://github.com/facebook/yoga/pull/388
Reviewed By: emilsjolander
Differential Revision: D4570778
Pulled By: splhack
fbshipit-source-id: 362983deaf6f040c42b3db8205b711e7e5e60eaf
Summary:
When using AOT mode on Mono one can't use instance methods for callbacks, the compiler needs the MonoPInvokeCallback attribute on a static method to know how to get back to the managed world.
This worked fine without the change in JIT mode.
I not sure if we should use a __MONO__ flag for this stuff as this could be needed for other usage that not only on iOS.
~~The adicional change is that one should as good practice call Dispose on the YogaNode when using callbacks to make sure we remove the handler from our dictionary, i was trying to write a test for this.. but i saw TestMeasureFuncWithDestructor was already there, but it doesn't seem correct to me, can you check splhack.~~
Closes https://github.com/facebook/yoga/pull/386
Reviewed By: emilsjolander
Differential Revision: D4546030
Pulled By: splhack
fbshipit-source-id: 121d44a2ecd14d754b9614493db6ac15fca02da2
Summary: Fix unit test for flexBasis
Reviewed By: emilsjolander
Differential Revision: D4572394
fbshipit-source-id: ce0b3cd28b5c8a9910106308c561c95d1b3866e9
Summary:
This PR removes some duplicate code by calculating with ```mainSize```/```crossSize``` and converting that to ```width``` or ```height``` at the end. See #395 .
Closes https://github.com/facebook/yoga/pull/396
Reviewed By: astreet
Differential Revision: D4564713
Pulled By: emilsjolander
fbshipit-source-id: 0b24e69cc9dc75cdf93deeb6c076dcacf134c6d8
Summary: There are still some pieces of RN which does not handle YGUnitAuto and makes use of either the value being nan or the unit being undefined. This diff makes this more robust to those kinds of situations.
Reviewed By: wwjholmes
Differential Revision: D4567045
fbshipit-source-id: ace5fd89bd534a6bb5ec7dba0c3afbf13d62d7c9
Summary: Travis builds are failing due to ANDROID_SDK not being set. So we set both it and ANDROID_HOME to where homebrew should have created a link to the installation.
Reviewed By: emilsjolander
Differential Revision: D4571703
fbshipit-source-id: a6dc4eb07006dc8baefb6ca938111ff256c6f018
Summary: Adds the Travis build badge for the android target to the README.md
Reviewed By: emilsjolander
Differential Revision: D4571693
fbshipit-source-id: a5110dac7d86989cc4a14b858c63d59332072869
Summary: The yoga splash screen that runs at the beginning of the app is unnecessary and can be removed for simplicty.
Reviewed By: emilsjolander
Differential Revision: D4571624
fbshipit-source-id: 3eb12f7c3447805f4546bd192df9670c5427572a
Summary:
I couldn't resist to do this 😄#394
This adds ```flex-wrap: wrap-reverse```
I think we hit a edge case here:
https://stackoverflow.com/questions/33891709/when-flexbox-items-wrap-in-column-mode-container-does-not-grow-its-width
as is differs here from chrome, but I think that yoga is here more correct.
So I haven't added this test yet as this would fail against chrome, as chrome outputs a width of 30 for root, whereas yoga gets a width of 60 here, which I think is correct. Strangely the output of ```flex-wrap:wrap``` is in jsfiddle also only with a (visual) width of 30 on chrome, while the tests gets generated with 60.
```html
<div id="wrap_reverse_column" style="height: 100px; flex-wrap: wrap-reverse">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
```
Looking forward what you think here emilsjolander
Closes https://github.com/facebook/yoga/pull/398
Reviewed By: astreet
Differential Revision: D4564711
Pulled By: emilsjolander
fbshipit-source-id: 33dc055abd8444b2aa7796ef90bd7ec99e961bb8
Summary:
I don't even know how people have been running tests (unless they install BUCK). This creates a workspace to make it much easier to run tests.
Closes https://github.com/facebook/yoga/pull/400
Differential Revision: D4565290
Pulled By: dshahidehpour
fbshipit-source-id: 762168ced81e517126ac05c92bb27ccad0d9d305
Summary:
We still had the default one from the template.
Closes https://github.com/facebook/yoga/pull/403
Reviewed By: astreet
Differential Revision: D4564708
Pulled By: emilsjolander
fbshipit-source-id: ec76325e0dca34f89e5a920627ced7fa812827de
Summary:
...to reflect the modern world we live in with dynamic DPI platforms :)
Closes https://github.com/facebook/yoga/pull/375
Reviewed By: dshahidehpour
Differential Revision: D4528518
Pulled By: emilsjolander
fbshipit-source-id: e422bd4ae148e02c598a7b484a6adfa8c0e1e0c9
Summary:
Even so I know there are some opinions against ```margin: 0 auto``` it's still part of the spec: https://www.w3.org/TR/css-flexbox-1/#auto-margins and pretty usefull if you have to position via ```justify-content```.
This PR adds an implementation for that.
It adds an additonal ```YGUnitAuto``` and margins got ```YGNodeStyleSetMarginAuto``` functions as well.
Closes https://github.com/facebook/yoga/pull/357
Reviewed By: astreet
Differential Revision: D4501142
Pulled By: emilsjolander
fbshipit-source-id: 86519f8632496f46e78a7c9dbc5b21e212e3e0c7
Summary: This is an update of facebook/yoga#368 which was reverted. It fixes support for align-content: strech with multiple lines. The problem with the last attempt at solving this was that align-items:stretch was interfering. We handle this now by detecting when the flex basis of the children hints at them overflowing. This is not 100% correct as the size of the items could change when remeasuring but it will work in 99% of cases.
Reviewed By: astreet
Differential Revision: D4551234
fbshipit-source-id: 2964f19cf415991dc55dfa2caa4868cb00c56bd0
Summary: The sample app has library-like elements (i.e. the `YogaLayout` and associated files). This separates them out into a separate tree.
Reviewed By: emilsjolander
Differential Revision: D4558263
fbshipit-source-id: 33f8cec99661ef20e0e882663b554c12ae33c12f
Summary: Adds a simple "photo with poster and comment" layout to the landing page as an example for Android, along with the XML.
Reviewed By: emilsjolander
Differential Revision: D4558478
fbshipit-source-id: c7302321a67e99f5853358e711ff538d192f06e9
Summary: Resources don't usually live under the package name. We want to gradle build this soon, so making the directory structure as traditional as possible is best.
Reviewed By: emilsjolander
Differential Revision: D4557978
fbshipit-source-id: 7f80599201fe007a895e52bc5141425f9a83eb51
Summary: Adds docs for how to build the Android sample app and use the `YogaLayout`.
Reviewed By: emilsjolander
Differential Revision: D4557955
fbshipit-source-id: 49a3b8fde20de81a895244ffcecbd5bf392455b0
Summary: && instead of ; and only update xctools if needed
Reviewed By: passy
Differential Revision: D4558044
fbshipit-source-id: 90d55bf0147026e527b238365835d803a4bee7fb
Summary: The sample app is simply moved into the repo. A few libraries are included and the buck targets rearranged.
Reviewed By: emilsjolander
Differential Revision: D4528129
fbshipit-source-id: 3e9e779857cd9219711a939876c9275d75e09929
Summary:
I'm cleaning up these files in their own revision because I want to trigger
dirsync sandcastle separately from my other cleanup.
Reviewed By: mzlee
Differential Revision: D4549131
fbshipit-source-id: 1d45118256d8b517dea7a2b6c9e50bca1ccc1b0c
Summary: For some internal Instagram diffs, and some external ones (auto-detection of dirty nodes). We need to give the dirty properties a little love. This adds a getter to find out if your node is dirty, and makes sure that the leaf node is properly setup before it is marked dirty to prevent a crash.
Reviewed By: emilsjolander
Differential Revision: D4549241
fbshipit-source-id: 36eda6fdb4ea7f968d126aab6da67896f4a01d40
Summary:
Currently, our configuration of Views looks like this:
```objc
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.isEnabled = YES;
view.yoga.height = 50;
view.yoga.width = 50;
```
Every time that we access `view.yoga` we have to access the associated object on `UIView` to get the `YGLayout`. This adds an extra `objc_msgSend` which increases binary size, and is slight perf impact.
This diff creates a way to modify the `YGLayout` with only a single `objc_msgSend`. Here's the new syntax:
```objc
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view configureLayoutWithBlock:^void(YGLayout *layout){
layout.isEnabled = YES
layout.height = 50;
layout.width = 50;
}];
```
Here's the Swift version:
```swift
let view = UIView(frame: .zero)
view.configureLayout { (layout) in
layout.isEnabled = true
layout.height = 50
layout.width = 50
}
```
Closes https://github.com/facebook/yoga/pull/393
Reviewed By: emilsjolander
Differential Revision: D4550382
Pulled By: dshahidehpour
fbshipit-source-id: 76d797d1e0de8e5dc767e02180a7fc440a70212e
Summary:
To date, our sample project was lacking. There is still a lot of work that can be done to improve, but, this is a step in the right direction.
Here are the changes in this commit:
1. The project is written in Swift.
2. Created new CollectionView (via [IGListKit](https://github.com/instagram/iglistkit)), making it very easy to add new examples.
3. New examples for basic layouts, and including/excluding layouts on the fly.
Here's a video!

Closes https://github.com/facebook/yoga/pull/392
Reviewed By: emilsjolander
Differential Revision: D4550379
Pulled By: dshahidehpour
fbshipit-source-id: 64a07acf96c1887f1d2ad0c54971fcedb64334a0
Summary: Split travis into one run per language. This should improve build speed as well as improve signal as to what is failing.
Reviewed By: dshahidehpour
Differential Revision: D4551194
fbshipit-source-id: 36bc60193b4b287352073ab62a7bd053b15eaedf
Summary: While debugging something at Instagram, I kept seeing a UILabel be truncated when it clearly had enough room to display all its' text. What I realized is that during our pixel rounding, we were losing precision because we were using the incorrect rounding function for floats. Changing from `round()` (which is for doubles) to `roundf()` fixed it.
Reviewed By: amonshiz
Differential Revision: D4549069
fbshipit-source-id: 78a1bb33e315e7c066b7fb625b1f5a28def76515
Summary:
Fixes ```align-content:strech``` on nodes without specified cross dimension, if there are multiple lines. Currently it uses the full height of the parent, but it has to use the line height. As we don't know the number of lines until here, we need to realign the relevant children.
Closes https://github.com/facebook/yoga/pull/368
Reviewed By: gkassabli
Differential Revision: D4528559
Pulled By: emilsjolander
fbshipit-source-id: 019e6f85fa452d0c3412f711e3886f0c4452da47
Summary:
Due to the changes in 46817a38. We have a bug if the layout changes.
This PR fixes this bug and adds a test for it.
Additionally it correctly marks negative percentage values as undefined dim.
It also changes the ```resolvedDimensions``` to use a reference instead of the full value in order to minimize the memory requirement of a ```YGNode``` and reduces the copying of the ```YGValue```.
Closes https://github.com/facebook/yoga/pull/379
Reviewed By: gkassabli
Differential Revision: D4528552
Pulled By: emilsjolander
fbshipit-source-id: c024fe3a009c3788af319b689858ea3374c46477
Summary:
Adds the two missing alignments ```space-between``` and ```space-around``` for ```align-content``` . Those values are a noop on ```align-items``` in order to prevent a breaking changes for an additional enum.
Fix#229
Closes https://github.com/facebook/yoga/pull/364
Reviewed By: gkassabli
Differential Revision: D4528561
Pulled By: emilsjolander
fbshipit-source-id: ea6291b6dd22cef05d9eec03893250d50371236e
Summary:
This PR changes the enums.py to create the header the same as format.sh would layout it. Reduces the clutter due to missed format.sh calls after enums.py generation.
Closes https://github.com/facebook/yoga/pull/380
Reviewed By: gkassabli
Differential Revision: D4529593
Pulled By: emilsjolander
fbshipit-source-id: 7281e0d500f79459c19cc8fe6dbc8fd77f0a537c
Summary:
Now that the Yoga library supports percentage values, the results returned from it's API were changed.
`YGNodeStyleGetPadding` returns the explicit value that you set, whereas `YGNodeLayoutGetPadding` returns the computed value. Since we are planning to build support for percentages, I'm modifying our API so that it strictly returns the value that was set. As a result:
```
view.yoga.margin = 10;
// view.yoga.margin == 10
// view.yoga.marginLeftWidth == 0
// view.yoga.marginRightWidth == 0
// etc.
```
Reviewed By: emilsjolander
Differential Revision: D4543471
fbshipit-source-id: a731025cd4b47e9f1a559c766494fc5a259291ae
Summary: Handles nans. Also if the unit is undefined there is no need to check the value.
Reviewed By: astreet
Differential Revision: D4531805
fbshipit-source-id: 723e15381e9fa39837a4c99f726501eda26af11b
Summary: This reflects a check to native code where style values will always return the value that was set on them and default to undefined.
Reviewed By: astreet
Differential Revision: D4531779
fbshipit-source-id: 97a789e70dcf0fb5174e2039991e7a2b27f45f01
Summary:
Two bugs:
1. Min/Max width/height should have higher priority than width/height
2. custom measure nodes percentages should be based in parent size like everything else.
Differential Revision: D4537576
fbshipit-source-id: c003f723f424afbca63170d41e54fd5ff837926d
Summary: Currently, we have an issue in YogaKit where it ignores the preexisting bounds a root view. There are multiple fixes for this, but the easiest one for developer experience is to apply the preexisting bounds of the root view to it's frame after layout calculation.
Reviewed By: emilsjolander
Differential Revision: D4537173
fbshipit-source-id: ccef8b1c1398ea299b4e5710abe597378347a48d
Summary: If a node has minDimension and maxDimension set at the same value, yoga will treat it as having a set dimension, doing less calculations.
Reviewed By: emilsjolander
Differential Revision: D4492395
fbshipit-source-id: 3f4293548399e006aa808b9586d24e77c7df1f21
Summary: Test fails when we have flexible child and min/max layout dimension. Yoga should flex the child to minimal size, while in reality Yoga flexes it to maximal size
Reviewed By: emilsjolander
Differential Revision: D4456312
fbshipit-source-id: 82a39bc93cf3bf2374b968e9f7403397e752908e
Summary:
Fix#241 and successor for #302
Added new property ```display``` with ```YGDisplayFlex``` and ```YGDisplayNone```. Allows to hide nodes from the layout without the need to remove it from the DOM.
Closes https://github.com/facebook/yoga/pull/369
Reviewed By: astreet
Differential Revision: D4501141
Pulled By: emilsjolander
fbshipit-source-id: 0dfeee381f6d1e4bbba81926126b83dd7abab9d6
Summary:
I incorrectly sized some assets, as a result, the sample project had some warnings about it when you built. This fixes it.
Closes https://github.com/facebook/yoga/pull/377
Differential Revision: D4515193
Pulled By: dshahidehpour
fbshipit-source-id: 3af6e79a17777bec3798bbf7294af5716f65e37a
Summary: The Sample app needed some love. It wouldn't build because of some import errors, adding files is very manual, and it looked bad. I have fixed all of these things.
Reviewed By: amonshiz
Differential Revision: D4508624
fbshipit-source-id: bda40defb167ef871d8d0d5bb853d8905b9682d8
Summary: For percentage paddings/margins/sizes to work on the root node we need to have the ability to pass down the parent sizes. This has always been possible with the C API but was never exposed to java. This diff exposes this functionality.
Reviewed By: astreet
Differential Revision: D4501016
fbshipit-source-id: 0c9502e86ff200c021c78afb7ac4b48cf11b3bdb
Summary: Previously we needed to be able to return a computed value from the style edge getters to correctly handle things like RTL in frameworks such as React Native. However we now have a more correct solution with is to expose layout outputs for these edge values. This means we can go back to returning the raw value set for padding/margin/border like we do with other styles.
Reviewed By: astreet
Differential Revision: D4500892
fbshipit-source-id: e7c26bdda9ecbfc76b6cf1f384f8cf9f38284120
Summary: For our YogaKit sample project we want to add Cocoapods support and reference the local podspec. Unfortunately, this won't work unless the podspec lives in the root directory.
Reviewed By: emilsjolander
Differential Revision: D4507887
fbshipit-source-id: 919a8c8506768c90e50b3ae27deb51394db021e6
Summary: If parent size was undefined and node specified percentage size it would pass does an exact measure mode with an undefined value which broke an assertion.
Reviewed By: gkassabli
Differential Revision: D4494265
fbshipit-source-id: 9efef9e39a1b66af2d0f144575a96c919d60dbf7
Summary: Ensure that a percentage size is only "defined" if the parent size is defined.
Reviewed By: gkassabli
Differential Revision: D4494258
fbshipit-source-id: 36c31444cbd113a820b067fe9e7b9560ae1d4df7
Summary:
This PR forces the order of the generated enums in alphabetically order. This is needed to have a predictable order of the enums across different python versions. Which reduces the pain for merging multiple enum additions.
Closes https://github.com/facebook/yoga/pull/370
Reviewed By: gkassabli
Differential Revision: D4501140
Pulled By: emilsjolander
fbshipit-source-id: 66c0ed9e4ea7a5990578b53b0a7e400c13dd53a9
Summary: values() create a shallow copy of the underlying array every time as there are no immutable arrays in java. By using fromInt() we avoid this allocation.
Reviewed By: pasqualeanatriello
Differential Revision: D4494371
fbshipit-source-id: 11cff65114803e185bc67a96da0bf2a2c4a3e6d9
Summary: Ensure that `format.sh` can be run from anywhere with the same results.
Reviewed By: emilsjolander
Differential Revision: D4494367
fbshipit-source-id: cbd2cc36476a0a54a77a732cbe1b79388f7e0c46
Summary:
The format.sh was referring to an outdated `benchmarks/` directory and left out
a bunch of other C/C++ files. This updates it to cover all but the build
artifacts and vendored libraries in `lib/`.
Reviewed By: emilsjolander
Differential Revision: D4481490
fbshipit-source-id: 056e00359f794d0aa999fd65ec1ef0c657738867
Summary:
Hey there, congrats on the launch - we use React Native at Artsy, and I've been wondering about what Yoga + Jest Snapshots for RN looks like but haven't had the time to explore that yet.
With https://github.com/CocoaPods/cocoadocs.org/pull/501 I added the ability to customize the location of the README for the front-page of the CocoaPods site. That is being deployed as I speak, so it should be available the next time you decide to ship a version of Yoga.
I also fixed the capitalisation of CocoaPods, and removed a redundant CocoaPods badge on your initial README.
Closes https://github.com/facebook/yoga/pull/366
Reviewed By: emilsjolander
Differential Revision: D4488011
Pulled By: dshahidehpour
fbshipit-source-id: 6c0c4efc23a69e1fcb936214b159b49217218b49
Summary: Make the two podspecs more consistent with each other.
Reviewed By: dshahidehpour
Differential Revision: D4481945
fbshipit-source-id: ab782abecd709c763b4e931b6839a5cae6346281
Summary: When people file issues, they are (in-general) missing a lot of useful information. This template will now be included when people file issues. More info here: https://github.com/blog/2111-issue-and-pull-request-templates
Reviewed By: emilsjolander
Differential Revision: D4481713
fbshipit-source-id: 8c173e282438d5156d50fe40c581e18730d6a5af
Summary: Without specifying the deployment target, it was default to iOS 4.3. This would cause a build error because we are `unable to synthesize weak properties` which didn't come around until iOS 5. Setting default target to iOS 8.
Reviewed By: emilsjolander
Differential Revision: D4481772
fbshipit-source-id: d3be88d0f73533c6242fc1d9045c70ad4628fd21
Summary:
Being a environment test, `npm run is-monolithic` is expected to fail when pulling the package from npm and to succeed when pulling it from github. Unfortunately, when returning false, npm will throw a tantrum by default if not explicitely disabled. It's not a hard failure, the build still complete, but it's better this way.
Closes https://github.com/facebook/yoga/pull/362
Reviewed By: gkassabli
Differential Revision: D4480608
Pulled By: emilsjolander
fbshipit-source-id: 0832a2158647f49b5230e2f658997f94774cec5b
Summary:
Adds a Xamarin Android support for Yoga and respective tests. Closes#276 with this PR all Xamarin platforms will be covered
Need to figure a better strategy for the build names for buck with splhack .
It's failing 3 tests related with YogaNode and the GC :) classic!

```
Facebook.Yoga.Android.Tests.dll : 660.87 ms
: 678.788 ms
Tests run: 130, Passed: 127, Failed: 3, Skipped: 0, Inconclusive: 0
```
Closes https://github.com/facebook/yoga/pull/340
Reviewed By: emilsjolander
Differential Revision: D4475370
Pulled By: splhack
fbshipit-source-id: f050f10415e68e9808f629b843682b0f87cca065
Summary:
This supersedes #309 and #305.
This is still a **work-in-progress.**
**TODO**
- [x] Create Xcode project that builds an iOS framework
- [x] Fix failing tests on Xcode
- [ ] Make `pod lib lint` pass and make sure YogaKit can be included using CocoaPods
- [ ] Add `pod lib lint` to .travis.yml
- [x] Migrate to travis osx image with Xcode 8.2
**FOLLOW-UP**
- [ ] Make YogaKitSample use framework built by new Xcode project.
- [ ] Make Travis to upload prebuilt versions of the framework. More [here](https://github.com/Carthage/Carthage#use-travis-ci-to-upload-your-tagged-prebuild-frameworks)
- [ ] Upgrade github/jekyll docs about installation using Cocoapods/Carthage
Closes https://github.com/facebook/yoga/pull/352
Reviewed By: emilsjolander
Differential Revision: D4471950
Pulled By: dshahidehpour
fbshipit-source-id: 8f30c69f9a487b26aa2e5f3b66841334b01b0ab1
Summary: aspect ratio did not account for the widths and heights being including padding. This diff fixes that.
Reviewed By: astreet
Differential Revision: D4473024
fbshipit-source-id: 5a747e2f267b077203bb3b63e4c152847dc30774
Summary: run format & gentest scripts. Some of the javascript tests had not been generated recently by the looks of it.
Reviewed By: dshahidehpour
Differential Revision: D4459455
fbshipit-source-id: fc1eca58fe897c8f4a2571638b4f7035d023b479
Summary: This is the first step to adding cocoapods support to YogaKit. We are going to publish a `Yoga` framework to the store that we can use as a dependency. This will also allow developers to build their own abstractions easily using the core API.
Reviewed By: nlutsenko, emilsjolander
Differential Revision: D4466788
fbshipit-source-id: 8f08bdbf524e57c88f7fc3400c4ba6ad58f98d7f
Summary: Absolute children should not be constraint to the size of their parent if the parent does not have a size as this was causes the layout of the child to be skipped.
Reviewed By: gkassabli
Differential Revision: D4453612
fbshipit-source-id: e8269521560d2f42b2d6f0f0ff264a1605a57d79
Summary: We are saving the class reference in a static variable to should be using findClassStatic to ensure the reference is always valid.
Reviewed By: mhorowitz
Differential Revision: D4420352
fbshipit-source-id: 8c66c1b2213fe295334a9bdc4e1dd7e1a4285aae
Summary:
I did some stylistic changes to the Objective-C unit tests for the following reasons:
- When an equality assert fails, the error messages reads as if the value we are testing is the first argument and the value we expect is the second argument. To improve the readability of test messages, I made sure all `XCTAssertEqual` and `XCTAssertNotEqual` have the arguments in the correct order.
- Because failing equality asserts already comes with a detailed message including the value tested and the expected value, I rewrote several truth asserts on `CGSizeEqual` to two equality asserts on the width and height: when those fail, the error message are clearer.
Closes https://github.com/facebook/yoga/pull/351
Reviewed By: emilsjolander
Differential Revision: D4454484
Pulled By: dshahidehpour
fbshipit-source-id: 0c1295a4a7e8477eacfb3f4ef6648984fd102a51
Summary: Currently, some YogaKit tests fail when they are run in Xcode, but pass in BUCK. This cleans up the tests so that they more definitively test what they say they are testing, and the results are not affected by the enviroment they are run in.
Reviewed By: emilsjolander
Differential Revision: D4453745
fbshipit-source-id: 238e41960afe63d31e9f6efdcd947cfac39f2dc4
Summary:
Doing this externally to trigger a Travis build. This will put our Travis infra on the newest Xcode.
Closes https://github.com/facebook/yoga/pull/353
Reviewed By: emilsjolander
Differential Revision: D4453795
Pulled By: dshahidehpour
fbshipit-source-id: 23416405fdd43486c934bea0b720c217fafd7f30
Summary:
I'm trying to fix some bugs I introduced in my latest PR, but while writing the Unit Tests for them, I saw a really weird behaviour. The following exact piece of code WORKS inside a Yoga C++ unit test, but fails from a Objective-C unit test. I had me completely confused and blocked me in my progression. Any ideas?
```
TEST(YogaTest, stupid_test) {
const YGNodeRef node = YGNodeNew();
YGNodeStyleSetPosition(node, YGEdgeLeft, 1);
ASSERT_FLOAT_EQ(1, YGNodeStyleGetPosition(node, YGEdgeLeft).value);
ASSERT_EQ(YGUnitPixel, YGNodeStyleGetPosition(node, YGEdgeLeft).unit);
YGNodeFree(node);
}
```
```
- (void)testPositionalPropertiesWork
{
YGNodeRef node = YGNodeNew();
YGNodeStyleSetPosition(node, YGEdgeLeft, 1);
XCTAssertEqual(1, YGNodeStyleGetPosition(node, YGEdgeLeft).value);
XCTAssertEqual(YGUnitPixel, YGNodeStyleGetPosition(node, YGEdgeLeft).unit);
YGNodeFree(node);
}
```
Closes https://github.com/facebook/yoga/pull/328
Reviewed By: dshahidehpour
Differential Revision: D4421504
Pulled By: emilsjolander
fbshipit-source-id: f59379edf70aee87a77cd1ad2986313cdfe71b94
Summary:
Fixes issue brought up in https://github.com/facebook/react-native/issues/10603
The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this.
Reviewed By: mmmulani
Differential Revision: D4182141
fbshipit-source-id: c73fd15d2577ab846fc8a202d529d0e6e1207b75
Summary:
Benchmarks are not located in folder benchmark. So rename folder
and buck target from 'benchmarks' to 'benchmark'.
Closes https://github.com/facebook/yoga/pull/339
Reviewed By: gkassabli
Differential Revision: D4420355
Pulled By: emilsjolander
fbshipit-source-id: 7a1bc6ece7f4b64c7cac506357e265c1b4790a4f
Summary:
Fix#326. I'll open another PR once this one gets accepted to add support for `YGLayoutGetBorder` 👌
Closes https://github.com/facebook/yoga/pull/335
Reviewed By: gkassabli
Differential Revision: D4409399
Pulled By: emilsjolander
fbshipit-source-id: 8153f6701cab60b55a485f6d2e0b9f7767481090
Summary:
Using shared code for reuse in other platforms based on iOS native implementation.
Adds YogaKit sample.
Adds YogaKit tests (same as objc).
```
YogaKitTest : 80 ms
Facebook.YogaKit.iOS.Tests.exe : 81 ms
Tests run: 11 Passed: 8 Inconclusive: 0 Failed: 3 Ignored: 1
```
Since we don't have extension properties we need to go with a extension method to get access to the YogaLayout .
I m also not sure this is leak free yet, would love some help with testing and feedback about view/node lifecycle
Closes https://github.com/facebook/yoga/pull/336
Reviewed By: splhack
Differential Revision: D4415027
Pulled By: emilsjolander
fbshipit-source-id: c88328212426c3200e6f0c48cda594cd2c432065
Summary:
Simple fix on a possible copy paste error. The test actually passes the same way by coincidence.
Closes https://github.com/facebook/yoga/pull/338
Reviewed By: dshahidehpour
Differential Revision: D4415019
Pulled By: emilsjolander
fbshipit-source-id: 823c3efc821db14b70d9dfe99ef87d1d7ebb75d0
Summary:
- Always launch buck build for Build, but copy native library when it was changed
- Rename Facebook.Yoga.Mac.Test to Facebook.Yoga.Mac.Sample
- Add Facebook.Yoga.Mac.Tests for NUnit test.
- "Run Unit Tests" menu item was activated for the target, but Mono still can't find libyoga.dylib
Closes https://github.com/facebook/yoga/pull/332
Reviewed By: emilsjolander
Differential Revision: D4408799
Pulled By: splhack
fbshipit-source-id: b3f5f9ebd8265cc152ca859176afbf54efa8f170
Summary: Need API needs some new docs. I also removed the repo's `.hgignore` and added everything to fbobjc `.hgignore` via `./Tools/generate_hgignore.py` which uses Yoga's `.gitignore`.
Reviewed By: emilsjolander
Differential Revision: D4403967
fbshipit-source-id: f2158e4feb27953d1d9e21c775926e6207220c4a
Summary:
Since there's a couple of changes after last month pr of #280 , here's a new pr for Xamarin support #276 , the idea is to add Xamarin iOS, Mac and Android support.
- Add Xamarin iOS support for Yoga, by providing a wrapper for the native lib.
- Add Xamarin iOS Unit testing project
~~- Adds a YogaKit shared implementation in c#.~~
~~- Adds a YogaKIt iOS implementation.~~
~~- Adds Yoga/YogaKit iOS sample application~~
Facebook.Yoga.iOS.Tests.exe : 169 ms
Tests run: 114 Passed: 114 Inconclusive: 0 Failed: 0 Ignored: 0

Closes https://github.com/facebook/yoga/pull/324
Reviewed By: emilsjolander
Differential Revision: D4401408
Pulled By: splhack
fbshipit-source-id: ecdae7967060361bef2bc25a5ef759cb9a957322
Summary: Allow aspect ratio to expand beyond bounds of parent as is generally accepted in css
Reviewed By: passy
Differential Revision: D4397547
fbshipit-source-id: d2b1ca7b096f2f17b3efbd8f47a50678bfe7bb5f
Summary:
@public
Cannot use NSInteger as NSInteger has a different size than int (which is the default type of a enum). Therefor when linking the Yoga C library into obj-c the header is a missmatch for the Yoga ABI.
Reviewed By: cwdick
Differential Revision: D4392272
fbshipit-source-id: 22b92ac8f3eb7114e81dbd9b0bec9044c3d43da5
Summary:
Compared to what was planned, I added the `overflow` value which seemed missing. I had to modify the implementation a bit for all values which are backed by a `YGValue`, but we should probably enable the pixel dimensions in Objective-C and Swift somehow later.
Closes https://github.com/facebook/yoga/pull/322
Reviewed By: cosmin1123
Differential Revision: D4391434
Pulled By: emilsjolander
fbshipit-source-id: e33f6f7b2bbaad29553100b7a5bb424496372110
Summary:
- Does not contain "magic" found in YogaKit yet, but enough to get started
- Simple test project showing use
- YGInteropSetLogger and YGNodeInit(IntPtr) were missing from native lib built by buck
Closes https://github.com/facebook/yoga/pull/278
Reviewed By: emilsjolander
Differential Revision: D4388480
Pulled By: splhack
fbshipit-source-id: a7387bb5b5554b6fce80d08c23e4fa18a4611cce
Summary:
Compared to what was planned, I added the `overflow` value which seemed missing. I had to modify the implementation a bit for all values which are backed by a `YGValue`, but we should probably enable the pixel dimensions in Objective-C and Swift somehow later.
Closes https://github.com/facebook/yoga/pull/322
Reviewed By: dshahidehpour
Differential Revision: D4386906
Pulled By: emilsjolander
fbshipit-source-id: 05ac0e571ef3a8ff0be31469e449a7b23f102218
Summary:
Added baseline support (see #132)
You have the ability for a custom baseline function (```float(*YGBaselineFunc)(YGNodeRef node);```) to return whatever baseline you want.
Closes https://github.com/facebook/yoga/pull/317
Reviewed By: splhack
Differential Revision: D4385061
Pulled By: emilsjolander
fbshipit-source-id: cb8a59a09237c840fa3e21753ab68239997dab0c
Summary: Add API for retrieving the computed final padding of a node. Many frameworks such as React Native retrieve padding via `YGNodeStyleGetPadding` but given that we now support percentage values this is not correct anymore.
Differential Revision: D4376572
fbshipit-source-id: 3ffb66e77090fc1257511bec5c933f9b0c304b9f
Summary:
In YogaKit, nodes are not dirtied when `sizeThatFits` of leaf nodes change. This makes it difficult to reuse views like `UILabel` when their content (text) changes. I wrote a failing test to prove it and wrote a fix by caching the latest value of `sizeThatFits` in `YGNodeBridge` and checking for changes in `YGAttachNodesFromViewHierachy` (renamed to `YGUpdateNodesFromViewHierachy` to make it clear it's not simply reattaching nodes anymore). When a new size is detected, I call `YGNodeMarkDirty` on the leaf node.
**Unfortunately**, this makes another test fail for no logical reason (`testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond`). Either there's something I don't understand or I've un-advertedly unearthed a bug in the C implementation, but in what case would setting a node dirty make the layout return a different size?
Closes https://github.com/facebook/yoga/pull/308
Reviewed By: emilsjolander
Differential Revision: D4378826
Pulled By: dshahidehpour
fbshipit-source-id: cd0640bc863debb9e434370739416e3e33e57a08
Summary:
When a non-leaf node becomes a leaf node, `YGAttachNodesFromViewHierachy` calls `YGNodeSetMeasureFunc` before `YGRemoveAllChildren`, which causes a crash because that node has children. Fixed by swapping the order of the calls and have a unit-test to make sure it works.
Closes https://github.com/facebook/yoga/pull/320
Differential Revision: D4383905
Pulled By: dshahidehpour
fbshipit-source-id: 4872b1e819f178adaaa66b1f1c233390d3ec3be9
Summary:
The C# wrapper project has been changed to a NETStandard (1.1) PCL allowing it
to be consumed by any project targeting .NET4.5 or greater including .NETCore
and UWP projects... The C# wrapper uses P/Invoke to call into the Native Yoga
DLL...
The "Yoga" C++ project has been updated to support ARM builds...
Added the ability to generate nuget packages for the C# wrapper that supports
copying the native DLLs to the target output directory.
Closes: https://github.com/facebook/yoga/pull/283
Reviewed By: splhack, emilsjolander
Differential Revision: D4381455
Pulled By: JoelMarcey
fbshipit-source-id: e6dc4190caa824ac63d5d5ee2eb4c7914efbb00f
Summary:
YogaValue.cs(20,30): error CS1644: Feature `expression bodied members' cannot be used because it is not part of the C# 4.0 language specification
YogaValue.cs(21,28): error CS1644: Feature `expression bodied members' cannot be used because it is not part of the C# 4.0 language specification
Closes https://github.com/facebook/yoga/pull/316
Reviewed By: emilsjolander
Differential Revision: D4381190
Pulled By: splhack
fbshipit-source-id: fea157ac03944260d87b9f137bf966605c01a10e
Summary:
It's not much, but still 4 bytes saved here by moving the ```bool```s together. (on compilers where ```bool``` is a single byte)
Closes https://github.com/facebook/yoga/pull/319
Reviewed By: gkassabli, passy
Differential Revision: D4383686
Pulled By: emilsjolander
fbshipit-source-id: 9a48eccbb69382850c016aa6ee730526704a15f2
Summary:
- Fix a few things related to how npm should publish the package (sources were in the gitignore file, so I think it would have break the build during install - I fixed this by adding a npmignore that should override the gitignore rules)
- The enumerations values are now generated directly from `enums.py`
- I added percent unit support (#258) to the bindings (`.setWidthPercent` is currently exposed, but I've also added a very very little parsing to also support `.setWidth("100%")` and `.setWidth(.getWidth())`), added the missing tests, and fixed Travis.
Closes https://github.com/facebook/yoga/pull/314
Reviewed By: mikearmstrong001
Differential Revision: D4377198
Pulled By: emilsjolander
fbshipit-source-id: 774dfafd416f5421f3be59a1d181eb7056487abe
Summary: We need this for scrollviews, bring on the overflow!
Reviewed By: emilsjolander
Differential Revision: D4376759
fbshipit-source-id: a427432da5e8679dbf9fdbfe4250707e727368f4
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
Summary:
- As mentioned in the title, this PR adds Javascript support to Yoga. Two different builds are included in this PR thanks to [nbind](https://github.com/charto/nbind), which conveniently allow to target both Node.js' native addons and browser environments via asmjs with approximately the same codebase. That should solve #215.
- All tests successfully pass on both codepaths. You can run `yarn test:all` inside the `javascript` directory to test it.
- Because of a bug in nbind, the [following PR](https://github.com/charto/nbind/pull/57) needs to be merged and a new version released before this one can be safely merged as well.
- I had to use `double` types instead of `float` in the C++ bindings because of an Emscripten [bug](https://github.com/kripken/emscripten/issues/3592) where symbols aren't correctly exported when using floats.
- There's some tweaks to do before this PR is 100% ready to merge, but I wanted to have your opinion first. What do you think of this?
---
To do:
- [x] Ensure th
Closes https://github.com/facebook/yoga/pull/304
Reviewed By: mikearmstrong001
Differential Revision: D4375187
Pulled By: emilsjolander
fbshipit-source-id: 47248558a9506b7c512b5ef281cd12fe1a60cab7
Summary: Preserve floating point values when passing them across the JNI bridge.
Differential Revision: D4366605
fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
Summary: Move yoga docs into master branch so that pull requests are able to include doc updates as part of other changes.
Reviewed By: JoelMarcey
Differential Revision: D4365700
fbshipit-source-id: 2f46a88974104c454c00bcdf1257abb5c4075a68
Summary:
Java still has the same problem (see #296)
Also there is no need to have double in the method signature as we only use float internally, which could confuse some.
Closes https://github.com/facebook/yoga/pull/300
Reviewed By: splhack
Differential Revision: D4365993
Pulled By: emilsjolander
fbshipit-source-id: 681f8b1725e63eddcfb9a6c756f2ae215a44425a
Summary:
Not re-calculate `paddingAndBorderAxisMain`/`paddingAndBorderAxisCross`/`paddingAndBorderAxisRow`/`paddingAndBorderAxisColumn` in Step1 of `YGNodelayoutImpl`.
They can be figure out by values calculated before.
Closes https://github.com/facebook/yoga/pull/298
Reviewed By: dshahidehpour
Differential Revision: D4365533
Pulled By: emilsjolander
fbshipit-source-id: 6caf60bc6ef3addd49915b39b48f01a8b4926e9c
Summary:
- Enable destructor unit tests in Unity Editor
- Exit pack.sh immediately if a command exits with a non-zero status
- Run unit tests before building Unity package
Reviewed By: emilsjolander
Differential Revision: D4365773
fbshipit-source-id: 20d0a51f4cef791154c17d329ac36598dc333a60
Summary:
This PR fixes issue #295
- Created a new internal YGNodeHandle class extending SafeHandle.
- YogaNode now stores a reference to YGNodeHandle.
- Removed finalizer from YogaNode.
- Pulling in System.Runtime.Handles 4.3.0.
Closes https://github.com/facebook/yoga/pull/297
Reviewed By: emilsjolander
Differential Revision: D4365462
Pulled By: splhack
fbshipit-source-id: 73293b105962cbedb71f4e3d8d1244251db1ea79
Summary:
- Change the CI config so it runs the tests for Editor on Sandcastle
- Don't run tests for effects-framework and yoga libraries when building for Mac (triggers code signing issues that I don't want to deal with right now)
- Add target for unit tests (aka EditorTests)
- Make the existing unit tests build and pass. These include both Objective-C and Swift (we should probably get rid of some of these though). I will convert these to Swift 3 before landing (after the migration is complete).
- Exclude the EditorUITests target for now. It only contains a single dummy test and it causes a code signing failure on Sandcastle. I did not manage to work around that yet but there is a separate task for it.
Reviewed By: Perspx
Differential Revision: D4352670
fbshipit-source-id: 0295004a72953bd8e7ae83895b2e5712bab7bd32
Summary:
Added Bash script and bat file to build a package of Yoga in order to import Yoga for Unity easily.
Closes https://github.com/facebook/yoga/pull/288
Reviewed By: emilsjolander
Differential Revision: D4344198
Pulled By: splhack
fbshipit-source-id: 49ae27dbc513b4a2d161840ca5c5f4c9df2ab227
Summary: Improve performance of allocations and reseting by writing fewer bits. Also just looks nicer imho.
Reviewed By: passy
Differential Revision: D4356994
fbshipit-source-id: ebbe52163e0c86230bfa4131b657941afe16fbf1
Summary: This should not be an enum. A define makes a whole lot more sense
Differential Revision: D4346529
fbshipit-source-id: 8641c4c5017d915d64e5884cae09ac8f01861337
Summary:
@public
AspectRatio is a new addition and soon after introduction we noticed use cases which is did not support. Specifically we wanted to support a node being as large as possible within a container while maintaining an arbitrary aspect ratio. This was not possible due to the low priority of AspectRatio, by increasing the priority of AspectRatio this is now possible as FlexGrow will grow an item to fit its parent unless the AspectRatio makes it too big in the cross axis, the AspectRatio will now override the FlexGrow in the main axis in that case.
Differential Revision: D4346720
fbshipit-source-id: 1f15613604190e3ad5ff4a467ba57db4bcfd2741
Summary:
@public
Aspect ratio being defined as width/height or height/width depending on the situation it was used in turned out to be very confusing. This diff makes aspect ratio always be defined as width/height irregardless of the usage.
Differential Revision: D4339132
fbshipit-source-id: e5da32750b55ddaf6acaf1cbd7662d86f2b480c3
Summary: We were incorrectly returning true for children which had no flex as the flex was nan and not 0.
Differential Revision: D4346712
fbshipit-source-id: 69ef0bb3fe5b4fcd3b3e2fe5aa348529be40252a
Summary: This test creates a repro case for Yoga to emulate UFI layout failure
Reviewed By: emilsjolander
Differential Revision: D4313632
fbshipit-source-id: 35be7d86b50a9ae08c81891a889a74e4b61f2d27
Summary:
There is a bug currently where we don't traverse the entire tree to detect view hierarchy changes.
Currently, if you had a hierachy like this:
```
container = UIView
container.subviews = @[subview1, subview2];
subview1.subviews = @[sub11, sub12, sub13];
subview2.subviews = @[sub21, sub22, sub23];
```
and then modified via:
```
subview2.subviews = @[newView1, newView2, newView3];
```
our algorithm wouldn't identify that we had new views that needed their layout calculated, and would cause a crash later on.
Reviewed By: emilsjolander
Differential Revision: D4357662
fbshipit-source-id: 2f61f213c5f1a62948a653f3b1fa3d874c5075f7
Summary: While building some views with YogaKit, I found an interesting problem. If you are apply `yg_` properties to a view which is constructed of subclassed views (that don't use Yoga.) we still treat view (and it's subviews) like they are using YogaKit. This fixes that behavior.
Reviewed By: emilsjolander
Differential Revision: D4348344
fbshipit-source-id: 37b8648918529f55afea1d1883a03af398aac849
Summary: I kept wrongly typing this function which is a good sign that the name is inconsistent.
Reviewed By: gkassabli
Differential Revision: D4333480
fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad
Summary:
- Problem: Can't link yoga static libraries with Unity and Xamarin.iOS since YGNodeInit is undefined in the libraries.
- Solution: Remove the reference in Native.cs
Reviewed By: emilsjolander
Differential Revision: D4338485
fbshipit-source-id: 9dc95aec8f1fd50f3f9d66e1623afe2fb1992210
Summary: This prevents android from matching in the middle of a platform.
Reviewed By: gkassabli
Differential Revision: D4306164
fbshipit-source-id: 7f62a6a017724f8f6741d3e53b5fbe0650c8c88e
Summary: Both New and Reset already call init internally. No reason to expose this function
Reviewed By: gkassabli
Differential Revision: D4276177
fbshipit-source-id: c4404d0534f381dfacee0625b2847d38de58e038
Summary: Running csharp tests should not result in uncommited files.
Reviewed By: splhack
Differential Revision: D4271411
fbshipit-source-id: abf6c69555ed657356a9426ca37864f8c2eaa78f
Summary: Update package name of java code to refer to yoga instead of csslayout. Still need to change the name of the folder where this code resides but that requires update github sync scripts etc so it is safer and easier to split these diffs apart.
Differential Revision: D4271420
fbshipit-source-id: b3cf150569a2331868410339cd19e5c694f2059e
Summary: Rename java api to new use yoga naming
Reviewed By: IanChilds
Differential Revision: D4265345
fbshipit-source-id: 69ecfd8fac214f86b8b70647b9b909acd83d78b5
Summary: Rename test files to use new name
Reviewed By: gkassabli
Differential Revision: D4265235
fbshipit-source-id: 0090d3949828058baf7435f33d4068de92756bad
Summary: This renames the core C api to use the new Yoga branding.
Differential Revision: D4259190
fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
Summary: static linking is dangerous here as more than one library could be including the same symbols. The used to only be used by the jni target previously but that is no longer true
Reviewed By: gkassabli
Differential Revision: D4258293
fbshipit-source-id: 053f9e607503707830e3766b1f268ab31d3081ff
Summary: D4213339 refactored some code and some logic was missed where negative values should only be ignored for at most measurements.
Reviewed By: gkassabli
Differential Revision: D4258254
fbshipit-source-id: e22e36e67260114081e483527fc7ce378f7f0df9
Summary: In case the java object has been GCed during layout calculation we will crash if we try to call a method on the now invalid weak pointer. Use fbjni weak_ref to skip calling to java when the java object does not exist any more.
Reviewed By: lexs
Differential Revision: D4251133
fbshipit-source-id: 2d8949252b31447ce54bc16a35cb25fabe72230b
Summary: static linking is dangerous here as more than one library could be including the same symbols. The used to only be used by the jni target previously but that is no longer true
Reviewed By: gkassabli
Differential Revision: D4248487
fbshipit-source-id: e5127a02561b145745cf5393a0188661469ec79b
Summary: Add compile flag from CSSLayout to jni target as well
Reviewed By: passy
Differential Revision: D4248473
fbshipit-source-id: 18a163a3daedc56e98c7bdc38e10fc8626999f94
Summary: Remove deprecated java code and make use of CSSEdge instead of the now removed Spacing class.
Reviewed By: AaaChiuuu
Differential Revision: D4233198
fbshipit-source-id: 736d79be266e1b9f2d62e5fe6d901de47123cdc1
Summary: The Style prefix does not make sense in the java and c# api and only a few methods had it. This diff removes the last of those.
Reviewed By: splhack
Differential Revision: D4232920
fbshipit-source-id: 6e2ff21bbb7e0e441892023c14df579d1bc7aa49
Summary: Soloader is safer than System load library, retrying with System load library just hides errors
Reviewed By: lexs
Differential Revision: D4243906
fbshipit-source-id: e4d691c9c49f3b9316f67e39b9f277657d78fb3c
Summary: Add notice in readme to prepare open source for large renaming diffs.
Reviewed By: splhack
Differential Revision: D4240761
fbshipit-source-id: 4c8070a06c3ac009b67eb7bef5de11ce3ab3e4d8
Summary:
At least or x86_64 linux, it appears that you need position-independent
code is required in order to link against it. Otherwise you see errors
like this:
```
/usr/bin/ld: lib_sys.rlib(CSSLayout.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: lib_sys.rlib(CSSNodeList.c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
```
If I understand it correctly, you don't strictly need PIC for static libraries, but as soon as you want to link *other* dynamically linked library into it, it is required - which makes logical sense to me. Let me know if you want to enable this by default or leave it up to the developers to enable this if needed.
Closes https://github.com/facebook/css-layout/pull/263
Reviewed By: passy
Differential Revision: D4237009
Pulled By: emilsjolander
fbshipit-source-id: e73ea0ea22520758ec958a031d6e2ca62fdcda15
Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.
Reviewed By: gkassabli
Differential Revision: D4226734
fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag.
Reviewed By: gkassabli
Differential Revision: D4222910
fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
Summary: I found that if you move a subview to a different index, it would cause a crash in subsequent layout passes because the `CSSNodeRef` representing it was being re-inserted into the list. I spent a lot of time figuring out the best way to "diff" the view hierarchy from before and after, and I found the easiest implementation is also the most reliable. We can continue to optimize, but this is a great start.
Reviewed By: emilsjolander
Differential Revision: D4218623
fbshipit-source-id: 06253089492ac37ae4b94b7c30140ce6ed680ed2
Summary:
Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely can be further improved. I'm looking forward to your ideas.
Closes https://github.com/facebook/css-layout/pull/256
Reviewed By: splhack
Differential Revision: D4214168
Pulled By: emilsjolander
fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236
Summary:
Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values.
Closes https://github.com/facebook/css-layout/pull/257
Reviewed By: splhack
Differential Revision: D4213809
Pulled By: emilsjolander
fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2
Summary:
We currently have a bug in `UIView+CSSLayout.m` that you can repro in a scenario like this:
```
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setIncludeInLayout:NO];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setIncludeInLayout:NO];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setIncludeInLayout:YES];
[container addSubview:subview3];
[container css_applyLayout];
```
`subview3` (which is the only view whose is going to be included in layout calculation) is inserted at child index 2, instead of 0. This eventually can cause crash in CSSLayout.c because it will attempt access a child in the list which is null.
Reviewed By: emilsjolander
Differential Revision: D4215659
fbshipit-source-id: a615f50e51f85b15d3bdb437e55958865898b183
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213339
fbshipit-source-id: 5ca35ca307594f3419fd0dee81321d3c2e06710f
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213313
fbshipit-source-id: 2061a809202f7f948bff1b3ee8dc4c230692a223
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213302
fbshipit-source-id: df4bc43848325e99ad338a2fa6d5c9404315b0e6
Summary: Implement aspect ratio as part of Yoga. Aspect ratio allows users of the library to specify the size of the undefined dimension in terms of an aspect ratio. See test cases for examples.
Reviewed By: gkassabli
Differential Revision: D4211458
fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d
Summary:
computed flex basis was incorrectly being reused in some circumstances between calls to caluclateLayout
also run format script.
Reviewed By: dshahidehpour
Differential Revision: D4207106
fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d
Summary:
```isnan``` is already defined in ```math.h``` (at least when using VS13) so there is no need to redefine it. it also is a nan for float and not for double opposed to ```_isnan```
Closes https://github.com/facebook/css-layout/pull/253
Reviewed By: emilsjolander
Differential Revision: D4199331
Pulled By: splhack
fbshipit-source-id: 139fb0efd68dd5df79bbaef863a8e8b9246c795d
Summary:
Use ```size_t```instead of ```unsinged long``` as this is the "offical" return type of ```strlen```. Is VS13 ```size_t``` is defined as ```unsigned long long``` which leads to a compiler warning.
Closes https://github.com/facebook/css-layout/pull/254
Reviewed By: emilsjolander
Differential Revision: D4199327
Pulled By: splhack
fbshipit-source-id: 5e1a91f282bf776e4d9f5806e6467dfe36c7a633
Summary:
- Add a convenience function to copy all style from one node to another.
- CSSNodeIsDirty will return true after this function if any style was changed in the destination node.
Reviewed By: emilsjolander
Differential Revision: D4188514
fbshipit-source-id: af8d7fb5e8688c64aea05ce7ad23fff9233fb441
Summary:
- Problem: Build error in Visual Studio since an array cannot have zero size.
- e6702e1168 (commitcomment-19839659)
- Solution: Add 1 until we'll have actual CSSExperimentalFeature value.
Reviewed By: emilsjolander
Differential Revision: D4191268
fbshipit-source-id: 53fdcc388292e76c2b97ad071f0d7c27d0613ecf
Summary:
When dealing with manual sizing in UIView's (or UIKit in general) we see a common pattern like so:
Below we have an example implementation of a view with two Labels that want to be stacked horizontally. If we don't pass a second string, we hide the second label and give up the available space to the first label. See below:
```
interface TitleSubtitleView : UIView
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;
end
implementation {
UILabel *_titleLabel;
UILabel *_subtitleLabel;
}
....
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
_titleLabel.text = title;
if (subtitle.length > 0) {
_subtitleLabel.hidden = NO;
_subtitleLabel.text = subtitle;
} else {
_subtitleLabel.hidden = YES;
}
}
- (CGSize)sizeThatFits:(CGSize)size {
const CGSize titleSize = [_titleLabel sizeThatFits:size];
CGSize subtitleSize = CGSizeZero;
if (!_subtitleLabel.isHidden) {
subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
const CGSize titleSize = [_titleLabel sizeThatFits:size];
_titleLabel.frame = CGRectMake(0, 0, titleSize.width, titleSize.height);
if (!_subtitleLabel.isHidden) {
subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
_subtitleLabel.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, subtitleSize.width, subtitleSize.height);
}
}
```
The problem is with the CSSLayout framework, as long as your view is in hierarchy, it's going to be allocated space during layout calculation. The only way to fix the view above would be to completely remove it from view hierarchy if it isn't being used. The problem is that adding/removing views from hierarchy is much less performant than hiding.
As a result, we need a way to tell the CSSLayoutKit library that even though a view is in hierarchy, we don't want to include it in layout. With this diff, we could change the class to look like this:
```
interface TitleSubtitleView : UIView
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;
end
implementation {
UILabel *_titleLabel;
UILabel *_subtitleLabel;
}
....
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
_titleLabel.text = title;
_subtitleLabel.text = subtitle;
const BOOL subtitleHasText = subtitle.length > 0;
_subtitleLabel.hidden = !subtitleHasText;
[_subtitleLabel css_includeInLayout:!subtitleHasText];
}
- (CGSize)sizeThatFits:(CGSize)size {
const intrinsicSize = [self css_intrinsicSize];
return CGSizeMake(MIN(size.width, intrinsicSize.width), MIN(size.height, intrinsicSize.height)));
}
- (void)layoutSubviews {
[super layoutSubviews];
[self css_applyLayout];
}
```
Reviewed By: emilsjolander
Differential Revision: D4189897
fbshipit-source-id: 403d11d84d47691e3ce0b5ac18a180b0e4c104c4
Summary: When I try to use this in practice, I have come to realize that css_sizeThatFits will 99% return to you the constrainedSize that you pass it, thus making it useless. Instead, we replace it with a new API that will tell you the optimal size of the resolved layout. From this we can choose to use that size, or scale it down.
Reviewed By: emilsjolander
Differential Revision: D4191873
fbshipit-source-id: d36a2850448d9d82f97e5ef4c7397778c2a14094
Summary: Remove infra for dynamically downloading gtest as this fails like 50% of the time on travis. I'll manually push gtest as a submodule instead.
Reviewed By: gkassabli
Differential Revision: D4183033
fbshipit-source-id: 09a121b8ede7a5974a29b6692edc63bff79aece7
Summary: For some reason these tests don't pass when running in travis. They are still running internally so we should catch any regressions. We can remove this if we figure out what is causing travis to fail here but until now I would rather get travis to pass.
Reviewed By: dshahidehpour
Differential Revision: D4189251
fbshipit-source-id: a27d3390f6b6fdcac6a3312d02581bb64969fd4b
Summary:
- Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib.
- Fixed memory leaks in tests.
- Close#247
For example, to use dlmalloc with USE_DL_PREFIX
CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree);
Reviewed By: emilsjolander
Differential Revision: D4178386
fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b
Summary: Keeping enums in sync between all the different bindings is tedious and error prone. Getting one of the values in the incorrect order could lead to many hours of debugging as they are passed as ints to C. This diff adds a simple python script to generate these enums for all languages. This also makes it much easier to add support for more languages in the future
Reviewed By: gkassabli
Differential Revision: D4174263
fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10
Summary: If some test previous to this test fails to de-allocate a node we don't want this test to fail.
Reviewed By: dshahidehpour
Differential Revision: D4182179
fbshipit-source-id: 229dd5736d6d7b9c1b22b181e022c788584b9c17
Summary: Talked with emilsjolander offline, and we want to keep the prefixes standardized in this lib. Changing CLK prefixes to CSS.
Reviewed By: emilsjolander
Differential Revision: D4175634
fbshipit-source-id: 7152268b9312df3fdb8eaee7ce3f6baabc5de937
Summary: We want to start experimenting with changes to the library in a more controlled and easier to measure manner. This diff adds the basics of an experiment layer to csslayout.
Reviewed By: gkassabli
Differential Revision: D4174260
fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd
Summary: Java and csharp already use CSSWrap and not CSSWrapType. Let's consolidate and stick with the shorter of the two.
Reviewed By: gkassabli
Differential Revision: D4174257
fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592
Summary:
Fixes issue brought up in https://github.com/facebook/react-native/issues/10603
The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this.
Reviewed By: gkassabli
Differential Revision: D4157971
fbshipit-source-id: 3cfae15ac8b65b70f01789444099ee684e1b099a
2016-11-14 02:22:44 -08:00
786 changed files with 128882 additions and 25037 deletions
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
We want to make contributing to this project as easy and transparent as
possible.
## Our Development Process
All the development is happening on GitHub first and we have internal tools to sync down to Facebook codebase.
## Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
## Pull Requests
We actively welcome your pull requests.
@@ -28,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 css-layout, you agree that your contributions will be licensed
under its BSD license.
By contributing to yoga, you agree that your contributions will be licensed
CSSLayout is a cross-platform implementation of flexbox. The goal of CSSLayout is allow native developers to have the same expressive layout system as developers developing for the modern web are used to. CSSLayout allows developers for web, android, iOS, and windows to use the same layout primitives across platforms. This saves time, increases collaboration between platform teams, and makes it easier for developers to work on multiple platforms.
## 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.
The goal of CSSLayout is not to re-implement all of css. CSSLayout only targets flexbox, and does not have any plans on implementing support for tables, floats, or any other css concepts. CSSLayout also does not plan on supporting styling properties which do not affect layout such as color or background properties.
## 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`.
## Differences from web
CSSLayout tries to stay as close as possible to the web implementation of flexbox. There are however certain cases where CSSLayout differs from the web implementation.
### Default values
CSSLayout has chosen to make changes to the default values of certain properties. These default values were chosen based on our usage of the library. When testing layout with tools such as JSFiddle you can apply the following css style to ensure the defaults match those of CSSLayout. Or fork the [following JSFiddle](http://jsfiddle.net/vjeux/y11txxv9/).
```css
div,span{
box-sizing:border-box;
position:relative;
display:flex;
flex-direction:column;
align-items:stretch;
flex-shrink:0;
align-content:flex-start;
border:0solidblack;
margin:0;
padding:0;
min-width:0;
}
```
-`box-sizing: border-box` is the most convenient way to express the relation between `width` and `borderWidth`.
- Everything is `display: flex` by default. All the behaviors of `block` and `inline-block` can be expressed in term of `flex` but not the opposite.
- All the flex elements are oriented from top to bottom, left to right and do not shrink. This is how things are laid out using the default CSS settings and what you'd expect.
- Everything is `position: relative`. This makes `position: absolute` target the direct parent and not some parent which is either `relative` or `absolute`. If you want to position an element relative to something else, you should move it in the DOM instead of relying of CSS. It also makes `top, left, right, bottom` do something when not specifying `position: absolute`.
### Size units
CSSLayout currently only supports pixel sizes. The reason being that we have not seen the need for any other units. We would like to support percentage units sometime in the future.
### -start and -end properties
We think supporting RTL locales is very important. Therefor CSSLayout supports non-standards -start and -end suffixed versions of margin, padding, border, and position.
## Usage
### C
The full API can be found in `CSSLayout/CSSLayout.h`.
The full API can be found in `java/com/facebook/csslayout/CSSNode.java`.
```java
CSSNoderoot=newCSSNode();
root.setStyleWidth(100);
root.setStyleHeight(100);
for(inti=0;i<10;i++){
CSSNodechild=newCSSNode();
child.setStyleHeight(10);
root.addChildAt(child,0);
}
root.calculateLayout(newCSSLayoutContext());
// Get for resulting layout
root.getLayoutX();
root.getLayoutY();
root.getLayoutWidth();
root.getLayoutHeight();
```
### UIKit
The full API can be found in `CSSLayoutKit/UIView+CSSLayout.h`.
```objective-c
UIView *root = [UIView new];
[root css_setUsesFlexbox:YES];
[root css_setWidth:100];
[root css_setHeight:100];
for (NSUInteger i = 0; i < 10; i++) {
UIView *child = [UIView new];
[child css_setUsesFlexbox:YES];
[child css_setHeight:10];
[root addSubview:child];
}
// Resulting layout will be set on the UIView hierarchy frames.
[root css_applyLayout];
```
### .NET
The full API can be found in `csharp/Facebook.CSSLayout/CSSNode.cs`.
```csharp
var root = new CSSNode();
root.StyleWidth = 100;
root.StyleHeight = 100;
for (var i = 0; i < 10; i++)
{
var child = new CSSNode();
child.StyleHeight = 10;
root.Insert(0, child);
}
// Get for resulting layout
root.LayoutX;
root.LayoutY;
root.LayoutWidth;
root.LayoutHeight;
```
## Contributing
To contribute to CSSLayout you need to first install [buck](https://buckbuild.com) which is the build system used by CSSLayout. CSSLayout is implemented in C with language bindings for Java, Objective-C, and .NET. When making changes to `CSSLayout/CSSLayout.h` please ensure to update `java/jni/CSSJNI.h`, `java/com/facebook/csslayout/CSSNode.java`, `uikit/CSSLayout/UIView+CSSLayout.m`, and `csharp/Facebook.CSSLayout/CSSNode.cs` to reflect the API change. Before submitting any code please run `format.sh` to ensure the code matches the project's code style.
Before making any larger changes to CSSLayout please open an issue with a RFC so the changes can be discussed first. Generally we are very open to changes and improvements that will benefit the community.
### Testing
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 at least one test to ensure we don't break anything in the future. Tests are located in `tests/CSSLayoutTest.cpp`. Run the tests by executing `buck test //:CSSLayout`.
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 CSSLayout, 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 generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:CSSLayout` to validate the behavior. One test case will be generated for every root `div` in the input html.
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:yoga` to validate the behavior. One test case will be generated for every root `div` in the input html.
You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script.
#### .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.CSSLayout/test_macos.sh`.
### .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`.
### Benchmarks
Benchmarks are located in `benchmarks/CSSBenchmark.c` and can be run with `buck run //benchmarks:benchmarks`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed.
## Benchmarks
Benchmarks are located in `benchmark/YGBenchmark.c` and can be run with `buck run //benchmark:benchmark`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.
### JavaScript
Installing through NPM
```sh
npm install yoga-layout
```
By default this will install the library and try to build for all platforms (node, browser asm, and standalone webpack). You may receive errors if you do not have the required platform development tools already installed. To preset the platform you'd like to build for you can set a .npmrc property first.
```sh
npm config set yoga-layout:platform standalone
```
This will now only run the standalone webpack build upon install.
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.'
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
```
pod 'YogaKit', '~> 1.7'
```
## Getting Started
Checkout the docs [here](https://facebook.github.io/yoga/docs/api/yogakit/).
We also have a sample project. To try it out, clone this repo and open `YogaKitSample.xcodeproj` in the [YogaKitSample](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample) directory.
## Contributing
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) file for how to help out.
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
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.