Commit Graph

947 Commits

Author SHA1 Message Date
Robert Spencer
a580712b2f Move in yoga sample android app
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
2017-02-14 00:11:38 -08:00
Michael Bolin
ce5d52b54e Update a number of build files in fbandroid/xplat to use the py_sdk build defs.
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
2017-02-13 22:26:31 -08:00
Dustin Shahidehpour
55fe6f0bc9 Add isDirty property and make markDirty less crashy/more performant.
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
2017-02-13 10:26:58 -08:00
Emil Sjolander
abf142ea3f Fix more travis file errors
Summary: and add badges to readme

Reviewed By: passy

Differential Revision: D4551571

fbshipit-source-id: c6eafe480e3667252eadc96c548c3b3c85046389
2017-02-13 09:41:35 -08:00
Dustin Shahidehpour
ae9f89b5d1 Add helper function for bulk updates.
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
2017-02-13 09:28:12 -08:00
Dustin Shahidehpour
058761e16e Give YogaKitSample some love, Convert it to a Swift Project
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!

![](https://media.giphy.com/media/l0ExcvTLa0ADdawRa/giphy.gif)
Closes https://github.com/facebook/yoga/pull/392

Reviewed By: emilsjolander

Differential Revision: D4550379

Pulled By: dshahidehpour

fbshipit-source-id: 64a07acf96c1887f1d2ad0c54971fcedb64334a0
2017-02-13 09:13:43 -08:00
Kazuki Sakamoto
ad8c6225fd Build i386 for iOS and macOS
Summary: Closes https://github.com/facebook/yoga/pull/391

Reviewed By: emilsjolander

Differential Revision: D4549469

Pulled By: splhack

fbshipit-source-id: 7500b7235218f9a4f564adb36044303dff520fd6
2017-02-13 08:26:20 -08:00
Emil Sjolander
1cbadf5f54 Fix mistakes in travis file
Summary: Fix yaml errors

Reviewed By: passy

Differential Revision: D4551330

fbshipit-source-id: d17087cf51f9556c7015ea0fc4ab11fec44917f2
2017-02-13 06:56:27 -08:00
Emil Sjolander
e7021715b8 Split travis builds into multiple runs
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
2017-02-13 05:27:03 -08:00
Emil Sjolander
0d2749a3fd Revert D4528559: [yoga][PR] Fix align-content strech with multiple lines
Summary: This reverts commit 019e6f85fa452d0c3412f711e3886f0c4452da47

Differential Revision: D4528559

fbshipit-source-id: 4bd82b399cb36acb348f2c6fedcae6b360513424
2017-02-13 01:11:16 -08:00
Dustin Shahidehpour
76fbd628e1 Use correct rounding function when rounding pixels.
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
2017-02-11 19:56:08 -08:00
Dustin Shahidehpour
15309d2bdd Update README.md
Summary: Closes https://github.com/facebook/yoga/pull/389

Differential Revision: D4549243

Pulled By: dshahidehpour

fbshipit-source-id: 2c8d6d78af9f98994ad2f5f028494ae743c354b4
2017-02-11 14:12:51 -08:00
Dustin Shahidehpour
4f6924a0c1 BREAKING CHANGE: rename applyLayout to applyLayoutPreservingOrigin.
Summary: Will update on Monday

Reviewed By: emilsjolander

Differential Revision: D4545786

fbshipit-source-id: f8189d82f1c64cd1eac532fd2dfaa9aea35d6004
2017-02-11 11:26:07 -08:00
Lukas Wöhrl
063f65d065 Fix align-content strech with multiple lines
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
2017-02-11 08:41:45 -08:00
Lukas Wöhrl
adf8691093 Fix resolving bug on changing layout and optimized memory usage
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
2017-02-11 08:41:45 -08:00
Lukas Wöhrl
6a7ad2125d Add support for space-between and space-around on align-content
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
2017-02-11 08:41:45 -08:00
Lukas Wöhrl
247aa26d3e Make enums.py c header output resistent to format.sh
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
2017-02-11 08:41:45 -08:00
Dustin Shahidehpour
3c9f620c77 BREAKING CHANGE: Computed edge values are no longer returned on concrete properties, fix tests.
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
2017-02-11 08:28:50 -08:00
Emil Sjolander
e0e2a61dfc Use Float.compare in java equals
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
2017-02-11 06:27:15 -08:00
Emil Sjolander
168ae4099d Always return undefined value if nothing is set
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
2017-02-11 06:27:12 -08:00
Emil Sjolander
6ceb4af2d4 Expose layout border to java
Summary: Expose layout border to java

Reviewed By: astreet

Differential Revision: D4543284

fbshipit-source-id: 6030915fc6f758e785a688f94c8ffbec7fbac8b8
2017-02-11 06:27:04 -08:00
Emil Sjolander
240c2dd657 Fix min/max not overriding width/height
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
2017-02-11 05:28:10 -08:00
Rui Marinho
a5b94ebd0c Add YogaDisplay to shared project
Summary: Closes https://github.com/facebook/yoga/pull/383

Reviewed By: emilsjolander

Differential Revision: D4537332

Pulled By: splhack

fbshipit-source-id: d3068fc09e567c9f175bdcc8974c8069575ef5f7
2017-02-10 11:13:24 -08:00
Dustin Shahidehpour
5037c2f365 Preserve the origin of the root view.
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
2017-02-09 13:10:59 -08:00
Dustin Shahidehpour
ef05404bee Bump YogaKit podspec.
Summary: See commit message. #accept2ship

Reviewed By: emilsjolander

Differential Revision: D4536585

fbshipit-source-id: 808e39e7a38f470c67459a42686e095d8b5e5fc6
2017-02-09 08:46:30 -08:00
Dustin Shahidehpour
3db493665e Bump podspec version.
Summary: See commit message. #accept2ship

Reviewed By: emilsjolander

Differential Revision: D4536570

fbshipit-source-id: 4fc72bd4d9418ea06d24a6ca0cdd6845def30465
2017-02-09 08:26:17 -08:00
Emil Sjolander
737f1cc67c Remove now not needed definition of allow_unsafe_import
Summary: not needed any more

Reviewed By: bolinfest

Differential Revision: D4532533

fbshipit-source-id: 43b4db9a21ae774f7d41187e4e4598e171b7a59c
2017-02-09 03:27:11 -08:00
Georgiy Kassabli
b5c2b09780 Revert D4456312: Fix for Yoga test failure for flexing with min stack dimension
Summary: This reverts commit 82a39bc93cf3bf2374b968e9f7403397e752908e

Differential Revision: D4456312

fbshipit-source-id: 6b396f0a8b67619308456599377238b75d0c1ab3
v2017.02.07.00
2017-02-07 05:18:19 -08:00
Antonio Corrado
46817a38c3 Setting min=max dimension is treated as setting dimension
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
2017-02-06 14:41:37 -08:00
Georgiy Kassabli
52f3471405 Fix for Yoga test failure for flexing with min stack dimension
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
2017-02-06 13:00:42 -08:00
Lukas Wöhrl
e567502750 Added property display: flex and none
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
2017-02-06 09:39:37 -08:00
Dustin Shahidehpour
c1cdc1de58 Fix warnings about icon assets.
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
2017-02-06 07:39:33 -08:00
Dustin Shahidehpour
f2c41f366f Made YogaKitSample build again, use cocoapods, add icon images.
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
2017-02-03 13:39:35 -08:00
Emil Sjolander
56d06e27cf Pass parent with down with calculateLayout to allow percentages on root node
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
2017-02-03 11:24:57 -08:00
Emil Sjolander
93e327f4a5 Return raw edge style value now that we have layout outputs for them
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
2017-02-03 11:24:57 -08:00
Dustin Shahidehpour
687668a4b3 Move podspec to root directory.
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
2017-02-03 10:24:55 -08:00
Emil Sjolander
cfeac79130 Fix percentage calculation when parent size is undefined
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
2017-02-03 05:40:00 -08:00
Emil Sjolander
4227e36ca5 Add tests for wrapping to child size
Summary: Add tests for container wrapping child size

Reviewed By: gkassabli

Differential Revision: D4494263

fbshipit-source-id: bebfdd4a180b0ccd8dbb14e566613f1e64fabd7a
2017-02-03 05:40:00 -08:00
Emil Sjolander
be1c9f249e Take parent size into account when determining if style dim is defined
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
2017-02-03 05:40:00 -08:00
Lukas Wöhrl
511a129a7e Generate enums in sorted order
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
2017-02-03 04:24:36 -08:00
Emil Sjolander
d62ca8c518 Use fromInt() instead of indexing values() as it allocates a new array
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
2017-02-02 15:39:33 -08:00
Pascal Hartig
30413265c7 Remove docs/CONTRIBUTING.md
Summary: Remove the outdated `CONTRIBUTING.md`.

Reviewed By: emilsjolander

Differential Revision: D4500973

fbshipit-source-id: 955395887330287f9973bfc21714a2c24c1fac2a
2017-02-02 05:54:39 -08:00
Pascal Hartig
bd5d8a77c9 Restore basedir format.sh behavior
Summary: Ensure that `format.sh` can be run from anywhere with the same results.

Reviewed By: emilsjolander

Differential Revision: D4494367

fbshipit-source-id: cbd2cc36476a0a54a77a732cbe1b79388f7e0c46
2017-02-01 02:39:33 -08:00
Pascal Hartig
326ae15532 Format C/C++ files
Summary: Run new `format.sh`.

Reviewed By: emilsjolander

Differential Revision: D4481501

fbshipit-source-id: 5791bee9919b44282d1549029ff8e078f253ddf8
2017-01-31 09:40:19 -08:00
Pascal Hartig
9afb65da34 Regenerate test comments
Reviewed By: emilsjolander

Differential Revision: D4482049

fbshipit-source-id: c30a6550ed175811df29c24ba03af92f3bd32713
2017-01-31 09:40:19 -08:00
Pascal Hartig
fe7643c84a Update gentest to match formatter
Reviewed By: emilsjolander

Differential Revision: D4482028

fbshipit-source-id: c6e1e0ecb0475fba62d25858c9e9960eab2701dc
2017-01-31 09:40:19 -08:00
Pascal Hartig
6daad3ae66 Update format.sh
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
2017-01-31 09:40:18 -08:00
Maël Nison
44590b8907 Updates the js build
Summary:
I've updated the js build. Let's see what Travis thinks of it!
Closes https://github.com/facebook/yoga/pull/365

Reviewed By: dshahidehpour

Differential Revision: D4488099

Pulled By: emilsjolander

fbshipit-source-id: d56ee2ccbfec84f766fcfdec9bcc9c5f610a6b0e
2017-01-31 08:39:32 -08:00
orta
4400b52aab Add support for showing the YogaKit README on CocoaPods.org
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
2017-01-31 07:39:45 -08:00
Dustin Shahidehpour
c217553cf8 Add README.md
Summary: This gives YogaKit its' own readme. #accept2ship

Reviewed By: emilsjolander

Differential Revision: D4482411

fbshipit-source-id: 24ddab586d9a12a8419ae8811fa4d03b27c1a19e
2017-01-30 11:09:45 -08:00