Summary:
@public
Xcode does not like it
Reviewed By: astreet
Differential Revision: D14580168
fbshipit-source-id: 6d26b3961b45a59ef9dc977b21493e60e3cf9396
Summary:
@public
After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.
Reviewed By: pasqualeanatriello
Differential Revision: D14576815
fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
Summary:
@public
Passing primitive data via JNI is more efficient than passing objects.
Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.
Reviewed By: foghina
Differential Revision: D14576755
fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
Summary:
@public
Moving all native methods in a single class provides the benefit of not having to load native bindings eagerly when just creating config objects in the startup paths, or setting Java-only values on them.
Loading native bindings triggers additional class loads (`YogaConfig` / `YogaNode`), and can lead to problems in multi-dex scenarions.
Reviewed By: pasqualeanatriello
Differential Revision: D14560658
fbshipit-source-id: 14e31e3c3b560675b5a752a38ae75ab80a565ea1
Summary:
@public
Yoga's Java license headers were not in the correct format.
Reviewed By: muraziz
Differential Revision: D14541087
fbshipit-source-id: 5b3cff398875bd59dadeaddbb43020700ef027e2
Summary:
Added a child class of YogaNodeJNIBase which will be used to separate layout outputs transfer logic.
This change set is for adding experiment for layout outputs batching using a float array
Reviewed By: davidaurelio
Differential Revision: D14368098
fbshipit-source-id: e0f10fb61cd09ee47cf9ce41fb400f4cfb3dd795
Summary:
@public
Contexts of nodes only hold a bit mask after we got rid of weak JNI refs.
We can simply store that data in a pointer-sized unsigned int.
Here, we replace all context heap allocations with usage of the node context (`void *`) as bitmask. We also add a couple of utility operators in order to keep the code comprehensible.
Reviewed By: fabiomassimo
Differential Revision: D14425742
fbshipit-source-id: f32c2184a1f09268c39dbb8cd09ac96517339674
Summary:
Renamed class from YogaNodeJNI to YogaNodeJNIBase.
This change set is for adding experiment for layout outputs batching using a float array where we will have two separate classes which will override how layout outputs are transferred to java YogaNode object.
We needed two separate classes because having everything in one class was causing memory issues as both the individual fields for width, height etc. and float array for batching needs to be present in code.
Reviewed By: davidaurelio
Differential Revision: D14368069
fbshipit-source-id: 0e98e28c8c7a9788345ccb92b2cd0f2cd4a53525
Summary:
Upgrade mobile `BUCK` and `.bzl` files to use C++14.
Let's see what happens.
Reviewed By: mzlee
Differential Revision: D14223329
fbshipit-source-id: ff642ca017103d9415c4d7f5beaf5ded07ef7ff1
Summary:
@public
This bumps Prettier to v1.16.4
Only format source files were updated.
Reviewed By: mjesun
Differential Revision: D14454893
fbshipit-source-id: 72f9872fe764a79dbf0d9fab9bebb1456b039f2f
Summary:
Moved all layout outputs fields which are set always on yoga node java object.
This change set is for adding experiment for layout outputs batching using a float array
Reviewed By: davidaurelio
Differential Revision: D14355025
fbshipit-source-id: 371d9c49fcb631efa8a79b62f8051ba5a17c232c
Summary: These constants are used for setting bit fields so they should be in power of 2
Reviewed By: davidaurelio
Differential Revision: D14384999
fbshipit-source-id: fa1f6994c874aff7a039ca98d5947cba317fa749
Summary:
@public
Removes the configuration field to avoid weak JNI refs. It is no longer used.
Reviewed By: marco-cova
Differential Revision: D14424594
fbshipit-source-id: f0877022615a11ac5079354e0977c6893b7d58d7
Summary:
@public
Completely removes the usage of weak JNI refs.
This is great, because node allocation and deallocation no longer go through a VM-global lock to access the weak reference table.
This is also great, because we can no longer overflow that ref table.
Performance is comparable to weak refs.
Reviewed By: marco-cova
Differential Revision: D14423068
fbshipit-source-id: 62003d2d6fd971e91460a26fb3477046f26e2ba5
Summary: Turns out Xcode does not like document-level comments.
Reviewed By: SidharthGuglani
Differential Revision: D14301138
fbshipit-source-id: f515a1881daa109031963688c1556cb8ef42758f
Summary:
@public
GCC up until v7 flags our way of reading edges in `YGNodeSetStyleInputs` as unused variables. I managed to work around that by rearranging the casts a bit.
Reviewed By: SidharthGuglani
Differential Revision: D14299439
fbshipit-source-id: eec0266185504d1b790b9ef574bd4a83c0059d3a
Summary:
Push version in podspec. We will use `-SNAPSHOT` for bintray
Pull Request resolved: https://github.com/facebook/yoga/pull/865
Differential Revision: D14299474
Pulled By: davidaurelio
fbshipit-source-id: e788479677e1b3c4155a24a336e625508e085f86
Summary:
@public
Moves all Java classes used from C++ to their own header + implementation file. In `YGJNI.cpp`, we only call methods on these objects deriving from `jni::JavaClass`.
This is only a bit of cleanup, no functional change.
Reviewed By: SidharthGuglani
Differential Revision: D14261043
fbshipit-source-id: 2db1d81cb7f56a4cdc24b182b2166e1d7e24ba3c
Summary:
@public
Allows to limit the number of measure cache entries used. This is purely for experimentation.
The measure cache uses about half of every `YGNode`. Reducing its size would allow us to reduce resident memory used by Yoga.
Reviewed By: SidharthGuglani
Differential Revision: D14279027
fbshipit-source-id: e0d22138230bee7fb129c193eb6e4085de02a36e
Summary: `YGConfigContext` was using `global_ref` instances for the config, leading to the config object never being freed. Since we no longer need it after getting rid of cloning, we can make the context a pointer to a `global_ref` to the logger.
Reviewed By: SidharthGuglani
Differential Revision: D14258571
fbshipit-source-id: cce632499839a680eef00a3854f61ab74ae2a87a
Summary:
@public
Having assignment operators for `YGNode` means that existing children on the node assigned to would have to be handled somehow.
Deallocating might be incorrect. Ignoring might leak.
Here, we `delete` copy assignment, and make move assignment private (it is used in `YGNode::reset()`).
Copy and move constructors *can* be implemented. The move constructor has to take ownership of the children, while the copy constructor leaves ownership untouched. Since children are copied lazily during layout, this does not expose true value semantics. We should consider removing the copy constructor, too.
Reviewed By: SidharthGuglani
Differential Revision: D14241663
fbshipit-source-id: 39ffdb07f1028bfcf2710c0674a06cdebf3bd650
Summary: Positive tests for all style input properties using JNI batching API
Reviewed By: davidaurelio
Differential Revision: D14207552
fbshipit-source-id: b7165c2115ace67bf131c76929d37df438921bf2
Summary:
We set flags to true when setting margin, padding, border, position individually
Doing the same for batching API
Reviewed By: davidaurelio
Differential Revision: D14207550
fbshipit-source-id: ddfdcd5056bea0dd76bd6762f47e90370e26c9e1
Summary:
Added a new API `YGNodeSetLayoutStyleInputs` to pass layout style inputs from java to native code.
All the style inputs are passed in a float array in [key1, key2, value2, key3, value3a, value3b .....] format over JNI layer.
There are three types of style inputs
- do not need any value to be passed along with them like WidthAuto, HeightAuto
- need one value to be passed like Width, Height
- need two values to be passed like Margin, Padding (edge value and actual margin, padding value)
Reviewed By: davidaurelio
Differential Revision: D14166948
fbshipit-source-id: 4bea64d6a429959c3962c87e337914dcd99199fd
Summary:
We have now create a yoga node context which consists of weak reference to java yoga node object and flag which tells us whether margin, padding , border are set or not.
This flag was initially in java layer and we have moved this to native layer as it will help us with enabling the bacthing API for setting style inputs.
Reviewed By: davidaurelio
Differential Revision: D14243378
fbshipit-source-id: fed935ef18c1abf2b07e5d69d9ca79ced51699f2
Summary: We are now not setting flags when we set style inputs margin, padding, border and position on yoga node.
Reviewed By: davidaurelio
Differential Revision: D14224000
fbshipit-source-id: deef4c1ab1a60fbc4909183bc2aa59fa23939d43
Summary:
@public
Moving logic from free C functions to the C++ layer.
This will allow us to get rid of the dangerous copy / move assignment operators of `YGNode`.
Reviewed By: SidharthGuglani
Differential Revision: D14241564
fbshipit-source-id: aae9f2a7ffd23bb839f1747e4a0694578bae86ae
Summary:
@public
The cloning features of YogaNode don’t seem to be used. Let’s remove them.
Reviewed By: SidharthGuglani
Differential Revision: D14165624
fbshipit-source-id: 5b710964a4abf1b35f3bcc25b143ffc719a03cec
Summary: "Critical" or "Fast" JNI methods are enticing by their name, but carry dangers that are not trivially visible.
Reviewed By: davidaurelio
Differential Revision: D14184560
fbshipit-source-id: 89ec70f53bb2cb89ff568d8b1fe222ede86c9824
Summary:
@public
If `jni_YGNodeFree` is called while GC is running, the weak reference table lock is held by the GC, leading to deadlock.
Here, we revert the method to being a regular native method, solving that problem.
Reviewed By: SidharthGuglani
Differential Revision: D14184220
fbshipit-source-id: 2882fa10586617cea2df99550a7dd8885376d11e
Summary:
@public
`setBaseLine` was the only place where we used a capitalised *L.* Fixed here.
Reviewed By: SidharthGuglani
Differential Revision: D14152320
fbshipit-source-id: abf54fe7d6088e03775968baa8421c4bf43d6a6e
Summary:
@public
Adds the ability to opt into avoiding global weak JNI refs via `YogaConfig`.
Note that only homogeneous trees are supported, i.e. **mixing weak-ref and non-weak-ref nodes will break!**
Not using JNI refs hopefully will help with avoiding JNI reference table overflows, and will help creating trees on multiple threads, as no lock has to be acquired at any time.
Reviewed By: SidharthGuglani
Differential Revision: D14151037
fbshipit-source-id: 56d94713d39aee080d54be4cb4cdf5e3eccb473a
Summary:
@public
`YGNodeRemoveAllChildren` can be used instead of removing children of a yoga node in a loop.
Reviewed By: zats
Differential Revision: D14131679
fbshipit-source-id: 6ee31f1e288b9b161c641b5bca4f2c1156d58c38
Summary:
@public
Adds `YogaConfig#avoidGlobalJNIRefs` to control whether nodes created with a config will use weak global JNI refs. Used for experimentation.
Reviewed By: SidharthGuglani
Differential Revision: D14149982
fbshipit-source-id: c777c8b3af2167d96154db5aa6afec1476dac35b
Summary:
@public
Context-aware cloning functions are an internal Yoga feature that will be used for Yoga’s JNI code.
It will be possible to specify a context when calculating layout, which will be passed on to cloning functions. This will be a private feature.
Reviewed By: SidharthGuglani
Differential Revision: D14149470
fbshipit-source-id: 1d11106e65f9d872d10f191763da001f8d158a61
Summary:
@public
Limit child cloning to layout calculation. This also allows for mixing shared and owned children.
Rationale:
We do allow for shared children if the caller manages themselves. The single known use case is React Native.
So far, we have cloned children eagerly whenever child lists are mutated, or layout is run. This was to allow for a quick check of the owner of any first child, assuming that either *all* or *no* child of a node are shared.
For Yoga/Java, we want to get rid of global weak JNI refs, and these are also used to invoke clone callbacks. We can achieve that goal by switching to an alternative approach, passing additional data to the layout pass. This additional data has to be passed to any configured cloning callback. Therefore, it is desirable to **only call cloning functions during the layout pass.**
The obvious solution seems to be to not uphold the invariant of the first child determining shared/owned state of all siblings, and allow for a mix of shared and own children.
Reviewed By: shergin
Differential Revision: D14136223
fbshipit-source-id: 34490cfeeb2170c99d6ed1b9bdcbcedb316813af
Summary:
@public
Encapsulates node cloning within `YGConfig`.
This is necessary for allowing for context-aware cloning functions, which will ultimately allow for removal of weak global JNI references.
Reviewed By: shergin
Differential Revision: D14132608
fbshipit-source-id: 0dec114c8e172b1e34a4b7fd146c43f13c151ade
Summary:
@public
Here, we extract an abstract class from `YogaNode`, in order to allow for experimentation with different implementations.
The reason for not choosing an interface is to keep ABI compatibility for `YogaNode.create()`.
Reviewed By: pasqualeanatriello
Differential Revision: D14044990
fbshipit-source-id: f8eb246338b55f34f0401198c0655abfcb7c9f37
Summary:
@public
Switches instance creation from `new YogaNode()` to `YogaNode.create()`.
This allows for experimentation with different implementations, while maintaining API + ABI compatibility internally at FB, as well as for dependent projects in open source and elsewhere.
Reviewed By: amir-shalem
Differential Revision: D14122975
fbshipit-source-id: f194b146b7cd693dba1a7dafdf92d350e54cb179
Summary:
@public
Context-aware print functions are an internal Yoga feature that will be used for Yoga’s JNI code.
It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.
Reviewed By: SidharthGuglani
Differential Revision: D14131098
fbshipit-source-id: 7a9da307274ceccba9f7debba581b70c1ebf2c98
Summary:
@public
Removes `YGNodeGetPrintFunc`, and encapsulates node printing within `YGNode`.
This is necessary for allowing for context-aware callback functions, which will ultimately allow for removal of weak global JNI references.
On a side node, the printing logic does not seem to be well thought through: print functions print as a side effect to whatever output they choose. Printing that uses callbacks is printing to different output streams or strings, though.
We need to consolidate Yoga debugging, and make it all more stringent.
Reviewed By: SidharthGuglani
Differential Revision: D14131024
fbshipit-source-id: 68704682dab3e7dfba61930bb03003d7d4723b80
Summary:
publc
Adds the ability to calculate layout with a context pointer set.
The context is passed through to measure and baseline functions of individual nodes.
This will be used to remove the necessity of holding weak global JNI references for each node.
Reviewed By: SidharthGuglani
Differential Revision: D14101426
fbshipit-source-id: 25047e1e44af48feb22ea686285d70803e8961bb
Summary:
@public
Context-aware measure and baseline functions are an internal Yoga feature that will be used for Yoga’s JNI code.
It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.
Reviewed By: SidharthGuglani
Differential Revision: D14100509
fbshipit-source-id: acf4a030549b2e38d5ce0cd5dbe837864e5ffd81
Summary:
@public
Stricter encapsulation of baseline and measure callbacks withing `YGNode`.
Instead of invoking these callbacks directly (`node->getBaseline()(...)`), they are invoked via methods on `YGNode` (`node->baseline(...)`).
This change will allow us to add the concept of a *Layout Context,* where measure and baseline functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows.
Changed API:
- `YGNodeGetMeasureFunc()` -> `YGNodeHasMeasureFunc()`
- `YGNodeGetBaselineFunc()` -> `YGNodeHasBaselineFunc()`
- `YGNode::getMeasure()` -> `YGNode::hasMeasureFunc()` + `YGNode::measure()`
- `YGNpde::getBaseline()` -> `YGNode::hasBaselineFunc()` + `YGNode::baseline()`
Reviewed By: SidharthGuglani
Differential Revision: D14099550
fbshipit-source-id: 2653ab36acc252a9747986bc88d21dac22d8c91b
Summary:
@public
Context-aware logging functions are an internal Yoga feature that will be used for Yoga’s JNI code.
It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.
Reviewed By: SidharthGuglani
Differential Revision: D14123482
fbshipit-source-id: 8ba3b6c493bf79fe09831f22d2b6da44f09e3d95
Summary:
@public
Stricter encapsulation of logging callbacks within `YGConfig`.
Instead of invoking the logging callback directly (`node->logger(...)`), callers now have to go through `YGConfig::log()`.
This change will allow us to add the concept of a *Layout Context,* where logging functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows.
Changed API:
- `YGConfig::logger()` -> `YGConfig::log()`
Reviewed By: SidharthGuglani
Differential Revision: D14123483
fbshipit-source-id: 87b8bb7de0e4346b6a41e57a70ac4eb8d79b24af
Summary:
@public
Makes logging implementation internal to Yoga.
Breaking changes: removed `YGLog` and `YGLogWithConfig`.
The upcoming changes to the JNI layer (removal of weak global refs for each node) requires adding additional parameters to the logging functions that will only be available when calculating layout.
Reviewed By: SidharthGuglani
Differential Revision: D14123390
fbshipit-source-id: 468e4a240c190342868ffbb5f8beb92324cdfdd6
Summary:
Hello! Just found some typos on the docs. Fixing them here :)
Pull Request resolved: https://github.com/facebook/yoga/pull/784
Reviewed By: davidaurelio
Differential Revision: D14100968
Pulled By: SidharthGuglani
fbshipit-source-id: 1462216a0d5315075871f2fb11b6b1279ae0097a
Summary: Adds the `-SNAPSHOT` specifier back to the version number in `gradle.properties`
Reviewed By: SidharthGuglani
Differential Revision: D14123308
fbshipit-source-id: e5d4c4dd9552557dc42440f0892c1452dd0195a5
Summary:
Adds a factory method to `YogaNode`.
While this is purely redundant at the moment, it will allow experimentation in follow-up diffs. We will have concrete implementations deriving from `YogaNode` (which will be abstract).
Going through `YogaNode.create()` means that we can maintain ABI compatibility.
Reviewed By: amir-shalem
Differential Revision: D14122974
fbshipit-source-id: 15d92f296d91cc8bbd79a196f370d2dbb69b3f92
Summary: Upgraded gradle build tool version to 3.1.0 to solve issue "No toolchains found in the NDK toolchains folder for ABI with prefix: mips-linux-android"
Reviewed By: davidaurelio
Differential Revision: D14042022
fbshipit-source-id: c615127fa296f30f589b183bffc8f2a95f7b943b
Summary:
Our OSS build was failing with the latest version of cocoapods(1.6.0). The reason was that the `post_install` script of adding a `SWIFT_VERSION` was not getting applied while building the project. So I added a `swift_version` in the YogaKit pod itself. So with this change we no longer need the `post_install` script to add `SWIFT_VERSION`.
I have also released a new version of YogaKit(1.10.0) on the CocoaPods. Usually the swift pods should specify the swift_version which is being used to develop it.Due to unknown reason, it was never mentioned in the podspec.
Reviewed By: jknoxville
Differential Revision: D13990363
fbshipit-source-id: 3c2f814765c03683fbedd17b3607ff0e6cdef566
Summary:
@public
Makes it work nicely with gtest.
Also allows rhs *and* lhs to offer `operator(YGStyle)()`.
Reviewed By: SidharthGuglani
Differential Revision: D13942573
fbshipit-source-id: ff8b3a9aa6f05ca1b0572eb97d0ad23b09d77871
Summary:
@public
Adds `_pt` and `_percent` user defined literals to create `YGValue` instances.
This allows to create `YGValue`s in the following form:
```
use namespace facebook::yoga::literals;
auto a = 123_pt; // == YGValue{123.0f, YGUnitPoint}
auto b = -12.5_percent; // == YGValue{-12.5f, YGUnitPercent}
```
Reviewed By: SidharthGuglani
Differential Revision: D13942100
fbshipit-source-id: ce1e2f9431c3e2a99c6e11896a712539cc535e0d
Summary:
Currently the CocoaPod for Yoga explicitly states platform requirements.
Since the Yoga implementation doesn't depend on any platform features, it would be safe to build it on any platform.
That can be configured by omitting the `platform`/`platforms` key:
> The platform on which this Pod is supported. Leaving this blank means the Pod is supported on all platforms.
>
> http://guides.cocoapods.org/syntax/podspec.html#platform
Among others, that would allow to use the pod in macOS projects
Pull Request resolved: https://github.com/facebook/yoga/pull/821
Reviewed By: passy
Differential Revision: D13848153
Pulled By: davidaurelio
fbshipit-source-id: 5a3e81d81ca97b120f2711bafd3c8b9e0c3f8088
Summary:
Specifically, updates the UWP .vcxproj for MSBuild and also exposes the UseLegacyStretchBehaviour API for use with react-native-windows.
Pull Request resolved: https://github.com/facebook/yoga/pull/848
Reviewed By: SidharthGuglani
Differential Revision: D13848609
Pulled By: davidaurelio
fbshipit-source-id: eab046ff3c47e49706f515e209d8aaf750c2198f
Summary:
Yoga currently has the concept of a 'dirtied func', which is called when a Node becomes dirty, which can be useful to trigger a repaint. This PR exposes that functionality in the Javascript bindings.
Pull Request resolved: https://github.com/facebook/yoga/pull/842
Reviewed By: SidharthGuglani
Differential Revision: D13847093
Pulled By: davidaurelio
fbshipit-source-id: 41913abd6eedc46ee7d66929140e08a084f23972
Summary:
@public
Extends `InstrumentationTest` with the ability to record more than one marker.
Instead of overwriting any previously recorder marker, we collect them in a `std::deque`.
`std::deque` was chosen, because it keeps pointers to elements stable.
Reviewed By: SidharthGuglani
Differential Revision: D13880777
fbshipit-source-id: f6f6606ac8625bdd90c06459fdb967c3478265e7
Summary:
Github and fbsource got out of sync, we have a PR to fix this: https://github.com/facebook/yoga/pull/843
This updates the internal-only file to match the PR, so that we can merge it without hassle.
Reviewed By: cuva
Differential Revision: D13879526
fbshipit-source-id: f83115617e580e118a5f4e0f37e877db38a8fcac
Summary:
@public
Adds the maximum number of measure cache entries in use to the metrics for `YGMarkerLayout`
Reviewed By: SidharthGuglani
Differential Revision: D13844731
fbshipit-source-id: fa66dbf1b7a1799494f72ecc17dfaef04d0b56e4
Summary:
@public
Evolves setup and helpers in `InstrumentationTest` to avoid repetition across test cases, and allow for more readable test by hiding default values where they don’t matter.
Reviewed By: SidharthGuglani
Differential Revision: D13839521
fbshipit-source-id: 7f7ad49fec84e0bbb09ad746dd8c28bd34de25b2
Summary:
@public
Adds marker meta data to `YGMarkerLayout`: the number of measures, and the numbers of layouts for all nodes in the tree.
Reviewed By: SidharthGuglani
Differential Revision: D13838975
fbshipit-source-id: d575c26a3d5a4f0b66834eb6bedecadc3f3ca265
Summary:
pubic
Passes layout marker data through the recursive calls of the layout algorithm, in order to allow for collecting metrics.
Reviewed By: SidharthGuglani
Differential Revision: D13819444
fbshipit-source-id: cdca04964fba6a03ca3eeaca4d169107019ba457
Summary:
@public
Adds a class for triggering markers.
This calls `startMarker()` on construction, and `endMarker()` on destruction, thus being usable like a "scope guard": the object is instantiated, and automatically destroyed when going out of scope.
Reviewed By: SidharthGuglani
Differential Revision: D13817589
fbshipit-source-id: fd88884af970c1c0933d9ca6843f3f8f5d28b9e6
Summary:
@public
Removes unused constexpr variables from YGStyle. Not polluting the global namespace is a good thing.
Reviewed By: SidharthGuglani
Differential Revision: D13816817
fbshipit-source-id: e4c27a8f2de466ccb759bbe52cdaea6fe451b961
Summary:
@public
Adds a function to allow to configure markers. The function is declared in `YGMarker.h`
Reviewed By: SidharthGuglani
Differential Revision: D13819111
fbshipit-source-id: f9158b3d4e5727da4e151c84b523c7c7e8158620
Summary: @public adds a first `YGMarker`, and the accompanying data type.
Reviewed By: SidharthGuglani
Differential Revision: D13817588
fbshipit-source-id: 6007eb09d19cf4021989bad5b5e880adb16364a0
Summary:
@public
this will lead to nicer enum member names.
Reviewed By: SidharthGuglani
Differential Revision: D13817587
fbshipit-source-id: 85355328f7977b4fb29a9474532f2d578a3cbf79
Summary:
@public
Removes `YGNodeInsertSharedChild` / `addSharedChildAt`.
This functionality is unused, and can cause memory leaks.
Reviewed By: SidharthGuglani
Differential Revision: D13711105
fbshipit-source-id: 86206c05393b3f1a497e6b046006f94ead88c6ce
Summary: Make the libfb jni code to be compatible with gcc7 compiler
Reviewed By: davidaurelio
Differential Revision: D13711390
fbshipit-source-id: 9a378a3ee4feb7e928dd97dae7d79a41f0658992
Summary:
After this diff D13403925 that got rid of `-ffast-math` we started to have a very odd behavior on Yoga when using release builds.
After digging a while we found that certain set of conditions on O2 and O3 optimization levels was causing Origami to set some `INFINITE` values on Yoga.
We found the root of the problem and fix it on Origami side. But I'm wondering if guarding agains `INFINITE` on Yoga side would be good too. Since now Yoga it's not using `-ffast-math` anymore, and I think infinite is not a a valid value anywhere on Yoga side, it seems to support the reason to guard against it.
I'm happy to abandon this diff if you guys think this is not a good solution.
Reviewed By: davidaurelio
Differential Revision: D13679319
fbshipit-source-id: 061448fea9d1a8496362ff07dc46b546e7f1ffa3
Summary:
@public
Repeated application and alternation of Clang Format rules has lead to unfortunate block comment formatting.
Here, we reflow comments
Reviewed By: SidharthGuglani
Differential Revision: D13677242
fbshipit-source-id: 3f1f5e38693eb15e9705f24fd363fc1618c78974
Summary:
@public
These URLs probably have been changed when CSSLayout was renamed to Yoga by search & replacing
Reviewed By: SidharthGuglani
Differential Revision: D13690829
fbshipit-source-id: 44dbd8fe256fc286006d164390609a7c3de6c4e6
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.
Same as D13597449, working around a defect in clang < 3.9
Reviewed By: amir-shalem
Differential Revision: D13634622
fbshipit-source-id: 344dc70e167b0caf746fe396cedd200f54e52219
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.
Reviewed By: shergin
Differential Revision: D13597449
fbshipit-source-id: edcee225ada4058e94f3a727246763e3cc45873d
Summary:
@public
Wraps enum definition in a single macro.
Down the line, this will allow us to add more functionality:
- Replace manual counts with `yoga::enums::count<YG...>()`
- `yoga::enums::max<YG...>()`
- A bitfield implementation with known memory layout using `max<>()`
Reviewed By: SidharthGuglani
Differential Revision: D13597259
fbshipit-source-id: 543a11a53090bedf1474d00328565ed57d059e23
Summary: Using default logger in test case
Reviewed By: davidaurelio
Differential Revision: D13565071
fbshipit-source-id: 93cee223a7f366e3e965fde2d5cdc7d4b27e310f
Summary:
@public
Previously untested. Allows us to ship with more confidence
Reviewed By: SidharthGuglani
Differential Revision: D13534350
fbshipit-source-id: a2e7577befdeeb7a27148e16624eeb7a347efd87
Summary:
@public
Adds test for the `hasNewLayout()` and `markLayoutSeen()` methods of `YogaNode`. The behavior of these methods wasn't previously covered by a test. This will allow us to change the implementation with confidence.
Reviewed By: SidharthGuglani
Differential Revision: D13534351
fbshipit-source-id: 23a9f9b70df18fd7c34023fd77b9df9fbd733f61
Summary:
@public
Further heap size reductions by using bitfields in `YGLayout` and `YGNode`.
Reviewed By: SidharthGuglani
Differential Revision: D13466325
fbshipit-source-id: ddcef0a1b3822e7449fe485d99c920d54139c893
Summary:
@public
Switches the storage in `facebook::yoga::detail::Values` from `YGValue` to `facebook::yoga::detail::CompactValue`.
This cuts heap size for arrays of values in half.
Reviewed By: SidharthGuglani
Differential Revision: D13465586
fbshipit-source-id: 49a4d6d29a73bdd44843b1f3c57bf746050c94d6
Summary:
@public
When switching to `CompactValue`, casting edges or dimensions to `std::array<YGValue, ...>` will do actual work.
In order to avoid that from happening implicitely, we remove the casting operator.
Reviewed By: SidharthGuglani
Differential Revision: D13464292
fbshipit-source-id: 217065b001a63cfa8adde715063682c583007a4d
Summary:
@public
Enforce more encapsulation of arrays of `YGValue` in `YGSty;e`.
This will allow us to use `CompactValue` in `YGStyle` while (mostly) retaining API compatibility.
Reviewed By: SidharthGuglani
Differential Revision: D13452042
fbshipit-source-id: 382b1c7245c4bea4280126ab1413e7e931b62eaa
Summary:
@public
`CompactValue` represents a `YGValue` in 32bits instead of 64. This comes at the cost of a range limitation, as one exponent bit is borrowed for the unit.
*Undefined* and *Auto* have no magnitude, and are represented as *NaN* values.
The data structure is meant to be used as a field type on `YGStyle` to save memory.
This is header-only for efficient inlining.
Reviewed By: jackerghan, aCorrado
Differential Revision: D13187211
fbshipit-source-id: 16e3ffad592e38e2493e4f7c8b952d372e449846
Summary:
@public
removes the `default` case from an already exhaustive switch.
Reviewed By: SidharthGuglani
Differential Revision: D13451869
fbshipit-source-id: 32727330c7fce013963f5c83c95a73b230d5c938
Summary:
@public
Replaces the `StyleProp` template with a simple setter macro / inlined getter code.
The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.
Reviewed By: SidharthGuglani
Differential Revision: D13439612
fbshipit-source-id: 36f6a86917d035be6891cb736d1f288d8e02f5cf
Summary:
@public
`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.
Reviewed By: SidharthGuglani
Differential Revision: D13439603
fbshipit-source-id: e12539ad5b3cccbd5bc27869866ca66c023b24a7
Summary:
@public
Replace `YGFloatOptional::getValue()` with `YGFloatOptional::unwrap()`.
`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.
Here, we eliminate the method, and just call `.unwrap()` everywhere.
Reviewed By: shergin
Differential Revision: D13439608
fbshipit-source-id: 5ae82b170537d0a10c301412567a7a66fd50bab4
Summary:
Replaces `YGUnwrapFloatOptional` with `YGFloatOptional::unwrap`.
This leads to more idiomatic C++, and to less function call nesting, thus increasing readability.
Reviewed By: SidharthGuglani
Differential Revision: D13439604
fbshipit-source-id: 33b43c08d725c253c359959e7cbbd83fd6bd9ba4
Summary:
@public
After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.
Reviewed By: SidharthGuglani
Differential Revision: D13439611
fbshipit-source-id: 93e90f72f0415edb228b4e7d145e1fae35cc6b43
Summary:
@public
Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.
Also fixes the incorrect definition of NAN.
Reviewed By: SidharthGuglani
Differential Revision: D13439602
fbshipit-source-id: 68eef2c391b6c9810f3c995b86fff7204ebe6511
Summary:
@public
`-ffast-math` does not have measurable performance benefits.
By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.
Reviewed By: astreet
Differential Revision: D13403925
fbshipit-source-id: b13d026bf556f24ab4699e65fb450af13a70961b
Summary:
I've noticed that when a child's size is determined by `align-items: stretch` in combination with `aspect-ratio` its size is wrongly calculated to account for margin in the main axis when there is more than enough space.
See playground: https://goo.gl/tgW6cD
I've yet to figure out exactly how to solve this but i've started by writing a failing test when can be seen in the first commit here.
I assumed I had found the bug here https://github.com/facebook/yoga/blob/master/yoga/Yoga.cpp#L1838 where margin is being subtracted from the desired width even though the measure mode tells it to measure to exactly that size. However, if we don't remove this margin from the available width then 15 tests fail (including the one I just added) not quite figured out why yet. I'm also a bit confused at to why this would only happen for nodes with `aspect-ratio` and not for nodes where an explicit height and width is set.
Pull Request resolved: https://github.com/facebook/yoga/pull/834
Reviewed By: astreet
Differential Revision: D13223579
Pulled By: davidaurelio
fbshipit-source-id: 6970e6072e79f3bb6f9097355ab6e441441bfd88
Summary:
@public
Replaces the `StyleProp` template with a simple setter macro / inlined getter code.
The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.
Reviewed By: SidharthGuglani
Differential Revision: D13233687
fbshipit-source-id: 218a7d5edb489b43a66c8c9d6156f74feefd2227
Summary:
@public
`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.
Reviewed By: SidharthGuglani
Differential Revision: D13209150
fbshipit-source-id: c7b937a640258256c97e082ba2f832754e191b9a
Summary:
@public
`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.
That forces `x.isUndefined() ? fallback : x.getValue()` as access pattern.
Here, we replace that by introducing `YGFloatOptional::orElse(float)` which encapsulates that pattern. Other additions are `orElseGet([] { … })` and some extra operators.
Reviewed By: SidharthGuglani
Differential Revision: D13209152
fbshipit-source-id: 4e5deceaaaaf8eaed44846a8c152cc8b235e815c
Summary:
@public
After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.
Reviewed By: SidharthGuglani
Differential Revision: D13209157
fbshipit-source-id: 21b83c837a78f924a4ec23a9236ca2440b3c8606
Summary:
@public
Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.
Also fixes the incorrect definition of NAN.
Reviewed By: SidharthGuglani
Differential Revision: D13172444
fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
Summary:
@public
`-ffast-math` does not have measurable performance benefits.
By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.
Reviewed By: SidharthGuglani
Differential Revision: D13119110
fbshipit-source-id: 4e6964240bf74ebc22d8783107b89d536a1a0842
Summary:
@public
This file shouldn’t be here
Reviewed By: SidharthGuglani
Differential Revision: D13255658
fbshipit-source-id: 1b40ab674bbf451d04797516a24c3bd2fef7222d
Summary: Found and fixed typo on https://yogalayout.com/docs/justify-content/
Reviewed By: danielbuechele
Differential Revision: D13199988
fbshipit-source-id: 029cf812f09c48822ec11b054bf0c987f718191d
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed
Reviewed By: davidaurelio
Differential Revision: D13147742
fbshipit-source-id: 3bbff1cfceeadfbf77380519e4638f2984fc2009
Summary:
@public
Adds types for a marker API in Yoga.
This will allow us to register callbacks that Yoga can use to log performance data without hard-coding the backend system for that.
Reviewed By: SidharthGuglani
Differential Revision: D13118830
fbshipit-source-id: b42a42c609f0cf66212186f7f20ee572522d59e3
Summary:
@public
`YGNodeComputeFlexBasisForChildren` was using an output parameter (`float&`) that is always initialised to `0.0f`.
Here, we move the initialisation inside `YGNodeComputeFlexBasisForChildren`, and simply return the result.
Reviewed By: astreet
Differential Revision: D13167509
fbshipit-source-id: cbea20e2deb82ec75a1c158b16c94f4a3e5e4c99
Summary:
@public
passes all enum values by value, not by reference.
Reviewed By: astreet
Differential Revision: D13156390
fbshipit-source-id: 56aea66c16ab3325594f67b9017afa18a678d281
Summary:
@public
Remove ability to configure Yoga to run with/without JNI fast calls on dalvik / art.
This switches to always run with fast calls.
Reviewed By: astreet
Differential Revision: D13144652
fbshipit-source-id: 091aab0cd1290d46346323d3e26a11dd0bb17187
Summary:
@public
Passes all `float`, `bool`, etc. by value, not by reference.
Reviewed By: astreet
Differential Revision: D13153500
fbshipit-source-id: 95529bc2efcff144044e2c25087915b2b7ede179
Summary:
Add getUndefined() method to obtain the undefined value.
This would allow to obtain the Yoga undefined value in runtime, and not just in compile time
Reviewed By: davidaurelio
Differential Revision: D13136972
fbshipit-source-id: aa198aa1ea65bb6b7302abeba6f9f5d483a45ff3
Summary:
@public
Restores the yearless format of the MIT license.
Reviewed By: SidharthGuglani
Differential Revision: D13082510
fbshipit-source-id: f5a849b06652cedf68547d4a7963398b2627915f
Summary:
@public
We added a functionality using which child node can tell parent node to use it as a reference baseline.
Added some tests for java, csharp, javascript language bindings.
Reviewed By: davidaurelio
Differential Revision: D12997442
fbshipit-source-id: 4717167d2b3862bf2af87b663bda82f9c1eae33e
Summary:
@public
Currently only parent can tell the layout to align its children based on baseline. But if one of the children is a column or row then basealign does not work as expected.
We have added an api setReferenceBaseline which when set to true would mean that it's baseline would be considered as the reference baseline for parent amongst its siblings. If there are more than one siblings with referenceBaseline set, the first one would be considered.
Reviewed By: davidaurelio
Differential Revision: D12883323
fbshipit-source-id: 19beccfc47d98bb38f81f5b66ba764e83680f821
Summary:
Yoga's JNI bindings are usually loaded during class loading, and can stall the UI thread.
Here, we try to mitigate the problem by adding the bindings to libcoldstart.
Reviewed By: michalgr
Differential Revision: D12956818
fbshipit-source-id: 9dda5cb6d26c2bae64606bc2d7c98ab8f7c05a30
Summary:
OS: Arch Linux
GCC Version: gcc (GCC) 8.2.1 20180831
Clang Version: 6.0.1 (tags/RELEASE_601/final)
Build Log Before Fix:
command: `buck build //:yoga`
```
Not using buckd because watchman isn't installed.
yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’:
yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess]
memset(&(node->getLayout()), 0, sizeof(YGLayout));
^
In file included from yoga/YGNode.h:11,
from yoga/Utils.h:9,
from yoga/Yoga.cpp:13:
yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here
struct YGLayout {
^~~~~~~~
cc1plus: all warnings being treated as errors
Build failed: Command failed with exit code 1.
stderr: yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’:
yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess]
memset(&(node->getLayout()), 0, sizeof(YGLayout));
^
In file included from yoga/YGNode.h:11,
from yoga/Utils.h:9,
from yoga/Yoga.cpp:13:
yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here
struct YGLayout {
^~~~~~~~
cc1plus: all warnings being treated as errors
When running <c++ preprocess_and_compile>.
When building rule //:yoga#compile-Yoga.cpp.o9b5477b5,default.
Parsing buck files: finished in 0.8 sec (100%)
Building: finished in 2.2 sec (100%) 10/10 jobs, 1 updated
Total time: 3.3 sec
```
Build Log After Fix
command: `buck build //:yoga`
```
Not using buckd because watchman isn't installed.
Parsing buck files: finished in 0.8 sec (100%)
Building: finished in 0.6 sec (100%) 1/1 jobs, 0 updated
Total time: 1.6 sec
```
All tests are passing
Pull Request resolved: https://github.com/facebook/yoga/pull/823
Reviewed By: davidaurelio
Differential Revision: D10486023
Pulled By: passy
fbshipit-source-id: e9de734c3ce6c45ea4a8edd5d78206901d85ca84
Summary:
@public
`flex_shrink_flex_grow_row` and `flex_shrink_flex_grow_child_flex_shrink_other_child` tests were present in YGFlexTest.cpp.
When running ruby script to generate tests, these were getting removed since they were not added in YGFlexTest.html using which tests are generated.
This diff adds tests in YGFlexTest.html and contains corresponding generated test cases for different languages.
Reviewed By: priteshrnandgaonkar
Differential Revision: D12838701
fbshipit-source-id: 5e92716d94fa392230db2c0ec3b8c131a089c55a
Summary:
@public
gentest.rb script generates tests in different languages cpp, java, csharp, js from html files.
Some tests were missing from csharp, java and js test files. This diff adds those in all the test files
Reviewed By: priteshrnandgaonkar
Differential Revision: D10853971
fbshipit-source-id: 11d7cee5889dd1f5a7440f6802fca78cea17aa4d
Summary:
@public
Our tests were manually parametrized, without adding the necessary code to the test case generation script.
This commit makes the necessary changes so that test generation won’t overwrite the parametrization.
Reviewed By: davidaurelio
Differential Revision: D10853163
fbshipit-source-id: b5e41755df16a6a296cf2061fbb89c3f27f8574d
Summary:
@public
We have changed Yoga’s license to a yearless format, but this was not reflected in the test generation script.
This commit changes the corresponding template/.
Reviewed By: davidaurelio
Differential Revision: D10852787
fbshipit-source-id: 0b79e253be6174a218f9dc8de942fc2496a425c8
Summary:
The current snapshot version is not in line with the standard versioning
scheme.
Tried to export this as PR first, but GitHub is having a day.
Reviewed By: muraziz
Differential Revision: D10486037
fbshipit-source-id: d5b08bd5dd2a7d382681ee198e040451a1c2aa11
Summary:
`extern "C"` disables name mangling, hence input parameter types does not influence the name. That makes it impossible to have several equality operators with `extern "C"` linkage (for different types).
One such operator is defined in Windows SDK, in `guiddef.h`. It in turn is included in `winnt.h` inside `extern "C" { ... }` block. Trying to compile file which both is dependent both on `winnt.h` and `Yoga.h` results in:
```
Yoga.h(50): error C2733: 'operator ==': second C linkage of overloaded function not allowed
guiddef.h(192): note: see declaration of 'operator =='
```
In general it doesn't make much sense to have cpp specific operator to have `extern "C"` linkage, so the change doesn't introduce any controlling flag (mangling on/off).
Note that it's breaking binary compatibility and yoga library should be rebuilt if those operators are used.
Reviewed By: milend
Differential Revision: D10418395
fbshipit-source-id: 2f1cccff26165e638b9a07eece07d94fccfa5e5a
Summary:
Fixes#815
Imagine a node with this style: `{ paddingHorizontal: 10, paddingStart: 0 }`.
After running layout on this node, we expect its computed `paddingStart` to be `0`. However, it is actually `10`.
Consider the expression `paddingEdgeStart.getValue() > 0.0f` in [`getLeadingPadding`](328ec7dc4d/yoga/YGNode.cpp (L461)). Why is `0` handled like a negative number rather than a positive number? I suspect this should be `>=` so `0` is handled like the positive numbers (this is how `getTrailingPadding` works).
It looks like 3a82d2b1a8 (diff-07b4949bf42749fde386e769ff08a124) changed the operator from `>=` to `>` in `getLeadingPadding`. I suspect it was a mistake. `getTrailingPadding` still uses `>=`.
I manually verified this using the code in #815 and added some unit tests to catch this bug and other similar issues.
Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/816
Reviewed By: priteshrnandgaonkar
Differential Revision: D10282617
Pulled By: shergin
fbshipit-source-id: 2ab2874ae39d9454308a020a960ace85573fe777
Summary:
Fixes#606.
If there are no subviews in `UIView`, yoga assumes that `sizeThatFits:` returns `CGSizeZero`. However, according to [the documentation](https://developer.apple.com/documentation/uikit/uiview/1622625-sizethatfits), `UIView` returns current size if there are no subviews.
This diff adds a check - if there are no subviews, `sizeThatFits:` doesn't get called, and CGSizeZero is returned.
Pull Request resolved: https://github.com/facebook/yoga/pull/610
Reviewed By: davidaurelio
Differential Revision: D6807406
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 9189cf14c393f840122bc365d3827881bf03548c
Summary:
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example:
```
YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0
```
However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`.
There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works.
A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see https://github.com/facebook/yoga/issues/824.
Fixes#824
Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/825
Reviewed By: priteshrnandgaonkar
Differential Revision: D10282064
Pulled By: shergin
fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
Summary:
This consists of several fixes:
- Some of the C++ functions called by the tests were missing `WIN_EXPORT`
- It looks like Yoga was changed to round up after `TestMeasureFuncWithFloat` was written. Here's the function call that results in the rounding: 357ca78f9f/yoga/Yoga.cpp (L4019-L4026)
- The format of the result of the `Print` method was changed after `TestPrint` was written.
Pull Request resolved: https://github.com/facebook/yoga/pull/818
Differential Revision: D10282902
Pulled By: shergin
fbshipit-source-id: a5fd732a7dbff1a704cbafbfc95ae3e0c0a0cdd8
Summary:
This PR is the C# version of 3a82d2b1a8
The above change moved Yoga away from NaN to facilitate usage of the `-ffast-math` compiler flag. However, that commit forgot to update the C# implementation.
Pull Request resolved: https://github.com/facebook/yoga/pull/817
Differential Revision: D10282642
Pulled By: shergin
fbshipit-source-id: 51681ce12344bc421f346ccc30e2950f4f39dbc6
Summary:
Updated the build number.
Removed armeabi from build.gradle, as gradle was complaining that it doesn't support armeabi.
Reviewed By: passy
Differential Revision: D10145261
fbshipit-source-id: ab04e2d709cb6faf8bce02a53b7c865c342edefe
Summary: While releasing android yoga release, gradle compained that armeabi is not supported, thus removing it
Reviewed By: passy
Differential Revision: D10194155
fbshipit-source-id: ddb03ae0fe41d5b338c9207ac066090f7e7748a9
Summary:
Changes all possible native JNI methods to critical methods.
For now, this only changes Android up and including v7. In order to be prepared for the `CriticalNative` annotation in Android v8, the following restrictions apply:
- Qualifying methods must be static (this is also enforced for Dalvik / Android v4)
- Method implementations can only consume primitive JNI types (`boolean`, jchar`, etc.)
Reviewed By: priteshrnandgaonkar
Differential Revision: D9943868
fbshipit-source-id: 728817eb37822b717fd3daf94cd9f02b42c17db6
Summary:
Moves binding of native methods into a separate native method that can be parameterized.
This will be used to experiment with JNI-related technology.
Reviewed By: priteshrnandgaonkar
Differential Revision: D9943870
fbshipit-source-id: 661f15537d5bbf7a3eef7717e3d99fed2de23904
Summary: This change drops the year from the copyright headers and the LICENSE file.
Reviewed By: yungsters
Differential Revision: D9727774
fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
Summary: Unused loads hurt readability and take time to process.
Reviewed By: hramos
Differential Revision: D9494120
fbshipit-source-id: 455b56efadab1cb976344cffcb427772bfda2f71
Summary: Exposes a bool in the config which will help log the yoga hierarchy. Also added a test case
Reviewed By: IanChilds
Differential Revision: D9560577
fbshipit-source-id: ef4998107ed51ea374853bab7cbe09e3232caa0c
Summary:
This diff fixes the height calculation logic for the nodes with baseline. Before height calculation for baseline was done at wrong place.
The task was created due to the regression caused by D9219678.
Reviewed By: IanChilds
Differential Revision: D9421551
fbshipit-source-id: 3fbb738314130b346c4186ec45d00c9ea63bc9f4
Summary:
This diff updates the logic which reassigns `remainingFreeSpace` when the node's calculated dimension falls below min width of the node.
So we will have to update the `remainingFreeSpace` as there is more available space since the calculated nodes width is less than the min width.
I have also added comments at relevant places in the code so that it is clearer.
This diff solves the issue raised in litho support grp. The details can be found here T32199608. This diff also makes sure that it doesn't break fblite, as the earlier version broke it, details of which can be found here T32881750.
Reviewed By: IanChilds
Differential Revision: D9359026
fbshipit-source-id: 4168e385e962c168a9de9370220c75f14a6726a7
Summary:
Aliases `std::array<YGValue, 2>` as `YGStyle::Dimensions` for increased readability.
This prepares a follow up, where the alias is used in `Yoga.cpp`.
Reviewed By: astreet
Differential Revision: D8874566
fbshipit-source-id: a7a7a1b02bff547d7d6b800c522c4785a62ad611
Summary:
Prior to this diff, if parents height was not set then the height of parent was deduced as max of childrens height(considering line ht, padding, margin etc. ), but it didn't consider the baseline scenario where the previous logic will fail as then the parents height will be determined by the space taken by children above and below the reference baseline. I added a test case for the same.
Look at the diff D9088051 which shows the screenshot of the bug.
It is solved to https://pxl.cl/gvVk
Reviewed By: dsyang
Differential Revision: D9219678
fbshipit-source-id: f4a0b9f1452c33e78bd8c6cf39f6fcf538a04074
Summary:
Removed the faulty calculation of `remainingFreeSpace` from the code. `remainingFreeSpace` already had the correct value that special condition was not required.
Also added a test case for this issue
Reviewed By: IanChilds
Differential Revision: D9286928
fbshipit-source-id: 915269602cda2cc4515e6eab8184b2ea98d3e6d4
Summary:
@public
Replaces local references to `YGStyle` objects, and assignment to `YGValue` members with direct assignment from temporaries.
This should increase readability, and eliminate duplicated checks for *undefined* values.
Reviewed By: astreet
Differential Revision: D9083531
fbshipit-source-id: 11386be465352f5cb167b8195b7da432d0055d6f
Summary:
@public
`YGNode.getStyle()` returns a reference to the enclosed `YGStyle` member. Assigning to a local copies unnecessarily.
Having eliminated the copy, we can also safely remove calls to `YGNode.setStyle()`, eliminating another copy.
Reviewed By: astreet
Differential Revision: D9083336
fbshipit-source-id: df8b603b5cc0b974cf5dd434c71956be4548e583
Summary:
@public
This reverts the Yoga/Java storage experiment. I will follow up with any learnings.
Reviewed By: pasqualeanatriello
Differential Revision: D9168405
fbshipit-source-id: fb227fb9353bd4c4e3bebbe9b04eec1132e532e8
Summary:
@public
Adds another version of property storage for `YogaNode`, using `sun.misc.Unsafe`.
Adopts the stub concept from Litho for `Unsafe`, as it is hidden by the Android SDK.
Reviewed By: pasqualeanatriello
Differential Revision: D9140103
fbshipit-source-id: a4b376eca341b724a00f873467ae8bf8eaac69f4
Summary:
Fix the `Werror` failures and update JUnit to 4.12 as we're making use of `Parameterized` features which aren't available in whichever version we have here.
Pull Request resolved: https://github.com/facebook/yoga/pull/800
Reviewed By: jknoxville
Differential Revision: D9132106
Pulled By: passy
fbshipit-source-id: 5e6a130ba65e4a1ebd1d9ec506fdb126ecd0e44a
Summary:
- adds more property assignments
- reduces the number of layout roots that exist simultanously
Reviewed By: pasqualeanatriello
Differential Revision: D8989389
fbshipit-source-id: 6a0ac800a4caad61a2f4bf98caa314855b70875f
Summary: The old link 404s. This is the new canonical location.
Reviewed By: IanChilds
Differential Revision: D9131447
fbshipit-source-id: 77b82a4184fff89faf1da76e922a5f1ce3de3314
Summary:
@public
Adds an implementation of `YogaNodeProperties` that sets style properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.
Reviewed By: pasqualeanatriello
Differential Revision: D9042225
fbshipit-source-id: c7f2b24eaeddd1190755bec85a5034079bd2f492
Summary:
@public
Adds an implementation of `YogaNodeProperties` that accesses style and layout properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.
This needs further cleanup after experimenting, e.g. to codegen the offsets.
Reviewed By: pasqualeanatriello
Differential Revision: D8911723
fbshipit-source-id: 3c24b57eb545155878896ebb5d64d4553eb6bedc
Summary:
Here we introduce an abstraction over node property storage, in order to experiment with different approaches for Java/C integration.
- interface `YogaNodeProperties` as abstraction
- current JNI code factored into `YogaNodePropertiesJNI.java`
- `YogaNode` delegates all calls, no API changes
Reviewed By: astreet
Differential Revision: D8769448
fbshipit-source-id: e67327ce41fa047a51a986c652b3d59992a510e2
Summary: We've mistakenly used `free()` to free the memory, where `delete` should have been used
Reviewed By: davidaurelio
Differential Revision: D9042347
fbshipit-source-id: e15cec0f498409066521a6de1e3fe4b7404ec46c
Summary: `-init` is marked unavailable, but `+new` does the same thing and is not.
Reviewed By: dshahidehpour
Differential Revision: D8957391
fbshipit-source-id: 42fcfe845db79726d8724efd9f6a4d37c19938ad
Summary:
@public
The existing test suite does not check every single style property settable in Java for defaults, reads, and effect on layout.
Here, we add these test, in order to make evolving the Java/C++ bridge as safe as possible.
Reviewed By: pasqualeanatriello
Differential Revision: D8952470
fbshipit-source-id: a94933adff01c313b3f440eb5207d2cb6a54a85d
Summary:
@public
It's very useful sometimes for product code to compare `YGValue`s (e.g. in Fabric).
Reviewed By: priteshrnandgaonkar
Differential Revision: D8937594
fbshipit-source-id: b93e1ab4a6419ada6746f233b587e8c9cb32c6d4
Summary:
@public
Replacing the `YG_NODE_STYLE_PROPERTY_IMPL` macro with template code, in order to make code easier to edit and grep.
Reviewed By: astreet
Differential Revision: D8868184
fbshipit-source-id: f52537376fa8d4dd53aa98bb43e93279699dbdd5
Summary:
@public
Inlines macros used for declarations of `YGNodeStyle*` and `YGNodeLayout*` functions.
Benefits easier grepping and code base navigation.
Reviewed By: astreet
Differential Revision: D8868168
fbshipit-source-id: d6b1b70981a59a2214dc7d166435a1d1a844e1b7
Summary:
There's been a breaking change in 0.5 and old versions
are ABI-incompatible with new ones.
Reviewed By: muraziz
Differential Revision: D8913456
fbshipit-source-id: 89221c5ac95c7c2197083a5390403c72e7e33af1
Summary: No need to type out the old version. This is exactly equivalent (unless I've misread and the old version did something other than memberwise copy).
Reviewed By: davidaurelio
Differential Revision: D8842326
fbshipit-source-id: c575ea4cee6caef9ea15aaf5967597385ed26ec3
Summary: It doesn't seem to be used internally, it hurts greppability, and there are setters for these properties as needed anyway.
Reviewed By: davidaurelio
Differential Revision: D8842084
fbshipit-source-id: f0275b490e585ea94df341c97c34b441ed91c4fb
Summary:
Top-level `if` statements are not allowed in a new Buck parser - Skylark.
https://buckbuild.com/concept/skylark.html
Reviewed By: grzmiel
Differential Revision: D8849590
fbshipit-source-id: 6648135f23e058adfeddf574932f8a98c7831fee
Summary: Holding floats by reference is unnecessary at best and may be detrimental to performance.
Reviewed By: davidaurelio
Differential Revision: D8826496
fbshipit-source-id: 2391f8aa26ebfbb440f6e4b7d57975be688f791c
Summary: I missed these two things: inline default ctor, getValue() should return a float.
Reviewed By: priteshrnandgaonkar
Differential Revision: D8826640
fbshipit-source-id: e6324dea0268ef276e6fa1722e72dffb5241e676
Summary:
It's wasteful to do it by value. I'm fairly sure this is
safe, especially because
fbd332dee8 (diff-ade2a4bbd6582e2898cbd9e0fa142ab5R215)
shows that we did access by reference before.
Reviewed By: priteshrnandgaonkar, davidaurelio
Differential Revision: D8822697
fbshipit-source-id: 791bcf0fa37453f67795af727c85c8adce3b0f69
Summary: Just some convention/weird style things. `float` should be passed by value, weird use of ?: operator instead of ||.
Reviewed By: priteshrnandgaonkar
Differential Revision: D8804407
fbshipit-source-id: e0d67363ccde36ec5bccec7497ed0ffd364b3fcf
Summary:
This PR adds support for using Yoga Swift dependents when Yoga is pulled as a static library.
Currently swift projects trying to pull static libraries are unable to import the module. The reason for that is because the `DEFINES_MODULES` build setting is set to`NO`. If a Swift Framework is trying to `pod spec lint --use-libraries` with `Yoga` as a dependency, the validation will fail. With the `DEFINES_MODULE` enabled, the product will be treated as defining its own module. This enables automatic production of LLVM module map files when appropriate, and allows the product to be imported as a module.
A workaround to this issue would be passing the `:modular_headers` flag to the `Podfile`, but that would not fix the `pod spec lint` validation for framework/library dependencies, it would just allow consuming applications to build and run.
An example of this issue would be [SonarKit](https://github.com/facebook/Sonar/blob/master/iOS/SonarKit.podspec). `SonarKit` wasn't able to validate its podspec due to `YogaKit` (Swift Framework) depending on `Yoga` and SonarKit validating with the `--use-libraries` flag due to the c++ dependencies. We had to create a new version of [Yoga 1.9 podspec](https://github.com/facebook/Sonar/blob/master/Specs/Yoga/1.9/Yoga.podspec.json) and make sure to set the `DEFINES_MODULE` flag of the pod target. After that, we were able to `pod spec lint` `SonarKit.podspec` successfully.
After merging a new `tag` should be created and the new podspec should be pushed to cocoapods master repository.
Pull Request resolved: https://github.com/facebook/yoga/pull/793
Reviewed By: passy
Differential Revision: D8820126
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 98eae3c31ec67a03c0fe97e05ab9e79446fa9f78
Summary: This linked list was never used, and YGNodeDeepClone was doing scary things to maintain it.
Reviewed By: davidaurelio
Differential Revision: D8792864
fbshipit-source-id: c578fabe65c837f0791aa9ac3e18f31d93691abd
Summary: There were a few missing prototypes and a -Wshadow violation. Merged YGBenchmark.h into YGBenchmark.c, added static where needed, fixed shadow violation.
Reviewed By: davidaurelio
Differential Revision: D8793124
fbshipit-source-id: c4b2dd348c38aa599169b5e9bea543c172439432
Summary:
Fixes the improper `singleFlexChild` optimization. In the case when all the childs have `flex-grow:0 flex-grow:0` except one child with `flex-grow:1 flex-shrink:1`, then one can simply measure all the non-flexing children and then give the flexing child all the remaining space.
Also added a test case which reproduced the bug
Reviewed By: IanChilds
Differential Revision: D8782684
fbshipit-source-id: ffd4d35b6122f82111b987540efb23bd2a8da5a2
Summary:
Replaces two nested if-blocks with guards. This is intended to help with restructuring this function in follow-ups.
@public
Reviewed By: priteshrnandgaonkar
Differential Revision: D8785659
fbshipit-source-id: 7b9d63e9814b83b999397c016ad67ad348bb0f72
Summary:
Updates all dependencies of the website to their latest version. This is made due to CVE-2018-3728 and a vunerable version of `hoek` used in s transitive dependency of the website. This updates `hoek` to v 4.2.1 which is not affected.
allow-large-files
Reviewed By: astreet
Differential Revision: D8734272
fbshipit-source-id: 3e96ea5890190f7d7b83cc4c18121fc925411f69
Summary:
On the first render the landing page was missing a CSS class. This ls probably related to https://github.com/gatsbyjs/gatsby/issues/5136
It is fixed by wrapping the page in a <div>
Reviewed By: priteshrnandgaonkar
Differential Revision: D8660801
fbshipit-source-id: dd1ac4145831f2556e2c7ceeaddb2a423447f833
Summary:
This diff refactors the cloning mechanism for YogaNode used from Fabric UI renderer and RN iOS graphs.
Previously, we were cleaning the owner of the child's cloned node inside the C++ implementation of YogaNode. This was a mistake because this modified the last commited YogaTree, causing side effect in RN iOS graphs.
Reviewed By: shergin
Differential Revision: D8672627
fbshipit-source-id: c9902d00690e0361fd58aed84b506c42258bd995
Summary:
Sync fbjni with `libaries/fbjni`.
This includes a hack to fix a deadlock we found for cmake-debug variants only. This still gets us back in sync with other fbjni consumers which is going to save us trouble in the future if Yoga ever wants to make use of a newer feature.
Manual changes made in addition to the hand-crafted CMakeLists and cxx buck rules:
- `jni::isObjectRefType` has SDK lookup disabled.
- `fbjni/` path is changed back to `fb/` to retain compatibility with Yoga.
Reviewed By: priteshrnandgaonkar
Differential Revision: D8531991
fbshipit-source-id: 776f519e2e5f9bea37f55990348f7ed81c4860b4
Summary: This diff cleans up the parent / owner references for children of ReactShadowNode / YogaNode during cloning. The reason of this behavior is to avoid retaining every generation of trees during cloning. This fixes a memory leak detected when running the ProgressBarExample.android.js in catalyst app
Reviewed By: fkgozali
Differential Revision: D8019894
fbshipit-source-id: b0d38f0c836ffec534f64fa1adbd7511ecf3473d
Summary:
Might be the smallest PR in the world, but it caught my eye reading the
docs so I figured I should fix it.
Closes https://github.com/facebook/yoga/pull/782
Reviewed By: emilsjolander
Differential Revision: D8351525
Pulled By: jknoxville
fbshipit-source-id: fc7a881f062e07d2e28b5ca2da8c52f20bad53be
Summary:
I'm not totally sure what I'm doing so if this needs changes let me know.
Closes https://github.com/facebook/yoga/pull/775
Reviewed By: emilsjolander
Differential Revision: D8331892
Pulled By: passy
fbshipit-source-id: eb1023e666322d2472e4081fd4a4e72a7b43d049
Summary:
@public
Bump Prettier to use version 1.13.4
All code changes are caused by running Prettier and should only affect files that have an `format` header.
All other changes caused by yarn.
Reviewed By: ryanmce
Differential Revision: D8251255
fbshipit-source-id: 0b4445c35f1269d72730f2000002a27c1bc35914
Summary:
The "copy share URL" button only works in the standalone playground, not the ones embedded on the landing page or the documentation, because, we don't want people to share a link to a modified documentation page.
This diff replaces the share URL button with a link to a standalone playground which then can be shared.
Reviewed By: astreet
Differential Revision: D8125135
fbshipit-source-id: 8b69b69caeadf5d598ed89b0abd9b742f5f07a9c
Summary:
This uses the latest version of `buildifier` that supports many
more Skylark syntax features.
Reviewed By: yfeldblum
Differential Revision: D8073585
fbshipit-source-id: 12322aebc09b89d5af9cc257b16c1bc0fbb066c1
Summary:
This is to make them `buildifier` compatible in order to start using
`buildifier` for all .bzl files.
Differential Revision: D8069457
fbshipit-source-id: f5bce02a3e6ba8dc4ccbf5bae70de224c30cbd64
Summary: Fix yoga podspec issue. The newly released versiong of Yoga i.e 1.8.0 was not building on iOS. So fixing the bug. Want to use this pod in SonarKitLayout
Reviewed By: emilsjolander
Differential Revision: D8024641
fbshipit-source-id: c8d7279e654145199fbee6655909e1c10d8b2114
Summary: The error message saying the playground is only available on bigger screens also was shown on big screens.
Reviewed By: emilsjolander
Differential Revision: D7989482
fbshipit-source-id: f444ca2d6608b868c4ff4d38fa6798d80b57c047
Summary:
Updates Prettier to v1.12.1, using `xplat/js/scripts/prettier-bump.js` based on the playbook by https://our.intern.facebook.com/intern/wiki/Prettier/upgrade-guide/
All changes related to upgrading or running Prettier
allow-many-files
allow-large-files
bypass-lint
drop-conflicts
ignore-conflict-markers
ignore-signed-source
ignore-nocommit
Reviewed By: benjaffe, ryanmce, yungsters
Differential Revision: D7652946
fbshipit-source-id: 396d45c675e93f2298cd2920d927630c81867447
Summary:
External partners have asked us to provide an easier way to migrate and this was
a breaking change in the most recent release.
Reviewed By: emilsjolander
Differential Revision: D7654526
fbshipit-source-id: efe44807caa97f495c5e5691dedcf281760fa23e
Summary: Several of dependencies and tests in repository are missing (e.g. because we don't support building certain library for MacOSX). Clean up those mistakes.
Differential Revision: D7625433
fbshipit-source-id: 332b7ff7eaed82cb52f459921f1ae67b702a1636
Summary: Several of dependencies and tests in repository are missing (e.g. because we don't support building certain library for MacOSX). Clean up those mistakes.
Differential Revision: D7618360
fbshipit-source-id: 421834892519998ad088a138b3fc3d96afe34d79
Summary:
Change the travis platform to Java and install Node via nvm instead. This
manually reinstalls buck and then publishes a snapshot if it builds and tests
correctly.
Reviewed By: emilsjolander, danielbuechele
Differential Revision: D7567862
fbshipit-source-id: fabdbbb13117ab8ead4eb9f10402a71d30f29c12
Summary: this diff re-add the assertion to check for owner reference before adding child that was removed by mistake in previous diff
Reviewed By: emilsjolander
Differential Revision: D7495417
fbshipit-source-id: b81174aeea3f2796d76ccdae4a8eddd0beace0aa
Summary:
This PR fixes the compilation on MSVC. I moved the `YGConfig` creation to a C++ constructor.
Addionally it removes the "dot" notation on `YGValue`, I didn't want to change that type to a C++ constructor, because I think this will break the ABI.
Closes https://github.com/facebook/yoga/pull/746
Differential Revision: D7498141
Pulled By: emilsjolander
fbshipit-source-id: 5f5308ff838dcd803065785ddc08b2404524acb9
Summary: Remove experimental setup of fast-math and add `-ffast-math` as a compiler flag for yoga.
Reviewed By: emilsjolander
Differential Revision: D7414228
fbshipit-source-id: 320e1b1953f6af867b13e617af7872eb8999160e
Summary: Change the return type of getMarginForAxis to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7350337
fbshipit-source-id: dd1ee2fcd295ccd14f7d414ab0c24090b24e91e0
Summary: Change the return type of getTrailingMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7350221
fbshipit-source-id: 61a67364c1975ec6dd1883bc2cb4968b830c73df
Summary: Changed the return type of getLeadingMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7349907
fbshipit-source-id: b20894fbc33fd5b29a28f3c9174d1b5f406774ab
Summary: Change the type of getTrailingPosition to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7344710
fbshipit-source-id: eb4c422b6e0f55d90b083221aa8ff1ab797d58a8
Summary: Changed the type of return value of getLeadingPosition to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7344367
fbshipit-source-id: 0f5a667ca357b2ce056c86763aa3e9e4c54b82f0
Summary: Changed the type of computedFlexBasis to YGFloatOptional in YGLayout
Reviewed By: emilsjolander
Differential Revision: D7340413
fbshipit-source-id: 39247b2b582a682e602f49f58b4bbd2bf0c995af
Summary: Changed the return type of trailing padding to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7339712
fbshipit-source-id: 483c5886838c14b17cb731c81abb9fc80f519956
Summary: Changed the arguments for the getter of leading padding to avoid copies. Added an assetion in getter of leading padding, as padding would always be defined even in the case when the user has not explicitly defined the value. In these cases it would take the default value of 0. So changing the type of `getLayoutPadding` to `YGFloatOptional`, doesn't make sense.
Reviewed By: emilsjolander
Differential Revision: D7336690
fbshipit-source-id: b2a2f010026f26fc2cc9fb35ad921da8f7017c9f
Summary: Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7323382
fbshipit-source-id: 8e3eb4f3744b5f3f9e2b353f56184905f7557191
Summary: Remove the use of YGUnwrapOptional from YGConstrainedMaxSizeForMode
Reviewed By: emilsjolander
Differential Revision: D7322743
fbshipit-source-id: d825c60bcdc9ecdc0c784a215dc6b1b8a7a7860e
Summary:
This PR fixes a type mismatch on `endOfLineIndex` where it should be of type `uint32_t` while it is of type `float`
Additonally it fixes some `double` casting in the rounding methods.
Closes https://github.com/facebook/yoga/pull/745
Differential Revision: D7494519
Pulled By: emilsjolander
fbshipit-source-id: 30a86574ce163458a6888f61a902d0640c1874fb
Summary: Changed the return type of YGResolveValueMargin to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7304090
fbshipit-source-id: cbec03a9367cf34976d083ad475d4da0b736e6d2
Summary: Move equaltiy function from utils to an operator on YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7303460
fbshipit-source-id: 41ec0076ace621ec1a5bdbab00b72eea57780fff
Summary: Change the type of aspect Ratio to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7302651
fbshipit-source-id: 53e3b4c9627207a379f927b1f3485e36a9c70601
Summary: Removes the use of YGUndefined from kYGValueAuto. Also fixed the setter and getter of dimensions. This diff also fixes a typo
Reviewed By: emilsjolander
Differential Revision: D7302453
fbshipit-source-id: e002a1ddd75bfc6fe142a7275e7913c064972e16
Summary:
This diff includes the following changes:
1 ) I extended the Java implementation of YogaNode to be able to get a full copy of a YogaNode object without copying the List of children of the original YogaNode. In other words, the new copy of the YogaNode will have the same data of the original YogaNode, but with an empty list of children.
2 ) We created a new method in Yoga.cpp called YGNodeInsertSharedChild. This new method is going to be used by Fabric in order to temporarily share a YogaNode between two "Yoga Trees" (the "current Yoga" tree and a partial "clone of the current Yoga tree"). We exposed this new functionality in the java implementation of Yoga (method addSharedChildAt)
I'm including sebmarkbage for more context.
Reviewed By: emilsjolander
Differential Revision: D7245421
fbshipit-source-id: 72578c8261f29e4a12fc6c72a91f2f891cd58d48
Summary:
In the persistent version of Yoga, a YogaNode can be shared between two YogaTrees, that means that a YogaNode could have more than one Parent at one point in time. That's why the concept of Parent of a YogaNode is not a 1-1 relationship anymore.
This diff changes the semantic of Parent of a YogaNode to Owner of a Yoga Node. CC sebmarkbage and priteshrnandgaonkar for more context.
Technically this diff renames the field YogaNode.parent to YogaNode.owner (and every internal field, Getter and Setter that is related to parent)
Note that as part of this diff I also modified the CSSLayoutDEPRECATED version of Yoga in order to keep compatibility with the C++ implementation.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7352778
fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
Summary:
We had functions for inserting/removing a specific child, but not for simply replacing the child set with another list.
`YGNodeSetChildren()` will unhook child nodes from the parent that don't appear in the new set. We set the disconnected child node layouts to `YGLayout()` b/c that's what the rest of the code does.
`YGTraversePreOrder()` walks the tree and calls a labmda for each node. We could very easily add a post-order traversal and the ability to stop traversal if we ever want, but for now this is an MVP.
Reviewed By: Woody17
Differential Revision: D7360203
fbshipit-source-id: 32df8e1213ead03bc0a026ec4bf453bc799bb9ce
Summary:
Podspec to push yoga 1.8.0 to cocoapods. There is an issue with cocoapods and it fails to lint those projects with C++ in its header, which is the case with yoga too.
Follow this thread https://github.com/CocoaPods/CocoaPods/issues/5152. To make the lint pass, one would have to change `app_target_helper.rb` cocoapod source file in the local machine. Follow my [gist](https://gist.github.com/priteshrnandgaonkar/dcca9639a3bc0a3b9adecae3a2b3b0c4).
I am able to pass the lint, but not able to push the pod in cocoapods as I am not the admin. @[759512522:emilsj], please push it on Cocoapods or give me permission.
Podspec now also exposes public header explicitly.
Reviewed By: gkassabli
Differential Revision: D7375018
fbshipit-source-id: 4e82e1c0b6340c3f8d3b8a96ecadbcb711d4bcd8
Summary: Adds an example of how to use yoga from JavaScript to the documentation pages.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7354390
fbshipit-source-id: 0dbc08e5341c06b621acd99bfb9ce7e789b67a45
Summary: These don't need to be copied twice.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291363
fbshipit-source-id: 22e606d0b3fa1133d7e0334c8cf9f5f1f32fe64b
Summary: These shouldn't be copying the arguments when they pass by value. Instead these only get copied when assigning the value to the member.
Reviewed By: priteshrnandgaonkar
Differential Revision: D7291096
fbshipit-source-id: 7a4025831811d622050adbb5f86608855b94d68e
Summary:
Earlier `YGfloatOptional` was plain struct with no privacy around the variables. This diff adds privacy and also enforces checks when one tries to access value of an undefined `YGFloatOptional`
This diff also adds a behaviour in which when a value of an undefined YGFloatOptional is accessed, it will normally terminate(Several cleanup steps are performed).
Reviewed By: emilsjolander
Differential Revision: D7288555
fbshipit-source-id: f61cc92c8fd0d48d2fc1f4d0e6fcef155f19ff8a
Summary: Fixed a typo of flexshrink and added a test case
Reviewed By: emilsjolander
Differential Revision: D7289221
fbshipit-source-id: 48ee9ccfac4adee51d515a366b5a11790f7236fc
Summary: Fix getters and setters of min and max Dimension to behave exactly the same way as it was before fast math changes
Reviewed By: emilsjolander
Differential Revision: D7274807
fbshipit-source-id: 7c1a4c19e8d0552b089a410c3330392cb26a6a47
Summary:
This diff fixes the setter and getter of margin, position, border and padding to the previous behaviour of yoga, before floatoptional change
This diff also removes the unrequired `#define`
Reviewed By: emilsjolander
Differential Revision: D7274115
fbshipit-source-id: 942a91e6562ef789ae79102a828f397889468fa7
Summary:
Earlier YGUndefined was NAN, but recently it was replaced with 10E20 and the check for `isUndefined` is as follows
```
public static boolean isUndefined(float value) {
return (Float.compare(value, (float) 10E8) >= 0 || Float.compare(value, (float) -10E8) <= 0);
}
```
If the number is in (-inf, -10E8] and [10E8, inf) then it is considered as undefined. Failing test passed values in this range, so thats why the test was failing. Current diff fixes this issue, and passes a big number which is outside the range as the result of measure function.
Reviewed By: emilsjolander
Differential Revision: D7272325
fbshipit-source-id: 81a77117c65c5dc0cec920f50f0735ec0a7433d1
Summary:
This diff exposes `shouldDiffLayoutWithoutLegacyStretchBehaviour` from YGConfig and `doesLegacyStretchFlagAffectsLayout` from YGLayout to YogaConfig and YogaNode respectively
Also added a positive test case. Didn't find the negative test case example. @[508947467:ianc] or @[759512522:emilsj], can you suggest a negative test case example.
Reviewed By: emilsjolander
Differential Revision: D7272067
fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
Summary: Remove the use of YGUndefined for default flex-basis value
Reviewed By: emilsjolander
Differential Revision: D7243924
fbshipit-source-id: 2bfaca1a5e3da40d5292a273cabf705f59c9d666
Summary: Change the type of flexShrink to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7232171
fbshipit-source-id: 3111119d3d74a7035c01132bff61b30cf44e120a
Summary: Change the type of flexGrow to YGFloatOptional
Reviewed By: emilsjolander
Differential Revision: D7215355
fbshipit-source-id: 1298ee332551d44e4d070169a1e4103d005c4f43
Summary: Change the type of flex to YGFloatOptional internally, but keeping the public facing API the same as before
Reviewed By: emilsjolander
Differential Revision: D7211327
fbshipit-source-id: 0d979b6ba00317317b98bbc6e63979c7f1feb2da
Summary: Changed the return type of YGResolveValue
Reviewed By: emilsjolander
Differential Revision: D7195099
fbshipit-source-id: 72c4163cd08691cf6e40df05394cc52e83b0de14
Summary: Remove the usage of YGUndefined in the default values of Border in YGStyle. In the getter of Border function, YGUndefined is used just to keep it logically consistent. The proper solution would be to change the api in `Yoga.h` to accept `YGFloatOptional`, but that would require to change lot of the code in client of this library. Will make a separate diff for that.
Reviewed By: emilsjolander
Differential Revision: D7195115
fbshipit-source-id: e635cf55ac94d8a90caef6cafce281579da2cbfc
Summary:
emilsjolander hi,
this PR solves the following common and probable layout pixel scenario:
the older code is presented for reference:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutWidth()),
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
Math.round(xOffset + node.getLayoutX()),
Math.round(yOffset + node.getLayoutY()),
Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
suppose now the following:
- `xOffset + node.getLayoutX() = 2.2`
- `node.getLayoutWidth() = 0.4` ==> `Math.round(node.getLayoutWidth()) = 0`
- `Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()) = Math.round(2.2 + 0.4) = 3`
this induces, the following measurements:
```java
view.measure(
View.MeasureSpec.makeMeasureSpec(
0,
View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY));
view.layout(
2,
Math.round(yOffset + node.getLayoutY()),
3,
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
```
the width measurement of the view is 0, while the layout is `(3 - 2 = 1)`.
my proposed solution is to measure the view the way it is now, but when layouting
I use the `#getMeasuredWidth/Height()` methods, this will stop this problem
from happening.
I also want to note that this bug happens with high probability.
Closes https://github.com/facebook/yoga/pull/712
Reviewed By: emilsjolander
Differential Revision: D7231798
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 171da519639dbecd75416a574bccc4456aa22f31
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
@@ -8,7 +8,7 @@ For testing we rely on [gtest](https://github.com/google/googletest) as a submod
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generate a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
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.'
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
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.