Summary: Refactored the `YGNodeToString` function from c to c++.
Reviewed By: emilsjolander
Differential Revision: D6397372
fbshipit-source-id: 79e701efe7f19db6dac1aea6328ebf0ac84a7ac3
Summary: Changed the extensions of c files to cpp and made the project build successfully
Reviewed By: gkassabli
Differential Revision: D6271299
fbshipit-source-id: 66c0e54ccf019d72d1fd0b4d117826e4e84fdc89
Summary:
**what is the change?:**
Adding a document linking to the Facebook Open Source Code of Conduct,
for visibility and to meet Github community standards.
**why make this change?:**
Facebook Open Source provides a Code of Conduct statement for all
projects to follow.
Exposing the COC via a separate markdown file is a standard being
promoted by Github via the Community Profile in order to meet their Open
Source Guide's recommended community standards.
As you can see, adding this file will complete [Yoga's Community Profile](https://github.com/facebook/yoga/community)
checklist and increase the visibility of our COC.
We also added a link to the COC in the CONTRIBUTING doc because folks may miss the separate CODE_OF_CONDUCT document.
**test plan:**
Viewing it on my branch -


**issue:**
internal task t23481323
Closes https://github.com/facebook/yoga/pull/670
Reviewed By: emilsjolander
Differential Revision: D6384655
Pulled By: flarnie
fbshipit-source-id: 6c5557094719cc8f1b08deb4d477ab56603caf39
Summary: Removed YGSetMemoryFuncs, as it is not used internally and barely externally.
Reviewed By: emilsjolander
Differential Revision: D6374147
fbshipit-source-id: 8c896dce23571268a1a52df5cc72486af9d66df7
Summary: Use internal linting rules instead of the custom once.
Differential Revision: D6284667
fbshipit-source-id: 65aae336f1d7f14dfefed7391b0f5b89b333495e
Summary: For our -objc efforts we'll be excluding vendorlibs from these changes for now and then working on getting them to not have to be fully linked as a second effort. The way -objc flag works is its an all or nothing flag for the app and thus for any library we still want to link completely we'll have to add a link_whole = True to the BUCK file. (Otherwise we'll have crashes in these libraries :P).
Reviewed By: kastiglione
Differential Revision: D6252740
fbshipit-source-id: fe074977a11b70c4aa63a4c69cb7518906c98eb9
Summary: We'll need these libraries for rainbow, and none of them exist in fbcode.
Reviewed By: mzlee
Differential Revision: D5897801
fbshipit-source-id: c379b76fef2ab204555ceded0834efc6ba932f90
Summary: YGRoundValueToPixelGrid does not handle float point values correctly. It causes layout bugs in arm 32 devices. The way values are rounded to pixel grid is the following: if value is close to the left pixel - discard error and set it equal to left pixel. If value is close to right pixel - set it equal to the right pixel. Otherwise if value is closer to the left - set it equal to the left, closer to the right - set it equal to the right. The problem is when values are close to the middle. Old implementation could produce either left or right boundaries. This patch moves all values that are close to the middle to right boundary. This way results are consistent.
Reviewed By: emilsjolander
Differential Revision: D6202484
fbshipit-source-id: bb80235452208caec388775574cc4f07bfd649c4
Summary: Yoga has an edge case that cause layout to return NaN. This happened when we used absolute position with percentage and infinite constraint in that dimension. This diff fixes that case to default to border+padding
Reviewed By: emilsjolander
Differential Revision: D6199731
fbshipit-source-id: f40ddf00614b2f507848fb35f348a9dfef14b323
Summary:
More fine grained dirty marking
Currently a node's dirty flag propagates to the root of the tree ensuring that when any node is invalidated its whole subtree will be re-calculated. This is often times not needed. There are many properties which only effects a node's children and would not need to propagate all the way to the root such as align-items. Also in cases where the style does change layout it may not need to propagate all the way to the root but can often stop at the nearest position: absolute parent.
This change has the potential of greatly improving performance of re-calculating a tree.
This might require adding a second dirty flag named hasDirtyDescendants ensuring that traversal still works even though a parent is not marked as dirty.
Reviewed By: emilsjolander
Differential Revision: D6134754
fbshipit-source-id: bbcfee14058140b946401de756a3f130de0f51cd
Summary:
Source-only ABIs are a new feature of Buck that allows massive parallelism
by generating ABI jars from just the source code (without looking at most
dependencies). Because dependencies are not available, the generator
makes assumptions about how we write Java code. This commit updates
Instagram's code to conform to those assumptions.
These changes were generated by Buck's automatic migration script.
Reviewed By: dreiss
Differential Revision: D6168048
fbshipit-source-id: 0e51319d93fd697db01ea3933f48cd06a6ffac12
Summary:
This is meant to show a possible route format for a persistent form of Yoga. Where previous layouts can remain intact while still taking advantage of incremental layout by reusing previous subtrees.
```c
YGNodeRef YGNodeClone(const YGNodeRef node);
```
The core of this functionality is a new API to clone an existing node. This makes a new detached node with all the same values as the previous one. Conceptually this makes the original node "frozen" from that point on. It's now immutable. (This is not yet enforced at runtime in this PR but something we should add.)
Since the original is frozen, we reuse the children set from the original node. Their parent pointers still point back to the original tree though.
The cloned node is still mutable. It can have its styles updated, and nodes can be inserted or deleted. If an insertion/deletion happens on a cloned node whose children were reused, it'll first shallow clone its children automatically.
As a convenience I also added an API to clear all children:
```c
void YGNodeRemoveAllChildren(const YGNodeRef node);
```
During insert/delete, or as a result of layout a set of reused children may need to be first cloned. A kind of copy-on-write. When that happens, the host may want to respond. E.g. by updating the `context` such as by cloning any wrapper objects and attaching them to the new node.
```c
typedef void (*YGNodeClonedFunc)(YGNodeRef oldNode,
YGNodeRef newNode,
YGNodeRef parent,
int childIndex);
void YGConfigSetNodeClonedFunc(YGConfigRef config,
YGNodeClonedFunc callback);
```
This PR doesn't change any existing semantics for trees that are not first cloned.
It's possible for a single node to exist in two trees at once and be used by multiple threads. Therefore it's not safe to recursively free a whole tree when you use persistence. To solve this, any user of the library has to manually manage ref counting or tracing GC. E.g. by replicating the tree structure in a wrapper.
In a follow up we could consider moving ref counting into Yoga.
Closes https://github.com/facebook/yoga/pull/636
Reviewed By: emilsjolander
Differential Revision: D5941921
Pulled By: sebmarkbage
fbshipit-source-id: c8e93421824c112d09c4773bed4e3141b6491ccf
Summary:
After about 500MB, Travis seems to kill the TLS connection. Could be a traffic
limit, could be a timeout. I've only seen this for their MacOS boxes. We're now
retrying a few times with curl, which seems to work.
Reviewed By: emilsjolander
Differential Revision: D6051024
fbshipit-source-id: feb73bfb9fd81b2a8b9b4d33d4e9f230a9899a66
Summary: This seems to have changed upstream.
Reviewed By: emilsjolander
Differential Revision: D6050471
fbshipit-source-id: b453831c1d5a5974572265a78da40b0612b1d1f2
Summary:
The native-dependencies plugin seems unused. Upgrade to the latest
gradle-bintray-plugin version that's supported for the current Gradle version.
I'll hold back the upgrade to Gradle 4 until the Gradle Android Plugin for the
version hits stable.
Reviewed By: IanChilds
Differential Revision: D5986549
fbshipit-source-id: d26aa19e9eba40a2b30b20d5ffa9d2b006450f95
Summary:
Use the `deprecated_prebuilt_cxx_library` wrapper instead of the deprecated
API of `prebuilt_cxx_library`.
Reviewed By: ttsugriy
Differential Revision: D5878523
fbshipit-source-id: 2c8c1fd1d19597ff7459bbd527c89573520db74b
Summary:
The Android logger adds newline automatically, which makes the log ugly on Android.
To avoid that, wrap the android logger, print to a memory buffer. Call __android_log_write() when '\n' is detected.
Reviewed By: emilsjolander
Differential Revision: D5842889
fbshipit-source-id: 8ecc829dc43614934c47fd3a68317259e403325a
Summary:
This fixes shrinking of elements which are in a non stretch alignment
Fixes#633
Closes https://github.com/facebook/yoga/pull/634
Differential Revision: D5874862
Pulled By: emilsjolander
fbshipit-source-id: 1426aa6b60f6ba42c2be702e6f24cea935ab7acb
Summary:
Add a new test named YGZeroOutLayoutRecursivlyTest, which verifies that padding and margin of a child node should be set to 0 when the display is set to none.
Modify YGZeroOutLayoutRecursivly function, use memset to clear the layout struct of the node.
Reviewed By: emilsjolander
Differential Revision: D5842351
fbshipit-source-id: d2c2b6f829588a200525b7ccbdb63003cb4dcc4e
Summary:
Only add UIView nodes to Yoga where they are enabled.
We check for it in `isLeaf` but I think we should also check for them in the check for sub views.
Closes https://github.com/facebook/yoga/pull/609
Reviewed By: emilsjolander
Differential Revision: D5643387
Pulled By: dshahidehpour
fbshipit-source-id: a85c62b6b2e0120b2913e7f2df8b094d43ca49a6
Summary:
This PR fixes a declaration mismatch for `YGNodeCanUseCachedMeasurement` where the last argument is declared non `const` in `.h` and `const` in `.c`.
Additionally it uses explicit `float` for fraction calculation do avoid usage of `double` assignment.
Closes https://github.com/facebook/yoga/pull/607
Differential Revision: D5677931
Pulled By: emilsjolander
fbshipit-source-id: 502da957089e4439ed956987ff8dec10bd033ba3
Summary: At least one compiler seems to care about it.
Reviewed By: emilsjolander
Differential Revision: D5675518
fbshipit-source-id: 72a6e208263dde0b6bb46a78fedb2796d0e0a600
Summary:
@public
== Before ==
- Aspect ratio would do its best to fit within it's parent constraints
- Aspect ratio would prioritize `alignItems: stretch` over other sizing properties.
== After ==
- Aspect ratio is allowed to make a node grow past its parent constraints. This matches many other aspects of flexbox where parent constraints are not treated as hard constraints but rather as suggestions.
- Aspect ratio only takes `alignItems: stretch` into account if no other size definition is defined. This matches the interaction of other properties with `alignItems: stretch`.
== Updating your code ==
**You probably don't need to do anything** but in case something does break in your product it should be as easy as adding `{width: '100%', height: '100%', flexShrink: 1}` to the style declaring the `aspectRatio`.
Reviewed By: gkassabli
Differential Revision: D5639187
fbshipit-source-id: 603e8fcc3373f0b7f2461da2dad1625ab59dcb19
Summary: There was an uncovered edge case where number close to the whole was forced to round down because it was considered non-whole and had forced flooring. This diff covers that + adds a bunch of test cases to cover rounding function
Reviewed By: emilsjolander
Differential Revision: D5465632
fbshipit-source-id: 57e11092a97eba5dd76daad15fa8619535ff9c1b
Summary:
There was one incorrect path and some caching problems. I hope this will take
care of it for good.
Reviewed By: emilsjolander
Differential Revision: D5470120
fbshipit-source-id: 17c9e783c952c92fa5c2ccfb18107a59d8a80e3d
Summary:
Phew, this took a while. Buck had some changes in how it picks up SDK/NDK
configs.
In order to satisfy the new demands, I'm now installing the NDK manually and no
longer through the SDK manager. I'm also trying to cache as much as possible to
reduce the flakiness here.
Reviewed By: emilsjolander
Differential Revision: D5465206
fbshipit-source-id: 61a4b9006fe96fc9a99fb9d75b822589064a9d1a
Summary:
Set to the next snapshot version so automatic snapshot publishing is reenabled.
We need those to keep in sync with the Litho snapshots.
Reviewed By: emilsjolander
Differential Revision: D5442493
fbshipit-source-id: ecb92071ec8edb9c3c6b625c08f5aad20368d0a3
Summary: Yoga had a bug in Rounding calculation that caused text nodes dimensions to be rounded up even when the dimensions didn't need rounding
Reviewed By: emilsjolander
Differential Revision: D5406211
fbshipit-source-id: df1d54ed0805dfc3abbd8f0ceae30f6d8c26d61a
Summary:
Currently the nbind asm.js output generates boilerplate code which can conditionally load node's `fs` and `path` modules. If this output is run directly in the browser there are no issues but if you run it through a bundler the build step will fail trying to resolve the node builtins.
Workarounds currently exist for bundlers like webpack (mentioned in #444) but this is not a safe assumption to make (for example such workarounds don't exist for `metro-bundler`).
I am by no means suggesting that this is the perfect solution but this might provide a stop-gap fix for people who are currently blocked by this issue (like I am).
Closes https://github.com/facebook/yoga/pull/585
Differential Revision: D5388660
Pulled By: emilsjolander
fbshipit-source-id: d3a51eb852df35e3d0610158fe7d9f5754e4e684