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

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

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

Closes https://github.com/facebook/yoga/pull/324
Reviewed By: emilsjolander
Differential Revision: D4401408
Pulled By: splhack
fbshipit-source-id: ecdae7967060361bef2bc25a5ef759cb9a957322
Summary: Allow aspect ratio to expand beyond bounds of parent as is generally accepted in css
Reviewed By: passy
Differential Revision: D4397547
fbshipit-source-id: d2b1ca7b096f2f17b3efbd8f47a50678bfe7bb5f
Summary:
@public
Cannot use NSInteger as NSInteger has a different size than int (which is the default type of a enum). Therefor when linking the Yoga C library into obj-c the header is a missmatch for the Yoga ABI.
Reviewed By: cwdick
Differential Revision: D4392272
fbshipit-source-id: 22b92ac8f3eb7114e81dbd9b0bec9044c3d43da5
Summary:
Compared to what was planned, I added the `overflow` value which seemed missing. I had to modify the implementation a bit for all values which are backed by a `YGValue`, but we should probably enable the pixel dimensions in Objective-C and Swift somehow later.
Closes https://github.com/facebook/yoga/pull/322
Reviewed By: cosmin1123
Differential Revision: D4391434
Pulled By: emilsjolander
fbshipit-source-id: e33f6f7b2bbaad29553100b7a5bb424496372110
Summary:
- Does not contain "magic" found in YogaKit yet, but enough to get started
- Simple test project showing use
- YGInteropSetLogger and YGNodeInit(IntPtr) were missing from native lib built by buck
Closes https://github.com/facebook/yoga/pull/278
Reviewed By: emilsjolander
Differential Revision: D4388480
Pulled By: splhack
fbshipit-source-id: a7387bb5b5554b6fce80d08c23e4fa18a4611cce
Summary:
Compared to what was planned, I added the `overflow` value which seemed missing. I had to modify the implementation a bit for all values which are backed by a `YGValue`, but we should probably enable the pixel dimensions in Objective-C and Swift somehow later.
Closes https://github.com/facebook/yoga/pull/322
Reviewed By: dshahidehpour
Differential Revision: D4386906
Pulled By: emilsjolander
fbshipit-source-id: 05ac0e571ef3a8ff0be31469e449a7b23f102218
Summary:
Added baseline support (see #132)
You have the ability for a custom baseline function (```float(*YGBaselineFunc)(YGNodeRef node);```) to return whatever baseline you want.
Closes https://github.com/facebook/yoga/pull/317
Reviewed By: splhack
Differential Revision: D4385061
Pulled By: emilsjolander
fbshipit-source-id: cb8a59a09237c840fa3e21753ab68239997dab0c
Summary: Add API for retrieving the computed final padding of a node. Many frameworks such as React Native retrieve padding via `YGNodeStyleGetPadding` but given that we now support percentage values this is not correct anymore.
Differential Revision: D4376572
fbshipit-source-id: 3ffb66e77090fc1257511bec5c933f9b0c304b9f
Summary:
In YogaKit, nodes are not dirtied when `sizeThatFits` of leaf nodes change. This makes it difficult to reuse views like `UILabel` when their content (text) changes. I wrote a failing test to prove it and wrote a fix by caching the latest value of `sizeThatFits` in `YGNodeBridge` and checking for changes in `YGAttachNodesFromViewHierachy` (renamed to `YGUpdateNodesFromViewHierachy` to make it clear it's not simply reattaching nodes anymore). When a new size is detected, I call `YGNodeMarkDirty` on the leaf node.
**Unfortunately**, this makes another test fail for no logical reason (`testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond`). Either there's something I don't understand or I've un-advertedly unearthed a bug in the C implementation, but in what case would setting a node dirty make the layout return a different size?
Closes https://github.com/facebook/yoga/pull/308
Reviewed By: emilsjolander
Differential Revision: D4378826
Pulled By: dshahidehpour
fbshipit-source-id: cd0640bc863debb9e434370739416e3e33e57a08
Summary:
When a non-leaf node becomes a leaf node, `YGAttachNodesFromViewHierachy` calls `YGNodeSetMeasureFunc` before `YGRemoveAllChildren`, which causes a crash because that node has children. Fixed by swapping the order of the calls and have a unit-test to make sure it works.
Closes https://github.com/facebook/yoga/pull/320
Differential Revision: D4383905
Pulled By: dshahidehpour
fbshipit-source-id: 4872b1e819f178adaaa66b1f1c233390d3ec3be9
Summary:
The C# wrapper project has been changed to a NETStandard (1.1) PCL allowing it
to be consumed by any project targeting .NET4.5 or greater including .NETCore
and UWP projects... The C# wrapper uses P/Invoke to call into the Native Yoga
DLL...
The "Yoga" C++ project has been updated to support ARM builds...
Added the ability to generate nuget packages for the C# wrapper that supports
copying the native DLLs to the target output directory.
Closes: https://github.com/facebook/yoga/pull/283
Reviewed By: splhack, emilsjolander
Differential Revision: D4381455
Pulled By: JoelMarcey
fbshipit-source-id: e6dc4190caa824ac63d5d5ee2eb4c7914efbb00f
Summary:
YogaValue.cs(20,30): error CS1644: Feature `expression bodied members' cannot be used because it is not part of the C# 4.0 language specification
YogaValue.cs(21,28): error CS1644: Feature `expression bodied members' cannot be used because it is not part of the C# 4.0 language specification
Closes https://github.com/facebook/yoga/pull/316
Reviewed By: emilsjolander
Differential Revision: D4381190
Pulled By: splhack
fbshipit-source-id: fea157ac03944260d87b9f137bf966605c01a10e
Summary:
It's not much, but still 4 bytes saved here by moving the ```bool```s together. (on compilers where ```bool``` is a single byte)
Closes https://github.com/facebook/yoga/pull/319
Reviewed By: gkassabli, passy
Differential Revision: D4383686
Pulled By: emilsjolander
fbshipit-source-id: 9a48eccbb69382850c016aa6ee730526704a15f2
Summary:
- Fix a few things related to how npm should publish the package (sources were in the gitignore file, so I think it would have break the build during install - I fixed this by adding a npmignore that should override the gitignore rules)
- The enumerations values are now generated directly from `enums.py`
- I added percent unit support (#258) to the bindings (`.setWidthPercent` is currently exposed, but I've also added a very very little parsing to also support `.setWidth("100%")` and `.setWidth(.getWidth())`), added the missing tests, and fixed Travis.
Closes https://github.com/facebook/yoga/pull/314
Reviewed By: mikearmstrong001
Differential Revision: D4377198
Pulled By: emilsjolander
fbshipit-source-id: 774dfafd416f5421f3be59a1d181eb7056487abe
Summary: We need this for scrollviews, bring on the overflow!
Reviewed By: emilsjolander
Differential Revision: D4376759
fbshipit-source-id: a427432da5e8679dbf9fdbfe4250707e727368f4
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
Summary:
- As mentioned in the title, this PR adds Javascript support to Yoga. Two different builds are included in this PR thanks to [nbind](https://github.com/charto/nbind), which conveniently allow to target both Node.js' native addons and browser environments via asmjs with approximately the same codebase. That should solve #215.
- All tests successfully pass on both codepaths. You can run `yarn test:all` inside the `javascript` directory to test it.
- Because of a bug in nbind, the [following PR](https://github.com/charto/nbind/pull/57) needs to be merged and a new version released before this one can be safely merged as well.
- I had to use `double` types instead of `float` in the C++ bindings because of an Emscripten [bug](https://github.com/kripken/emscripten/issues/3592) where symbols aren't correctly exported when using floats.
- There's some tweaks to do before this PR is 100% ready to merge, but I wanted to have your opinion first. What do you think of this?
---
To do:
- [x] Ensure th
Closes https://github.com/facebook/yoga/pull/304
Reviewed By: mikearmstrong001
Differential Revision: D4375187
Pulled By: emilsjolander
fbshipit-source-id: 47248558a9506b7c512b5ef281cd12fe1a60cab7
Summary: Preserve floating point values when passing them across the JNI bridge.
Differential Revision: D4366605
fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
Summary: Move yoga docs into master branch so that pull requests are able to include doc updates as part of other changes.
Reviewed By: JoelMarcey
Differential Revision: D4365700
fbshipit-source-id: 2f46a88974104c454c00bcdf1257abb5c4075a68
Summary:
Java still has the same problem (see #296)
Also there is no need to have double in the method signature as we only use float internally, which could confuse some.
Closes https://github.com/facebook/yoga/pull/300
Reviewed By: splhack
Differential Revision: D4365993
Pulled By: emilsjolander
fbshipit-source-id: 681f8b1725e63eddcfb9a6c756f2ae215a44425a
Summary:
Not re-calculate `paddingAndBorderAxisMain`/`paddingAndBorderAxisCross`/`paddingAndBorderAxisRow`/`paddingAndBorderAxisColumn` in Step1 of `YGNodelayoutImpl`.
They can be figure out by values calculated before.
Closes https://github.com/facebook/yoga/pull/298
Reviewed By: dshahidehpour
Differential Revision: D4365533
Pulled By: emilsjolander
fbshipit-source-id: 6caf60bc6ef3addd49915b39b48f01a8b4926e9c
Summary:
- Enable destructor unit tests in Unity Editor
- Exit pack.sh immediately if a command exits with a non-zero status
- Run unit tests before building Unity package
Reviewed By: emilsjolander
Differential Revision: D4365773
fbshipit-source-id: 20d0a51f4cef791154c17d329ac36598dc333a60
Summary:
This PR fixes issue #295
- Created a new internal YGNodeHandle class extending SafeHandle.
- YogaNode now stores a reference to YGNodeHandle.
- Removed finalizer from YogaNode.
- Pulling in System.Runtime.Handles 4.3.0.
Closes https://github.com/facebook/yoga/pull/297
Reviewed By: emilsjolander
Differential Revision: D4365462
Pulled By: splhack
fbshipit-source-id: 73293b105962cbedb71f4e3d8d1244251db1ea79
Summary:
- Change the CI config so it runs the tests for Editor on Sandcastle
- Don't run tests for effects-framework and yoga libraries when building for Mac (triggers code signing issues that I don't want to deal with right now)
- Add target for unit tests (aka EditorTests)
- Make the existing unit tests build and pass. These include both Objective-C and Swift (we should probably get rid of some of these though). I will convert these to Swift 3 before landing (after the migration is complete).
- Exclude the EditorUITests target for now. It only contains a single dummy test and it causes a code signing failure on Sandcastle. I did not manage to work around that yet but there is a separate task for it.
Reviewed By: Perspx
Differential Revision: D4352670
fbshipit-source-id: 0295004a72953bd8e7ae83895b2e5712bab7bd32
Summary:
Added Bash script and bat file to build a package of Yoga in order to import Yoga for Unity easily.
Closes https://github.com/facebook/yoga/pull/288
Reviewed By: emilsjolander
Differential Revision: D4344198
Pulled By: splhack
fbshipit-source-id: 49ae27dbc513b4a2d161840ca5c5f4c9df2ab227
Summary: Improve performance of allocations and reseting by writing fewer bits. Also just looks nicer imho.
Reviewed By: passy
Differential Revision: D4356994
fbshipit-source-id: ebbe52163e0c86230bfa4131b657941afe16fbf1
Summary: This should not be an enum. A define makes a whole lot more sense
Differential Revision: D4346529
fbshipit-source-id: 8641c4c5017d915d64e5884cae09ac8f01861337
Summary:
@public
AspectRatio is a new addition and soon after introduction we noticed use cases which is did not support. Specifically we wanted to support a node being as large as possible within a container while maintaining an arbitrary aspect ratio. This was not possible due to the low priority of AspectRatio, by increasing the priority of AspectRatio this is now possible as FlexGrow will grow an item to fit its parent unless the AspectRatio makes it too big in the cross axis, the AspectRatio will now override the FlexGrow in the main axis in that case.
Differential Revision: D4346720
fbshipit-source-id: 1f15613604190e3ad5ff4a467ba57db4bcfd2741
Summary:
@public
Aspect ratio being defined as width/height or height/width depending on the situation it was used in turned out to be very confusing. This diff makes aspect ratio always be defined as width/height irregardless of the usage.
Differential Revision: D4339132
fbshipit-source-id: e5da32750b55ddaf6acaf1cbd7662d86f2b480c3
Summary: We were incorrectly returning true for children which had no flex as the flex was nan and not 0.
Differential Revision: D4346712
fbshipit-source-id: 69ef0bb3fe5b4fcd3b3e2fe5aa348529be40252a
Summary: This test creates a repro case for Yoga to emulate UFI layout failure
Reviewed By: emilsjolander
Differential Revision: D4313632
fbshipit-source-id: 35be7d86b50a9ae08c81891a889a74e4b61f2d27
Summary:
There is a bug currently where we don't traverse the entire tree to detect view hierarchy changes.
Currently, if you had a hierachy like this:
```
container = UIView
container.subviews = @[subview1, subview2];
subview1.subviews = @[sub11, sub12, sub13];
subview2.subviews = @[sub21, sub22, sub23];
```
and then modified via:
```
subview2.subviews = @[newView1, newView2, newView3];
```
our algorithm wouldn't identify that we had new views that needed their layout calculated, and would cause a crash later on.
Reviewed By: emilsjolander
Differential Revision: D4357662
fbshipit-source-id: 2f61f213c5f1a62948a653f3b1fa3d874c5075f7
Summary: While building some views with YogaKit, I found an interesting problem. If you are apply `yg_` properties to a view which is constructed of subclassed views (that don't use Yoga.) we still treat view (and it's subviews) like they are using YogaKit. This fixes that behavior.
Reviewed By: emilsjolander
Differential Revision: D4348344
fbshipit-source-id: 37b8648918529f55afea1d1883a03af398aac849
Summary: I kept wrongly typing this function which is a good sign that the name is inconsistent.
Reviewed By: gkassabli
Differential Revision: D4333480
fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad
Summary:
- Problem: Can't link yoga static libraries with Unity and Xamarin.iOS since YGNodeInit is undefined in the libraries.
- Solution: Remove the reference in Native.cs
Reviewed By: emilsjolander
Differential Revision: D4338485
fbshipit-source-id: 9dc95aec8f1fd50f3f9d66e1623afe2fb1992210
Summary: This prevents android from matching in the middle of a platform.
Reviewed By: gkassabli
Differential Revision: D4306164
fbshipit-source-id: 7f62a6a017724f8f6741d3e53b5fbe0650c8c88e
Summary: Both New and Reset already call init internally. No reason to expose this function
Reviewed By: gkassabli
Differential Revision: D4276177
fbshipit-source-id: c4404d0534f381dfacee0625b2847d38de58e038
Summary: Running csharp tests should not result in uncommited files.
Reviewed By: splhack
Differential Revision: D4271411
fbshipit-source-id: abf6c69555ed657356a9426ca37864f8c2eaa78f
Summary: Update package name of java code to refer to yoga instead of csslayout. Still need to change the name of the folder where this code resides but that requires update github sync scripts etc so it is safer and easier to split these diffs apart.
Differential Revision: D4271420
fbshipit-source-id: b3cf150569a2331868410339cd19e5c694f2059e
Summary: Rename java api to new use yoga naming
Reviewed By: IanChilds
Differential Revision: D4265345
fbshipit-source-id: 69ecfd8fac214f86b8b70647b9b909acd83d78b5
Summary: Rename test files to use new name
Reviewed By: gkassabli
Differential Revision: D4265235
fbshipit-source-id: 0090d3949828058baf7435f33d4068de92756bad
Summary: This renames the core C api to use the new Yoga branding.
Differential Revision: D4259190
fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
Summary: static linking is dangerous here as more than one library could be including the same symbols. The used to only be used by the jni target previously but that is no longer true
Reviewed By: gkassabli
Differential Revision: D4258293
fbshipit-source-id: 053f9e607503707830e3766b1f268ab31d3081ff
Summary: D4213339 refactored some code and some logic was missed where negative values should only be ignored for at most measurements.
Reviewed By: gkassabli
Differential Revision: D4258254
fbshipit-source-id: e22e36e67260114081e483527fc7ce378f7f0df9
Summary: In case the java object has been GCed during layout calculation we will crash if we try to call a method on the now invalid weak pointer. Use fbjni weak_ref to skip calling to java when the java object does not exist any more.
Reviewed By: lexs
Differential Revision: D4251133
fbshipit-source-id: 2d8949252b31447ce54bc16a35cb25fabe72230b
Summary: static linking is dangerous here as more than one library could be including the same symbols. The used to only be used by the jni target previously but that is no longer true
Reviewed By: gkassabli
Differential Revision: D4248487
fbshipit-source-id: e5127a02561b145745cf5393a0188661469ec79b
Summary: Add compile flag from CSSLayout to jni target as well
Reviewed By: passy
Differential Revision: D4248473
fbshipit-source-id: 18a163a3daedc56e98c7bdc38e10fc8626999f94
Summary: Remove deprecated java code and make use of CSSEdge instead of the now removed Spacing class.
Reviewed By: AaaChiuuu
Differential Revision: D4233198
fbshipit-source-id: 736d79be266e1b9f2d62e5fe6d901de47123cdc1
Summary: The Style prefix does not make sense in the java and c# api and only a few methods had it. This diff removes the last of those.
Reviewed By: splhack
Differential Revision: D4232920
fbshipit-source-id: 6e2ff21bbb7e0e441892023c14df579d1bc7aa49
Summary: Soloader is safer than System load library, retrying with System load library just hides errors
Reviewed By: lexs
Differential Revision: D4243906
fbshipit-source-id: e4d691c9c49f3b9316f67e39b9f277657d78fb3c
Summary: Add notice in readme to prepare open source for large renaming diffs.
Reviewed By: splhack
Differential Revision: D4240761
fbshipit-source-id: 4c8070a06c3ac009b67eb7bef5de11ce3ab3e4d8
Summary:
At least or x86_64 linux, it appears that you need position-independent
code is required in order to link against it. Otherwise you see errors
like this:
```
/usr/bin/ld: lib_sys.rlib(CSSLayout.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: lib_sys.rlib(CSSNodeList.c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
```
If I understand it correctly, you don't strictly need PIC for static libraries, but as soon as you want to link *other* dynamically linked library into it, it is required - which makes logical sense to me. Let me know if you want to enable this by default or leave it up to the developers to enable this if needed.
Closes https://github.com/facebook/css-layout/pull/263
Reviewed By: passy
Differential Revision: D4237009
Pulled By: emilsjolander
fbshipit-source-id: e73ea0ea22520758ec958a031d6e2ca62fdcda15
Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.
Reviewed By: gkassabli
Differential Revision: D4226734
fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag.
Reviewed By: gkassabli
Differential Revision: D4222910
fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
Summary: I found that if you move a subview to a different index, it would cause a crash in subsequent layout passes because the `CSSNodeRef` representing it was being re-inserted into the list. I spent a lot of time figuring out the best way to "diff" the view hierarchy from before and after, and I found the easiest implementation is also the most reliable. We can continue to optimize, but this is a great start.
Reviewed By: emilsjolander
Differential Revision: D4218623
fbshipit-source-id: 06253089492ac37ae4b94b7c30140ce6ed680ed2
Summary:
Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely can be further improved. I'm looking forward to your ideas.
Closes https://github.com/facebook/css-layout/pull/256
Reviewed By: splhack
Differential Revision: D4214168
Pulled By: emilsjolander
fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236
Summary:
Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values.
Closes https://github.com/facebook/css-layout/pull/257
Reviewed By: splhack
Differential Revision: D4213809
Pulled By: emilsjolander
fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2
Summary:
We currently have a bug in `UIView+CSSLayout.m` that you can repro in a scenario like this:
```
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setIncludeInLayout:NO];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setIncludeInLayout:NO];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setIncludeInLayout:YES];
[container addSubview:subview3];
[container css_applyLayout];
```
`subview3` (which is the only view whose is going to be included in layout calculation) is inserted at child index 2, instead of 0. This eventually can cause crash in CSSLayout.c because it will attempt access a child in the list which is null.
Reviewed By: emilsjolander
Differential Revision: D4215659
fbshipit-source-id: a615f50e51f85b15d3bdb437e55958865898b183
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213339
fbshipit-source-id: 5ca35ca307594f3419fd0dee81321d3c2e06710f
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213313
fbshipit-source-id: 2061a809202f7f948bff1b3ee8dc4c230692a223
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213302
fbshipit-source-id: df4bc43848325e99ad338a2fa6d5c9404315b0e6
Summary: Implement aspect ratio as part of Yoga. Aspect ratio allows users of the library to specify the size of the undefined dimension in terms of an aspect ratio. See test cases for examples.
Reviewed By: gkassabli
Differential Revision: D4211458
fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d
Summary:
computed flex basis was incorrectly being reused in some circumstances between calls to caluclateLayout
also run format script.
Reviewed By: dshahidehpour
Differential Revision: D4207106
fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d
Summary:
```isnan``` is already defined in ```math.h``` (at least when using VS13) so there is no need to redefine it. it also is a nan for float and not for double opposed to ```_isnan```
Closes https://github.com/facebook/css-layout/pull/253
Reviewed By: emilsjolander
Differential Revision: D4199331
Pulled By: splhack
fbshipit-source-id: 139fb0efd68dd5df79bbaef863a8e8b9246c795d
Summary:
Use ```size_t```instead of ```unsinged long``` as this is the "offical" return type of ```strlen```. Is VS13 ```size_t``` is defined as ```unsigned long long``` which leads to a compiler warning.
Closes https://github.com/facebook/css-layout/pull/254
Reviewed By: emilsjolander
Differential Revision: D4199327
Pulled By: splhack
fbshipit-source-id: 5e1a91f282bf776e4d9f5806e6467dfe36c7a633
Summary:
- Add a convenience function to copy all style from one node to another.
- CSSNodeIsDirty will return true after this function if any style was changed in the destination node.
Reviewed By: emilsjolander
Differential Revision: D4188514
fbshipit-source-id: af8d7fb5e8688c64aea05ce7ad23fff9233fb441
Summary:
- Problem: Build error in Visual Studio since an array cannot have zero size.
- e6702e1168 (commitcomment-19839659)
- Solution: Add 1 until we'll have actual CSSExperimentalFeature value.
Reviewed By: emilsjolander
Differential Revision: D4191268
fbshipit-source-id: 53fdcc388292e76c2b97ad071f0d7c27d0613ecf
Summary:
When dealing with manual sizing in UIView's (or UIKit in general) we see a common pattern like so:
Below we have an example implementation of a view with two Labels that want to be stacked horizontally. If we don't pass a second string, we hide the second label and give up the available space to the first label. See below:
```
interface TitleSubtitleView : UIView
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;
end
implementation {
UILabel *_titleLabel;
UILabel *_subtitleLabel;
}
....
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
_titleLabel.text = title;
if (subtitle.length > 0) {
_subtitleLabel.hidden = NO;
_subtitleLabel.text = subtitle;
} else {
_subtitleLabel.hidden = YES;
}
}
- (CGSize)sizeThatFits:(CGSize)size {
const CGSize titleSize = [_titleLabel sizeThatFits:size];
CGSize subtitleSize = CGSizeZero;
if (!_subtitleLabel.isHidden) {
subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
const CGSize titleSize = [_titleLabel sizeThatFits:size];
_titleLabel.frame = CGRectMake(0, 0, titleSize.width, titleSize.height);
if (!_subtitleLabel.isHidden) {
subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
_subtitleLabel.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, subtitleSize.width, subtitleSize.height);
}
}
```
The problem is with the CSSLayout framework, as long as your view is in hierarchy, it's going to be allocated space during layout calculation. The only way to fix the view above would be to completely remove it from view hierarchy if it isn't being used. The problem is that adding/removing views from hierarchy is much less performant than hiding.
As a result, we need a way to tell the CSSLayoutKit library that even though a view is in hierarchy, we don't want to include it in layout. With this diff, we could change the class to look like this:
```
interface TitleSubtitleView : UIView
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;
end
implementation {
UILabel *_titleLabel;
UILabel *_subtitleLabel;
}
....
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
_titleLabel.text = title;
_subtitleLabel.text = subtitle;
const BOOL subtitleHasText = subtitle.length > 0;
_subtitleLabel.hidden = !subtitleHasText;
[_subtitleLabel css_includeInLayout:!subtitleHasText];
}
- (CGSize)sizeThatFits:(CGSize)size {
const intrinsicSize = [self css_intrinsicSize];
return CGSizeMake(MIN(size.width, intrinsicSize.width), MIN(size.height, intrinsicSize.height)));
}
- (void)layoutSubviews {
[super layoutSubviews];
[self css_applyLayout];
}
```
Reviewed By: emilsjolander
Differential Revision: D4189897
fbshipit-source-id: 403d11d84d47691e3ce0b5ac18a180b0e4c104c4
Summary: When I try to use this in practice, I have come to realize that css_sizeThatFits will 99% return to you the constrainedSize that you pass it, thus making it useless. Instead, we replace it with a new API that will tell you the optimal size of the resolved layout. From this we can choose to use that size, or scale it down.
Reviewed By: emilsjolander
Differential Revision: D4191873
fbshipit-source-id: d36a2850448d9d82f97e5ef4c7397778c2a14094
Summary: Remove infra for dynamically downloading gtest as this fails like 50% of the time on travis. I'll manually push gtest as a submodule instead.
Reviewed By: gkassabli
Differential Revision: D4183033
fbshipit-source-id: 09a121b8ede7a5974a29b6692edc63bff79aece7
Summary: For some reason these tests don't pass when running in travis. They are still running internally so we should catch any regressions. We can remove this if we figure out what is causing travis to fail here but until now I would rather get travis to pass.
Reviewed By: dshahidehpour
Differential Revision: D4189251
fbshipit-source-id: a27d3390f6b6fdcac6a3312d02581bb64969fd4b
Summary:
- Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib.
- Fixed memory leaks in tests.
- Close#247
For example, to use dlmalloc with USE_DL_PREFIX
CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree);
Reviewed By: emilsjolander
Differential Revision: D4178386
fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b
Summary: Keeping enums in sync between all the different bindings is tedious and error prone. Getting one of the values in the incorrect order could lead to many hours of debugging as they are passed as ints to C. This diff adds a simple python script to generate these enums for all languages. This also makes it much easier to add support for more languages in the future
Reviewed By: gkassabli
Differential Revision: D4174263
fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10
Summary: If some test previous to this test fails to de-allocate a node we don't want this test to fail.
Reviewed By: dshahidehpour
Differential Revision: D4182179
fbshipit-source-id: 229dd5736d6d7b9c1b22b181e022c788584b9c17
Summary: Talked with emilsjolander offline, and we want to keep the prefixes standardized in this lib. Changing CLK prefixes to CSS.
Reviewed By: emilsjolander
Differential Revision: D4175634
fbshipit-source-id: 7152268b9312df3fdb8eaee7ce3f6baabc5de937
Summary: We want to start experimenting with changes to the library in a more controlled and easier to measure manner. This diff adds the basics of an experiment layer to csslayout.
Reviewed By: gkassabli
Differential Revision: D4174260
fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd
Summary: Java and csharp already use CSSWrap and not CSSWrapType. Let's consolidate and stick with the shorter of the two.
Reviewed By: gkassabli
Differential Revision: D4174257
fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592
Summary:
Fixes issue brought up in https://github.com/facebook/react-native/issues/10603
The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this.
Reviewed By: gkassabli
Differential Revision: D4157971
fbshipit-source-id: 3cfae15ac8b65b70f01789444099ee684e1b099a
Summary: There is a little bit of tidying that was needed for this class. The documentation was inconsistent in the header, the static functions were prefixed with underscores (discouraged by apple). Cleaned it all up.
Reviewed By: rnystrom
Differential Revision: D4167936
fbshipit-source-id: 6e9a6e7fb78e3cff290b867a1ac0d5dd5cc9de5b
Summary: Just firming up some stuff with more compiler flags.
Reviewed By: rnystrom
Differential Revision: D4168081
fbshipit-source-id: fced407f03944081bdd70cc28c57e3dc842ff7f0
Summary: Previous fix for flex in max size constraint was not entirely correct and was missing a test case for the time when the max constraint is not applied. This diff addresses that.
Reviewed By: gkassabli
Differential Revision: D4162104
fbshipit-source-id: 08feba6cb4e789c9aa12179e2cdeadc66b011841
Summary:
When trying to integrate this into an Xcode project that already included CSSLayout.[c|h], we were getting a linker error.
Upon digging in, I found out that Xcode was becoming confused because the imports of the uikit library and the c library are both `#import <CSSLayout/CSSLayout.h>`. So, it needed a new name.
Reviewed By: emilsjolander
Differential Revision: D4162621
fbshipit-source-id: b5f7624eb29f1b9eaebbed5104ec9ea8a12ad2e5
Summary: Currently travis logs indicate it is building with the wrong cxx platform. Explicitly set this to and ios simulator for ios tests
Reviewed By: dshahidehpour
Differential Revision: D4162159
fbshipit-source-id: 50f563132456ee4ba4e5b3b4b1f50b636cb94306
Summary: Same as Java, it allows to use float and double values in Make arguments.
Reviewed By: emilsjolander
Differential Revision: D4163347
fbshipit-source-id: f373247b3f37e7940a66044000cca2935068decf
Summary: Pointed out by the Xcode analyzer
Reviewed By: emilsjolander
Differential Revision: D4159938
fbshipit-source-id: 8b9ff3896c0e222e8e89546881129214bc6ba566
Summary: It was always a mistake to have a measure function here but the recent addition of an assertion made us notice it.
Reviewed By: splhack
Differential Revision: D4156754
fbshipit-source-id: 98fcea6e233cb4f5706ebca37028c8d67edb4c09
Summary: Add tests for checking C side asserts in managed
Reviewed By: emilsjolander
Differential Revision: D4154869
fbshipit-source-id: 5203db27eff963d46f188de448f607a24ed63fab
Summary: Travis builds have been broken for a while. This diff fixes some of the issues surrounding bad buck file configuration as well as missing jni.h file.
Reviewed By: astreet
Differential Revision: D4148724
fbshipit-source-id: 1e284db61280326a4bcbb9337e804a4804348aa6
Summary:
If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.
This is a re-land of D4147298. I have updated the diff to check explicitly for exact measure mode to also handle at_most case correctly.
Reviewed By: gkassabli
Differential Revision: D4153133
fbshipit-source-id: 2333150a83857cc30078cc8d52761cbd00652830
Summary:
@public
The goal of this diff is to have assertion failures show up as error logs on Android. To do this, I updated the logging API to take calls with log levels. We now have to pass around va_list unfortunately since you can't re-expand or pass along var-args to a subcall.
Reviewed By: emilsjolander
Differential Revision: D4140898
fbshipit-source-id: e0eb9a1f0b08a7d90a8233f66bb857d5b871b6ad
Summary: Default value for positions should be undefined not 0px. Fixing this leads to more correct tests.
Reviewed By: gkassabli
Differential Revision: D4153329
fbshipit-source-id: d0f194f9c47eac93d3815ec7e55568a1016bc7fe
Summary: Within `UIView+CSSLayout`, we often nil out the measure function of a node because view hierarchy can often change. Unfortunately, this causes us to hit an assert which crashes the app. Instead, lets the measure func to be set to NULL, regardless of how many children a node might have.
Reviewed By: emilsjolander
Differential Revision: D4148727
fbshipit-source-id: 79a0f3ef1bf7b1dce9a14de96f870e35c042b78b
Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.
Reviewed By: gkassabli
Differential Revision: D4147298
fbshipit-source-id: 8416508a31e8d317bf59d956abdbe5760b55bb6d
Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.
Reviewed By: gkassabli
Differential Revision: D4147298
fbshipit-source-id: 51152e57eff8e322a833a6d698c30f8c5e2dcc35
Summary:
Max dimension constraints were not correctly passed down to children.
see https://github.com/facebook/css-layout/issues/230 for more info
fixes#230
Reviewed By: gkassabli
Differential Revision: D4147199
fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9
Summary: Scrolling through feed and logging when this optimization is hit leads to... 0 logs. If anything this just adds to confusion. It was initially added due to instinct and not data, which was a mistake. I am happy to add some similar optimization in the future if we have data that it is useful in real world situations, currently it just leads to bugs and confusion though.
Reviewed By: astreet
Differential Revision: D4146785
fbshipit-source-id: e20d780fbd5759b8f38b809e8cadf29cedee82a8
Summary: Not sure why this didn't catch during my testing, but, this causes a build error. #accept2ship
Reviewed By: emilsjolander
Differential Revision: D4143108
fbshipit-source-id: 01c35c5b91767c95485d615eb06e836b023e125a
Summary: For some reason I didn't get a signal of this breakage. Fixing unit tests.
Reviewed By: emilsjolander
Differential Revision: D4140327
fbshipit-source-id: 95049b510a8869b6f68cc841e7f8731364417af9
Summary: css-layout will only call measure which it is unsure of the size of a node so it will never call measure with both modes equal to exact.
Reviewed By: dshahidehpour
Differential Revision: D4142193
fbshipit-source-id: fb8423cf0d45852ecb9df8fed042b25d1a443eea
Summary:
Not all platforms have gtest death tests. There is a define to check for that.
Bracketed the relevant tests with the define.
Reviewed By: youerkang
Differential Revision: D4141823
fbshipit-source-id: 1396657f3ee83853fcda85d5a51708d4e77642cb
Summary: We don't want to expose this in our first usage. Lets kill it.
Reviewed By: emilsjolander
Differential Revision: D4140377
fbshipit-source-id: 0c53845ec65466692b847a5ce40c3b9823dd9557
Summary: You can lose a lot of performance on UIView's if they are not pixel-aligned. This protects it from happening in views which use css-layout.
Reviewed By: emilsjolander
Differential Revision: D4140306
fbshipit-source-id: 53493c08c084a7e3dcd4e05f6a665a99340ea5a6
Summary:
The inline keyword is available only in C++. The __inline and __forceinline keywords are available in both C and C++. For compatibility with previous versions, _inline is a synonym for __inline.
https://msdn.microsoft.com/en-us/library/z8y1yy88(v=vs.120).aspx
Closes https://github.com/facebook/css-layout/pull/239
Reviewed By: astreet
Differential Revision: D4138941
Pulled By: emilsjolander
fbshipit-source-id: cb59dc91ef285e5378036c4912217fd4ec8d9f79
Summary: As I've begun to integrate this into the codebase, I've found that sometimes our layouts are affected by bad implementations of sizeThatFits:. For example, in certain configurations of UILabel it won't take clipping into account and return a size that is much larger than the max size we requested. This adds some checks to make sure we never return a size that is larger than the one specified by `_measure`. This also fixes the bug where `CSSMeasureModeExactly` won't be applied if the measure mode for other parameter is node `CSSMeasureModeExactly`.
Reviewed By: emilsjolander
Differential Revision: D4131195
fbshipit-source-id: 4659fd83892a2c149b3b70733b06b19217507bf9
Summary:
@public
In the JNI portion of CSSLayout, there's a subtle bug where we were caching the jmethodid of the 'measure' of the first object that had measure called on it. However, if that class had overriden measure, then the jmethodid would be specific to that subclass's implementation and would not work for other classes. Conversely, if a regular CSSNode had been called first, then the super method would be called on the subclass instead of the proper overriden method.
Since there's not really a reason to overriden measure anyway (since you can just provide a different measure function), it's safest to just mark it final and explicitly cache the appropriate methodid
Reviewed By: emilsjolander
Differential Revision: D4132428
fbshipit-source-id: 6fb51597d80f1c03681e6611153b52b73b392245
Summary:
@public
We don't need to allocate a list for every node since leaf nodes don't have children.
Reviewed By: emilsjolander
Differential Revision: D4130818
fbshipit-source-id: 80d3e98fce9d2daa0676fd1cbed0e81edcf7adb3
Summary:
@public
Instead of silently ignorning non-leaf nodes with measure functions, we should assert that we don't create those kinds of trees.
Reviewed By: emilsjolander
Differential Revision: D4130770
fbshipit-source-id: a3ef10a2e63bbc12b5aa07977e4b84c8d59e3ffe
Summary: flex is just shorthand for flexBasis, flexGrow and flexShrink, and I don't want to expose overflow yet, so, removing them from the API.
Reviewed By: ryanolsonk
Differential Revision: D4126773
fbshipit-source-id: e3b9ef714832cb5665bd20d7fa92f97a266c9210
Summary: Currently, when we try to remove a child from a node, that node is mark dirty //regardless of whether or not anything was actually removed//. This fixes it.
Reviewed By: gkassabli
Differential Revision: D4125453
fbshipit-source-id: 745cfc55269415fea106a80c72401eb3074f2d31
Summary: This exposes an API so people can find out the resulting size of a layout calculation without changing the frame of the view.
Reviewed By: emilsjolander
Differential Revision: D4124630
fbshipit-source-id: f2b28d8a5474857cb1c92e021a1f161806826cda
Summary: We need to expose CSSLayout caching check to CKFlexboxComponent to enable performant bridging to CKComponentKit
Reviewed By: emilsjolander
Differential Revision: D4124705
fbshipit-source-id: 23284967900585fa20dcb51c9cc1bee829b32975
Summary: With the current implementation, as long as you had set a value on usesFlexbox (YES or NO), it would return YES. This fixes it.
Reviewed By: amonshiz
Differential Revision: D4124485
fbshipit-source-id: 32fe4ec0109b5c8678a112f9d4295bd17a6f6dc2
Summary: We don't want people to somehow change the underlying cnode on our CSSNodeBridge. Making it readonly.
Reviewed By: rnystrom
Differential Revision: D4124496
fbshipit-source-id: f88ed82c1df17d401aeca6f6341e429c95e55624
Summary:
Even so the problem of #236 has been fixed via ced779b there is still a case where you have a out of bound array access of undefined behaviour. This PR prevents the out of bound access of the underlying c array. The out of bound access happens if you already have 4 subViews and add another one. Then you will access CSSNodeGetChild with 4 which points into uninitialized memory.
Closes https://github.com/facebook/css-layout/pull/237
Reviewed By: dshahidehpour
Differential Revision: D4107743
Pulled By: emilsjolander
fbshipit-source-id: 0f21397f3a77308369acfea7327733f74eb72e00
Summary: Previously, we would preallocate Node's with a child list of 4. We recently removed that logic (see diff below), and as a result, if you tried to access a Node's list of children before it had been allocated, you would crash. I added a simple check to protect from crashes, the operation of the check is O(1) so we shouldn't see a perf hit.
Reviewed By: emilsjolander
Differential Revision: D4104093
fbshipit-source-id: cd7b09818759aa76415b97e241f1a6746a2bc50c
Summary: Simplify logic for what value to return in smaller functions with a preference for ternary operator where possible.
Reviewed By: gkassabli
Differential Revision: D4101772
fbshipit-source-id: 626df10c0fc76278c330c86be4dc82fdda5f5156
Summary: This list can only contain CSSNodeRefs so don't use void*
Reviewed By: gkassabli
Differential Revision: D4101773
fbshipit-source-id: 8a5c9066da796967bd02ce6b1fc74ff40e15dfe1
Summary: Add a more complex benchmark which actually take a couple milliseconds to perform. This makes it easier to see if optimizations have any effect. More styles should be added later to make sure the benchmarks covers most of the csslayout code.
Reviewed By: gkassabli
Differential Revision: D4101780
fbshipit-source-id: 6bdf703edfbe64c47c77e04ef1ca946f4b75d093
Summary: Since these functions are private and only used in the implementation file, we don't need to declare them beforehand.
Reviewed By: emilsjolander
Differential Revision: D4088488
fbshipit-source-id: 738175a4aae27d88d32f8c2cf6b47a4f6ae32aab
Summary:
- bit operation with long
- Clean up _measureOutput which is no longer needed
- Fix unittests (SetMeasureFunction, unused error)
Reviewed By: emilsjolander
Differential Revision: D4082401
fbshipit-source-id: b3b2dd002d108c5b43f36a4a73ce8e5233281b45
Summary: Set layout outputs on CSSNode from C after layout calculation finishes instead of relying on calling jni gettings from java code. This should be much more efficient as it avoids a lot of jni overhead and also allows for calling getLayoutWidth() etc multiple times without incurring a penalty.
Reviewed By: lexs
Differential Revision: D4077968
fbshipit-source-id: bce86ba610cd5ae36cfb45d78b2609c63a14cfa3
Summary: To perform some JNI optimizations for java we need a reference to the node in the measure function. This updates the API to provide the whole node as input instead of just the context.
Reviewed By: javache
Differential Revision: D4081544
fbshipit-source-id: d49679025cea027cf7b8482898de0a01fe0f9d40
Summary: This is an API breaking change done to allow us to avoid an allocation during measurement. Instead we do the same trick as is done when passing measure results to C, we path them into a long.
Reviewed By: splhack
Differential Revision: D4081037
fbshipit-source-id: 28adbcdd160cbd3f59a0fdd4b9f1200ae18678f1
Summary: This state was never reset when we switched to doing reset in C instead of re-allocating.
Differential Revision: D4081049
fbshipit-source-id: 0b9ad70339ad906ad5219ad2679329cfe2fd7abc
Summary:
- Prevent the GC from collecting MeasureInternal in order to call managed MeasureFunction properly from unmanaged
- TestMeasureFuncWithDestructor will fail without the fix
- Avoid new as C implementation
Reviewed By: emilsjolander
Differential Revision: D4080765
fbshipit-source-id: d58fa18f6f74012aeda5dd15dfa7ceb0b64584d0
Summary: Many layout systems query the padding after calculation to as it is needs to be propagated to the underlying view system on the platform. However most nodes have no padding set on them so going 4-6 times through JNI layer to figure this out is a waste of time.
Differential Revision: D4080909
fbshipit-source-id: 7eb1885c615191055aa21e3435c6fbc652b883ae
Summary: There is no reason to malloc a list of 4 child pointers for every CSS node eagerly. Instead, we malloc the list (preserving the default size of 4) when we try to put stuff in it.
Reviewed By: emilsjolander
Differential Revision: D4078012
fbshipit-source-id: 7cdcab03ec4067550a5fee5e1baea14344f3a8f9
Summary: sleeping in the measure function was done to ensure we were not regressing in double measure calls. This was before we have CSSLayoutMeasureCacheTest though. Let's switch over benchmark to purely benchmark the algorithm and not simulate measure time.
Reviewed By: swolchok
Differential Revision: D4078186
fbshipit-source-id: e1c16806b3c8714e223e1cfcb6c43846f8f6bbb2
Summary:
This PR leads to removing the children from the end. [So we don't have the overhead of copying them to the front](dcaef7ecb0/CSSLayout/CSSNodeList.c (L62)).
Closes https://github.com/facebook/css-layout/pull/233
Reviewed By: emilsjolander
Differential Revision: D4075905
Pulled By: splhack
fbshipit-source-id: d8b460badb01bfc6ea647004c799395b9cab9e7c
Summary:
- Update CSSNodeFree to unlink parent and children for C#, Java and Objective-C bindings finalizer.
- [C#] Fix build (Fix#232)
- [C#] Add Clear API for convenience as CSSNodeFreeRecursive.
- [C#] Revise and add unit tests
Reviewed By: emilsjolander
Differential Revision: D4069655
fbshipit-source-id: 1fd764059784d7968af38b6aaf7fb6f70fdee8ee
Summary: canUseCachedMeasurement function was not handling CSSMeasureModeAtMost correctly so a bunch of measurements that could have been reused were not. When a previous measurement used AtMost and the new one as an AtMost with a smaller constraint but still bigger than the previous computed size it should be OK to re-use the previously computed size.
Reviewed By: gkassabli
Differential Revision: D4071621
fbshipit-source-id: 19d87d939051ddf8ee2e1c6e60efee22d173bbb9
Summary: Remove duplicate functions calls. Using instruments I could see a 5% perf increase from this change.
Reviewed By: gkassabli
Differential Revision: D4068140
fbshipit-source-id: 91261afb73e1c5e23c2cfc84df6ecc5c844a4e78
Summary: The current implementation was made out of simplicity and to keep the same API as before. Now that the java version of csslayout is deprecated it is time to change the API to make the calls more efficient for the JNI version. This diff with reduce allocations as well as reduce the number of JNI calls done.
Differential Revision: D4050773
fbshipit-source-id: 3fd04c27f887a36875e455b5404a17154ac18f91
Summary: Instead of having different lifetimes for java and c memory we can can tie them together and make them much easier to manage. This also leads to automatically pooling native memory if pooling java memory.
Differential Revision: D4051454
fbshipit-source-id: 8f5d010be520b3d1c981a7f85e5e6d95773ea6c1
Summary: It doesn't make sense to have a getter for the shorthand as it is the computed flexGrow and flexShrink values that you should care about.
Reviewed By: gkassabli
Differential Revision: D4064674
fbshipit-source-id: 69935b85042020b4e8c61a393c1be8f4d42a6674
Summary: when setting both flex and flexGrow then flexGrow should override flex even though flex was setter after.
Reviewed By: gkassabli
Differential Revision: D4064696
fbshipit-source-id: db2d4b8e60209f0a9eed6794a167b85e453be41c
Summary:
- Update README for gentest
- Fix gentest.rb for the right working dir
Reviewed By: emilsjolander
Differential Revision: D4065863
fbshipit-source-id: 5c6bd9d18779c05c1de24c06a83b148889facb6b
Summary:
- Revise scripts to generate Java and C# unittests using the same HTML fixtures as well as C for code coverage.
- Add wrap_column test workaround in gentest.js.
- Add checkDefaultValues for sanity check of the CSSLayout default values by test-template.html
- Add `align-content: flex-start;` in default div to align with CSSLayout default
$ cd csharp/gentest
$ ruby gentest.rb
- macOS example for C#
$ cd csharp/tests/Facebook.CSSLayout
$ clang -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -g -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp
$ mcs -debug -t:library -r:nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs
$ mono64 --debug nunit-console.exe CSSLayoutTest.dll
Reviewed By: emilsjolander
Differential Revision: D4053777
fbshipit-source-id: 84450208015e65baf604987bd56c6a268598b545
Summary:
When using CSS-Layout in a C# UWP project in x86, by default the MSVC compiler defaults the delegate calling convention to cdecl, while .NET assumes that all delegates are declared using stdcall. This causes a problem when invoking such as this error:
```
Run-Time Check Failure #0 - The value of ESP was not properly saved across
a function call. This is usually a result of calling a function declared with one
calling convention with a function pointer declared with a different calling
convention.
```
This PR changes the calling convention in the C# code to reflect cdecl by using the `UnmanagedFunctionPointer` attribute and setting the calling convention to `CallingConvention.Cdecl`.
```csharp
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate CSSSize CSSMeasureFunc(
IntPtr context,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode);
```
I have updated all calls as well to other functions. I
Closes https://github.com/facebook/css-layout/pull/231
Reviewed By: emilsjolander
Differential Revision: D4063437
Pulled By: splhack
fbshipit-source-id: b1069a1b9f675d2623a64a1c5f3189292a18a646
Summary: ryandm pointed out that `use_cxx_library` is necessary for fbcode overrides. And that's also true for fbandroid now.
Reviewed By: ryandm
Differential Revision: D4053192
fbshipit-source-id: 453e77df6f31b9bf6b2d221d7def8361e2966ff2
Summary:
Originally, we thought that skipping the measurement of views that were hidden would be a nice optimiatzion. Upon further review, we saw that according to Apple's `UIView` documentation:
> A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual.
So, to keep parity with common iOS layout APIs, we are going to size and layout views, even if they are hidden.
Reviewed By: emilsjolander
Differential Revision: D4051225
fbshipit-source-id: 0794cbad293a7de83d109dad2b3983d83845d145
Summary: Fixup format file for hopefully the last time in a while and re-format code
Reviewed By: gkassabli
Differential Revision: D4044545
fbshipit-source-id: 60ebb73cfdd9dbc9b5fae62ddebf37e9b1e6eecf
Summary:
- CSSLayoutSetLogger
- Problem: Unity or other logging system can't use printf output
- Solution: Add CSSLogger to pass CSSNodePrint result to UnityEngine.Debug.Log or other logging system via CSSLogger function for debugging purpose
Reviewed By: emilsjolander
Differential Revision: D4027044
fbshipit-source-id: 90e2e449260888770f71fa7ea790ca9764d91c44
Summary: Flex basis should override height/width. Not the other way around.
Reviewed By: gkassabli
Differential Revision: D4029374
fbshipit-source-id: bc3c72879f3937a50bf8a636b547adc7b9a4f5a7
Summary: Use typedefs from header for print and measure functions
Reviewed By: gkassabli
Differential Revision: D4036421
fbshipit-source-id: 01f15cb840363850970e6a60e661af06fd6ec9e0
Summary:
The flag to use in fbandroid is `-Duses_native_libraries` passed in via `vm_args`
In `fbandroid/third-party/build-tools/java/java.sh` looks for this flag to override the default java with the fbcode runtime java.
Reviewed By: ryandm
Differential Revision: D4024857
fbshipit-source-id: 0ace0ee94fea32376a24004582556fa1d7d2e222
Summary: If we ever add more cases to an enum the compiler would not complain if we used default.
Reviewed By: gkassabli
Differential Revision: D4036440
fbshipit-source-id: f5ef4c8afff0f353de50681ad304878f90255fef
Summary: Prefer inline style to computed style as inline style should be the source of truth and computed style may differ
Reviewed By: gkassabli
Differential Revision: D4029373
fbshipit-source-id: 39ce9d577f295c2361dc384212d7467418c63c33
Summary: Min dimension was not respected when calculating justify content. This diff ensures that the min dimension is taken into account when at most measure spec is used.
Reviewed By: gkassabli, lucasr
Differential Revision: D4021443
fbshipit-source-id: 00f58c6078ac3076221e1148aacc34712786deb5
Summary: using `IS_THIS_FBOBJC` will break the tests in the open-source repo. This fixes Facebook builds and open source builds.
Reviewed By: WaseemTheDream, mzlee
Differential Revision: D4025580
fbshipit-source-id: 8280520a63134744fd24518aa6f45423aa0ecd03
Summary: Now that we have some tests, lets run them.
Reviewed By: emilsjolander
Differential Revision: D4023765
fbshipit-source-id: 9f2fa723dc9a33f12c0470b782d6329b432546fa
Summary: Gate it with `THIS_IS_FBOBJC` for now - the better solution is gating with fb_xplat_cxx_library and fb_xplat_cxx_test
Reviewed By: dshahidehpour
Differential Revision: D4024973
fbshipit-source-id: 2ce744fd67630b39b0498d0479a034d0b05c68ed
Summary: Wrote some tests to make sure the associated objects we use for layout live and die with the objects. This was worthwhile because it made me realize UIView+CSSLayout wasn't enabled to ARC. As a result, my tests were failing because they weren't explicitly deallocing nodes.
Reviewed By: rnystrom
Differential Revision: D4023324
fbshipit-source-id: 5356cf4f0522582d75f83b5eb2193d9bc8d63aee
Summary: `sizeThatFits:` can be expensive, this optimizes our measuring function so that we do not call it if we know that we are going to use the exact height and width that were passed-in.
Reviewed By: rnystrom
Differential Revision: D4023715
fbshipit-source-id: dc02703b50bafd168ffab62ed98a7f6342100cc9
Summary: If views are hidden on screen, we don't want to bother including them in layout calculations.
Reviewed By: rnystrom
Differential Revision: D4022992
fbshipit-source-id: 2e93eb911f26223f305ef7ce788f86d050b83e4a
Summary: I'm going to make some changes, but first, I want to get testing setup.
Reviewed By: rnystrom
Differential Revision: D4022585
fbshipit-source-id: a48516faad0bcb1a9cf5610ab21da5ee099c6f16
Summary: Don't assume a node with a measure function is a leaf node
Reviewed By: gkassabli
Differential Revision: D4021096
fbshipit-source-id: 7e039239b1697a0ac42dce9f4b7e252a931bad7e
Summary: Rename C test target to match pattern of other test targets
Reviewed By: gkassabli
Differential Revision: D4014931
fbshipit-source-id: 2b4b831d6073214e8162a1d27b7478f3665a795f
Summary: This diff adds compatibility with Apple TVOS Buck build for CSSLayout library. Warning fixes are needed to ensure correct build
Reviewed By: emilsjolander
Differential Revision: D4001901
fbshipit-source-id: f095b4ac0ba91addb28d877b411ec27ecff4aad6
Summary: Update readme adding UIKit and fixing things that have changed
Differential Revision: D4015068
fbshipit-source-id: 213a60bea6f16ca01a4e613c8e3563f7c354ca8e
Summary:
The changed functions tripped -Wmissing-prototypes. (e.g.,
`void Foo();` doesn't count as a prototype in C. you need `void
Foo(void);`)
Reviewed By: mzlee
Differential Revision: D4012611
fbshipit-source-id: f56949d464e0ce602138b60f4abfd45b211be3b2
Summary: Add flexbox support to UIViews via a category
Reviewed By: dshahidehpour
Differential Revision: D4002873
fbshipit-source-id: f89de3acdf8fd89c7801918dcad34ba9011dd025
Summary: Move java buck rules out of the root buck file and into the java subfolder. This matches how buck should be used. Having one huge buck file is not best practice.
Reviewed By: lucasr
Differential Revision: D4008408
fbshipit-source-id: 5895c62cc8806d6a849e1b2cc6ea95c36b9d99b6
Summary: Remove tests for CSSNodeDEPRECATED. Java tests will be replaced by jni binding tests in upcoming diff.
Reviewed By: lucasr
Differential Revision: D3992821
fbshipit-source-id: d4877674c96f667f5acf92aab58af02aa27da4c2
Summary: Rename init() -> reinit() to be more in line with what it now does as the initiall init is done when constructing the object.
Reviewed By: lucasr
Differential Revision: D3992811
fbshipit-source-id: 61a10acc873ec028b2789007a400d89e62cf31d6
Summary: Rename reset() -> free() to be more in line with what it now does as the default implementation is JNI
Reviewed By: lucasr
Differential Revision: D3992808
fbshipit-source-id: 8428ae33268d1417ce8642b741e47150a17bf077
Summary: Don't require calling init() to used an allocated object. This makes more sense and is more in line with how jni in java is generally managed.
Reviewed By: lucasr
Differential Revision: D3992802
fbshipit-source-id: 06d65821f1802ed8f2b2db651cef69f6851803f2
Summary: JNI version is the default, its name should reflect that
Reviewed By: lucasr
Differential Revision: D3992777
fbshipit-source-id: cdd4cc58f3c15b5db1158f6f794394eb5c44a44d
Summary: Remove internal xcode_public_headers_symlinks flag from open source in hope to fix travis builds.
Reviewed By: lucasr
Differential Revision: D3992698
fbshipit-source-id: 1bd19bdd18d1bdfff595c19475bb2adc23d95335
Summary: Clearly mark java CSSNode as deprecated. It will go away very soon.
Reviewed By: lucasr
Differential Revision: D3992775
fbshipit-source-id: b3ceca277e5c7426eb51f8cbeacf5e2fe451c6ec
Summary: Move csharp tests into csharp/tests instead of tests. I feel like it makes more sense to have tests next to source. This is similar to how the C version has it as well.
Reviewed By: splhack
Differential Revision: D3993002
fbshipit-source-id: d9241f8ce7707c17a49c17fea2cce9959d52697d
Summary: buck rules are not meant to be in the root buck file but instead next to source files. This diff moves benchmark rule into benchmark folder.
Reviewed By: lucasr
Differential Revision: D3992992
fbshipit-source-id: 34782ff73bbd5b799d83d0f01b553bfab928f1df
Summary: Ensure all native memory is released once gc deallocates the java object reference.
Reviewed By: lucasr
Differential Revision: D3992759
fbshipit-source-id: f648b72ead5bdb7257a5197496b19795f71f3788
Summary: Add some dependencies to enable running the native version of csslayout within robolectric internally.
Reviewed By: lucasr
Differential Revision: D3960840
fbshipit-source-id: 08a45f7299b04f70f643b0c9b95da13f90690dd8
Summary:
- Define CSS_ASSERT_FAIL_ENABLED for P/Invoke (Visual Studio project already has it)
- Pass managed delegate pointer to unmanaged side via P/Invoke.
- CSSAssertFail will call the managed delegate when assert failed.
- The delegate will throw managed exception.
Reviewed By: emilsjolander
Differential Revision: D3982084
fbshipit-source-id: 058a87c10ca89238362be4d8759cc00dd0c9b376
Summary: - Use WeakReference for parent to avoid circular reference although GC will treat it
Reviewed By: emilsjolander
Differential Revision: D3982520
fbshipit-source-id: b0f6764aa4df3da53be51f6cb4fe2994d989afdf
Summary:
- Add CSSNodeGetInstanceCount API to get the number of native instances.
- It makes testing easy.
Reviewed By: emilsjolander
Differential Revision: D3981990
fbshipit-source-id: 98005ae1fc21d4c8802f24030fff9ffb00bd292d
Summary:
- Unused _context GCHandle prevent calling CSSNode destructor.
- CSSNode C# impl will retain children node when calling CSSNodeInsertChild, so the lifetime of C# object is the same as the lifetime of native instance.
Reviewed By: emilsjolander
Differential Revision: D3981697
fbshipit-source-id: 71f0f7be97fd694d27934d7d07deb64ee08b2840
Summary: This diff resolves some differences in behaviour between jni and java css nodes. This ensures certain test cases pass with both implementations.
Reviewed By: lucasr
Differential Revision: D3960755
fbshipit-source-id: 3e13a9435208851a96a619c07625ef2a5402f5ec
Summary: In the libraries where headers symlinks are required, we enable them.
Reviewed By: skotchvail
Differential Revision: D3943274
fbshipit-source-id: c7ec741af020a60bb7c39b10773cea58a33adc3e
Summary: Its very usefull to be able to run valgrind on the tests and benchmarks. We were previously not freeing test memory so valgrind output was very messy.
Reviewed By: javache
Differential Revision: D3937493
fbshipit-source-id: 23c6970d7769b081575d39de583ba954fc65a397
Summary:
This PR adds the C# version of the `CSSNode` API calls where it currently has only Java and C versions.
Closes https://github.com/facebook/css-layout/pull/225
Reviewed By: lucasr
Differential Revision: D3936431
Pulled By: emilsjolander
fbshipit-source-id: 689cb359c204c6c52e04e031c66615fb04c001af
Summary: I accidentally turned the logic around when cleaning up some code. This was subtle and only caught a week later by a RN product engineer. This fixes the bug without reverting the rest of the code cleanup.
Reviewed By: lucasr
Differential Revision: D3923635
fbshipit-source-id: bfeb175bb40393be63cafb6a995b22701b87ffec
Summary: Oops, when regexing start->left/right end->left/right I did not take into account flex-start and flex-end. Easiest solution is to regex back flex-left and flex-right into their correct values.
Reviewed By: lucasr
Differential Revision: D3930244
fbshipit-source-id: 20742cbc8e5f23af694e14584c7c3df89526876e
Summary:
Closes#222 for the `csharp` implementation which does not use the `CSSLayoutContext` parameter in the `CalculateLayout` method call.
Closes https://github.com/facebook/css-layout/pull/223
Reviewed By: lucasr
Differential Revision: D3918948
Pulled By: emilsjolander
fbshipit-source-id: 8708e08b226500727e33d131ed880bb7e077c08e
Summary:
@public
This fixes measuring of items in the main axis of a container. Previously items were in a lot of cases measured with UNSPECIFIED instead of AT_MOST. This was to support scrolling containers. The correct way to handle scrolling containers is to instead provide them with their own overflow value to activate this behavior. This is also similar to how the web works.
This is a breaking change. Most of your layouts will continue to function as before however some of them might not. Typically this is due to having a `flex: 1` style where it is currently a no-op due to being measured with an undefined size but after this change it may collapse your component to take zero size due to the implicit `flexBasis: 0` now being correctly treated. Removing the bad `flex: 1` style or changing it to `flexGrow: 1` should solve most if not all layout issues your see after this diff.
Reviewed By: majak
Differential Revision: D3876927
fbshipit-source-id: 81ea1c9d6574dd4564a3333f1b3617cf84b4022f
Summary:
This version of the css-layout project includes support for .NET projects. Up in the air is how many configurations of .NET projects we allow for, such as Portable Class Libraries, Universal Windows Platform, .NET Core, etc. Still needs integration with Buck.
Closes https://github.com/facebook/css-layout/pull/220
Reviewed By: lucasr
Differential Revision: D3909367
Pulled By: emilsjolander
fbshipit-source-id: aaaa9c4ff2d3452649f256c3268cf873cf33a0b9
Summary: Add tests to check that measure modes are set correctly.
Reviewed By: lucasr
Differential Revision: D3856585
fbshipit-source-id: 421b368d2d2cbca1d2ba4d58d850836cb22128ac
Summary:
@public
Introduce `overflow:scroll` so that scrolling can be implemented without the current overflow:visible hackiness. Currently we use AT_MOST to measure in the cross axis but not in the main axis. This was done to enable scrolling containers where children are not constraint in the main axis by their parent. This caused problems for non-scrolling containers though as it meant that their children cannot be measured correctly in the main axis. Introducing `overflow:scroll` fixes this.
Reviewed By: astreet
Differential Revision: D3855801
fbshipit-source-id: 3c365f9e6ef612fd9d9caaaa8c650e9702176e77
Summary: Add tests to check that measure modes are set correctly.
Reviewed By: lucasr
Differential Revision: D3856585
fbshipit-source-id: 5fa407f149b1c081503b4ad7aa5f0203ec5b1cc0
Summary:
@public
Introduce `overflow:scroll` so that scrolling can be implemented without the current overflow:visible hackiness. Currently we use AT_MOST to measure in the cross axis but not in the main axis. This was done to enable scrolling containers where children are not constraint in the main axis by their parent. This caused problems for non-scrolling containers though as it meant that their children cannot be measured correctly in the main axis. Introducing `overflow:scroll` fixes this.
Reviewed By: astreet
Differential Revision: D3855801
fbshipit-source-id: 6077b0bcb68fe5ddd4aa22926acab40ff4d83949
Summary: Now that gentest has been used to cover all flexbox properties as well as some internal behavior I thought it was time to remove the old CSSLayoutTest.cpp. This removes a huge amount of previously regex transpiled code in favor of the new test suite which does more fine grained assertions and uses the public api. Given that RTL support was added to gentest now I feel confident that the new test suite covers all and more cases than the old one.
Reviewed By: lucasr
Differential Revision: D3863095
fbshipit-source-id: a2c4f87cd2263b4cc1fcdec4f2a0964f0696472f
Summary: previously when copying in a test inout into an editor the user of gentest needed to remove the ` * ` prefix. This was annoying so this diff fixes that by removing that from gentest.
Reviewed By: lucasr
Differential Revision: D3862943
fbshipit-source-id: 06bd3ee3fa3f85cc44b6ea1d67cf3e91ed368791
Summary: Make input html easier to read by indenting it and adding a space between children. The code to do this could very well be improved but it works for the current set of inputs.
Reviewed By: lucasr
Differential Revision: D3798087
fbshipit-source-id: 0d50ff276000f14ed078cf5ce2e7560ace285a6a
Summary:
When an absolutely positioned node appeared inside an overflow:hidden
parent, we were limiting its height. This is inconsistent with how
layout behaves on the web.
Closes https://github.com/facebook/css-layout/pull/218
Reviewed By: lucasr
Differential Revision: D3797285
Pulled By: emilsjolander
fbshipit-source-id: 98f98e77aa26edce86b9882c1cac284799b69a27
Summary: Generate tests for border. This required modifying gentest to add the parent clientLeft and clientTop so that border width are accounted for in output.
Reviewed By: lucasr
Differential Revision: D3791286
fbshipit-source-id: 698cc2332a3f4118e1afdfbfd745ba824e8ec3f4
Summary: While adding tests for CSSEdge I found that when setting both horizontal/vertical/all + left/right then left/right were not correctly overriding the others. This is now fixed and validated through added tests
Reviewed By: lucasr
Differential Revision: D3791106
fbshipit-source-id: 3e0c943f94218848a1fbf36e5ae48dbc720ea923
Summary: Previous test for dirty propagation (last test in CSSLayoutTest.cpp) only tested one specific case. This tests much more of the bahavior to ensure that a vital optimization in css-layout is applied correctly.
Reviewed By: lucasr
Differential Revision: D3790968
fbshipit-source-id: af11a5924640cd1d497920cd97549603a9f147cc
Summary: Use fbjni for safer and easier jni bridging. This diff includes all of fbjni as it currently does not live as its own open source project. The code was copied from the react-native open source distribution.
Reviewed By: ritzau
Differential Revision: D3764065
fbshipit-source-id: 7ff566af314dcb5279460c322c476ef6f6ed8131
Summary: Measure caching is a crucial optimization to css-layout which re-uses the output of the measure function if possible. This logic was never covered by tests.
Reviewed By: lucasr
Differential Revision: D3790915
fbshipit-source-id: 7fe6d5ebb1303d3186d24d15e401901bc7c8ecdb
Summary: don't hardcode .so extension. Different platforms use different extensions such as .dll, .so, .dylib
Reviewed By: lucasr
Differential Revision: D3785675
fbshipit-source-id: c326e330741e65a7f5d3cb4e4105894c582a2a12
Summary: Don't want to autoformat tests as they are autogenerated. Also they contain html which we don't want to get limited by line length.
Reviewed By: lucasr
Differential Revision: D3785246
fbshipit-source-id: 3e07b300ad16a1f0de53840e399eea25f4672b58
Summary: Allow adding test name within html through the id of the root element. This makes it much easier to re-generate test files.
Differential Revision: D3771966
fbshipit-source-id: 313e1648dcf4521e7c649f54c4ced2aa3297bf06
Summary: So that it can be reset when Spacing is used outside CSSNode.
Differential Revision: D3763593
fbshipit-source-id: 27436c0dbd292b38cfc98f4cfb8e2d12787b85d6
Summary: Revert changes to flex-basis as it broke some specific layouts. Will update later with a more comprehensive set of tests
Differential Revision: D3776987
fbshipit-source-id: 06bd154a36f895782f45511cd8cf49cc6d7cbe7d
Summary: Generate tests for flex-properties and fix bug where flex basis was not taken into account when parent main dimension was undefined.
Differential Revision: D3771513
fbshipit-source-id: 1b5edc7a28bb26217e8a6d10d1829d9031c3ae2e
Summary: Generate tests for flex wrap. The behavior for how the parents cross dimension is sized based on the children differs between browsers but looking at the spec this is the correct implementation.
Differential Revision: D3771140
fbshipit-source-id: bf144d506834e1d4217222bc2422150884a0be1c
Summary: These props were never tested so I didn't notice the typo until now.
Differential Revision: D3771132
fbshipit-source-id: 9d7c2037195f29b3cac5d21599035edf3b7830ff
Summary: generate absolute layout tests. Also make sure default value for position is relative (#default div is absolutely positioned)
Reviewed By: IanChilds
Differential Revision: D3770947
fbshipit-source-id: 0327b071c0dc1aa4574ded759dcc667768b28f55
Summary: Remove output properties from computed styles as they will be computed to their output values before we can read them. Only include them if they are explicitly set by the user.
Reviewed By: IanChilds
Differential Revision: D3770917
fbshipit-source-id: e55996cf8744073496debea19c36a188d2e5086c
Summary: Make the test cases absolute to ensure left/top are both zero for each layout in the test case.
Reviewed By: IanChilds
Differential Revision: D3770913
fbshipit-source-id: c3085c2f8709b52fde0af7f47e1417252997b610
Summary: Implement flexShrink flexGrow and flexBasis in java as well because it will take a bit until the java code is removed
Reviewed By: lucasr
Differential Revision: D3753231
fbshipit-source-id: ea41d887cd99d1f03d2bc876a2fd7141dbe48320
Summary: Benchmarks were broken by const diff leaving in some code which should not have changed. This was not caught earlier due to benchmarks only being run on travis.
Reviewed By: IanChilds
Differential Revision: D3751151
fbshipit-source-id: 08207ce7ad584d4681a27ec0727bbfdbc1198d05
Summary: Use const where possible. This does not use const for all variables as that would require too much refactoring for one diff. It does however use const where currently possible as well as does some small refactoring to enable const usage in more locations. Striving for 100% const usage leads to code with is easier to reason about as a reference will always reference the same value. The compiler will also assist if you accidentally override a reference.
Reviewed By: IanChilds
Differential Revision: D3741999
fbshipit-source-id: 1ba7da5784c3047f2d4c03746890192f724aa65e
Summary: Remove unnecessary function calls which just caused indirection and thus confusion. These were an artifact of the regex transpilation.
Reviewed By: IanChilds
Differential Revision: D3741988
fbshipit-source-id: fdb31dc45a478508b41c522f0e1b3ef842971b50
Summary: The concept of default padding was confusing and only used by react-native android. Makes more sense to let them manage this themselve.
Reviewed By: foghina
Differential Revision: D3709574
fbshipit-source-id: 6e0277bd97407a5c642d742f93ca2ac70d7307da
Summary: When moving over java code to JNI we must make sure things like spacing behave the same. This introduces the same concepts to the C code.
Reviewed By: lexs
Differential Revision: D3728742
fbshipit-source-id: aa19400880afa49664f7bde72b1df45314e699bb
Summary: When adding CSSEdge I kinda forgot we had CSSPosition. I should have just refactor renamed CSSPosition and added some fields. Well this cleans that up.
Reviewed By: IanChilds
Differential Revision: D3728740
fbshipit-source-id: 19dc817a637b80d1f6df8d76982feb2e1fb2705a
Summary: Pointers are 64 bit on 64 bit platforms so using an int might truncate the pointer. Using longs supports 32 bit platforms as well.
Reviewed By: davidaurelio
Differential Revision: D3722479
fbshipit-source-id: c132f24c92c8476b328713861ad30670a43040c4
Summary: JNI code isn't covered by tests yet so I accidentally passed the spacing constant as a pointer value. oops.
Differential Revision: D3722391
fbshipit-source-id: 9adaf7b80d7bad93887a122c10eb06159a5189c2
Summary: We don't run this file internally so this was not caught earlier. Must of course include the function before using it.
Reviewed By: lucasr
Differential Revision: D3717080
fbshipit-source-id: 15c070b6b18bfa4fdd495e8c3b1b5ae62cb09824
Summary:
marginLeft(node, margin) -> margin(node, CSSEdgeLeft, margin)
This reduces the api surface of CSSLayout as well as puts the api more in line with the java version. This also adds support for CSSEdgeAll which java has had support for for a while. This also open up the possibility of doing margin(node, CSSEdgeLeft | CSSEdgeTop, margin) in the future.
Reviewed By: lucasr
Differential Revision: D3715201
fbshipit-source-id: ea81ed426f0f7853bb542355c01fc16ae4360238
Summary: We don't want to format files in lib/ for example. For some reason java/jni and tests/CSSLayoutTestUtils folders were previously ignored. This change formats those folders as well.
Reviewed By: lucasr
Differential Revision: D3715203
fbshipit-source-id: 37bcbd36bcf8535cfca73d6a806ab0f1d097dde7
Summary: Previously format script had to be run from the root directory. With this change it can be run from anywhere
Reviewed By: lucasr
Differential Revision: D3715186
fbshipit-source-id: a46bc0b49aa32f0860bb3e3097ae7b08bdccbf2e
Summary: Add header to generated code so that code can easily be re-generated in case test generation is improved in the future.
Reviewed By: lucasr
Differential Revision: D3715181
fbshipit-source-id: 593baa691c2d7c7f171c6673898fb8a2ecf0e008
Summary: Modify test generation script to be able to generate multiple test cases
Reviewed By: lucasr
Differential Revision: D3714577
fbshipit-source-id: d2bc2155712f946c5a24231a9532d2acc097524c
Summary: Add support for flex-grow, flex-shrink, and flex-basis properties. The flex property behavior is preserved for backwards compatibility.
Reviewed By: lucasr
Differential Revision: D3714520
fbshipit-source-id: 80d3a9a1e2b6f74b863bbe22357f2c9865fa290e
Summary: Spent a couple hours customizing the clang-format rules to better match the desired code style.
Reviewed By: IanChilds
Differential Revision: D3714510
fbshipit-source-id: f6d0436346416aab023aacbedd70ea189e583e8d
Summary: allow_unsafe_import was added to internal builds. add no-op version for open source
Reviewed By: IanChilds
Differential Revision: D3714497
fbshipit-source-id: fac9710726fd981d442c84c5b5879a94b955d102
Summary:
Enable build file sandboxing in fbandroid.
Importing modules in build files that are not whitelisted will be blocked, this can be overriden by using
with allow_unsafe_import():
import foo
`import os` and `import os.path` will not be blocked and will import a safe version of `os` module instead (functions not accessing the file system like `os.path.join()` will be accessible), full `os` module can be imported using `allow_unsafe_import()`
Reviewed By: plamenko
Differential Revision: D3649817
fbshipit-source-id: 3e6a3ab9c4c6a56a99ca7adf599323143a5844f4
Summary: Mean was previously printed just because it was the quickest. Median is a better measurement and we need to include stddev for the sake of comparison against previous diff.
Differential Revision: D3709165
fbshipit-source-id: 67aff0877192143df82a9c24cbedb1f49616eec7
Summary: A .so file is only needed for the JNI target. The main library can be static.
Differential Revision: D3703897
fbshipit-source-id: b2efb98a6ae4488e6107c736c263cad35ef7c4fe
Summary:
Add first version of test generation script. Currently works for most layouts and styles. Probably has a bunch of broken edge-case.
Usage:
$ gentest/gentest.sh
<Enter HTML with inline styles> e.g. <div style="width: 100px; height: 100px;"></div>
Open chrome dev tools console tab.
Copy code from console into file and save.
Run buck test //:CSSLayout
Differential Revision: D3697812
fbshipit-source-id: e6809f95bf6782e7e2cc47b9cdd3a25a13163c5c
Summary: Modern C allows us to document this kind of thing using C and not comments.
Reviewed By: adamjernst
Differential Revision: D3698569
fbshipit-source-id: c92b18540140662979cf001aeedaa76504c6a3ac
Summary: The previous repetition count did not scale to many benchmarks. Also add more benchmarks
Reviewed By: adamjernst
Differential Revision: D3697280
fbshipit-source-id: 56fe424f36936445f31d6e9fa080abbdd816d32d
Summary: Building on osx machines makes things a lot easier.
Differential Revision: D3693987
fbshipit-source-id: f6e2599f99a3fd4ac6fb2a6efd5563074da707d0
Summary: .buckversion is not needed in open source and we have no good way to keep it updated.
Differential Revision: D3696643
fbshipit-source-id: 3ce47a605730935e40f3cd3256a8ec3bd1f7b396
Summary: This means we don't need to use buck fetch. soloader ships as an aar and does not get updated often.
Differential Revision: D3696638
fbshipit-source-id: 57fc7c24067ee833f47ed7c34b927a0d84e20200
Summary: Use spacing for position in public api. This was already the case internally
Differential Revision: D3690235
fbshipit-source-id: 4c04952e6ded32fd5fbfdccf63736cf025ae470e
Summary:
As they're were not available yet.
Emil, I'm going to wait for your diffs to land before pushing this to
avoid disruptions on your side.
Differential Revision: D3669177
fbshipit-source-id: b06f382cb89546e817a2475298cf2cad17d95a2c
Summary:
Consistently namespace all of css-layout's public C API with "CSS". The only function that needed to be renamed was isUndefined, which I renamed to CSSValueIsUndefined.
Fixes#210.
Closes https://github.com/facebook/css-layout/pull/211
Reviewed By: lucasr
Differential Revision: D3674922
Pulled By: emilsjolander
fbshipit-source-id: 1752f477bde45586db112fe2654d0404cc52e1d1
Summary: This code used to be auto generated. Let's let clang-format clean up some stuff for us.
Reviewed By: lucasr
Differential Revision: D3662225
fbshipit-source-id: ddd4064cbf9be21ca6a97001ace1b56b4314c86f
Summary: The C version already has this ability via the same name 'context'. This can be used to attach arbitrary data about your view hierarchy to a CSSNode. Previously this could only be done in java via subclassing CSSNode.
Reviewed By: lucasr
Differential Revision: D3662065
fbshipit-source-id: 560a768092f17381e99b349d08bd4a8b365541be
Summary: To make the library easier to get started with we don't want to force people to use SoLoader. If SoLoader is not initialized we will fall back to the standard System.loadLibrary() method.
Reviewed By: lucasr
Differential Revision: D3661990
fbshipit-source-id: f2003577aa3d2f89ec579b6f889fdfb684110b60
Summary: This caches the class and method id references between calls. The class lookup is done once per method still but I think that is ok for now as the code becomes somewhat cleaner and more self contained.
Reviewed By: lucasr
Differential Revision: D3661989
fbshipit-source-id: 68d4557364bb8957400aefb2603c2e46424ccec3
Summary: Add jni bindings for csslayout. First step in many of removing LayoutEngine.java and performing all layout in native.
Reviewed By: lucasr
Differential Revision: D3648793
fbshipit-source-id: d0e696e196fa7c63109c9117a65645ca3d6c9c00
Summary: Anyone importing this header would have abort() redefined to nothing. That's not good. Fix mistake by defining a CSS_ABORT() macro instead.
Differential Revision: D3661871
fbshipit-source-id: 14a9d076299b4f21d17a2bed68aa30b796c438a5
Summary: assert.h assertion gets stripped from builds. I don't want these assertions to be stripped so implement a custom assert macro. This also allows the assertion to be documented with a message.
Reviewed By: javache
Differential Revision: D3648805
fbshipit-source-id: a6bf1bb55e1e0ee37284647ab76d66f3956a66c0
Summary: #pragma once is widely supported and is a lot harder to get wrong than #ifdef include guards.
Reviewed By: lucasr
Differential Revision: D3648895
fbshipit-source-id: faf42cda82764adaf41cf3f3f9109d48aea203fe
Summary: Java instructions were missing from the readme. Add a quick note about how to run tests in java.
Reviewed By: lucasr
Differential Revision: D3648981
fbshipit-source-id: d9009a60bb1bb0837722f914981ef4e31f0adb68
Summary: stdint.h defines the modern standard c types which have a fixed memory size. This makes the program run more predictably as well as removing the need to ugly double work types such as `unsigned int` or `long long`.
Reviewed By: lucasr
Differential Revision: D3649096
fbshipit-source-id: dc9fc8861c3106494c5d00d6ac337da50a4c945b
Summary: Implement some very basic benchmarking infra. We need benchmarks in css-layout and I want to add something now so that others have the option to follow an example when implementing a benchmark.
Reviewed By: lucasr
Differential Revision: D3648889
fbshipit-source-id: 60b93c6e5ed027a37195a9a5d86e681e3e79a5b9
Summary: This moves the api in line with the java api. hasNewLayout makes for sense than shouldUpdate because the API is not telling css layout to update but is instead just a marker for the user of the API to know if there has been a new layout since last time it checked.
Reviewed By: majak
Differential Revision: D3613695
fbshipit-source-id: 4e16e8d4de90660a09d6e1d3a43c6c5e89349993
Summary:
@public The make current RCTShadowView support RTL layout.
1 Change all left/right to start/end for margin, padding, boarder and position
2 Calculate position in the same way as margin, padding and boarder
Reviewed By: fkgozali
Differential Revision: D3619292
fbshipit-source-id: eaaa6faeee93c964d59bb6f498d89effc09ed567
Summary: @public The new CSSLayout have a wrong calculate for the getRelativePosition. So use the getLeadingPosition will get 0 instead of return undefined. Fix it with using isLeadingPosDefined.
Reviewed By: fkgozali
Differential Revision: D3640799
fbshipit-source-id: 50d3bd2ea4c0d8bf96ba34297425ba269b0535cd
Summary: The test case CSSLayoutTest/test_layout_node_with_bottom has some problem. I can't find a way to fix it without get the screen size. I decided to remove it first. If we could find a better way to right this test case. We can add it again.
Reviewed By: fkgozali
Differential Revision: D3629662
fbshipit-source-id: 303f81a74919e5d3bf037e2809e1345a554a7009
Summary:
@public The current CSSLayout can't support RTL because wrong calculation for absolute position.
This change is mainly to fix the issue: https://github.com/facebook/css-layout/issues/197
Three main problems I fixed:
1. Calculate the position in the same way as margin, boarder, and padding. So that to fix the absolute problem.
2. Fix one wrong calculation for leading value when we only know the trailing value. It was hard code for the LTR situation. Now I changed it to depends on the main Axis.
3. Expose getter and setter function for RN to read layout direction and start/end position value.
Reviewed By: fkgozali
Differential Revision: D3616949
fbshipit-source-id: ae7a47cc0a5d02b42b95f87232be51ab144056d9
Summary: The test case CSSLayoutTest/test_layout_node_with_bottom has some problem. I can't find a way to fix it without get the screen size. I decided to remove it first. If we could find a better way to right this test case. We can add it again.
Reviewed By: fkgozali
Differential Revision: D3629662
fbshipit-source-id: 62d6cd3827d20ae670af55d1c072bd9645a701b9
Summary: Update readme with info about building and github markdown syntax
Differential Revision: D3613284
fbshipit-source-id: 1f57009ccf02a48fe100f675ce08503e15cb6c22
We already did this optimization when there wasn't any
available horizontal space. Now we're covering the
vertical space case as well.
This optimization assumes that, for a node with a
measure function, if there isn't any available
horizontal or vertical space, then we don't need to
measure the node and can assume that the node is 0x0.
Introduced heuristics that enable css-layout to avoid
calling measure functions under a number of conditions.
This enables us to save time by skipping unnecessary
measurements.
We found a case where a flexible item with a max width that was supposed
to be centered was positioned in the wrong location.
The problem was with our 2 pass approach for sizing flexible items with
a min/max width/height. Items sized in the first pass were being double
counted when calculating the remainingFreeSpace. Specifically, their
sizes were being subtracted from remainingFreeSpace in both the first
and second passes.
I also noticed a second unrelated bug. We weren't correctly calculating
deltaFreeSpace in the first pass. When calculating deltaFreeSpace, we
need to take into account the flex basis like we do in the second pass.
Consequently, in the first pass I changed this:
deltaFreeSpace -= boundMainSize;
To this:
deltaFreeSpace -= boundMainSize - childFlexBasis;
The problem there was that we'd end up double counting childFlexBasis
in the remainingFreeSpace.
The primary goals of this change are:
- Better conformance to the W3C flexbox standard (https://www.w3.org/TR/css-flexbox-1/)
and a clear articulation of the areas where it deviates from the spec.
- Support for flex-shrink.
- Conformance with layout effects of "overflow: hidden".
Specifically, here are the limitations of this implementation as compared to the W3C
flexbox standard (this is also documented in Layout.js):
- Display property is always assumed to be 'flex' except for Text nodes, which
are assumed to be 'inline-flex'.
- The 'zIndex' property (or any form of z ordering) is not supported. Nodes are
stacked in document order.
- The 'order' property is not supported. The order of flex items is always defined
by document order.
- The 'visibility' property is always assumed to be 'visible'. Values of 'collapse'
and 'hidden' are not supported.
- The 'wrap' property supports only 'nowrap' (which is the default) or 'wrap'. The
rarely-used 'wrap-reverse' is not supported.
- Rather than allowing arbitrary combinations of flexGrow, flexShrink and
flexBasis, this algorithm supports only the three most common combinations:
- flex: 0 is equiavlent to flex: 0 0 auto
- flex: n (where n is a positive value) is equivalent to flex: n 0 0
- flex: -1 (or any negative value) is equivalent to flex: 0 1 auto
- Margins cannot be specified as 'auto'. They must be specified in terms of pixel
values, and the default value is 0.
- The 'baseline' value is not supported for alignItems and alignSelf properties.
- Values of width, maxWidth, minWidth, height, maxHeight and minHeight must be
specified as pixel values, not as percentages.
- There is no support for calculation of dimensions based on intrinsic aspect ratios
(e.g. images).
- There is no support for forced breaks.
- It does not support vertical inline directions (top-to-bottom or bottom-to-top text).
And here is how the implementation deviates from the standard (this is also documented in
Layout.js):
- Section 4.5 of the spec indicates that all flex items have a default minimum
main size. For text blocks, for example, this is the width of the widest word.
Calculating the minimum width is expensive, so we forego it and assume a default
minimum main size of 0.
- Min/Max sizes in the main axis are not honored when resolving flexible lengths.
- The spec indicates that the default value for 'flexDirection' is 'row', but
the algorithm below assumes a default of 'column'.
This diff:
* adds height as another parameter passed to the measure function, computed the same way width is
* adds tests for this extension, which has involved adding a new measure function to all of js, c, java and c# tests
also, on line 134, I could be wrong, but be wary of this sentence: "No C implementation of this function is provided in provided..." Perhaps this is a mistake.
thanks for all the awesome code!
8f6a96adbc added a test in isDimDefined that checks if `value > 0.0`, but unfortunately, it did not faithfully port the JavaScript version which is `value >= 0.0`. Sadly, no test covered this so it went unnoticed.
It turns the spacing resolution in Java is fairly expensive right now
because it doesn't a bunch of unnecessary checks in the array,
especially when the Spacing instance doesn't have any values set on it.
This diff changes Spacing to store the state of the defined values in a
bitwise flag so that padding/border/margin queries are a lot faster
during layout calculations. This gives us as extra 20% performance win
in my local benchmarks on Android
Unfortunately, Java doesn't have any build-time inlining solution and
method invocations do have a big performance impact on Android. This
changes Java's transpiler to inline almost all internal methods at build
time. This gives us a 30% performance win in my local benchmarks.
There's a drawback from moving code to the transpiler but I think this
is worth it (given the massive perf wins here) and the inlined methods
are fairly simple.
Change the initial line loop to opportunistically position children in
the in container with simple stacking params i.e. vertical/horizontal
stacking on non-flexible STRETCH/FLEX_START aligned. This allows us to
skip the main and cross axis loops (Loop C and D, respectively)
partially and even completely in many common scenarios.
In my benchamrks, this gives us about ~15% performance win in many
setups.
We were traversing all children to only perform calculations/changes to
flexible children in order to avoid new allocations during layout. This
diff ensures we only visit flexible children during layout calculations
if any are present. We accomplish this by keeping a private linked list
of flexible children.
There's no need to go through all absolute children at the end of the
layout calculation if the node at hand doesn't have any. This also
ensures only absolutely positioned children are traversed in the final
loop.
There's no need to go through all children before starting the main line loop
as we'll visit all children in the former loop anyway. This diff merges the
pre-fill loop into the main line one to avoid an extraneous traversal on the
node's children.
There's no need to set the trailing position on left-to-right layouts
as the nodes will already have what we need (x, y, width, and height).
This means we still have an extra cost for reversed layout directions
but they are not as common as LTR ones.
Store immutable values from the node being laid out to avoid unnecessary
method invocations during layout calculation. This gives us a 3%-5%
performance boost in my benchmarks on Android.
Method invocations are not entirely free on Android. Change the
generated Java code to use the same array-based approach used in
JS and C to compute dimensions, positions, etc instead of relying
too heavily on method invovations. As a bonus, the Java transpiler
becomes a lot simpler because the code is more analogous to the C
counterpart.
In my local benchmarks this change gives us a major performance
boost on Android (between 15% and 30%) depending on the device
and the runtime (Dalvik|Art).
This project implements a subset of CSS including flexbox and the box model using pure JavaScript, then transpiled to C and Java. The goal is to have a small standalone library to layout elements. It doesn't rely on the DOM at all.
In order to make sure that the code is correct, it is developed in JavaScript using TDD where each commit adds a unit test and the associated code to make it work. All the unit tests are tested against Chrome's implementation of CSS.
[]()
[]()
The JavaScript version has been implemented in a way that can be easily transpiled to C and Java via regexes. The layout function doesn't do any allocation nor uses any of the dynamic aspect of JavaScript. The tests are also transpiled to make sure that the implementations are correct everywhere.
## Building
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
## Testing
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
Usage
-----
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`.
A single function `computeLayout` is exposed that
- takes a tree of nodes: `{ style: { ... }, children: [ nodes ] }`
- computes the layout and writes it back to the node tree.
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.
For example,
```javascript
// create an initial tree of nodes
varnodeTree={
"style":{
"padding":50
},
"children":[
{
"style":{
"padding":10,
"alignSelf":"stretch"
}
}
]
};
// compute the layout
computeLayout(nodeTree);
// the layout information is written back to the node tree, with
Run `gentest/gentest.rb` to generate test code and re-run `buck test //:yoga` to validate the behavior. One test case will be generated for every root `div` in the input html.
Name | Value
----:|------
width, height | positive number
minWidth, minHeight | positive number
maxWidth, maxHeight | positive number
left, right, top, bottom | number
margin, marginLeft, marginRight, marginTop, marginBottom | number
padding, paddingLeft, paddingRight, paddingTop, paddingBottom | positive number
borderWidth, borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth | positive number
You may need to install the latest watir-webdriver gem (`gem install watir-webdriver`) and [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) to run `gentest/gentest.rb` Ruby script.
-`inherit` value is not implemented because it's a way to disambiguate between multiple colliding rules. This should be done in a pre-processing step, not in the actual layout algorithm.
### .NET
.NET testing is not integrated in buck yet, you might need to set up .NET testing environment. We have a script which to launch C# test on macOS, `csharp/tests/Facebook.Yoga/test_macos.sh`.
## Code style
For the main C implementation of Yoga clang-format is used to ensure a consistent code style. Please run `bash format.sh` before submitting a pull request. For other languages just try to follow the current code style.
Default values
--------------
Since we are only using flexbox, we can use defaults that are much more sensible. This is the configuration to use in order to get the same behavior using the DOM and CSS. You can try those default settings with the [following JSFiddle](http://jsfiddle.net/vjeux/y11txxv9/).
```css
div,span{
box-sizing:border-box;
position:relative;
display:flex;
flex-direction:column;
align-items:stretch;
flex-shrink:0;
align-content:flex-start;
border:0solidblack;
margin:0;
padding:0;
}
```
-`box-sizing: border-box` is the most convenient way to express the relation between `width` and `borderWidth`.
- Everything is `display: flex` by default. All the behaviors of `block` and `inline-block` can be expressed in term of `flex` but not the opposite.
- All the flex elements are oriented from top to bottom, left to right and do not shrink. This is how things are laid out using the default CSS settings and what you'd expect.
- Everything is `position: relative`. This makes `position: absolute` target the direct parent and not some parent which is either `relative` or `absolute`. If you want to position an element relative to something else, you should move it in the DOM instead of relying of CSS. It also makes `top, left, right, bottom` do something when not specifying `position: absolute`.
Development
-----------
The core logic resides with `Layout.js`, which is transpiled into equivalent C and Java implementations.
The JavaScript build process is managed via Grunt. The build performs linting, runs the tests against Chrome, transpiles and packages the code (JavaScript and Java) into the `dist` folder. For JavaScript, the build output uses the Universal Module Format (UMD) so that it can be used via AMD / RequireJS, CommonJS or included directly into an HTML page.
While developing you can just run the lint / Chrome-based tests a follows:
```
grunt test-javascript
```
## Benchmarks
Benchmarks are located in `benchmark/YGBenchmark.c` and can be run with `buck run //benchmark:benchmark`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. Benchmarks are run on every commit in CI.
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
```
pod 'YogaKit', '~> 1.3'
```
## Getting Started
Checkout the docs [here](https://facebook.github.io/yoga/docs/api/yogakit/).
We also have a sample project. To try it out, clone this repo and open `YogaKitSample.xcodeproj` in the [YogaKitSample](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample) directory.
## Contributing
We welcome all pull-requests! At Facebook we sync the open source version of `YogaKit` daily, so we're always testing the latest changes.
See the [CONTRIBUTING.md](https://github.com/facebook/yoga/blob/master/CONTRIBUTING.md) file for how to help out.
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.