Summary:
In the persistent version of Yoga, a YogaNode can be shared between two YogaTrees, that means that a YogaNode could have more than one Parent at one point in time. That's why the concept of Parent of a YogaNode is not a 1-1 relationship anymore.
This diff changes the semantic of Parent of a YogaNode to Owner of a Yoga Node. CC sebmarkbage and priteshrnandgaonkar for more context.
Technically this diff renames the field YogaNode.parent to YogaNode.owner (and every internal field, Getter and Setter that is related to parent)
Note that as part of this diff I also modified the CSSLayoutDEPRECATED version of Yoga in order to keep compatibility with the C++ implementation.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7352778
fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
Summary:
We had functions for inserting/removing a specific child, but not for simply replacing the child set with another list.
`YGNodeSetChildren()` will unhook child nodes from the parent that don't appear in the new set. We set the disconnected child node layouts to `YGLayout()` b/c that's what the rest of the code does.
`YGTraversePreOrder()` walks the tree and calls a labmda for each node. We could very easily add a post-order traversal and the ability to stop traversal if we ever want, but for now this is an MVP.
Reviewed By: Woody17
Differential Revision: D7360203
fbshipit-source-id: 32df8e1213ead03bc0a026ec4bf453bc799bb9ce
Summary:
Podspec to push yoga 1.8.0 to cocoapods. There is an issue with cocoapods and it fails to lint those projects with C++ in its header, which is the case with yoga too.
Follow this thread https://github.com/CocoaPods/CocoaPods/issues/5152. To make the lint pass, one would have to change `app_target_helper.rb` cocoapod source file in the local machine. Follow my [gist](https://gist.github.com/priteshrnandgaonkar/dcca9639a3bc0a3b9adecae3a2b3b0c4).
I am able to pass the lint, but not able to push the pod in cocoapods as I am not the admin. @[759512522:emilsj], please push it on Cocoapods or give me permission.
Podspec now also exposes public header explicitly.
Reviewed By: gkassabli
Differential Revision: D7375018
fbshipit-source-id: 4e82e1c0b6340c3f8d3b8a96ecadbcb711d4bcd8
Summary: Adds an example of how to use yoga from JavaScript to the documentation pages.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7354390
fbshipit-source-id: 0dbc08e5341c06b621acd99bfb9ce7e789b67a45
Summary: These don't need to be copied twice.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291363
fbshipit-source-id: 22e606d0b3fa1133d7e0334c8cf9f5f1f32fe64b
Summary: These shouldn't be copying the arguments when they pass by value. Instead these only get copied when assigning the value to the member.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291096
fbshipit-source-id: 7a4025831811d622050adbb5f86608855b94d68e
Summary:
Earlier `YGfloatOptional` was plain struct with no privacy around the variables. This diff adds privacy and also enforces checks when one tries to access value of an undefined `YGFloatOptional`
This diff also adds a behaviour in which when a value of an undefined YGFloatOptional is accessed, it will normally terminate(Several cleanup steps are performed).
Reviewed By: emilsjolander
Differential Revision: D7288555
fbshipit-source-id: f61cc92c8fd0d48d2fc1f4d0e6fcef155f19ff8a
Summary: Fixed a typo of flexshrink and added a test case
Reviewed By: emilsjolander
Differential Revision: D7289221
fbshipit-source-id: 48ee9ccfac4adee51d515a366b5a11790f7236fc
Summary: Fix getters and setters of min and max Dimension to behave exactly the same way as it was before fast math changes
Reviewed By: emilsjolander
Differential Revision: D7274807
fbshipit-source-id: 7c1a4c19e8d0552b089a410c3330392cb26a6a47
Summary:
This diff fixes the setter and getter of margin, position, border and padding to the previous behaviour of yoga, before floatoptional change
This diff also removes the unrequired `#define`
Reviewed By: emilsjolander
Differential Revision: D7274115
fbshipit-source-id: 942a91e6562ef789ae79102a828f397889468fa7
Summary:
Earlier YGUndefined was NAN, but recently it was replaced with 10E20 and the check for `isUndefined` is as follows
```
public static boolean isUndefined(float value) {
return (Float.compare(value, (float) 10E8) >= 0 || Float.compare(value, (float) -10E8) <= 0);
}
```
If the number is in (-inf, -10E8] and [10E8, inf) then it is considered as undefined. Failing test passed values in this range, so thats why the test was failing. Current diff fixes this issue, and passes a big number which is outside the range as the result of measure function.
Reviewed By: emilsjolander
Differential Revision: D7272325
fbshipit-source-id: 81a77117c65c5dc0cec920f50f0735ec0a7433d1
Summary:
This diff exposes `shouldDiffLayoutWithoutLegacyStretchBehaviour` from YGConfig and `doesLegacyStretchFlagAffectsLayout` from YGLayout to YogaConfig and YogaNode respectively
Also added a positive test case. Didn't find the negative test case example. @[508947467:ianc] or @[759512522:emilsj], can you suggest a negative test case example.
Reviewed By: emilsjolander
Differential Revision: D7272067
fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
Summary: Remove the use of YGUndefined for default flex-basis value
Reviewed By: emilsjolander
Differential Revision: D7243924
fbshipit-source-id: 2bfaca1a5e3da40d5292a273cabf705f59c9d666
Summary: Change the type of flexShrink to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7232171
fbshipit-source-id: 3111119d3d74a7035c01132bff61b30cf44e120a
Summary: Change the type of flexGrow to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7215355
fbshipit-source-id: 1298ee332551d44e4d070169a1e4103d005c4f43
Summary: Change the type of flex to YGFloatOptional internally, but keeping the public facing API the same as before
Reviewed By: emilsjolander
Differential Revision: D7211327
fbshipit-source-id: 0d979b6ba00317317b98bbc6e63979c7f1feb2da
Summary: Changed the return type of YGResolveValue
Reviewed By: emilsjolander
Differential Revision: D7195099
fbshipit-source-id: 72c4163cd08691cf6e40df05394cc52e83b0de14
Summary: Remove the usage of YGUndefined in the default values of Border in YGStyle. In the getter of Border function, YGUndefined is used just to keep it logically consistent. The proper solution would be to change the api in `Yoga.h` to accept `YGFloatOptional`, but that would require to change lot of the code in client of this library. Will make a separate diff for that.
Reviewed By: emilsjolander
Differential Revision: D7195115
fbshipit-source-id: e635cf55ac94d8a90caef6cafce281579da2cbfc
Summary:
emilsjolander hi,
this PR solves the following common and probable layout pixel scenario:
the older code is presented for reference:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutWidth()),
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
Math.round(xOffset + node.getLayoutX()),
Math.round(yOffset + node.getLayoutY()),
Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
suppose now the following:
- `xOffset + node.getLayoutX() = 2.2`
- `node.getLayoutWidth() = 0.4` ==> `Math.round(node.getLayoutWidth()) = 0`
- `Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()) = Math.round(2.2 + 0.4) = 3`
this induces, the following measurements:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
0,
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
2,
Math.round(yOffset + node.getLayoutY()),
3,
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
the width measurement of the view is 0, while the layout is `(3 - 2 = 1)`.
my proposed solution is to measure the view the way it is now, but when layouting
I use the `#getMeasuredWidth/Height()` methods, this will stop this problem
from happening.
I also want to note that this bug happens with high probability.
Closes https://github.com/facebook/yoga/pull/712
Reviewed By: emilsjolander
Differential Revision: D7231798
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 171da519639dbecd75416a574bccc4456aa22f31
Summary: When we don't explicitly set header_namespace, we can get differing behavior between Android and iOS. Even when it is not explicitly necessary, we are going to try to enforce this properly.
Reviewed By: scottrice
Differential Revision: D7141155
fbshipit-source-id: 74d1488c3909f89ad9d6d0ee0de335b789dc2ccd
Summary:
Some files have crept into the repo with the old license header. These are usually from PRs that were opened prior to the re-licensing of the project.
Let the script run, prior to fixing the errant files. The script outputs the following:
```
PATENTS crept into some new files?
--- /dev/fd/63 2018-03-01 01:42:48.250153746 +0000
+++ /dev/fd/62 2018-03-01 01:42:48.250153746 +0000
@@ -1 +1,9 @@
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.h
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.m
+ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+ReactAndroid/src/main/java/com/facebook/react/views/text/CustomLetterSpacingSpan.java
+ReactCommon/yoga/yoga/YGLayout.cpp
+ReactCommon/yoga/yoga/YGLayout.h
+ReactCommon/yoga/yoga/YGStyle.cpp
+ReactCommon/yoga/yoga/YGStyle.h
scripts/circleci/check_license.sh
Exited with code 1
```
Fix the headers in these files and run the script again. No output, exit code 0.
Closes https://github.com/facebook/react-native/pull/18143
Reviewed By: sophiebits
Differential Revision: D7119356
Pulled By: hramos
fbshipit-source-id: d238e4d4a3ae320a2c8e625c2fa29690057a4814
Summary:
Changed NaN with large number to support `-ffast-math` compiler flag.For `-ffast-math` to work, all floating point numbers should be finite. Reason for not going with `FLT_MAX`, is that, it may cause number overflow during math operations. So thats why I opted for big number smaller than `FLT_MAX`. Earlier we used NaN, while NaN is involved in comparision the comparision operator behaves differently, it always returns false. Also operators like, fmaxf,fminf etc. have wierd beahviours. This diff takes care of those things as far as possible, and all tests are passing.
Running ./instrumentation_tests/run instrumentation_tests/com/facebook/feed/ctacoalescing:ctacoalescing --class AttachmentCallToActionSelectorBenchmarkTest --benchmark --extra-arg iterations=100 shows the perf gain of 13-15%
Reviewed By: emilsjolander
Differential Revision: D6969537
fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
Summary: removing the old `docs` folder as we are switching to `gh-pages` branch.
Reviewed By: emilsjolander
Differential Revision: D7110147
fbshipit-source-id: a27e6fc3a115f2f62b8a0dd5833d872e24698021
Summary: Tracks a Google Analytics event once the code generator is opened.
Reviewed By: emilsjolander
Differential Revision: D7097182
fbshipit-source-id: 637a96db981f5e90c9f7ce155ba8669b8dac98fa
Summary: Travis builds for the website were failing. The problem was due to `yoga-layout` not compiling. However, we don't need to compile `yoga-layout` at all, because we are only using the asm.js version. This adds the `--ignore-scripts` flag to the `yarn` command, to ignore the post-install script which tries to compile yoga.
Reviewed By: emilsjolander
Differential Revision: D7097154
fbshipit-source-id: 3bf9efda0e2ae6166181dad66621cf6fc9586e88
Summary: Travis defaults to node version 0.10 (!). Explicitly setting the node version to 8.
Reviewed By: emilsjolander
Differential Revision: D7056888
fbshipit-source-id: f6e31cc75009dc4f322c1750c2ce540afdd641ce
Summary: Removes travis build as they were currently not in use and prevented website from being deployed.
Reviewed By: emilsjolander
Differential Revision: D7055369
fbshipit-source-id: f227b1da1fea748c526b9faeedef063f9eeff61f
Summary: Adds a deploy step to travis.yml file to depoly the docs to github pages.
Reviewed By: emilsjolander
Differential Revision: D7028804
fbshipit-source-id: bb91c6b1ad2a306a6957a48679f164128c5b1be1
Summary:
"feature" should be "features" but it's already used twice in that paragraph so
I replaced it with "showcases" instead.
Reviewed By: emilsjolander
Differential Revision: D7042770
fbshipit-source-id: 0287f8746feca5c9f651950c8e9c24d2e86d55e9
Summary: Specify that the jni rule is really for android
Reviewed By: emilsjolander
Differential Revision: D7015911
fbshipit-source-id: 5fbff4bb15d2d1256261b13417653b68bb6dc5aa
Summary: Added default constructor for YGCachedMeasurement. This diff uses the default initialiser to get rid off the older designated initializer syntax. This diff also addresses https://github.com/facebook/yoga/pull/700
Reviewed By: emilsjolander
Differential Revision: D7020337
fbshipit-source-id: e084e234bf6a2ae22e53e739959683abca169b88
Summary: Add default constructor in YGLayout and moved to separate file. This diff also addresses https://github.com/facebook/yoga/pull/700
Reviewed By: emilsjolander
Differential Revision: D7019653
fbshipit-source-id: 5a2655626db0915fcebe7d4517e2d0b2e2484460
Summary: Moved YGStyle to separate file and added default constructor to it. This diff also gets rid off of the default values, which were earlier declared in Yoga-interna.h and instead uses default constructor. This diff also addresses https://github.com/facebook/yoga/pull/700
Reviewed By: emilsjolander
Differential Revision: D7016575
fbshipit-source-id: eb28df0ffb4cc813b23edaff80d7d4ebc56ce6af
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
Summary: Yoga logo was hotlinked from the old pages. This adds the logo to the sources
Reviewed By: emilsjolander
Differential Revision: D7009804
fbshipit-source-id: d913223e042b1bd9cf2ddab7c74d864e482d94b3
Summary: The position record defaulted to 0, which was wrong. No it defaults to NaN, which is the same as not having a value at all.
Reviewed By: emilsjolander
Differential Revision: D7009783
fbshipit-source-id: 83810da87e983f8d4d3e428f1f5fab0928bce58d
Summary: select the value of any input element once the field gets focus.
Reviewed By: emilsjolander
Differential Revision: D7009723
fbshipit-source-id: e1bc0f4b219958d8bdb79ef1a583cad86157b050