Summary: Remove experimental setup of fast-math and add `-ffast-math` as a compiler flag for yoga.
Reviewed By: emilsjolander
Differential Revision: D7414228
fbshipit-source-id: 320e1b1953f6af867b13e617af7872eb8999160e
Summary: Change the return type of getMarginForAxis to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7350337
fbshipit-source-id: dd1ee2fcd295ccd14f7d414ab0c24090b24e91e0
Summary: Change the return type of getTrailingMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7350221
fbshipit-source-id: 61a67364c1975ec6dd1883bc2cb4968b830c73df
Summary: Changed the return type of getLeadingMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7349907
fbshipit-source-id: b20894fbc33fd5b29a28f3c9174d1b5f406774ab
Summary: Change the type of getTrailingPosition to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7344710
fbshipit-source-id: eb4c422b6e0f55d90b083221aa8ff1ab797d58a8
Summary: Changed the type of return value of getLeadingPosition to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7344367
fbshipit-source-id: 0f5a667ca357b2ce056c86763aa3e9e4c54b82f0
Summary: Changed the type of computedFlexBasis to YGFloatOptional in YGLayout
Reviewed By: emilsjolander
Differential Revision: D7340413
fbshipit-source-id: 39247b2b582a682e602f49f58b4bbd2bf0c995af
Summary: Changed the return type of trailing padding to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7339712
fbshipit-source-id: 483c5886838c14b17cb731c81abb9fc80f519956
Summary: Changed the arguments for the getter of leading padding to avoid copies. Added an assetion in getter of leading padding, as padding would always be defined even in the case when the user has not explicitly defined the value. In these cases it would take the default value of 0. So changing the type of `getLayoutPadding` to `YGFloatOptional`, doesn't make sense.
Reviewed By: emilsjolander
Differential Revision: D7336690
fbshipit-source-id: b2a2f010026f26fc2cc9fb35ad921da8f7017c9f
Summary: Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7323382
fbshipit-source-id: 8e3eb4f3744b5f3f9e2b353f56184905f7557191
Summary: Remove the use of YGUnwrapOptional from YGConstrainedMaxSizeForMode
Reviewed By: emilsjolander
Differential Revision: D7322743
fbshipit-source-id: d825c60bcdc9ecdc0c784a215dc6b1b8a7a7860e
Summary:
This PR fixes a type mismatch on `endOfLineIndex` where it should be of type `uint32_t` while it is of type `float`
Additonally it fixes some `double` casting in the rounding methods.
Closes https://github.com/facebook/yoga/pull/745
Differential Revision: D7494519
Pulled By: emilsjolander
fbshipit-source-id: 30a86574ce163458a6888f61a902d0640c1874fb
Summary: Changed the return type of YGResolveValueMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7304090
fbshipit-source-id: cbec03a9367cf34976d083ad475d4da0b736e6d2
Summary: Move equaltiy function from utils to an operator on YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7303460
fbshipit-source-id: 41ec0076ace621ec1a5bdbab00b72eea57780fff
Summary: Change the type of aspect Ratio to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7302651
fbshipit-source-id: 53e3b4c9627207a379f927b1f3485e36a9c70601
Summary: Removes the use of YGUndefined from kYGValueAuto. Also fixed the setter and getter of dimensions. This diff also fixes a typo
Reviewed By: emilsjolander
Differential Revision: D7302453
fbshipit-source-id: e002a1ddd75bfc6fe142a7275e7913c064972e16
Summary:
This diff includes the following changes:
1 ) I extended the Java implementation of YogaNode to be able to get a full copy of a YogaNode object without copying the List of children of the original YogaNode. In other words, the new copy of the YogaNode will have the same data of the original YogaNode, but with an empty list of children.
2 ) We created a new method in Yoga.cpp called YGNodeInsertSharedChild. This new method is going to be used by Fabric in order to temporarily share a YogaNode between two "Yoga Trees" (the "current Yoga" tree and a partial "clone of the current Yoga tree"). We exposed this new functionality in the java implementation of Yoga (method addSharedChildAt)
I'm including sebmarkbage for more context.
Reviewed By: emilsjolander
Differential Revision: D7245421
fbshipit-source-id: 72578c8261f29e4a12fc6c72a91f2f891cd58d48
Summary:
In the persistent version of Yoga, a YogaNode can be shared between two YogaTrees, that means that a YogaNode could have more than one Parent at one point in time. That's why the concept of Parent of a YogaNode is not a 1-1 relationship anymore.
This diff changes the semantic of Parent of a YogaNode to Owner of a Yoga Node. CC sebmarkbage and priteshrnandgaonkar for more context.
Technically this diff renames the field YogaNode.parent to YogaNode.owner (and every internal field, Getter and Setter that is related to parent)
Note that as part of this diff I also modified the CSSLayoutDEPRECATED version of Yoga in order to keep compatibility with the C++ implementation.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7352778
fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
Summary:
We had functions for inserting/removing a specific child, but not for simply replacing the child set with another list.
`YGNodeSetChildren()` will unhook child nodes from the parent that don't appear in the new set. We set the disconnected child node layouts to `YGLayout()` b/c that's what the rest of the code does.
`YGTraversePreOrder()` walks the tree and calls a labmda for each node. We could very easily add a post-order traversal and the ability to stop traversal if we ever want, but for now this is an MVP.
Reviewed By: Woody17
Differential Revision: D7360203
fbshipit-source-id: 32df8e1213ead03bc0a026ec4bf453bc799bb9ce
Summary:
Podspec to push yoga 1.8.0 to cocoapods. There is an issue with cocoapods and it fails to lint those projects with C++ in its header, which is the case with yoga too.
Follow this thread https://github.com/CocoaPods/CocoaPods/issues/5152. To make the lint pass, one would have to change `app_target_helper.rb` cocoapod source file in the local machine. Follow my [gist](https://gist.github.com/priteshrnandgaonkar/dcca9639a3bc0a3b9adecae3a2b3b0c4).
I am able to pass the lint, but not able to push the pod in cocoapods as I am not the admin. @[759512522:emilsj], please push it on Cocoapods or give me permission.
Podspec now also exposes public header explicitly.
Reviewed By: gkassabli
Differential Revision: D7375018
fbshipit-source-id: 4e82e1c0b6340c3f8d3b8a96ecadbcb711d4bcd8
Summary: Adds an example of how to use yoga from JavaScript to the documentation pages.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7354390
fbshipit-source-id: 0dbc08e5341c06b621acd99bfb9ce7e789b67a45
Summary: These don't need to be copied twice.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291363
fbshipit-source-id: 22e606d0b3fa1133d7e0334c8cf9f5f1f32fe64b
Summary: These shouldn't be copying the arguments when they pass by value. Instead these only get copied when assigning the value to the member.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291096
fbshipit-source-id: 7a4025831811d622050adbb5f86608855b94d68e
Summary:
Earlier `YGfloatOptional` was plain struct with no privacy around the variables. This diff adds privacy and also enforces checks when one tries to access value of an undefined `YGFloatOptional`
This diff also adds a behaviour in which when a value of an undefined YGFloatOptional is accessed, it will normally terminate(Several cleanup steps are performed).
Reviewed By: emilsjolander
Differential Revision: D7288555
fbshipit-source-id: f61cc92c8fd0d48d2fc1f4d0e6fcef155f19ff8a
Summary: Fixed a typo of flexshrink and added a test case
Reviewed By: emilsjolander
Differential Revision: D7289221
fbshipit-source-id: 48ee9ccfac4adee51d515a366b5a11790f7236fc
Summary: Fix getters and setters of min and max Dimension to behave exactly the same way as it was before fast math changes
Reviewed By: emilsjolander
Differential Revision: D7274807
fbshipit-source-id: 7c1a4c19e8d0552b089a410c3330392cb26a6a47
Summary:
This diff fixes the setter and getter of margin, position, border and padding to the previous behaviour of yoga, before floatoptional change
This diff also removes the unrequired `#define`
Reviewed By: emilsjolander
Differential Revision: D7274115
fbshipit-source-id: 942a91e6562ef789ae79102a828f397889468fa7
Summary:
Earlier YGUndefined was NAN, but recently it was replaced with 10E20 and the check for `isUndefined` is as follows
```
public static boolean isUndefined(float value) {
return (Float.compare(value, (float) 10E8) >= 0 || Float.compare(value, (float) -10E8) <= 0);
}
```
If the number is in (-inf, -10E8] and [10E8, inf) then it is considered as undefined. Failing test passed values in this range, so thats why the test was failing. Current diff fixes this issue, and passes a big number which is outside the range as the result of measure function.
Reviewed By: emilsjolander
Differential Revision: D7272325
fbshipit-source-id: 81a77117c65c5dc0cec920f50f0735ec0a7433d1
Summary:
This diff exposes `shouldDiffLayoutWithoutLegacyStretchBehaviour` from YGConfig and `doesLegacyStretchFlagAffectsLayout` from YGLayout to YogaConfig and YogaNode respectively
Also added a positive test case. Didn't find the negative test case example. @[508947467:ianc] or @[759512522:emilsj], can you suggest a negative test case example.
Reviewed By: emilsjolander
Differential Revision: D7272067
fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
Summary: Remove the use of YGUndefined for default flex-basis value
Reviewed By: emilsjolander
Differential Revision: D7243924
fbshipit-source-id: 2bfaca1a5e3da40d5292a273cabf705f59c9d666
Summary: Change the type of flexShrink to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7232171
fbshipit-source-id: 3111119d3d74a7035c01132bff61b30cf44e120a
Summary: Change the type of flexGrow to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7215355
fbshipit-source-id: 1298ee332551d44e4d070169a1e4103d005c4f43
Summary: Change the type of flex to YGFloatOptional internally, but keeping the public facing API the same as before
Reviewed By: emilsjolander
Differential Revision: D7211327
fbshipit-source-id: 0d979b6ba00317317b98bbc6e63979c7f1feb2da
Summary: Changed the return type of YGResolveValue
Reviewed By: emilsjolander
Differential Revision: D7195099
fbshipit-source-id: 72c4163cd08691cf6e40df05394cc52e83b0de14
Summary: Remove the usage of YGUndefined in the default values of Border in YGStyle. In the getter of Border function, YGUndefined is used just to keep it logically consistent. The proper solution would be to change the api in `Yoga.h` to accept `YGFloatOptional`, but that would require to change lot of the code in client of this library. Will make a separate diff for that.
Reviewed By: emilsjolander
Differential Revision: D7195115
fbshipit-source-id: e635cf55ac94d8a90caef6cafce281579da2cbfc
Summary:
emilsjolander hi,
this PR solves the following common and probable layout pixel scenario:
the older code is presented for reference:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutWidth()),
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
Math.round(xOffset + node.getLayoutX()),
Math.round(yOffset + node.getLayoutY()),
Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
suppose now the following:
- `xOffset + node.getLayoutX() = 2.2`
- `node.getLayoutWidth() = 0.4` ==> `Math.round(node.getLayoutWidth()) = 0`
- `Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()) = Math.round(2.2 + 0.4) = 3`
this induces, the following measurements:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
0,
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
2,
Math.round(yOffset + node.getLayoutY()),
3,
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
the width measurement of the view is 0, while the layout is `(3 - 2 = 1)`.
my proposed solution is to measure the view the way it is now, but when layouting
I use the `#getMeasuredWidth/Height()` methods, this will stop this problem
from happening.
I also want to note that this bug happens with high probability.
Closes https://github.com/facebook/yoga/pull/712
Reviewed By: emilsjolander
Differential Revision: D7231798
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 171da519639dbecd75416a574bccc4456aa22f31
Summary: When we don't explicitly set header_namespace, we can get differing behavior between Android and iOS. Even when it is not explicitly necessary, we are going to try to enforce this properly.
Reviewed By: scottrice
Differential Revision: D7141155
fbshipit-source-id: 74d1488c3909f89ad9d6d0ee0de335b789dc2ccd
Summary:
Some files have crept into the repo with the old license header. These are usually from PRs that were opened prior to the re-licensing of the project.
Let the script run, prior to fixing the errant files. The script outputs the following:
```
PATENTS crept into some new files?
--- /dev/fd/63 2018-03-01 01:42:48.250153746 +0000
+++ /dev/fd/62 2018-03-01 01:42:48.250153746 +0000
@@ -1 +1,9 @@
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.h
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.m
+ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+ReactAndroid/src/main/java/com/facebook/react/views/text/CustomLetterSpacingSpan.java
+ReactCommon/yoga/yoga/YGLayout.cpp
+ReactCommon/yoga/yoga/YGLayout.h
+ReactCommon/yoga/yoga/YGStyle.cpp
+ReactCommon/yoga/yoga/YGStyle.h
scripts/circleci/check_license.sh
Exited with code 1
```
Fix the headers in these files and run the script again. No output, exit code 0.
Closes https://github.com/facebook/react-native/pull/18143
Reviewed By: sophiebits
Differential Revision: D7119356
Pulled By: hramos
fbshipit-source-id: d238e4d4a3ae320a2c8e625c2fa29690057a4814
Summary:
Changed NaN with large number to support `-ffast-math` compiler flag.For `-ffast-math` to work, all floating point numbers should be finite. Reason for not going with `FLT_MAX`, is that, it may cause number overflow during math operations. So thats why I opted for big number smaller than `FLT_MAX`. Earlier we used NaN, while NaN is involved in comparision the comparision operator behaves differently, it always returns false. Also operators like, fmaxf,fminf etc. have wierd beahviours. This diff takes care of those things as far as possible, and all tests are passing.
Running ./instrumentation_tests/run instrumentation_tests/com/facebook/feed/ctacoalescing:ctacoalescing --class AttachmentCallToActionSelectorBenchmarkTest --benchmark --extra-arg iterations=100 shows the perf gain of 13-15%
Reviewed By: emilsjolander
Differential Revision: D6969537
fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
Summary: removing the old `docs` folder as we are switching to `gh-pages` branch.
Reviewed By: emilsjolander
Differential Revision: D7110147
fbshipit-source-id: a27e6fc3a115f2f62b8a0dd5833d872e24698021
Summary: Tracks a Google Analytics event once the code generator is opened.
Reviewed By: emilsjolander
Differential Revision: D7097182
fbshipit-source-id: 637a96db981f5e90c9f7ce155ba8669b8dac98fa