Compare commits

...

504 Commits

Author SHA1 Message Date
Ahmed El-Helw
8d74e01f41 Fix typo in generated Yoga classes
Reviewed By: emilsjolander

Differential Revision: D4416273

fbshipit-source-id: fa3f87b86560121e1186cdc0ee295eb052fb3a97
2017-01-19 16:24:33 -08:00
David Hart
5404bb13d4 Fix bugs introduced with YogaKit improvements
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
2017-01-18 09:24:35 -08:00
Lukas Woehrl
be8773fee0 Fix wraping calculation if min-size constraint exists
Summary:
Fixes #261
Closes https://github.com/facebook/css-layout/pull/262

Reviewed By: splhack

Differential Revision: D4245200

Pulled By: emilsjolander

fbshipit-source-id: 77d802d71010ed426511d6a01e6de1e7c9194179
2017-01-16 16:24:35 -08:00
Emil Sjolander
0bcec80dfe BREAKING - Fix sizing of container with child overflowing parent
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
2017-01-16 11:09:32 -08:00
Thanabodee Charoenpiriyakij
2c8c2bffda Edit README.md in Benchmarks section
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
2017-01-16 10:39:37 -08:00
Maël Nison
d70f289e73 Add YGLayoutGetMargin
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
2017-01-15 15:24:30 -08:00
Rui Marinho
498a5980e8 Add YogaKit Shared and iOS version
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
2017-01-15 14:54:29 -08:00
Rui Marinho
8021c5d968 Fix test bug
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
2017-01-15 14:54:29 -08:00
Kazuki Sakamoto
c536ab214d Update buck build in Visual Studio
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
2017-01-12 10:24:54 -08:00
Dustin Shahidehpour
adb81e2a1e Update docs to show new API.
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
2017-01-12 10:24:53 -08:00
Kazuki Sakamoto
c4a3e12add Launch buck from Visual Studio (Xamarin Studio) for Mac and iOS
Summary:
Launch buck from Visual Studio before `CopyInNativeLib` in `CompileDependsOn`
- Mac `buck build //csharp:yoganet#default,shared`
- iOS `buck build //csharp:yoganet-ios`

Reviewed By: emilsjolander

Differential Revision: D4403163

fbshipit-source-id: 2e5fd3fd154ef53574129ac9cb834ae3a58f2466
2017-01-11 07:54:35 -08:00
Rui Marinho
a3d7d72421 Xamarin iOS Support
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

![simulator screen shot 6 jan 2017 02 05 15](https://cloud.githubusercontent.com/assets/1235097/21705017/f851e9d8-d3b4-11e6-9c44-646dab559643.png)
Closes https://github.com/facebook/yoga/pull/324

Reviewed By: emilsjolander

Differential Revision: D4401408

Pulled By: splhack

fbshipit-source-id: ecdae7967060361bef2bc25a5ef759cb9a957322
2017-01-11 07:54:35 -08:00
Emil Sjolander
47266b9ae8 Add percentage support to react native
Summary:
@public

Adds support for percentage value in react native.

syntax: property: 100 | property | '100%'

supported properties:
padding
margin
width
height
minWidth
minHeight
maxWidth
maxHeight
flexBasis

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{backgroundColor: 'white', padding: 10, paddingTop: 30, height: '100%'}}>
        <Text>
          If you want to quickly test out something,
          open the Playground.js file and start coding.
        </Text>
        <View style={{backgroundColor: 'red', height: 50, width: 50}}/>
        <View style={{backgroundColor: 'blue', height: '50%', width: '50%'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4376549

fbshipit-source-id: c41d68a7555396f95d063a7527ee081773ac56dc
2017-01-11 04:09:34 -08:00
Emil Sjolander
e39f13a8ea Allow aspect ratio to expand beyond bounds of parent
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
2017-01-10 08:39:36 -08:00
Emil Sjolander
c04604dbc0 Implement java bindings for custom baseline function
Summary: Implement java bindings for custom baseline function

Differential Revision: D4392516

fbshipit-source-id: 39cf6066f8e5982268becd87e54c9ab51fbf7a90
2017-01-10 07:09:33 -08:00
Emil Sjolander
1782646723 Update aspect ratio documentation to match changes recently made
Summary: Fixes #313 https://github.com/facebook/yoga/issues/313

Reviewed By: gkassabli

Differential Revision: D4397691

fbshipit-source-id: 29daabe9a4bbde3f330e952ca5e644c7cfdbcccf
2017-01-10 06:39:41 -08:00
Kazuki Sakamoto
78e64e3d5b Add Copy Constructor for C# YogaNode
Summary:
Add Copy Constructor for convenience.

    YogaNode defaultStyle = new YogaNode
    {
      Width = 100,
      Height = 100,
    };

    YogaNode node0 = new YogaNode(defaultStyle)
    {
        FlexDirection = YogaFlexDirection.Row,
        JustifyContent = YogaJustify.FlexEnd,
    };

    YogaNode node1 = new YogaNode(defaultStyle)
    {
        AlignItems = YogaAlign.Center,
    };

Reviewed By: emilsjolander

Differential Revision: D4393234

fbshipit-source-id: b4b73071aab4dc1b3ae422969de659380bd0e3ad
2017-01-09 11:24:37 -08:00
Emil Sjolander
0acb620159 Use int instead of NSInteger for ABI compatibility
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
2017-01-09 08:39:36 -08:00
David Hart
9982295e10 Improved the objective-c and swift api
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
2017-01-08 11:54:32 -08:00
Kazuki Sakamoto
8ed71b2777 Add spacing properties
Summary:
Align C# implementation with YogaKit #322
Closes https://github.com/facebook/yoga/pull/327

Reviewed By: emilsjolander

Differential Revision: D4390687

Pulled By: splhack

fbshipit-source-id: 28c87a45898fcd958a422d5e254ead0ec00d3562
2017-01-08 08:09:34 -08:00
Chris Hamons
969b3709db Add basic Xamarin.Mac support
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
2017-01-08 08:09:34 -08:00
Ben Holcomb
e2a7938b26 Revert D4386906: [YogaKit] Improved the objective-c and swift api
Summary: This reverts commit 05ac0e571ef3a8ff0be31469e449a7b23f102218

Differential Revision: D4386906

fbshipit-source-id: adac0d8e71ce9f3442f3bfd14b5157f88367c998
2017-01-07 10:24:37 -08:00
Kazuki Sakamoto
70a4221b9e C# Baseline function
Summary:
same as Measure function, based on #317
Closes https://github.com/facebook/yoga/pull/321

Reviewed By: emilsjolander

Differential Revision: D4385336

Pulled By: splhack

fbshipit-source-id: b583ec79861d2e9abba31a72503e2f706bfda8e8
2017-01-07 09:09:35 -08:00
David Hart
8d320ceac2 Improved the objective-c and swift api
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
2017-01-07 08:24:52 -08:00
Lukas Woehrl
c169a98be6 Baseline support
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
2017-01-06 06:54:41 -08:00
Emil Sjolander
6d48307c8d Expose layout paddding in csharp api
Summary: Expose layout padding api from D4376572

Reviewed By: splhack

Differential Revision: D4377070

fbshipit-source-id: 501628612675e3fdce9a8e77f929cb9c6eddc209
2017-01-05 12:54:45 -08:00
Emil Sjolander
e539ecc9aa Expose layout paddding in java api
Summary: Expose layout padding api from D4376572

Reviewed By: passy

Differential Revision: D4377069

fbshipit-source-id: 2e0c04104560e1be586562b27b3457576590dc18
2017-01-05 12:54:45 -08:00
Emil Sjolander
bf5eeaf61e Add api for retrieving computed padding
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
2017-01-05 12:54:45 -08:00
Kazuki Sakamoto
a36faf89e3 Fix dll path in Unity build script
Summary: sync with vcproj

Reviewed By: emilsjolander

Differential Revision: D4384510

fbshipit-source-id: 964c5b84c063a5241b3aab0f276b2b5a080677aa
2017-01-05 12:10:03 -08:00
David Hart
29c44e281c Set nodes dirty when sizeThatFits changes
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
2017-01-05 08:39:36 -08:00
David Hart
1877a97898 Fix crash when a non-leaf node becomes a leaf node
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
2017-01-05 08:24:39 -08:00
Andrew Forster
bf6602ebff Update C# wrapper to support both desktop and UWP projects
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
2017-01-05 07:09:41 -08:00
Kazuki Sakamoto
6bcf0e3a50 Fix Unity build
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
2017-01-05 06:39:38 -08:00
Lukas Woehrl
d0aeabb8f0 Optimized memory alignment
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
2017-01-05 06:24:31 -08:00
Lukas Woehrl
956df20c64 Use float instead of double for test values
Summary:
Use explicit float values to remove warning.
Closes https://github.com/facebook/yoga/pull/318

Reviewed By: gkassabli

Differential Revision: D4383687

Pulled By: emilsjolander

fbshipit-source-id: a820bf829f74a7bdaefc39e783d03b42e27d0b3b
2017-01-05 04:54:36 -08:00
Maël Nison
7108454455 Improve JS bindings
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
2017-01-04 04:39:40 -08:00
Dustin Shahidehpour
663a93912b Add Overflow API.
Summary: We need this for scrollviews, bring on the overflow!

Reviewed By: emilsjolander

Differential Revision: D4376759

fbshipit-source-id: a427432da5e8679dbf9fdbfe4250707e727368f4
2017-01-03 06:39:40 -08:00
Lukas Woehrl
a85bd4ad2a Add feature to use percentage as value unit
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
2017-01-02 05:24:35 -08:00
Maël Nison
6f462a72bf Adds Javascript Support
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
2017-01-02 02:24:38 -08:00
Emil Sjolander
352f592767 Allow decimal measurements on java
Summary: Preserve floating point values when passing them across the JNI bridge.

Differential Revision: D4366605

fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
2016-12-29 04:55:56 -08:00
Emil Sjolander
f2080e520f Move yoga docs into docs folder on master branch
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
2016-12-28 04:09:48 -08:00
Lukas Woehrl
cd78291de5 C# use YogaSize throughout the measure call chain
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
2016-12-24 02:54:38 -08:00
Emil Sjolander
ab595d1875 ignore .buckversion
Summary: ignore .buckversion file from source control

Reviewed By: vjeux

Differential Revision: D4366002

fbshipit-source-id: 910173bab5f3235673a8686ae6b606624380df09
2016-12-24 02:54:38 -08:00
Emil Sjolander
597544e30a Add note about gtest submodule to readme
Summary: Add note about gtest submodule to readme

Reviewed By: vjeux

Differential Revision: D4366004

fbshipit-source-id: 13ddc040faa251d52aa4c253caff9f5478e12ca6
2016-12-24 02:54:38 -08:00
Kazuki Sakamoto
9f59a13836 Remove unused P/Invoke interface
Summary:
- Remove YGNodeGetContext and YGNodeSetContext from Native.cs
- https://github.com/facebook/yoga/pull/297#discussion_r93789907

Reviewed By: emilsjolander

Differential Revision: D4365845

fbshipit-source-id: 89b41ec773baa1b4901f637f5e83427c9fba4aed
2016-12-23 12:09:40 -08:00
Kazuki Sakamoto
12017e49bd Update .git/hgignore
Summary: Fix paths

Reviewed By: emilsjolander

Differential Revision: D4365853

fbshipit-source-id: 1eb5b1046f4bb7a18b8f29d2876c0d560c3fad49
2016-12-23 12:09:40 -08:00
Kazuki Sakamoto
abad796c44 Fix BUCK
Summary: Remove internal arg

Reviewed By: emilsjolander

Differential Revision: D4365827

fbshipit-source-id: 705855732146e03da65f21cbaa746277719b72f4
2016-12-23 11:24:37 -08:00
desmondyao
92137273a2 Not re-calculate value in Step1.
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
2016-12-23 10:24:32 -08:00
Kazuki Sakamoto
f1ab289022 Run unit tests before building Unity package
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
2016-12-23 09:54:32 -08:00
David Hart
a302b76d59 Added gitignore rule for Xcode xcuserdata
Summary: Closes https://github.com/facebook/yoga/pull/294

Reviewed By: dshahidehpour

Differential Revision: D4365534

Pulled By: emilsjolander

fbshipit-source-id: ff899d3526156ce9bbe8cba07418ca77b2f38ac8
2016-12-23 08:54:37 -08:00
Filip Frącz
4717594e93 Switched to using SafeHandle for native code interrupt
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
2016-12-23 08:39:33 -08:00
Hannes Verlinde
df0f76bba5 Run unit tests on Sandcastle
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
2016-12-23 02:09:35 -08:00
Kazuki Sakamoto
e43c9f66ff Add script to build Unity package
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
2016-12-22 08:39:35 -08:00
Emil Sjolander
0df58d8aa2 Declaratively initialize default values of nodes
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
2016-12-22 03:10:06 -08:00
David Hart
ff1a0e1eb8 Transform the Count enum values into private constants
Summary:
Hides implementation details for the C, Objective-C and Swift APIs.
Closes https://github.com/facebook/yoga/pull/292

Differential Revision: D4351523

Pulled By: emilsjolander

fbshipit-source-id: 18a1149d169f0d52bd078714295000b5d07434dd
2016-12-22 03:10:06 -08:00
Emil Sjolander
ed765fe508 Convert max cache count into a define
Summary: This should not be an enum. A define makes a whole lot more sense

Differential Revision: D4346529

fbshipit-source-id: 8641c4c5017d915d64e5884cae09ac8f01861337
2016-12-22 03:10:06 -08:00
Emil Sjolander
1b5eb7da5e BREAKING - Increase priority of AspectRatio to override flex, align stretch, and fixed sizes if specified.
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
2016-12-22 03:10:06 -08:00
Emil Sjolander
071f576db9 BREAKING - Change aspect ratio to always be width/height
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
2016-12-22 03:10:06 -08:00
Emil Sjolander
3d10ba5f72 Correctly check if child is flex by also accounting for undefined
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
2016-12-22 03:10:05 -08:00
Georgiy Kassabli
85b8386ba1 Test for minHeight with flexing
Summary: This test creates a repro case for Yoga to emulate UFI layout failure

Reviewed By: emilsjolander

Differential Revision: D4313632

fbshipit-source-id: 35be7d86b50a9ae08c81891a889a74e4b61f2d27
2016-12-21 11:39:34 -08:00
Dustin Shahidehpour
7ec3607446 Fix diffing algorithm for reattaching views.
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
2016-12-21 11:09:38 -08:00
Dustin Shahidehpour
835bb1cd9c Add isLeaf flag to Views.
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
2016-12-20 11:39:36 -08:00
yiminghe
9d35dce63e explicit default justifyContent value
Summary:
make default justifyContent value explicit like alignItems

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content

https://developer.mozilla.org/en-US/docs/Web/CSS/align-items

https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
Closes https://github.com/facebook/yoga/pull/293

Differential Revision: D4351597

Pulled By: emilsjolander

fbshipit-source-id: b65ff2284ede4d75f1cc5e22d4106042ab0b0d02
2016-12-20 03:24:40 -08:00
Emil Sjolander
74fb205083 Rename test files to match other test file names
Summary: Rename test files to match other test file names

Differential Revision: D4335198

fbshipit-source-id: b8f38162c3094231476059eb1f54326d8ba84848
2016-12-16 09:09:37 -08:00
Kazuki Sakamoto
ba0bb10366 Build iOS fat static library for Unity and Xamarin
Summary:
$ buck build //csharp:yoganet-ios
    $ buck targets --show-output //csharp:yoganet-ios
    //csharp:yoganet-ios buck-out/gen/csharp/yoganet-ios/libyoga.a

    $ lipo -info buck-out/gen/csharp/yoganet-ios/libyoga.a
    Architectures in the fat file: buck-out/gen/csharp/yoganet-ios/libyoga.a are: armv7 x86_64 arm64

    $ nm buck-out/gen/csharp/yoganet-ios/libyoga.a|grep -e 'T _YGNodeNew' -e 'ygNode' -e 'T _YGInteropSetLogger'
    0000000000000000 T _YGNodeNew
    0000000000001070 t -[UIView(Yoga) ygNode]
    0000000000000000 T _YGInteropSetLogger
Closes https://github.com/facebook/yoga/pull/286

Reviewed By: emilsjolander

Differential Revision: D4338919

Pulled By: splhack

fbshipit-source-id: 7acfdfa0dc4d152d7bfe92161efdeb9f161f70e6
2016-12-16 06:54:35 -08:00
Emil Sjolander
0296511f2c YGNodeChildCount -> YGNodeGetChildCount for consistency
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
2016-12-16 04:39:41 -08:00
Kazuki Sakamoto
04fe81f88f YGNodeInit is no longer exported
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
2016-12-16 00:09:40 -08:00
Kazuki Sakamoto
98bbc15435 Support Xamarin.iOS
Summary:
- `__Internal`

https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/#Static_Libraries

 > Since you can only use static libraries on iOS, there is no external shared library to link with, so the path parameter in the DllImport attribute needs to use the special name __Internal (note the double underscore characters at the start of the name) as opposed to the path name.

- `__IOS__`

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_4_-_platform_divergence_abstraction_divergent_implementation/#iOS

 > Xamarin.iOS defines __IOS__ which you can use to detect iOS devices.
Closes https://github.com/facebook/yoga/pull/277

Reviewed By: emilsjolander

Differential Revision: D4338420

Pulled By: splhack

fbshipit-source-id: 375efecbaf88fffbba544073c6d6b30fb1f4c8ba
2016-12-16 00:09:40 -08:00
Kazuki Sakamoto
25b206ac53 Build native library with BUCK for .NET (Mono, Xamarin)
Summary:
Examples:

- macOS on macOS (Mono, Xamarin.Mac, Unity)
  - `buck build //csharp:yoganet#shared,default` -> `libyoga.dylib`
- Android (Xamarin.Android, Unity)
  - `buck build //csharp:yoganet#shared,android-armv7` -> `libyoga.so`
- iOS (Xamarin.iOS, Unity)
  - `buck build //:yoga#static,iphoneos-arm64` -> `libyoga.a`
  - `buck build //csharp:yoganet#static,iphoneos-arm64` -> `libyoganet.a`
Closes https://github.com/facebook/yoga/pull/282

Reviewed By: emilsjolander

Differential Revision: D4333811

Pulled By: splhack

fbshipit-source-id: 54f4364d93b2419d7504392eb558296a5d06772f
2016-12-15 13:54:34 -08:00
Emil Sjolander
88a4e44fd4 Add YGNodeGetParent api
Summary: Fixes https://github.com/facebook/css-layout/issues/248

Reviewed By: gkassabli

Differential Revision: D4333456

fbshipit-source-id: 388afd0a01c19a6db73c175bf24c566278832cb9
2016-12-15 09:54:35 -08:00
Kazuki Sakamoto
642ea07d6f Update unmanaged dll name
Summary: - Update unmanaged dll name from `Yoga.dll` to `yoga.dll` since Native.cs `DllName` referes lowercase `yoga`

Reviewed By: emilsjolander

Differential Revision: D4295954

fbshipit-source-id: 16b91c407506685b84902102cf4380cb149b5b2c
2016-12-15 07:24:46 -08:00
Kazuki Sakamoto
e85c5ce39d lowercase argument
Summary: - Fix arguments of YogaNode.Create

Reviewed By: emilsjolander

Differential Revision: D4296488

fbshipit-source-id: f6eb5074b1b1462f2251d330929f7b8082ad72eb
2016-12-15 07:24:46 -08:00
Jatin Pandey
cf753af247 Make documentation clearer
Summary:
Fixing a typo :)
Closes https://github.com/facebook/yoga/pull/270

Reviewed By: dshahidehpour

Differential Revision: D4333129

Pulled By: emilsjolander

fbshipit-source-id: 28215de8fcd571fb889fe145ff303f231a50c598
2016-12-15 07:24:46 -08:00
Emil Sjolander
12efe604bb Fix YogaKit tests on travis
Summary: Fix include path

Reviewed By: dshahidehpour

Differential Revision: D4333185

fbshipit-source-id: 27638324e093260aa1b23134fab5140a0c703bc9
2016-12-15 07:24:46 -08:00
Emil Sjolander
f36f545d75 Add an anchor to the android platform regex
Summary: This prevents android from matching in the middle of a platform.

Reviewed By: gkassabli

Differential Revision: D4306164

fbshipit-source-id: 7f62a6a017724f8f6741d3e53b5fbe0650c8c88e
2016-12-10 17:37:12 -08:00
Joel Marcey
8fcd544c81 A bit more syncing after the name change 2016-12-10 17:31:11 -08:00
Emil Sjolander
73662ebf83 example license 2016-12-07 17:41:50 +00:00
Emil Sjolander
47a8ec06a1 Add sample project for YogaKit 2016-12-07 17:27:25 +00:00
Emil Sjolander
b611fac20b update naming and fix test 2016-12-07 16:18:13 +00:00
Emil Sjolander
b11155423c Rename directories
Reviewed By: gkassabli

Differential Revision: D4284681

Summary: Rename csslayout directories to yoga

fbshipit-source-id: f0c6855c2c6e4389b7867f48f72cbb697830fc5a
2016-12-07 05:22:52 -08:00
Emil Sjolander
40371cbf2d Remove init from api
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
2016-12-06 14:52:34 -08:00
Emil Sjolander
613590b0d8 Ignore csharp test dependencies which are downloaded on the fly
Summary: Running csharp tests should not result in uncommited files.

Reviewed By: splhack

Differential Revision: D4271411

fbshipit-source-id: abf6c69555ed657356a9426ca37864f8c2eaa78f
2016-12-05 12:37:36 -08:00
Emil Sjolander
4710a65f7a Fix an error initializing needsCrossTrailingPos
Summary: https://github.com/facebook/css-layout/pull/259

Reviewed By: gkassabli

Differential Revision: D4271422

fbshipit-source-id: e8d72af742d96829684958780eb56e2c375df20c
2016-12-05 09:37:38 -08:00
Emil Sjolander
901f65ca05 Fix prefix typo in YogaKit
Summary: Forgot to update this in rename.

Reviewed By: dshahidehpour, gkassabli

Differential Revision: D4271399

fbshipit-source-id: cf354928a8839a864e9961e091d9f48840a5d4d4
2016-12-05 08:07:41 -08:00
Emil Sjolander
72cf6806de Add #pragma once and extern C to YGEnums.h
Summary: Makes YGEnums.h header looks like other Yoga headers

Reviewed By: gkassabli

Differential Revision: D4274156

fbshipit-source-id: 9fa0ae146bb9e5bd40d93fa3c56f83424ebd2bf9
2016-12-05 05:07:37 -08:00
Emil Sjolander
1b7ae2ed3d Update java package name to yoga
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
2016-12-05 03:07:33 -08:00
Emil Sjolander
c6100d0771 Rename java API
Summary: Rename java api to new use yoga naming

Reviewed By: IanChilds

Differential Revision: D4265345

fbshipit-source-id: 69ecfd8fac214f86b8b70647b9b909acd83d78b5
2016-12-03 04:53:39 -08:00
Emil Sjolander
6339467b6d Rename tests
Summary: Rename test files to use new name

Reviewed By: gkassabli

Differential Revision: D4265235

fbshipit-source-id: 0090d3949828058baf7435f33d4068de92756bad
2016-12-03 04:53:39 -08:00
Emil Sjolander
dda24b1e23 Rename C api
Summary: This renames the core C api to use the new Yoga branding.

Differential Revision: D4259190

fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
2016-12-03 04:53:38 -08:00
Emil Sjolander
f7cc614d67 rename csharp code
Summary: new name

Reviewed By: splhack

Differential Revision: D4247106

fbshipit-source-id: 6e1097de104f3a011c78ae65b33e57865b007711
2016-12-02 11:23:20 -08:00
Emil Sjolander
4bbf35832e Rename CSSLayoutKit
Summary: new name

Reviewed By: dshahidehpour

Differential Revision: D4245987

fbshipit-source-id: 880f558c694bd041abbedadeb91225a3ca6c14f9
2016-12-02 11:23:20 -08:00
Emil Sjolander
b9feb10420 Rename benchmarks
Summary: new name

Reviewed By: splhack

Differential Revision: D4245765

fbshipit-source-id: c524183ead279ad1d9159a1da2f18fc1b96c2b51
2016-12-02 11:23:20 -08:00
Emil Sjolander
42b6f6b6e5 Rename enums
Summary: new name, start by renaming enums

Differential Revision: D4244360

fbshipit-source-id: c9fcbdd231098c9ff230a6055676bbc7cbd11001
2016-12-02 05:52:59 -08:00
Emil Sjolander
07cf47baad Remove force_static
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
2016-12-02 05:22:49 -08:00
Emil Sjolander
686289814d Rename defs file
Summary: new name

Reviewed By: gkassabli

Differential Revision: D4258291

fbshipit-source-id: 4b9ad8773c68aed25afba57fcfa92721e6acc1a6
2016-12-02 05:22:49 -08:00
Emil Sjolander
bb37e65ab1 Fix error from refactor of setMeasuredDimensionsIfEmptyOrFixedSize
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
2016-12-01 07:37:31 -08:00
Emil Sjolander
31b961d8b3 Revert D4245638: [yoga] Rename defs file
Summary: This reverts commit 14050d02c4298014a5fcadd75c4f364537ec2396

Differential Revision: D4245638

fbshipit-source-id: 5eba4f87cbf5a64e235dd16e038326e916cdda77
2016-11-30 12:37:49 -08:00
Emil Sjolander
4a578284a5 Revert D4248487: [yoga] Remove force_static
Summary: This reverts commit e5127a02561b145745cf5393a0188661469ec79b

Differential Revision: D4248487

fbshipit-source-id: c826eb6543ff6b8d512bf688fbd395e9766df2fb
2016-11-30 12:22:31 -08:00
Emil Sjolander
c5bbcd78ae Fix usage of weak references to check for null
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
2016-11-30 10:14:15 -08:00
Emil Sjolander
4fbe0495b4 Remove force_static
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
2016-11-30 08:22:32 -08:00
Emil Sjolander
ff3d2e1691 Rename defs file
Summary: new name

Reviewed By: gkassabli

Differential Revision: D4245638

fbshipit-source-id: 14050d02c4298014a5fcadd75c4f364537ec2396
2016-11-30 08:07:44 -08:00
Emil Sjolander
684a36d6cf Add -fPIC to jni target
Summary: Add compile flag from CSSLayout to jni target as well

Reviewed By: passy

Differential Revision: D4248473

fbshipit-source-id: 18a163a3daedc56e98c7bdc38e10fc8626999f94
2016-11-30 03:22:35 -08:00
Emil Sjolander
7d74e1cb66 Add test case covering padding on child
Summary: Add coverage exposed by https://github.com/facebook/css-layout/pull/262

Reviewed By: splhack

Differential Revision: D4247282

fbshipit-source-id: 25500bcfced58a8095665b73eeebca8d1c266a17
2016-11-29 16:22:32 -08:00
Emil Sjolander
b32b6029de Remove deprecated java code
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
2016-11-29 12:37:47 -08:00
Emil Sjolander
5fa42cd1b0 Remove Style prefix in java and cs apis
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
2016-11-29 09:07:34 -08:00
Emil Sjolander
6318801470 Always use soloader. Catching exception and re-trying hides errors
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
2016-11-29 04:37:32 -08:00
Emil Sjolander
97d524fa96 Add notice in readme about ongoing API changes
Summary: Add notice in readme to prepare open source for large renaming diffs.

Reviewed By: splhack

Differential Revision: D4240761

fbshipit-source-id: 4c8070a06c3ac009b67eb7bef5de11ce3ab3e4d8
2016-11-28 15:52:33 -08:00
Emil Sjolander
c31df519e0 Dont strip class names referenced from native
Summary: Ensure we don't strip classes used from native

Reviewed By: lexs

Differential Revision: D4237790

fbshipit-source-id: 1bd0780d965efbb8334917011ffd65896670ece1
2016-11-28 09:22:41 -08:00
Pascal Hartig
0240d09949 Enable -fPIC for C library
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
2016-11-28 09:22:41 -08:00
Emil Sjolander
22b0fdb3e6 Add experiment support to gentest
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
2016-11-23 11:22:36 -08:00
Emil Sjolander
a0d560a24b Fixup recent fix to flex basis and put it behind an experimental flag
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
2016-11-23 05:37:32 -08:00
Dustin Shahidehpour
dc10fdd958 Fix bug where swapping views in hierarchy throws an assert.
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
2016-11-22 08:37:38 -08:00
Lukas Woehrl
b90f6e21bd Added feature to use rounded values
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
2016-11-22 05:37:34 -08:00
Lukas Woehrl
d54f09e32b Use ASSERT_FLOAT_EQ instead of ASSERT_EQ
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
2016-11-22 02:52:30 -08:00
Dustin Shahidehpour
49a21e657b Fix bug where we insert nodes at wrong index in view hierarchy.
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
2016-11-21 18:07:36 -08:00
Emil Sjolander
2d58a36619 Move measure code for known dimensions out of main layout function
Summary: Try to move more code out of the main measure function

Reviewed By: gkassabli

Differential Revision: D4213339

fbshipit-source-id: 5ca35ca307594f3419fd0dee81321d3c2e06710f
2016-11-21 11:07:45 -08:00
Emil Sjolander
f56e8a5163 Move measure code for empty containers out of main layout function
Summary: Try to move more code out of the main measure function

Reviewed By: gkassabli

Differential Revision: D4213313

fbshipit-source-id: 2061a809202f7f948bff1b3ee8dc4c230692a223
2016-11-21 11:07:45 -08:00
Emil Sjolander
e78cf02a30 Move custom measure code out of main layout function
Summary: Try to move more code out of the main measure function

Reviewed By: gkassabli

Differential Revision: D4213302

fbshipit-source-id: df4bc43848325e99ad338a2fa6d5c9404315b0e6
2016-11-21 11:07:45 -08:00
Emil Sjolander
55fc795686 Add aspectRatio style property
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
2016-11-21 10:22:32 -08:00
Emil Sjolander
b16c22a8f3 Only skip updating computed flex basis within the same generation
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
2016-11-20 05:07:33 -08:00
Lukas Wöhrl
56ec33a463 Fix CS0675 warning in c#
Summary:
Fix CS0675 warning in c#.
Closes https://github.com/facebook/css-layout/pull/255

Reviewed By: emilsjolander

Differential Revision: D4204765

Pulled By: splhack

fbshipit-source-id: bcf71796e1bf585a94b3549905cb6d6bc78a34b8
2016-11-18 09:37:33 -08:00
Lukas Wöhrl
367c3a28be use fmaxf to prevent casting from and to double
Summary:
Use ```fmaxf``` to prevent double casting.
Closes https://github.com/facebook/css-layout/pull/251

Reviewed By: emilsjolander

Differential Revision: D4199342

Pulled By: splhack

fbshipit-source-id: c04bc68a3c9c97b92e910e885457cf2fe00da28b
2016-11-17 20:52:54 -08:00
Lukas Wöhrl
653150a7c4 Change more method arguments to const
Summary:
Change more method arguments to ```const```
Closes https://github.com/facebook/css-layout/pull/252

Reviewed By: emilsjolander

Differential Revision: D4199335

Pulled By: splhack

fbshipit-source-id: f54fccaea8051a49c6cdf0fcaf1a68c025ba26da
2016-11-17 20:52:54 -08:00
Lukas Wöhrl
542fc50409 do not redefine isnan if already defined via math.h
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
2016-11-17 20:52:54 -08:00
Lukas Wöhrl
4f192481ee use size_t instead of unsigned long
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
2016-11-17 20:52:54 -08:00
Kazuki Sakamoto
0bb2955c5c CSSNodeCopyStyle API for Java and C#
Summary: Add CopyStyle API for Java and C#

Reviewed By: emilsjolander

Differential Revision: D4189954

fbshipit-source-id: 10759fdb27bf67350d3151614f7815aa09bf7e04
2016-11-17 09:22:37 -08:00
Kazuki Sakamoto
191ac98b89 Introduce CSSNodeCopyStyle
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
2016-11-17 09:22:37 -08:00
Kazuki Sakamoto
32c175ac55 Workaround fix for Visual Studio
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
2016-11-17 09:07:28 -08:00
Dustin Shahidehpour
4b61cdccea Add flag to not include view in layout.
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
2016-11-17 08:37:34 -08:00
Kazuki Sakamoto
b9c4c403a9 Fix memory func test
Summary: Reset gNodeInstanceCount before memory func test.

Reviewed By: emilsjolander

Differential Revision: D4193712

fbshipit-source-id: a4aba84d054d98a7baf438e213a90bd7ef34e979
2016-11-17 07:52:34 -08:00
Dustin Shahidehpour
56aa279fef BREAKING: remove css_sizeThatFits:, replace with new API.
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
2016-11-17 07:37:32 -08:00
Kazuki Sakamoto
7e4bb732ff Introduce CSSNode.Create API
Summary:
Add a convenience construction method for CSSNode.

    CSSNode node = CSSNode.Create(
        positionType: CSSPositionType.Absolute,
        wrap: CSSWrap.Wrap,
        position: new Spacing(top:6, right:4),
        margin: new Spacing(bottom:5, left:3));

Reviewed By: emilsjolander

Differential Revision: D4193380

fbshipit-source-id: 30b917f64e92997355a76e3b11799883b86fb9de
2016-11-17 07:07:32 -08:00
Emil Sjolander
32ba5ae647 Make gtest a submodule in open source
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
2016-11-17 04:52:31 -08:00
Emil Sjolander
2fa6f5087d Disable UIKit memory tests on travis
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
2016-11-17 04:37:34 -08:00
Emil Sjolander
c2aac9f46e Add googletest submodule 2016-11-16 16:36:36 +01:00
Kazuki Sakamoto
ef81d4b0c7 Introduce CSSLayoutSetMemoryFuncs
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
2016-11-15 20:22:51 -08:00
Kazuki Sakamoto
667858990c Fix build
Summary: Fix C# build

Reviewed By: emilsjolander

Differential Revision: D4183287

fbshipit-source-id: 7dda449a940589de1d37f4024964a6512ab123e3
2016-11-15 17:37:34 -08:00
Kazuki Sakamoto
d80bac4234 Use LTR and RTL instead obsolete enums
Summary: Use LTR and RTL instead obsolete LeftToRight and RightToLeft enums

Reviewed By: emilsjolander

Differential Revision: D4175897

fbshipit-source-id: d22af46d3292f9ad1754f571e95cb64b11722f7b
2016-11-15 09:22:45 -08:00
Emil Sjolander
d1c555fede Autogenerate enum defenitions for all languages
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
2016-11-15 08:52:59 -08:00
Emil Sjolander
ac4d0ab2a1 Count allocations relative to start of test
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
2016-11-15 07:22:34 -08:00
Emil Sjolander
603321e1ab Install and use java 8 on travis
Summary: Java tests need to run with java 8, ensure travis runs java 8

Reviewed By: gkassabli

Differential Revision: D4182384

fbshipit-source-id: 61ba77d3e0f008f50912d088d3e504cb96e46bdc
2016-11-15 06:40:51 -08:00
Dustin Shahidehpour
129437f49e Change CLK prefix on static functions to CSS.
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
2016-11-14 13:22:52 -08:00
Fred Liu
204aba80b9 Revert D4157971: [csslayout] BREAKING - Fix sizing of container with child overflowing parent
Summary: This reverts commit 3cfae15ac8b65b70f01789444099ee684e1b099a

Differential Revision: D4157971

fbshipit-source-id: be055cf018fd39b3cee9af0bc777831fcf757190
2016-11-14 12:22:58 -08:00
Emil Sjolander
e6702e1168 Implement standard interface for toggling experimental features
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
2016-11-14 03:37:45 -08:00
Emil Sjolander
b99172d28b rename CSSWrapType to shorter CSSWrap matching java and csharp
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
2016-11-14 03:37:45 -08:00
Emil Sjolander
7a3df9999b BREAKING - Fix sizing of container with child overflowing parent
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
2016-11-14 02:22:44 -08:00
Dustin Shahidehpour
e0e88f97b6 Cleanup documentation, add pragma marks, and rename static functions in UIView+CSSLayout
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
2016-11-11 16:52:47 -08:00
Dustin Shahidehpour
b4d0e1a17c Add some more compiler flags to CSSLayoutKit.
Summary: Just firming up some stuff with more compiler flags.

Reviewed By: rnystrom

Differential Revision: D4168081

fbshipit-source-id: fced407f03944081bdd70cc28c57e3dc842ff7f0
2016-11-11 15:07:35 -08:00
Kazuki Sakamoto
e40af30fa5 Update .travis.yml for C# test
Summary: Closes https://github.com/facebook/css-layout/pull/246

Reviewed By: emilsjolander

Differential Revision: D4167133

Pulled By: splhack

fbshipit-source-id: d55c0ff5155311f4da859b12b6485b120dac480b
2016-11-11 09:07:44 -08:00
Emil Sjolander
cd054ecf26 Expose CSSLayoutSetLogger to java
Summary: Expose CSSLayoutSetLogger to java

Reviewed By: astreet

Differential Revision: D4153502

fbshipit-source-id: 630909d9d0d36d94d7cd3027476ddb52668b8cc0
2016-11-11 08:23:14 -08:00
Emil Sjolander
aaa977f645 Fix flex within max size if max size is not constraint to
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
2016-11-11 08:07:42 -08:00
Dustin Shahidehpour
70e01a4476 Rename uikit/CSSLayout to CSSLayoutKit.
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
2016-11-11 07:38:15 -08:00
Emil Sjolander
3e2c13f418 Fix running ios tests in travis
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
2016-11-10 19:52:56 -08:00
Kazuki Sakamoto
0dbbfc5910 Add convenient cast method for MeasureOutput.Make
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
2016-11-10 19:22:36 -08:00
Pieter De Baets
f222d22ba8 Remove useless store in CSSLayout.c
Summary: Pointed out by the Xcode analyzer

Reviewed By: emilsjolander

Differential Revision: D4159938

fbshipit-source-id: 8b9ff3896c0e222e8e89546881129214bc6ba566
2016-11-10 08:53:05 -08:00
Emil Sjolander
087d1f3a82 Fix benchmark
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
2016-11-09 20:22:41 -08:00
Kazuki Sakamoto
c382d513fb Remove CSSAssertSetFailFunc
Summary: Remove CSSAssertSetFailFunc and use CSSLogLevelError for throwing managed exception.

Reviewed By: emilsjolander

Differential Revision: D4155452

fbshipit-source-id: 5a19c79a212f204d13064527fd6e5843bab76e6b
2016-11-09 17:38:10 -08:00
Kazuki Sakamoto
8a7183f465 Add tests for SetMeasureFunction
Summary: Add tests for checking C side asserts in managed

Reviewed By: emilsjolander

Differential Revision: D4154869

fbshipit-source-id: 5203db27eff963d46f188de448f607a24ed63fab
2016-11-09 13:23:00 -08:00
Emil Sjolander
ff602d4606 Absolute positioned items should apear inside padding but outside border
Summary:
Absolute positioned elements were not correctly respecting border / padding.

https://github.com/facebook/css-layout/issues/245
fixes #245

Reviewed By: gkassabli

Differential Revision: D4153332

fbshipit-source-id: 251e29e02018a433f60349b78c03feb121512797
2016-11-09 11:52:54 -08:00
Emil Sjolander
f5912a97e4 Fix issues with running test in open source
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
2016-11-09 11:37:48 -08:00
Emil Sjolander
a253c6fbb7 Dont measure single flex grow+shrink child
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
2016-11-09 11:37:48 -08:00
Kazuki Sakamoto
863378d74e Sync Logger API
Summary: - Sync Logger API with C implementation

Reviewed By: emilsjolander

Differential Revision: D4143019

fbshipit-source-id: f20203320bad5b8f4b9cce01a5b2e7c615a4d923
2016-11-09 10:22:42 -08:00
Andy Street
f1fcd5e382 Update logging to support levels, print messages in Android logcat on assertion failures
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
2016-11-09 09:52:43 -08:00
Emil Sjolander
6a6efe0764 change default value of position styles
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
2016-11-09 09:22:40 -08:00
Dustin Shahidehpour
e54af5e854 Allow MeasureFunc to be set to NULL no matter how many children a node has.
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
2016-11-09 08:52:45 -08:00
Jing Chen
502f3c7010 Reverted commit D4147298
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
2016-11-09 00:07:45 -08:00
Emil Sjolander
12ebaa56b6 Dont measure single flex grow+shrink child
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
2016-11-08 15:37:48 -08:00
Emil Sjolander
3e567fdcae Fix flex within max width constraint
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
2016-11-08 09:53:00 -08:00
Emil Sjolander
1baa239389 Remove isTextNode optimization
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
2016-11-08 09:22:38 -08:00
Dustin Shahidehpour
b50090a04e NSAssert -> NSCAssert.
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
2016-11-08 07:22:48 -08:00
Kazuki Sakamoto
ba2905dd1d Add C# test script for macOS
Summary: - Updated README and added bash script for testing C# on macOS

Reviewed By: emilsjolander

Differential Revision: D4142507

fbshipit-source-id: c682778e42d10242e02f3fdafe8a23f906bfabc5
2016-11-07 19:37:57 -08:00
Dustin Shahidehpour
997088ffbb Fix broken unit tests.
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
2016-11-07 14:37:56 -08:00
Emil Sjolander
ffb90e6ff2 Remove check for both modes being exact as this will never happen
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
2016-11-07 14:37:55 -08:00
Rachit Siamwalla
1c22a1aa53 Fix xplat CSSLayoutTests to compile on platforms without death tests.
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
2016-11-07 14:07:49 -08:00
Dustin Shahidehpour
7082734c6b Kill border API.
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
2016-11-07 13:37:47 -08:00
Dustin Shahidehpour
366a61af8d Take care of pixel rounding for UIView.
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
2016-11-07 13:37:47 -08:00
安秋亮
18fe0959f0 Add inline definition for Microsoft Visual Studio
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
2016-11-07 13:07:40 -08:00
Dustin Shahidehpour
1ffce3edb1 Sanitize results from sizeThatFits:, fix bug where only one of the measure modes is CSSMeasureModeExactly.
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
2016-11-07 06:52:47 -08:00
Andy Street
6165d7a2be Make CSSNode#measure final, cache more correct methodid
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
2016-11-07 06:07:36 -08:00
Andy Street
01a3881426 Lazy create children list when first child is added
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
2016-11-07 05:52:41 -08:00
Andy Street
9c1896043d Assert that node can have measure function <==> node is a leaf node
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
2016-11-07 05:37:45 -08:00
Dustin Shahidehpour
0f822bbef2 Remove overflow and flex from API.
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
2016-11-04 13:37:40 -07:00
Dustin Shahidehpour
e00e30ca15 Only mark Nodes dirty if an actual node is removed.
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
2016-11-03 13:38:05 -07:00
Dustin Shahidehpour
b938017ccf Add Sizing API that doesn't change view's frame.
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
2016-11-03 13:07:37 -07:00
Georgiy Kassabli
630ae0972b Exposing layout cache check publicly
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
2016-11-03 10:52:43 -07:00
Dustin Shahidehpour
d8662805d5 Fix incorrect results from css_usesFlexbox
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
2016-11-03 09:37:41 -07:00
Dustin Shahidehpour
26e7490fc9 Make CSSNodeRef readonly.
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
2016-11-03 09:07:37 -07:00
Dustin Shahidehpour
d94363ea7e Cleanup Measure method.
Summary: We have redundant/dead code in UIKit's sizing method, lets clean it up.

Reviewed By: emilsjolander

Differential Revision: D4110939

fbshipit-source-id: 35e856aa6c60fd24316bc67cc564f7eec2d9d714
2016-11-02 17:07:47 -07:00
Lukas Wöhrl
af5e6771d7 Prevent array out of bound access
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
2016-11-01 20:54:00 -07:00
Dustin Shahidehpour
ced779b259 Prevent crash when accessing child count, but child list is NULL.
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
2016-10-31 12:52:52 -07:00
Emil Sjolander
a65e6930cf Some small simplifications for function return values
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
2016-10-31 11:08:05 -07:00
Emil Sjolander
267e17f23a void* -> CSSNodeRef in CSSNodeList
Summary: This list can only contain CSSNodeRefs so don't use void*

Reviewed By: gkassabli

Differential Revision: D4101773

fbshipit-source-id: 8a5c9066da796967bd02ce6b1fc74ff40e15dfe1
2016-10-31 11:08:02 -07:00
Emil Sjolander
df6368e048 Add complex layout to benchmark
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
2016-10-31 10:38:02 -07:00
Emil Sjolander
ba20d75992 Fix benchmark
Summary: Benchmark accidentally broke during a refactor

Reviewed By: gkassabli

Differential Revision: D4101776

fbshipit-source-id: 00094837b7856c06c0463c48929f960122c0c8ac
2016-10-31 10:38:02 -07:00
Dustin Shahidehpour
620cb3f507 Remove static method declarations.
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
2016-10-27 12:52:43 -07:00
Kazuki Sakamoto
3201e24780 Fix build and clean up
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
2016-10-27 11:53:11 -07:00
Emil Sjolander
2cac77eaa1 Set layout outputs on java object from C
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
2016-10-27 10:52:57 -07:00
Emil Sjolander
46823878a5 BREAKING - Make first parameter of measure and print functions CSSNodeRef instead of just context
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
2016-10-27 10:52:57 -07:00
Emil Sjolander
b59ce09109 BREAKING - Change measure() api to remove need for MeasureOutput allocation
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
2016-10-27 10:52:57 -07:00
Emil Sjolander
c34299edc9 Reset java state in jni reset method
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
2016-10-26 07:37:47 -07:00
Kazuki Sakamoto
1ba81d9ec7 Prevent GC and avoid new
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
2016-10-26 06:52:41 -07:00
Emil Sjolander
d6d817c142 Dont go down through JNI to figure out that no margin/padding/border/position was set
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
2016-10-26 03:07:42 -07:00
Scott Wolchok
01c2ac3369 Don't preallocate child lists
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
2016-10-25 17:22:47 -07:00
Emil Sjolander
0cc1b83569 Remove nanosleep from benchmark measure and increase loop count
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
2016-10-25 16:23:04 -07:00
Lukas Wöhrl
c8d77b2aae Remove children from the end to prevent copying over
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
2016-10-25 12:22:48 -07:00
Emil Sjolander
01507044b3 Suggest the compiler to inline smaller functions
Summary: Suggest the compiler inline some functions. Shows ~15% performance benefit on android compiling with gcc.

Reviewed By: gkassabli

Differential Revision: D4074580

fbshipit-source-id: 69b63fadf2011cb688af58f09d67c2cb711a0e20
2016-10-25 10:37:45 -07:00
Kazuki Sakamoto
2168d68007 Update CSSNodeFree for C#, Java and Objective-C
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
2016-10-25 07:52:39 -07:00
Emil Sjolander
4d0e657653 Fix bug in canUseCachedMeasurement causing unneeded double measure
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
2016-10-25 07:37:59 -07:00
Kazuki Sakamoto
4452c7be5c Remove no longer needed Spacing.cs
Summary: - Remove no longer needed Spacing.cs

Reviewed By: emilsjolander

Differential Revision: D4073539

fbshipit-source-id: 916cf85119c6bac3d516de5396ea3ba7b0af1475
2016-10-25 07:08:00 -07:00
Emil Sjolander
15f5c4cea5 Reduce duplicate function calls
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
2016-10-24 12:37:49 -07:00
Emil Sjolander
97fef59f96 Dont hold strong reference to java objects creating a cycle
Summary: Use weak reference to avoid cycle

Reviewed By: splhack

Differential Revision: D4064773

fbshipit-source-id: 4088fef5e088a8415747898ef17851e21ada5180
2016-10-24 12:37:49 -07:00
Emil Sjolander
e9b9973cae Dont create a spacing object for returning margin, padding, border, and position
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
2016-10-24 10:37:51 -07:00
Emil Sjolander
69c374e74e Simplify memory model between managed and unmanaged memory
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
2016-10-24 10:37:51 -07:00
Emil Sjolander
4c57029a28 Remove flex shorthand getter because it doesnt make a lot of sense
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
2016-10-24 03:37:49 -07:00
Emil Sjolander
c28429efc8 Dont override flexShrink, flexGrow, and flexBasis with shorthand flex
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
2016-10-24 03:37:48 -07:00
Emil Sjolander
ab4ce535b9 Forward gLogger output to adb on android platforms
Summary: use android/log on android platforms

Reviewed By: splhack

Differential Revision: D4064619

fbshipit-source-id: de23e72844e25106d0db756064f5699959f45ed2
2016-10-23 11:07:43 -07:00
Emil Sjolander
7fee10691c Add test to assert default values
Summary: assert default values in test

Reviewed By: splhack

Differential Revision: D4064659

fbshipit-source-id: f7bf06232ebbbaa72c0202c5d9f15dd0d8005e22
2016-10-23 10:52:40 -07:00
Kazuki Sakamoto
4d964bdbc3 Update README
Summary:
- Update README for gentest
- Fix gentest.rb for the right working dir

Reviewed By: emilsjolander

Differential Revision: D4065863

fbshipit-source-id: 5c6bd9d18779c05c1de24c06a83b148889facb6b
2016-10-23 10:37:40 -07:00
Kazuki Sakamoto
ef538a45cd Add generated tests
Summary: - Add Java and C# test code generated by gentest

Reviewed By: emilsjolander

Differential Revision: D4065904

fbshipit-source-id: c0d489f37ee0a3132185636812057dc95725d59a
2016-10-23 10:37:39 -07:00
Kazuki Sakamoto
dc5e613285 gentest for Java and C#
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
2016-10-23 10:37:39 -07:00
mattpodwysocki
1488f822c3 Fix C# delegate calling conventions
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
2016-10-22 09:52:42 -07:00
Michael Lee
7673de823f Clean up the vm_args override and use_cxx_libraries instead
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
2016-10-20 15:22:39 -07:00
Dustin Shahidehpour
26bcc1e072 Remove view.isHidden optimization from sizing/layout.
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
2016-10-20 09:37:39 -07:00
Emil Sjolander
2e090cb1c8 Fixup format file for hopefully the last time in a while and re-format code
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
2016-10-20 06:22:37 -07:00
Kazuki Sakamoto
daed6f5b8a Introduce CSSLayoutSetLogger to pass the print result to C# side
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
2016-10-19 11:08:08 -07:00
Emil Sjolander
e4ad7d3c12 Change flex basis to override main axis size
Summary: Flex basis should override height/width. Not the other way around.

Reviewed By: gkassabli

Differential Revision: D4029374

fbshipit-source-id: bc3c72879f3937a50bf8a636b547adc7b9a4f5a7
2016-10-19 06:52:43 -07:00
Emil Sjolander
fa2ffc72a4 Use typedefs from header
Summary: Use typedefs from header for print and measure functions

Reviewed By: gkassabli

Differential Revision: D4036421

fbshipit-source-id: 01f15cb840363850970e6a60e661af06fd6ec9e0
2016-10-18 10:29:22 -07:00
Emil Sjolander
d1d9326fa4 Use switch instead of ifelse chain
Summary: easier to read

Reviewed By: gkassabli

Differential Revision: D4036445

fbshipit-source-id: 2159946f53507ff3d7505795e5baa5f820cdb65c
2016-10-18 10:07:46 -07:00
Emil Sjolander
9c3970dd75 Fix flex-shrink when shrinking to zero size
Summary: Fix flex-shrink when shrinking to zero size

Reviewed By: gkassabli

Differential Revision: D4036345

fbshipit-source-id: f6848d7a316a694426f761d5e51d972bd379d90e
2016-10-18 09:22:42 -07:00
Michael Lee
6152ca46c8 Tell the java wrapper to use the fbcode java
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
2016-10-18 08:07:45 -07:00
Emil Sjolander
9fb1b29f14 Remove default: usage to ensure compiler can help with missing cases
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
2016-10-18 06:52:51 -07:00
Emil Sjolander
82dafa75cf Move absolute layout calculation out into seperate function
Summary: Move absolute layout calculation out into seperate function

Reviewed By: gkassabli

Differential Revision: D4028329

fbshipit-source-id: 2903f66b028063cec0a6b3037ca7cb4d6552176d
2016-10-17 12:22:49 -07:00
Emil Sjolander
eb4f1cdc96 Fix justify content + min dimension when children overflow
Summary: Fix justify content + min dimension when children overflow

Reviewed By: gkassabli

Differential Revision: D4029442

fbshipit-source-id: d28ebd269c452c3359e16ecc5749a415da6e4d75
2016-10-17 08:07:48 -07:00
Emil Sjolander
501ed57784 Only look at computed style if key was not set inline
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
2016-10-17 06:37:45 -07:00
Emil Sjolander
bfb9b926b3 Move flex basis calculation out into seperate function
Summary: Move flex basis calculation out into seperate function

Reviewed By: gkassabli

Differential Revision: D4028328

fbshipit-source-id: 6d5f3bf1321077675eaa65408a70c9dc92a675be
2016-10-17 05:37:44 -07:00
Emil Sjolander
b21efa45e6 Fix justify content + min dimension usage in root
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
2016-10-17 04:23:55 -07:00
Dustin Shahidehpour
c619c0be5a Proper fix for broken android builds.
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
2016-10-14 17:52:48 -07:00
Dustin Shahidehpour
63d3e8f3f3 Add uikit tests to Travis.
Summary: Now that we have some tests, lets run them.

Reviewed By: emilsjolander

Differential Revision: D4023765

fbshipit-source-id: 9f2fa723dc9a33f12c0470b782d6329b432546fa
2016-10-14 16:52:47 -07:00
Michael Lee
770fa6d254 Turn off the apple_test getting pulled into end-to-end tests
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
2016-10-14 16:22:55 -07:00
Dustin Shahidehpour
eedee80f25 Add Test to make sure associated objects live/die with lifetime of UIView.
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
2016-10-14 14:52:57 -07:00
Dustin Shahidehpour
0254e3e97f Don't call sizeThatFits: if measure modes are exact.
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
2016-10-14 14:52:57 -07:00
Dustin Shahidehpour
05ba3a2565 Do not measure the view if it is hidden.
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
2016-10-14 14:37:43 -07:00
Dustin Shahidehpour
89440f630f Add Testing to uikit.
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
2016-10-14 13:37:50 -07:00
Kazuki Sakamoto
832d07902e Modify unittest
Summary:
- Disable destructor tests in Unity Editor, seems GC is flaky.
- Use current native instance counts

Reviewed By: emilsjolander

Differential Revision: D4018951

fbshipit-source-id: a57f0e1fa5a46e7de0b88235124d437d20e4082b
2016-10-14 07:08:29 -07:00
Emil Sjolander
b45a7e3737 Don't assume a node with a measure function is a leaf node
Summary: Don't assume a node with a measure function is a leaf node

Reviewed By: gkassabli

Differential Revision: D4021096

fbshipit-source-id: 7e039239b1697a0ac42dce9f4b7e252a931bad7e
2016-10-14 04:37:53 -07:00
Emil Sjolander
14009ec470 Rename C test target to match pattern of other test targets
Summary: Rename C test target to match pattern of other test targets

Reviewed By: gkassabli

Differential Revision: D4014931

fbshipit-source-id: 2b4b831d6073214e8162a1d27b7478f3665a795f
2016-10-13 11:39:35 -07:00
Georgiy Kassabli
203e3dc9b8 Compatibility with Apple TVOS
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
2016-10-13 10:52:44 -07:00
Kazuki Sakamoto
7548164edb Clean up MeasureFunc and PrintFunc
Summary:
- Remove unneeded instance variables
- Simplify MeasureFunc call
- Add unittest

Reviewed By: emilsjolander

Differential Revision: D4013176

fbshipit-source-id: 4cdfa3ac3ad60a6bac5cda10644376ee9c46300b
2016-10-13 08:07:58 -07:00
Kazuki Sakamoto
722bfb9032 Align C# implementation with Java
Summary:
- Align C# implementation with Java JNI implementation
  - No need to call init(reinit)
  - Rename Initialize and Reset
- Add unittests

Reviewed By: emilsjolander

Differential Revision: D4009351

fbshipit-source-id: 191ddec30b0c8518eb0d76c0579afe909b673fac
2016-10-13 08:07:58 -07:00
Emil Sjolander
2a8a4e10c6 Update readme adding UIKit and fixing things that have changed
Summary: Update readme adding UIKit and fixing things that have changed

Differential Revision: D4015068

fbshipit-source-id: 213a60bea6f16ca01a4e613c8e3563f7c354ca8e
2016-10-13 06:22:53 -07:00
Scott Wolchok
8df9320f4c Fix build with -Wmissing-prototypes
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
2016-10-12 21:22:55 -07:00
Emil Sjolander
df6b4d3682 Add tests for java jni bindings
Summary: Add tests for java jni integration

Reviewed By: lucasr

Differential Revision: D4008411

fbshipit-source-id: c896a3925ff3f7fa368176a3d03c84eb7188ef60
2016-10-12 10:08:54 -07:00
Emil Sjolander
8939bcb96d UIView category
Summary: Add flexbox support to UIViews via a category

Reviewed By: dshahidehpour

Differential Revision: D4002873

fbshipit-source-id: f89de3acdf8fd89c7801918dcad34ba9011dd025
2016-10-12 09:37:42 -07:00
Kazuki Sakamoto
d3fc24e842 Implement SetPosition
Summary: Implement missing SetPosition method in CSSNode

Reviewed By: emilsjolander

Differential Revision: D4006153

fbshipit-source-id: 488263965c2b3b2bd46f3ac58575776a748e3eb9
2016-10-12 09:22:54 -07:00
Emil Sjolander
7f6b942146 Move java rules into java directory
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
2016-10-12 09:07:51 -07:00
Emil Sjolander
29fa232129 Remove tests for CSSNodeDEPRECATED
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
2016-10-12 06:07:42 -07:00
Emil Sjolander
41b64478c4 Rename init() -> reinit() to be more in line with what it now does
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
2016-10-12 03:53:04 -07:00
Emil Sjolander
23acf2156f Rename reset() -> free() to be more in line with what it now does
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
2016-10-12 03:53:04 -07:00
Emil Sjolander
1de914737a Automatically init native memory when allocating java wrapper
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
2016-10-12 03:53:04 -07:00
Emil Sjolander
033658196f JNI version is the default, its name should reflect that
Summary: JNI version is the default, its name should reflect that

Reviewed By: lucasr

Differential Revision: D3992777

fbshipit-source-id: cdd4cc58f3c15b5db1158f6f794394eb5c44a44d
2016-10-12 03:53:04 -07:00
Emil Sjolander
136ec25e8c Remove xcode_public_headers_symlinks from open source
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
2016-10-12 03:22:42 -07:00
Emil Sjolander
62dba4c741 Clearly mark java CSSNode as deprecated. It will go away very soon
Summary: Clearly mark java CSSNode as deprecated. It will go away very soon.

Reviewed By: lucasr

Differential Revision: D3992775

fbshipit-source-id: b3ceca277e5c7426eb51f8cbeacf5e2fe451c6ec
2016-10-12 02:52:56 -07:00
Emil Sjolander
871a7cf310 Move csharp tests into csharp folder
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
2016-10-11 07:08:10 -07:00
Emil Sjolander
cdf4ee1e59 Move benchmark buck file into benchmark directory
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
2016-10-11 05:52:50 -07:00
Emil Sjolander
588d2c91ba Remove unused buck rule
Summary: CSSLayoutTestUtils doesn't exist anymore

Reviewed By: lucasr

Differential Revision: D3992982

fbshipit-source-id: 427270e5a164974a8e964a4b23461b18d9b91066
2016-10-11 05:07:40 -07:00
Emil Sjolander
f61fbd269e Add finalizer to release any unreleased native memory
Summary: Ensure all native memory is released once gc deallocates the java object reference.

Reviewed By: lucasr

Differential Revision: D3992759

fbshipit-source-id: f648b72ead5bdb7257a5197496b19795f71f3788
2016-10-11 04:52:49 -07:00
Emil Sjolander
d506e6ab94 Enable running within robolectric
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
2016-10-08 06:22:50 -07:00
Kazuki Sakamoto
56f6efdecf Introduce CSSAssertSetFailFunc and CSSAsserFail to throw managed exception
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
2016-10-07 12:38:08 -07:00
Kazuki Sakamoto
90844d62c5 WeakReference for parent
Summary: - Use WeakReference for parent to avoid circular reference although GC will treat it

Reviewed By: emilsjolander

Differential Revision: D3982520

fbshipit-source-id: b0f6764aa4df3da53be51f6cb4fe2994d989afdf
2016-10-07 11:23:00 -07:00
Kazuki Sakamoto
c233bafeb2 Introduce CSSNodeGetInstanceCount API
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
2016-10-07 11:23:00 -07:00
Kazuki Sakamoto
b57abb2f60 Remove unused GCHandle
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
2016-10-07 11:22:59 -07:00
Emil Sjolander
56279110c0 Resolve some differences between CSSNode and CSSNodeJNI
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
2016-10-07 05:22:45 -07:00
Kazuki Sakamoto
01115b8bbd Add unittest
Summary: - Unittest for P/Invoke integration

Reviewed By: emilsjolander

Differential Revision: D3977114

fbshipit-source-id: 11f6bf747898433226c920997839e938734cbd77
2016-10-06 06:08:06 -07:00
Kazuki Sakamoto
47bd1bb943 Align C# implementation with Java and Dispose pattern
Summary:
- Align C# implementation with Java JNI implementation
  - AssertNativeInstance
    - is this instance disposed?
    - does this instance have native instance pointer?
- Align Dispose and destructor with Dispose pattern
  - https://msdn.microsoft.com/en-us/library/fs2xkftw(v=vs.110).aspx

    if (disposing)
    {
      Free maanged objects here
    }
    Free unmanaged objects here
    disposed = true;

Reviewed By: emilsjolander

Differential Revision: D3977015

fbshipit-source-id: 023cf5b15aacfada14a85c321576aa81d7f95125
2016-10-06 06:08:05 -07:00
Kazuki Sakamoto
2870d3ce4d Remove .dll from DllName for other platforms
Summary:
- Different platforms have different naming conventions
  - http://www.mono-project.com/docs/advanced/pinvoke/#library-names
- Unity iOS requires special name `__Internal`
  - https://docs.unity3d.com/Manual/PluginsForIOS.html

Reviewed By: emilsjolander

Differential Revision: D3976369

fbshipit-source-id: 4c1d7fe226c5c2a89531ee1c2ee8b47df847b3e4
2016-10-06 06:08:05 -07:00
mattpodwysocki
23f2878808 rocket: fix P/Invoke sig for bool
Summary:
Fixes the `bool` marshaling issue as describe on [MSDN](https://blogs.msdn.microsoft.com/jaredpar/2008/10/14/pinvoke-and-bool-or-should-i-say-bool/) so C# will now act properly.
Closes https://github.com/facebook/css-layout/pull/226

Reviewed By: IanChilds

Differential Revision: D3967349

Pulled By: emilsjolander

fbshipit-source-id: f61d3bb39eb1b0b6e749629825234615b425e930
2016-10-05 02:37:55 -07:00
Hoa Dinh
11f85ce91e create symlinks in xplat
Summary: In the libraries where headers symlinks are required, we enable them.

Reviewed By: skotchvail

Differential Revision: D3943274

fbshipit-source-id: c7ec741af020a60bb7c39b10773cea58a33adc3e
2016-09-29 10:23:33 -07:00
Emil Sjolander
1f300a58fb Free memory used in tests to enable use of valgrind
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
2016-09-29 04:22:47 -07:00
mattpodwysocki
dbf3b11946 Add C# example for css-layout CSSNode
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
2016-09-28 03:23:26 -07:00
Emil Sjolander
3b1515f2b7 Fix bug introduced by D3886866
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
2016-09-27 10:22:59 -07:00
Emil Sjolander
6b16dc4060 Fix flex-end/flex-start RTL transpilation
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
2016-09-27 08:52:44 -07:00
mattpodwysocki
9c93c7fc42 Removes unnecessary CSSLayoutContext param from CalculateLayout
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
2016-09-27 04:37:37 -07:00
Emil Sjolander
15d5cb0169 BREAKING - Fix unconstraint sizing in main axis
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
2016-09-26 06:22:39 -07:00
Christopher Chedeau
dba5faabb2 Syntax highlight C code in README
Summary: Closes https://github.com/facebook/css-layout/pull/221

Reviewed By: vjeux

Differential Revision: D3914024

Pulled By: emilsjolander

fbshipit-source-id: 4cb0741e526dfefbbb41e8afed1c2f52823df08a
2016-09-23 09:22:38 -07:00
mattpodwysocki
ff8f17ac99 Introducing .NET version of css-layout using P/Invoke
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
2016-09-22 16:37:46 -07:00
Emil Sjolander
017fb2c734 Cleanup some multiline code
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886866

fbshipit-source-id: e19c1be4af58605933f90b5bf381008338be2236
2016-09-20 10:23:09 -07:00
Emil Sjolander
8fd14c710c Move justifyContent check into switch statement
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886861

fbshipit-source-id: 17ba2962016af34b5add3ce6d8355c9c305a35c0
2016-09-20 10:23:09 -07:00
Emil Sjolander
1415a5d7fd Remove empty line in function call
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886856

fbshipit-source-id: cf76ad9b6c85a62b9f2683618a6abe986d98acc2
2016-09-20 10:23:09 -07:00
Emil Sjolander
2592894d2d Remove use of snake_case
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886849

fbshipit-source-id: eaf3f219fe1ccb717ba363dba0d2f475ffb204e3
2016-09-20 10:23:09 -07:00
Ben Hiller
dcaef7ecb0 Reverted commit D3856585
Summary: Add tests to check that measure modes are set correctly.

Reviewed By: lucasr

Differential Revision: D3856585

fbshipit-source-id: 421b368d2d2cbca1d2ba4d58d850836cb22128ac
2016-09-14 12:07:40 -07:00
Emil Sjolander
2dcd8b4074 Reverted commit D3855801
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
2016-09-14 11:37:51 -07:00
Emil Sjolander
1951242a52 Add tests for measure modes
Summary: Add tests to check that measure modes are set correctly.

Reviewed By: lucasr

Differential Revision: D3856585

fbshipit-source-id: 5fa407f149b1c081503b4ad7aa5f0203ec5b1cc0
2016-09-14 09:07:44 -07:00
Emil Sjolander
d4121401d7 BREAKING - Fix unconstraint sizing in main axis
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
2016-09-14 09:07:44 -07:00
Emil Sjolander
0be3b1013f Remove legacy test suite
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
2016-09-14 08:52:44 -07:00
Emil Sjolander
21a05417cd Generate RTL version of tests
Summary: Generate RTL versions of css-layout tests

Reviewed By: lucasr

Differential Revision: D3863081

fbshipit-source-id: df4debb3c1e371425d7c297f8d013b8042ad1e0e
2016-09-14 08:52:44 -07:00
Emil Sjolander
8fcb265830 Make generated test input more copy pastable
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
2016-09-14 08:52:44 -07:00
Emil Sjolander
64fffcb8f3 Remove flex section from readme as it now supports all web properties
Summary: Update readme to reflect new support.

Reviewed By: lucasr

Differential Revision: D3856292

fbshipit-source-id: 012f3d1171330cc93c34de300153ff4bb1326819
2016-09-14 08:22:37 -07:00
Emil Sjolander
059384f277 Improve formatting of generated test code input
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
2016-08-31 11:22:42 -07:00
Emil Sjolander
57725e849a Copy fbjni library from react-native 2016-08-31 16:15:15 +01:00
Adam Comella
b51e832e4e Fix sizing of absolutely positioned nodes inside overflow:hidden parent
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
2016-08-31 08:07:59 -07:00
Emil Sjolander
d9191431ff Generate test for border (and fix gentest to include border offset)
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
2016-08-31 08:07:59 -07:00
Emil Sjolander
251a499ba6 Generate tests for padding
Summary: Add generated tests for padding

Reviewed By: lucasr

Differential Revision: D3791211

fbshipit-source-id: 7fb4580c2ab8fba05532df746297c7a0ec6a734e
2016-08-31 08:07:59 -07:00
Emil Sjolander
3c33184dbb Add tests for margin
Summary: Generate tests for margins

Reviewed By: lucasr

Differential Revision: D3791131

fbshipit-source-id: e038ccd8b9314a8cc472e4f57d77c5f097228344
2016-08-31 08:07:59 -07:00
Emil Sjolander
583830b3df Fix and add tests for cssedge priority
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
2016-08-31 08:07:59 -07:00
Emil Sjolander
36eaae88e0 Add tests for dirty propagation
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
2016-08-31 08:07:59 -07:00
Emil Sjolander
284634c880 Remove unnecesarry imports for tests
Summary: Minimal imports

Reviewed By: lucasr

Differential Revision: D3790919

fbshipit-source-id: 496078d8132252307ef2b3cb45472917a19d7750
2016-08-31 06:22:46 -07:00
Emil Sjolander
94bbbde930 Make use of fbjni
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
2016-08-31 05:08:29 -07:00
Emil Sjolander
1051c39a59 Add tests for measure caching
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
2016-08-31 05:08:29 -07:00
Emil Sjolander
1abb2d1714 Change dynamic library extension depending on platform
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
2016-08-30 10:22:36 -07:00
Emil Sjolander
c28148caff Exclude tests from formatting as they are auto-generated and include html
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
2016-08-30 10:07:53 -07:00
Emil Sjolander
e3fa40e694 Allow specifying the test name in the input to gentest
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
2016-08-26 10:38:01 -07:00
Lucas Rocha
89c00a7a3b Make Spacing.release() public
Summary: So that it can be reset when Spacing is used outside CSSNode.

Differential Revision: D3763593

fbshipit-source-id: 27436c0dbd292b38cfc98f4cfb8e2d12787b85d6
2016-08-26 04:22:54 -07:00
Emil Sjolander
2808e547c6 Revert changes causing layout failures
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
2016-08-26 03:22:35 -07:00
Emil Sjolander
8b4a61df1a Generate tests for min/max height/width
Summary: Generate tests for min/max height/width

Differential Revision: D3771576

fbshipit-source-id: a114f79bdb3d36237d7ecc22f8cef69b6899fc3d
2016-08-25 15:38:14 -07:00
Emil Sjolander
43faff434a Generate tests for flex properties
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
2016-08-25 15:38:14 -07:00
Emil Sjolander
ea9a6ce06f Generate test for justify content
Summary: Generate tests for justify content

Differential Revision: D3771389

fbshipit-source-id: 2f6c5a38e6899b9ef05b7ad2da9b881c3b71e15c
2016-08-25 15:38:14 -07:00
Emil Sjolander
beb51fac1b Generate test for align content
Summary: Generate tests for align content

Differential Revision: D3771383

fbshipit-source-id: 4a0798486522bdfd7f10ca4db7086096494f03d8
2016-08-25 15:38:14 -07:00
Emil Sjolander
d33befeb98 Generate test for align self
Summary: Generate tests for align self

Differential Revision: D3771377

fbshipit-source-id: eaeec8a7ac5609bd8dd95d31500054510ab749d9
2016-08-25 15:38:14 -07:00
Emil Sjolander
2fc622adbd Generate test for flex wrap
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
2016-08-25 15:38:14 -07:00
Emil Sjolander
1fd3a16116 Fix naming of some style props in gentest
Summary: These props were never tested so I didn't notice the typo until now.

Differential Revision: D3771132

fbshipit-source-id: 9d7c2037195f29b3cac5d21599035edf3b7830ff
2016-08-25 15:38:14 -07:00
Emil Sjolander
aa70125f6c Generate tests for absolute layout
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
2016-08-25 15:38:14 -07:00
Emil Sjolander
9985e398b3 Generate test for align items
Summary: generate align-items tests

Reviewed By: IanChilds

Differential Revision: D3770946

fbshipit-source-id: 30ec043a8819d31a611f689bf89635f6a51c1628
2016-08-25 15:38:14 -07:00
Emil Sjolander
b629bcacab Generate test for flex direction
Summary: Generate flex-direction tests

Reviewed By: IanChilds

Differential Revision: D3770939

fbshipit-source-id: 7c02fe91bd50345c18653f70d1b572b643c44d26
2016-08-25 15:38:14 -07:00
Emil Sjolander
f65febb1af Remove certain computed values from output style
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
2016-08-25 15:38:14 -07:00
Emil Sjolander
ccbfee3841 Ensure multiple test cases all have the same origin
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
2016-08-25 15:38:14 -07:00
Emil Sjolander
9eb75e27cc Update gentest to new api
Summary: Update gentest to handle new CSSEdge api

Reviewed By: IanChilds

Differential Revision: D3770906

fbshipit-source-id: 1fa978354209fb8f4d0c5a2f892e1c79b062d4de
2016-08-25 15:38:14 -07:00
rh389
15afb4207c Use quote style for local includes
Summary:
This PR changes `#include <CSSLayout/*.h>` to  `#include "*.h"` within the `CSSLayout` directory.

Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility.

I think this is the best fix for https://github.com/facebook/react-native/issues/9014, and seems like good practice in any case.
Closes https://github.com/facebook/css-layout/pull/217

Reviewed By: majak

Differential Revision: D3764132

Pulled By: emilsjolander

fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
2016-08-24 10:52:35 -07:00
Emil Sjolander
f1ae87cd73 Implement flex properties in java version as well
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
2016-08-23 04:37:46 -07:00
Emil Sjolander
e8465aee45 Fix benchmark build
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
2016-08-22 08:22:38 -07:00
Emil Sjolander
ca72b2b796 Use const where possible
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
2016-08-22 07:07:41 -07:00
Emil Sjolander
4bcefd8845 Remove unnecessary indirection
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
2016-08-22 07:07:41 -07:00
Emil Sjolander
0672f5572f Move default spacing out of csslayout
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
2016-08-18 03:37:37 -07:00
Emil Sjolander
9d34b4e110 Compute edge values similar to how Spacing.java does it
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
2016-08-17 10:38:40 -07:00
Emil Sjolander
dab03cb800 Remove CSSPosition in favor of CSSEdge
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
2016-08-17 10:38:38 -07:00
Emil Sjolander
dd2346f8ac Document format.sh
Summary: Mention format.sh script in README and CONTRIBUTING docs

Reviewed By: IanChilds

Differential Revision: D3728789

fbshipit-source-id: 1d5d99dc627b6cb87898d282aae8adfcaeec7c14
2016-08-17 06:37:43 -07:00
Emil Sjolander
dde2b349f2 Support 64 bit platforms
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
2016-08-16 08:52:38 -07:00
Emil Sjolander
7cd6305371 Fix parameter order
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
2016-08-16 06:07:42 -07:00
Emil Sjolander
f28dacf280 import function before using it
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
2016-08-16 03:52:43 -07:00
Emil Sjolander
a960203567 Use single function for margin, position, padding, and border
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
2016-08-15 09:23:28 -07:00
Emil Sjolander
48e5304276 Specify format folders more granularly
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
2016-08-15 09:23:28 -07:00
Emil Sjolander
53ff4f59ca Allow format script to be run from anywhere
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
2016-08-15 09:23:28 -07:00
Emil Sjolander
28bc42a988 Add generation script header to generated tests
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
2016-08-15 09:23:28 -07:00
Emil Sjolander
c373056d80 Add the ability to generate multiple test cases
Summary: Modify test generation script to be able to generate multiple test cases

Reviewed By: lucasr

Differential Revision: D3714577

fbshipit-source-id: d2bc2155712f946c5a24231a9532d2acc097524c
2016-08-15 09:23:28 -07:00
Emil Sjolander
f68521aa69 Add support for flex-grow, flex-shrink, and flex-basis
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
2016-08-15 09:23:28 -07:00
Emil Sjolander
fdd5c8ce82 Use library style imports
Summary: Use library style imports to avoid lint warning

Reviewed By: IanChilds

Differential Revision: D3714512

fbshipit-source-id: 4c42d52b3ab92903e9e9451df0ca1564e2d33f0f
2016-08-15 09:23:28 -07:00
Emil Sjolander
7a1e353404 Update clang-format rules
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
2016-08-15 09:23:27 -07:00
Emil Sjolander
6a44dbc43b Add no-op allow_unsafe_import for open source
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
2016-08-15 09:23:27 -07:00
Michal Lowicki
597354a43b Enable build file sandboxing in fbandroid
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
2016-08-12 09:38:05 -07:00
Emil Sjolander
1ce14cd097 Update readme
Summary: Docs!

Reviewed By: IanChilds

Differential Revision: D3709305

fbshipit-source-id: 1c8b7c1395bd78f073195eade1839ead4d9dacad
2016-08-12 08:52:41 -07:00
Emil Sjolander
d125911894 Print more detailed benchmark results including median and stddev
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
2016-08-12 06:22:38 -07:00
Emil Sjolander
e307dc22d1 Expose alignContent to java
Summary: Expose already existing alignContent property to java

Reviewed By: IanChilds

Differential Revision: D3709071

fbshipit-source-id: 421d75924ecc12d6d0975e342f3862cf5592f65f
2016-08-12 04:22:41 -07:00
Emil Sjolander
916170f6ac Dont generate so for main library
Summary: A .so file is only needed for the JNI target. The main library can be static.

Differential Revision: D3703897

fbshipit-source-id: b2efb98a6ae4488e6107c736c263cad35ef7c4fe
2016-08-12 03:53:52 -07:00
Emil Sjolander
57021eba9d Run benchmarks on previous revision as well
Summary: Checkout previous revision and re-run benchmark on travis

Differential Revision: D3697439

fbshipit-source-id: 260c5e379ae5caa667cf315e210ff4a7349b5868
2016-08-11 11:52:44 -07:00
Emil Sjolander
a43b813517 Add test generation scripts
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
2016-08-11 11:52:44 -07:00
Emil Sjolander
e5a3f7bf5b Turn on higher optimization level
Summary: quicker the better

Reviewed By: adamjernst

Differential Revision: D3697615

fbshipit-source-id: 822fb0927601849b364d3a649af934a0e82108e3
2016-08-11 03:07:51 -07:00
Emil Sjolander
af5b14335e Use modern initializer syntax instead of comments
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
2016-08-11 03:07:51 -07:00
Emil Sjolander
118f64f206 Add benchmarks and change repetition count
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
2016-08-11 02:37:38 -07:00
Emil Sjolander
450472766d Fix travis build
Summary: Building on osx machines makes things a lot easier.

Differential Revision: D3693987

fbshipit-source-id: f6e2599f99a3fd4ac6fb2a6efd5563074da707d0
2016-08-10 08:37:46 -07:00
Emil Sjolander
759cb707a4 Remove .buckversion
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
2016-08-10 08:37:46 -07:00
Emil Sjolander
328db9ca1c Include soloader as aar
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
2016-08-10 08:37:46 -07:00
Emil Sjolander
f15b563166 Use spacing for position
Summary: Use spacing for position in public api. This was already the case internally

Differential Revision: D3690235

fbshipit-source-id: 4c04952e6ded32fd5fbfdccf63736cf025ae470e
2016-08-10 05:22:32 -07:00
Emil Sjolander
7f27046cc5 Expose methods to set position Start|End
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
2016-08-09 04:37:45 -07:00
ymmuse
faad5cdf4d fix CSSNodeList memory leak
Summary:
CSSNodeListFree does not free the list->items memory
Closes https://github.com/facebook/css-layout/pull/214

Differential Revision: D3683643

Pulled By: emilsjolander

fbshipit-source-id: 7f9ef19f4603d5558cc2f8302756b3bcec2f6c12
2016-08-08 04:52:35 -07:00
James Ide
256d080fd2 Prefix isUndefined with "CSS"
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
2016-08-05 06:37:38 -07:00
Emil Sjolander
efe1595f0e Add and run clang format script
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
2016-08-04 08:23:02 -07:00
Emil Sjolander
9278ff462e Add the ability to attach data to a java CSSNode
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
2016-08-04 08:23:02 -07:00
Emil Sjolander
b32d384337 Fallback to System.loadLibrary if SoLoader has not been initialized
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
2016-08-04 08:23:02 -07:00
Emil Sjolander
f5caf93c6e Only perform class and method lookup once
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
2016-08-04 08:23:01 -07:00
Emil Sjolander
c74eae50ac Add jni bindings
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
2016-08-04 08:23:01 -07:00
Emil Sjolander
7af5e3d68d Dont redefine abort() as it may leak into other files
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
2016-08-03 02:07:39 -07:00
Emil Sjolander
9689062f6c Implement custom assert macro
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
2016-08-02 08:08:09 -07:00
Emil Sjolander
ac44d2ea6e use #pragma once
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
2016-08-02 08:08:09 -07:00
Emil Sjolander
9ab97af05d Re-enable travis
Summary: Add travis config file.

Reviewed By: lucasr

Differential Revision: D3649004

fbshipit-source-id: 27f257246965db473dc85ec6fed6b9a32bc8a621
2016-08-02 08:08:09 -07:00
Emil Sjolander
cdf18b9c2b Update readme with java instructions
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
2016-08-02 08:08:09 -07:00
Emil Sjolander
c7d02257e3 Make use of modern standard types
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
2016-08-02 08:08:09 -07:00
Emil Sjolander
c72321f8a9 Add first benchmark
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
2016-08-01 07:40:11 -07:00
Emil Sjolander
a0805d0b90 shouldUpdate -> hasNewLayout
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
2016-08-01 05:37:31 -07:00
Mengjue Wang
5207b90420 Provide RTL support for RCTShadowView according to new csslayout
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
2016-07-29 10:37:40 -07:00
Mengjue Wang
5e7d95b403 bottom styling isn't applied when a View is not absolute-positioned
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
2016-07-28 23:37:41 -07:00
Mengjue Wang
041960fcbc Reverted commit D3629662
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
2016-07-28 21:52:33 -07:00
Mengjue Wang
46c842c71a Fix CSSLayout to Support RTL
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
2016-07-28 14:52:40 -07:00
Mengjue Wang
b26794a375 Fix the test files according to new CSSLayout change
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
2016-07-28 11:07:38 -07:00
Emil Sjolander
8ffff2bfaf update readme
Summary: Update readme with info about building and github markdown syntax

Differential Revision: D3613284

fbshipit-source-id: 1f57009ccf02a48fe100f675ce08503e15cb6c22
2016-07-25 09:52:59 -07:00
FBShipIt
fdd8552c4e Import new C source of truth css-layout
fbshipit-source-id: e866918d6c62fc1cf3a04c269f782b94db9b875a
2016-07-25 15:53:07 +01:00
Emil Sjolander
93809b69c8 Restructure things to fit upcoming diff 2016-07-25 15:48:39 +01:00
Emil Sjölander
667106e423 Merge pull request #206 from facebook/revert-199-measure-fix
Revert "Correctly size cross axis when measuring flex basis"
2016-07-13 11:02:05 +01:00
Emil Sjölander
57874a1a9e Revert "Correctly size cross axis when measuring flex basis" 2016-07-13 10:42:03 +01:00
Emil Sjölander
8b7f353746 Merge pull request #199 from emilsjolander/measure-fix
Correctly size cross axis when measuring flex basis
2016-07-08 16:47:19 +01:00
Emil Sjolander
ca34ff4446 Correctly size cross axis when measuring flex basis 2016-07-08 16:05:21 +01:00
Emil Sjölander
d878091c4b Merge pull request #203 from emilsjolander/at-most-root-js
Add missing js implementation for PR #200
2016-07-08 15:52:19 +01:00
Emil Sjolander
c4fa32cfd3 Add missing js implementation for PR #200 2016-07-08 14:43:30 +01:00
Emil Sjölander
6e05325f08 Merge pull request #200 from emilsjolander/at-most-root
Use AT_MOST measurespec when onyl max dimension is defined
2016-07-04 23:25:04 +01:00
Emil Sjolander
a1f36b53f5 Use AT_MOST measurespec when onyl max dimension is defined 2016-07-02 11:22:57 +01:00
Emil Sjölander
383d8a6b3d Merge pull request #195 from emilsjolander/imrpove-cache-hit
Improve heuristic for cache re-use
2016-06-09 10:55:48 -04:00
Emil Sjolander
7b0c008300 Improve heuristic for cache re-use 2016-06-09 10:33:00 -04:00
Emil Sjölander
45e595e6ae Merge pull request #193 from emilsjolander/stretch-perf
Measure with exact measurement when stretch is defined
2016-06-09 10:21:04 -04:00
Emil Sjolander
2a816bf5a7 Measure with exact measurement when stretch is defined 2016-06-08 14:00:31 -04:00
Emil Sjölander
71eb25d1cc Merge pull request #196 from emilsjolander/styling
Remove whitespace on empty lines etc.
2016-06-03 22:19:53 +01:00
Emil Sjolander
c06752e052 Remove whitespace on empty lines etc. 2016-06-03 22:19:03 +01:00
Emil Sjölander
bd92550d57 Merge pull request #192 from rigdern/rigdern/expose-props
Expose getters and setters for some new properties
2016-06-02 17:20:30 +01:00
Adam Comella
9260363fef Expose getters and setters for some new properties
The properties include overflow and min/max height/width.
2016-06-01 12:56:35 -07:00
Emil Sjölander
9d62cee68b Merge pull request #185 from rigdern/rigdern/spec-conformance
Alter layout engine to conform closer to W3C spec
2016-05-31 11:04:41 +01:00
Adam Comella
16f43dac87 Skip measurement when there's no available vertical space
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.
2016-05-25 10:53:15 -07:00
Adam Comella
8177bfe702 Heuristics for skipping calls to the measure function
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.
2016-05-18 13:40:34 -07:00
Adam Comella
8779d942ea Fix positioning of items with min/max width/height
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.
2016-05-11 00:29:40 -07:00
Adam Comella
f3dd51ab97 Alter layout engine to conform closer to W3C spec
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'.
2016-04-26 19:45:58 -07:00
Emil Sjölander
b0d00ad338 Merge pull request #163 from emilsjolander/measuremode
Add support for measure mode
2016-04-06 18:07:37 +01:00
Emil Sjolander
7bd6b2b7dd Add support for measure mode 2016-04-01 11:01:16 +01:00
Pieter De Baets
68e0b0cc58 Merge pull request #182 from javache/skip-layout-correctly
Correct skipLayout condition in Layout.c
2016-03-30 15:22:43 +01:00
Pieter De Baets
5b56be412c Correct skipLayout condition in Layout.c
Fixes #155
2016-03-30 12:11:49 +01:00
Lucas Rocha
3454511947 Merge pull request #178 from javache/node-layout-reset 2016-03-29 11:15:53 +01:00
Pieter De Baets
b157ab4a00 Reset child position/sizes before calculating layout 2016-03-29 11:05:53 +01:00
Lucas Rocha
8d5cdd4e6c Merge pull request #145 from alebo/issue-127 2016-03-01 23:07:14 +00:00
Alex Bogomazov
425345aa8d Redo layout of 'stretch' aligned items for correct positioning of nested
items

Fixes facebook/css-layout#83, facebook/css-layout#100,
facebook/css-layout#127.
2016-02-26 00:43:58 +03:00
Christopher Chedeau
dd8e5cd65d Merge pull request #170 from casandrasilva/patch-1
fixes UMD url
2016-02-05 03:57:39 -08:00
Casandra Silva Zenteno
64704dd708 fixes UMD url 2016-02-04 23:31:16 -08:00
Christopher Chedeau
dc7059d340 Merge pull request #166 from RReverser/patch-1
Add C# to the supported language list
2016-01-13 06:26:40 -08:00
Ingvar Stepanyan
acd295e470 Add C# to the supported language list 2016-01-13 14:15:48 +00:00
Lucas Rocha
5d5630d3c8 Merge pull request #161 from emilsjolander/master 2016-01-07 12:17:49 +00:00
Emil Sjolander
c9094f94d0 Check layout instead of style before setting height and width to whatever is set in layout 2016-01-06 15:07:41 +00:00
Christopher Chedeau
f3b6fb3be0 Merge pull request #159 from CatalystCode/dirty
Need dirty() to be virtual to override in special cases.
2016-01-05 07:19:23 -08:00
Eric Rozell
3d7bc48fa6 Need dirty() to be virtual to override in special cases.
See, for example ReactShadowNode in the ReactAndroid code base, which overrides this virtual.
2016-01-05 08:55:32 -05:00
Lucas Rocha
219bdaed15 Merge pull request #154 from majak/width 2015-12-14 16:28:52 +00:00
Martin Kralik
f2aa5ba604 passing height to the measure function
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
2015-12-14 15:00:13 +00:00
Colin Eberhardt
53769ccbc5 Merge pull request #153 from casandrawith1s/patch-1
'package-all' tense consistency
2015-11-22 14:36:31 +00:00
Casandra Silva
2733ebf1d0 'package-all' tense consistency
Change 'package-all' comment to present tense and unfiform grammar for consistency
2015-11-21 21:51:50 -08:00
Colin Eberhardt
45227c0b9a Merge pull request #151 from pragmatrix/csharp-travis-pr
Configure travis to install mono and run the C# tests from within the…
2015-11-20 09:11:27 +00:00
Armin Sander
e848706911 Configure travis to install mono and run the C# tests from within the Gruntfile 2015-11-19 21:27:58 +01:00
Colin Eberhardt
79d7291906 1.1.1 2015-11-12 14:32:34 +00:00
Colin Eberhardt
bae4eb1830 Updated distribution build 2015-11-12 14:31:58 +00:00
Colin Eberhardt
609d4ae69d Do not delete release instructions! 2015-11-12 14:26:15 +00:00
Colin Eberhardt
99c3a88df4 Update release process to include a build step!
See #149
2015-11-12 11:52:07 +00:00
Colin Eberhardt
4364c6ebb2 Merge pull request #150 from wpcarro/patch-1
grammatical fix
2015-11-11 07:41:42 +00:00
Colin Eberhardt
73b1e63bd7 1.1.0 2015-11-11 07:27:17 +00:00
William Carroll
b7856ce26a grammatical fix
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!
2015-11-10 22:46:41 -08:00
Christopher Chedeau
f5eefe51f8 Merge pull request #148 from moneppo/master
Add C usage to documentation.
2015-11-07 08:39:01 -08:00
Michael
aac6694127 Add C usage to documentation.
Fixes #114.
2015-11-07 08:29:12 -08:00
Krzysztof Magiera
6e499300ff Merge pull request #146 from lucasr/style-getters
New style getters and cleanups in CSSNode
2015-10-21 16:42:46 +01:00
Lucas Rocha
d3b702e1ad Rename getStylePadding() to getPadding() for consistency
So that we're consistent with other style-only methods. Move existing
getters to be close to their matching setters in CSSNode.
2015-10-21 14:31:35 +01:00
Lucas Rocha
eb1d1726b9 Add getters for all style properties
For consistency and because now we have some use cases for it.
2015-10-21 10:37:09 +01:00
Christopher Chedeau
8f7632bc7f Merge pull request #144 from woehrl01/woehrl01-width
return correct value from Width property (C#)
2015-10-14 08:45:59 -07:00
Lukas Wöhrl
d2e66a8d82 return correct value from Width property 2015-10-14 08:50:49 +02:00
Lucas Rocha
4b4cd06be2 Merge pull request #140 from lucasr/fast-reset 2015-10-08 15:06:49 +01:00
Lucas Rocha
a821f6c555 Add reset() method to CSSNode
This allows users of css-layout in Java to perform faster resets on
CSSNode in cases when you want to recycle instances.
2015-10-08 14:49:28 +01:00
Colin Eberhardt
fbeef4542d Merge pull request #139 from ColinEberhardt/eslint
Eslint - enforces many more rules.
2015-10-07 22:26:04 +01:00
Colin Eberhardt
f02fbfc10c Changed from '"typeof foo === 'undefined'" to "foo === undefined" 2015-10-07 22:18:27 +01:00
Colin Eberhardt
e4c93e8c59 Updated to use eslint from fbjs-scripts 2015-10-07 21:52:22 +01:00
Krzysztof Magiera
35bd01e3f2 Merge pull request #141 from lucasr/enum-comparison
Faster enum comparisons in CSSNode
2015-10-07 13:19:56 +01:00
Colin Eberhardt
040f0f3e7c relaxed the eqeqeq rule to permit 'foo != null' 2015-10-07 06:40:17 +01:00
Lucas Rocha
af09213d1a Faster enum comparisons in CSSNode
Enums are singletons by design so it's safe (and faster) to compare by
reference. This also covers the null case.
2015-10-05 17:07:23 +01:00
Colin Eberhardt
538cb2e940 Fixed build
(I was using an older verson of eslint locally)
2015-10-05 13:30:59 +01:00
Colin Eberhardt
45f62c424c Widened scope of CI eslint to all JavaScript files 2015-10-05 13:21:19 +01:00
Colin Eberhardt
c33e255182 Enforced quote style and indentation 2015-10-05 13:18:27 +01:00
Colin Eberhardt
0f43977bb2 Enforced the eqeqeq rule 2015-10-05 12:50:54 +01:00
Colin Eberhardt
9b75493988 auto-configured eslint and fixed gruntfile linting failures 2015-10-05 08:08:57 +01:00
Christopher Chedeau
0faaabb78c Merge pull request #138 from devongovett/js-caching
Implement caching in the JS version
2015-10-04 16:07:45 -07:00
Devon Govett
e510c72111 Update based on feedback 2015-10-04 14:36:44 -07:00
Devon Govett
57d41f3e35 Add a shouldUpdate property to nodes whose layout changed 2015-10-04 14:19:02 -07:00
Devon Govett
e9d880a105 Add isDirty support 2015-10-04 14:11:55 -07:00
Devon Govett
221510cfcf Fix nits 2015-10-04 14:11:07 -07:00
Devon Govett
2636a4fbed Merge branch 'master' of github.com:facebook/css-layout into js-caching 2015-10-04 12:33:17 -07:00
Devon Govett
7b2140d7f9 Implement caching in the JS version 2015-10-04 11:45:54 -07:00
Christopher Chedeau
3042bac0bb Merge pull request #137 from devongovett/js-optimization
JS optimization
2015-10-04 07:24:43 -07:00
Devon Govett
5af85c5ef6 Inline some isUndefined calls 2015-10-03 23:14:04 -07:00
Devon Govett
0f5d3ae8f0 Don't use the in operator 2015-10-03 23:13:33 -07:00
Devon Govett
39b45c65c1 Speed up margin/padding/border lookups 2015-10-03 23:11:09 -07:00
Christopher Chedeau
948241b659 Merge pull request #136 from getsetbro/patch-1
Update README.md
2015-10-02 15:51:43 -07:00
Seth Broweleit
2cf795c118 Update README.md
"alignContent" is not supported - see image: https://raw.githubusercontent.com/getsetbro/images/gh-pages/screenshots/reactnative.no.flexbox.aligncontent.png
2015-10-02 16:36:29 -05:00
Christopher Chedeau
9eb00949ae Merge pull request #135 from pragmatrix/csharp5-pr
Don't use C#6 language features for the time being
2015-09-30 09:21:05 -07:00
Armin Sander
2e908bfdee don't use C#6 language features for the time being 2015-09-30 07:57:59 +02:00
Christopher Chedeau
cefd6ccb96 Merge pull request #134 from vjeux/fix_dim_0
Fix width being ignored when has a value of 0
2015-09-25 14:43:52 -07:00
Christopher Chedeau
e280a577ae Fix width being ignored when has a value of 0
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.
2015-09-25 13:10:21 -07:00
Christopher Chedeau
246005cc84 Update dist/ to be the latest version 2015-09-24 11:56:18 -07:00
Christopher Chedeau
4ca2ea3466 Merge pull request #129 from pragmatrix/csharp-fb-pr
C# Transpiler, API, and Tests
2015-09-23 09:08:15 -07:00
Armin Sander
4de0721a24 C# transpiler, API, and tests 2015-09-23 09:27:45 +02:00
Lucas Rocha
4ef24028be Merge pull request #126 from AaaChiuuu/master 2015-09-16 08:20:50 +01:00
Aaron Chiu
a353a11bf4 Merge pull request #1 from AaaChiuuu/publicConstants
Make CSSLayout constants public
2015-09-15 11:43:10 +01:00
Aaron Chiu
4a7936aa24 Make CSSLayout constants public 2015-09-15 11:42:30 +01:00
Aaron Chiu
f51c2d004d Merge pull request #123 from lucasr/omg-faster-flexbox
Even faster flexbox
2015-09-15 04:37:43 +01:00
Lucas Rocha
e43a8b28d6 Add 'package' comment in CSSNode for consistency 2015-09-14 18:23:36 +01:00
Lucas Rocha
cf94d35b51 Implement cascasing checks via bitwise flags
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
2015-09-14 18:23:36 +01:00
Lucas Rocha
ebc56fee59 Inline private methods at build time in Java
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.
2015-09-14 18:23:36 +01:00
Christopher Chedeau
2120285467 Merge pull request #122 from lucasr/even-faster-flexbox
Even faster flexbox
2015-09-10 14:25:41 -07:00
Lucas Rocha
765ff8463e Add fast path for simple stack layouts
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.
2015-09-10 11:19:28 +01:00
Lucas Rocha
2d869489ef More efficient resetResult() loop in LayoutEngine 2015-09-10 11:19:28 +01:00
Lucas Rocha
909c14117f Fix dimension check for STRETCH children
The correct check is on the layout state, no the style.
2015-09-10 11:19:28 +01:00
Lucas Rocha
9a149c83ff Avoid extra work when justifyContent is FLEX_START
Remaining space and between space only need to be updated when
justifyContent is not FLEX_START.
2015-09-10 11:19:28 +01:00
Lucas Rocha
2321165d53 Move condition to the non-redundant block
No need to check for RELATIVE position when position type is ABSOLUTE
and dimension is set.
2015-09-08 15:34:51 +01:00
Lucas Rocha
d1a49a4f0b Reduce search range of flexible children
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.
2015-09-08 15:34:51 +01:00
Lucas Rocha
793220faf8 Skip final loop on absolute children, if possible
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.
2015-09-08 15:34:51 +01:00
Lucas Rocha
996f2a03d5 Merge pre-fill loop into main line 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.
2015-09-08 15:34:27 +01:00
Lucas Rocha
877a2838a6 Skip trailing position loop, if possible
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.
2015-09-08 15:33:26 +01:00
Lucas Rocha
1ab785b7a3 Inline immutable values in layout algorithm
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.
2015-09-08 15:15:52 +01:00
Lucas Rocha
06c708053f Change Java to use array indexes instead of methods
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).
2015-09-08 15:15:46 +01:00
Colin Eberhardt
486b9a84bf 1.0.0 2015-09-08 07:45:08 +01:00
Colin Eberhardt
00c8428015 Merge pull request #119 from ColinEberhardt/keywords
Keywords
2015-09-01 06:51:59 +01:00
Colin Eberhardt
ecb8f8e610 Added layout keyword 2015-09-01 06:10:34 +01:00
Colin Eberhardt
baf34484fe Updated repo to include cdnjs / npm instructions 2015-08-31 22:15:46 +01:00
Colin Eberhardt
5dd1482148 Minor build change
removed duplication of the step that creates the 'dist' folder
2015-08-31 22:09:30 +01:00
Colin Eberhardt
9d1abd8d51 added keywords 2015-08-31 22:05:14 +01:00
Christopher Chedeau
e6d3aea73d Merge pull request #117 from paramaggarwal/watch
Watch for changes and run tests during development using `grunt watch`.
2015-08-28 09:49:46 -07:00
Param Aggarwal
f9d308f923 Watch for changes and run tests during development using grunt watch. 2015-08-28 22:15:57 +05:30
Colin Eberhardt
68d45b4b9a 0.0.6 2015-08-21 11:05:20 +01:00
Colin Eberhardt
99f44302fe Giving up on travis!
OK, Travis you have defeated me! reverting to a more manual release process
2015-08-21 11:04:46 +01:00
576 changed files with 71899 additions and 27050 deletions

2
.buckconfig Normal file
View File

@@ -0,0 +1,2 @@
[cxx]
gtest_dep = //lib/gtest:gtest

View File

@@ -1,24 +0,0 @@
{
"browser": true,
"shadow": true,
"globals": {
"jasmine": true,
"describe": true,
"beforeEach": true,
"afterEach": true,
"spyOn": true,
"it": true,
"xit": true,
"expect": true,
"require": true,
"global": true,
"__dirname": true,
"module": true,
"console": true,
"setTimeout": true,
"define": true
},
"rules": {
"quotes": [2, "single"]
}
}

69
.gitignore vendored
View File

@@ -1,7 +1,62 @@
a.out
*.class
/**/java/out/*
/**/.idea/workspace.xml
/lib/
/node_modules/
npm-debug.log
.DS_STORE
/buck-cache/
/buck-out/
/.buckconfig.local
/.buckd
/gentest/test.html
.buckversion
# Jekyll
/.sass-cache/
/_site/
# Visual studio code
.vscode
*.pdb
*.tlog
*.obj
*.pch
*.log
*.orig
# Xcode
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "lib/gtest/googletest"]
path = lib/gtest/googletest
url = https://github.com/google/googletest.git

View File

@@ -1,22 +1,42 @@
language: node_js
node_js:
- "0.12"
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
sudo: false
os: osx
osx_image: xcode7.3
language: cpp
compiler: clang
before_install:
- npm install grunt-cli -g
- brew update
- brew tap facebook/fb
- brew install buck
- brew cask install java
- brew outdated xctool || brew upgrade xctool
- brew install mono
addons:
apt:
packages:
- gcc
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
- export PATH=$JAVA_HOME/bin:$PATH
deploy:
provider: npm
email: ceberhardt@scottlogic.com
api_key:
secure: "Dk69FV717n91CRMv0UqzqZG6mrd4dSwd2PJDf1Fe0GOVPrVG9pmSTUmsk7JGli7EB57ovPGRhE/lcDGnlE+hEVw5DjZhGUUmZIFGg+FdcVomoiTRUYjRLwRUKEVxYw1TGCjJHm4rEx4qdkghahjf1YRYnivOn7ADhdH5THr7uQE="
on:
tags: true
branch: master
install:
- cd javascript
- npm install
- cd $TRAVIS_BUILD_DIR
script:
- buck test //:yoga
- buck test //java:java
- buck test //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
- sh csharp/tests/Facebook.Yoga/test_macos.sh
- cd javascript
- npm run test:all
- npm run bench
- cd $TRAVIS_BUILD_DIR
- buck run //benchmark:benchmark
- git checkout HEAD^
- buck run //benchmark:benchmark

42
BUCK Normal file
View File

@@ -0,0 +1,42 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
include_defs('//YOGA_DEFS')
GMOCK_OVERRIDE_FLAGS = [
# gmock does not mark mocked methods as override, ignore the warnings in tests
'-Wno-inconsistent-missing-override',
]
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11', '-fPIC']
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11']
cxx_library(
name = 'yoga',
soname = 'libyogacore.$(ext)',
srcs = glob(['yoga/*.c']),
tests=[':YogaTests'],
exported_headers = subdir_glob([('', 'yoga/*.h')]),
header_namespace = '',
compiler_flags = COMPILER_FLAGS,
deps = [] if THIS_IS_FBOBJC else [
yoga_dep('lib/fb:ndklog'),
],
visibility = ['PUBLIC'],
)
cxx_test(
name = 'YogaTests',
contacts = ['emilsj@fb.com'],
srcs = glob(['tests/*.cpp']),
compiler_flags = TEST_COMPILER_FLAGS,
deps = [
':yoga',
GTEST_TARGET,
],
visibility = ['PUBLIC'],
)

View File

@@ -1,10 +1,7 @@
# Contributing to css-layout
# Contributing to yoga
We want to make contributing to this project as easy and transparent as
possible.
## Our Development Process
All the development is happening on GitHub first and we have internal tools to sync down to Facebook codebase.
## Pull Requests
We actively welcome your pull requests.
1. Fork the repo and create your branch from `master`.
@@ -29,10 +26,8 @@ disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.
## Coding Style
* 2 spaces for indentation rather than tabs
* 80 character line length
* ...
* format.sh
## License
By contributing to css-layout, you agree that your contributions will be licensed
By contributing to yoga, you agree that your contributions will be licensed
under its BSD license.

View File

@@ -1,184 +0,0 @@
'use strict';
module.exports = function(grunt) {
var fs = require('fs');
var path = require('path');
var isWindows = /^win/.test(process.platform);
require('load-grunt-tasks')(grunt);
// config
var config = {
delimiter: path.delimiter,
libName: 'css-layout',
distFolder: 'dist',
srcFolder: 'src',
testFolder: 'src/__tests__',
javaLibFolder: 'src/java/lib',
javaSource: 'src/java/tests/com/facebook/csslayout/*.java',
javaTestFiles: 'org.junit.runner.JUnitCore com.facebook.csslayout.LayoutEngineTest com.facebook.csslayout.LayoutCachingTest com.facebook.csslayout.CSSNodeTest'
};
// C compilation configuration
if (isWindows) {
// Windows build, assumes cl is in the path (see https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx).
config.cTestOutput = 'c_test.exe';
config.cTestCompile = 'cl -nologo -Zi -Tpsrc/__tests__/Layout-test.c -Tpsrc/Layout.c -Tpsrc/Layout-test-utils.c -link -incremental:no -out:"<%= config.cTestOutput %>"';
config.cTestExecute = '<%= config.cTestOutput %>';
config.cTestClean = ['<%= config.cTestOutput %>','*.obj','*.pdb'];
}
else {
// GCC build (OSX, Linux, ...), assumes gcc is in the path.
config.cTestOutput = 'c_test';
config.cTestCompile = 'gcc -std=c99 -Werror -Wno-padded src/__tests__/Layout-test.c src/Layout.c src/Layout-test-utils.c -lm -o "./<%= config.cTestOutput %>"';
config.cTestExecute = './<%= config.cTestOutput %>';
config.cTestClean = ['<%= config.cTestOutput %>'];
}
grunt.initConfig({
config: config,
mkdir: {
dist: {
options: {
create: ['<%= config.distFolder %>']
},
},
},
clean: {
dist: ['<%= config.distFolder %>'],
cTest: config.cTestClean,
javaTest: ['**/*.class']
},
eslint: {
options: {
configFile: '.eslintrc'
},
target: ['<%= config.srcFolder %>/Layout.js']
},
includereplace: {
options: {
prefix: '// @@',
},
main: {
src: '<%= config.srcFolder %>/<%= config.libName %>.js',
dest: '<%= config.distFolder %>/<%= config.libName %>.js'
}
},
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true
},
main: {
files: {
'<%= config.distFolder %>/<%= config.libName %>.min.js':
['<%= config.distFolder %>/<%= config.libName %>.js']
}
}
},
karma: {
main: {
options: {
files: [
'<%= config.srcFolder %>/Layout.js',
'<%= config.srcFolder %>/Layout-test-utils.js',
'<%= config.testFolder %>/Layout-test.js',
'<%= config.testFolder %>/Layout-consts-test.js'
],
browsers: ['Chrome'],
frameworks: ['jasmine'],
singleRun: true
}
}
},
execute: {
transpile: {
src: ['<%= config.srcFolder %>/transpile.js']
}
},
concat: {
options: {
separator: '\n',
// Replace all 'use strict' statements in the code with a single one at the top
banner: [
'/*',
' * #define CSS_LAYOUT_IMPLEMENTATION',
' * before you include this file in *one* C or C++ file to create the implementation.',
' */\n'
].join('\n'),
process: function(src, filepath) {
if (path.extname(filepath) === '.c') {
return [
'#ifdef CSS_LAYOUT_IMPLEMENTATION',
src,
'#endif // CSS_LAYOUT_IMPLEMENTATION'
].join('\n')
}
else {
return src;
}
},
},
dist: {
src: ['<%= config.srcFolder %>/Layout.h', '<%= config.srcFolder %>/Layout.c'],
dest: '<%= config.distFolder %>/css-layout.h',
},
},
shell: {
cCompile: {
command: config.cTestCompile
},
cTestExecute: {
command: config.cTestExecute
},
javaCompile: {
command: 'javac -cp <%= config.javaLibFolder %>/junit4.jar<%= config.delimiter %><%= config.javaLibFolder %>/jsr305.jar<%= config.delimiter %><%= config.javaLibFolder %>/infer-annotations-1.4.jar' + ' -sourcepath ./src/java/src<%= config.delimiter %>./src/java/tests' + ' <%= config.javaSource %>'
},
javaTestExecute: {
command: 'java -cp ./src/java/src<%= config.delimiter %>./src/java/tests<%= config.delimiter %><%= config.javaLibFolder %>/junit4.jar<%= config.delimiter %><%= config.javaLibFolder %>/infer-annotations-1.4.jar <%= config.javaTestFiles %>'
},
javaPackage: {
command: 'jar cf <%= config.distFolder %>/<%= config.libName %>.jar <%= config.javaSource %>'
}
}
});
// Compiles and runs the Java tests
grunt.registerTask('test-java', ['shell:javaCompile', 'shell:javaTestExecute', 'clean:javaTest']);
// Compiles and runs the C tests
grunt.registerTask('test-c', ['shell:cCompile', 'shell:cTestExecute', 'clean:cTest']);
// Transpiles the JavaScript to C and Java, running tests
grunt.registerTask('transpile', ['execute:transpile', 'test-c', 'test-java']);
// Lints and tests the JavaScritp using Chrome
grunt.registerTask('test-javascript', ['eslint', 'karma']);
// Packages the JavaScript as a single UMD module and minifies
grunt.registerTask('package-javascript', ['mkdir:dist', 'includereplace', 'uglify']);
// Packages the Java as a JAR
grunt.registerTask('package-java', ['mkdir:dist', 'shell:javaPackage']);
// Packages the C code as a single header
grunt.registerTask('package-c', ['mkdir:dist', 'concat']);
// Default build, performs the full works!
grunt.registerTask('build', ['test-javascript', 'transpile', 'clean:dist', 'package-javascript', 'package-java', 'package-c']);
// The JavaScript unit tests require Chrome (they need a faithful flexbox implementation
// to test against), so under CI this step is skipped.
grunt.registerTask('ci', ['eslint', 'transpile', 'clean:dist', 'package-javascript', 'package-java', 'package-c']);
grunt.registerTask('default', ['build']);
};

View File

@@ -1,8 +1,8 @@
BSD License
For css-layout software
For yoga software
Copyright (c) 2014, Facebook, Inc. All rights reserved.
Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

9
LICENSE-examples Normal file
View File

@@ -0,0 +1,9 @@
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,6 +1,6 @@
Additional Grant of Patent Rights Version 2
"Software" means the CSS Layout software distributed by Facebook, Inc.
"Software" means the yoga software distributed by Facebook, Inc.
Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software
(“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable

146
README.md
View File

@@ -1,138 +1,30 @@
css-layout [![Build Status](https://travis-ci.org/facebook/css-layout.svg?branch=master)](https://travis-ci.org/facebook/css-layout)
==========
# Yoga [![Build Status](https://travis-ci.org/facebook/yoga.svg?branch=master)](https://travis-ci.org/facebook/yoga)
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.
## 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.
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.
## 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`.
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.
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
Usage
-----
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.
For example,
```javascript
// create an initial tree of nodes
var nodeTree = {
"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
// each node now having a layout property:
// JSON.stringify(nodeTree, null, 2);
{
"style": {
"padding": 50
},
"children": [
{
"style": {
"padding": 10,
"alignSelf": "stretch"
},
"layout": {
"width": 20,
"height": 20,
"top": 50,
"left": 50,
"right": 50,
"bottom": 50,
"direction": "ltr"
},
"children": [],
"lineIndex": 0
}
],
"layout": {
"width": 120,
"height": 120,
"top": 0,
"left": 0,
"right": 0,
"bottom": 0,
"direction": "ltr"
}
}
```html
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
<div style="width: 50px; height: 50px;"></div>
</div>
```
Supported Attributes
--------------------
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
flexDirection | 'column', 'row'
justifyContent | 'flex-start', 'center', 'flex-end', 'space-between', 'space-around'
alignItems, alignSelf, alignContent | 'flex-start', 'center', 'flex-end', 'stretch'
flex | positive number
flexWrap | 'wrap', 'nowrap'
position | 'relative', 'absolute'
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: 0 solid black;
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.

35
YOGA_DEFS Normal file
View File

@@ -0,0 +1,35 @@
YOGA_ROOT = '//...'
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations'
JSR_305_TARGET = '//lib/jsr-305:jsr-305'
JUNIT_TARGET = '//lib/junit:junit'
PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations'
SOLOADER_TARGET = '//lib/soloader:soloader'
GTEST_TARGET = '//lib/gtest:gtest'
JNI_TARGET = '//lib/jni:jni'
FBJNI_TARGET = '//lib/fb:fbjni'
THIS_IS_FBOBJC = False
CXX_LIBRARY_WHITELIST = [
'//:yoga',
'//lib/fb:fbjni',
'//java:jni',
]
BASE_COMPILER_FLAGS = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-O3',
]
def yoga_dep(dep):
return '//' + dep
class allow_unsafe_import:
def __enter__(self):
pass
def __exit__(self, type, value, traceback):
pass

58
YogaKit/BUCK Normal file
View File

@@ -0,0 +1,58 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
include_defs('//YOGA_DEFS')
COMPILER_FLAGS = [
'-fobjc-arc',
'-Wconditional-uninitialized',
'-Wdangling-else',
'-Wdeprecated-declarations',
'-Wimplicit-retain-self',
'-Wincomplete-implementation',
'-Wobjc-method-access',
'-Wobjc-missing-super-calls',
'-Wmismatched-return-types',
'-Wreturn-type',
'-Wno-global-constructors',
'-Wno-shadow',
'-Wunused-const-variable',
'-Wunused-function',
'-Wunused-property-ivar',
'-Wunused-result',
'-Wunused-value',
]
apple_library(
name = 'YogaKit',
compiler_flags = COMPILER_FLAGS,
srcs = glob(['*.m']),
exported_headers = glob(['*.h']),
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
],
deps = [
yoga_dep(':yoga'),
],
visibility = ['PUBLIC'],
)
apple_test(
name = 'YogaKitTests',
compiler_flags = COMPILER_FLAGS,
info_plist = 'Tests/Info.plist',
srcs = glob(['Tests/**/*.m']),
frameworks = [
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
],
deps = [
':YogaKit',
],
visibility = ['PUBLIC'],
)

22
YogaKit/Tests/Info.plist Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.facebook.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -0,0 +1,596 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <XCTest/XCTest.h>
#import <YogaKit/UIView+Yoga.h>
#import <YogaKit/YGLayout+Private.h>
#import <yoga/Yoga.h>
@interface YogaKitTests : XCTestCase
@end
@implementation YogaKitTests
#ifndef TRAVIS_CI
- (void)testNodesAreDeallocedWithSingleView
{
XCTAssertEqual(0, YGNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.flexBasis = 1;
XCTAssertEqual(1, YGNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, YGNodeGetInstanceCount());
}
- (void)testNodesAreDeallocedCascade
{
XCTAssertEqual(0, YGNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.flexBasis = 1;
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
subview.yoga.flexBasis = 1;
[view addSubview:subview];
}
XCTAssertEqual(11, YGNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, YGNodeGetInstanceCount());
}
#endif
- (void)testIsEnabled
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertFalse(view.yoga.isEnabled);
view.yoga.isEnabled = YES;
XCTAssertTrue(view.yoga.isEnabled);
view.yoga.isEnabled = NO;
XCTAssertFalse(view.yoga.isEnabled);
}
- (void)testSizeThatFitsAsserts
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
dispatch_sync(dispatch_queue_create("com.facebook.Yoga.testing", DISPATCH_QUEUE_SERIAL), ^(void){
XCTAssertThrows(view.yoga.intrinsicSize);
});
}
- (void)testSizeThatFitsSmoke
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
container.yoga.alignItems = YGAlignFlexStart;
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
longTextLabel.numberOfLines = 1;
longTextLabel.yoga.isEnabled = YES;
longTextLabel.yoga.flexShrink = 1;
[container addSubview:longTextLabel];
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
textBadgeView.yoga.isEnabled = YES;
textBadgeView.yoga.marginLeft = 3.0;
textBadgeView.yoga.width = 10;
textBadgeView.yoga.height = 10;
[container addSubview:textBadgeView];
const CGSize containerSize = container.yoga.intrinsicSize;
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
}
- (void)testThatMarkingLeafsAsDirtyWillTriggerASizeRecalculation
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
container.yoga.alignItems = YGAlignFlexStart;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.text = @"This is a short text.";
label.numberOfLines = 1;
label.yoga.isEnabled = YES;
[container addSubview:label];
[container.yoga applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(146,21), label.bounds.size), @"Size is actually %@", NSStringFromCGSize(label.bounds.size));
label.text = @"This is a slightly longer text.";
[label.yoga markDirty];
[container.yoga applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(213,21), label.bounds.size), @"Size is actually %@", NSStringFromCGSize(label.bounds.size));
}
- (void)testFrameAndOriginPlacement
{
const CGSize containerSize = CGSizeMake(320, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
for (int i = 0; i < 3; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
subview.yoga.isEnabled = YES;
subview.yoga.flexGrow = 1;
[container addSubview:subview];
}
[container.yoga applyLayout];
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
CGFloat totalWidth = 0;
for (UIView *view in container.subviews) {
totalWidth += view.bounds.size.width;
}
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
}
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
{
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayout];
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame));
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
subview2.yoga.isIncludedInLayout = NO;
[container.yoga applyLayout];
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
// this frame shouldn't have been modified since last time.
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
}
- (void)testThatWeRespectIncludeInLayoutFlag
{
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
[container addSubview:subview3];
[container.yoga applyLayout];
for (UIView *view in container.subviews) {
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), view.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
}
subview3.yoga.isIncludedInLayout = NO;
[container.yoga applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
// We don't set the frame to zero, so, it should be set to what it was previously at.
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size));
}
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.isIncludedInLayout = NO;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.isIncludedInLayout = NO;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.isIncludedInLayout = YES;
[container addSubview:subview3];
[container.yoga applyLayout];
XCTAssertEqual(1, container.yoga.numberOfChildren);
subview2.yoga.isIncludedInLayout = YES;
[container.yoga applyLayout];
XCTAssertEqual(2, container.yoga.numberOfChildren);
}
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionRow;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.flexGrow = 1;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.flexGrow = 1;
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
subview3.yoga.isEnabled = YES;
subview3.yoga.flexGrow = 1;
subview3.yoga.isIncludedInLayout = NO;
[container addSubview:subview3];
[container.yoga applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size));
subview3.yoga.isIncludedInLayout = YES;
[container.yoga applyLayout];
for (UIView *view in container.subviews) {
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), view.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
}
}
- (void)testyg_isLeafFlag
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertTrue(view.yoga.isLeaf);
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[view addSubview:subview];
}
XCTAssertTrue(view.yoga.isLeaf);
view.yoga.isEnabled = YES;
view.yoga.width = 50.0;
XCTAssertTrue(view.yoga.isLeaf);
UIView *const subview = view.subviews[0];
subview.yoga.isEnabled = YES;
subview.yoga.width = 50.0;
XCTAssertFalse(view.yoga.isLeaf);
}
- (void)testThatWeCorrectlyAttachNestedViews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
container.yoga.flexDirection = YGFlexDirectionColumn;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
subview1.yoga.width = 100;
subview1.yoga.flexGrow = 1;
subview1.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
subview2.yoga.width = 150;
subview2.yoga.flexGrow = 1;
subview2.yoga.flexDirection = YGFlexDirectionColumn;
[container addSubview:subview2];
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayout];
// Add the same amount of new views, reapply layout.
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
someView.yoga.isEnabled = YES;
someView.yoga.flexGrow = 1;
[view addSubview:someView];
}
[container.yoga applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 25), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
for (UIView *subview in subview1.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subviewSize));
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 25), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
for (UIView *subview in subview2.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subview.bounds.size));
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
}
- (void)testThatANonLeafNodeCanBecomeALeafNode
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
container.yoga.isEnabled = YES;
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
subview1.yoga.isEnabled = YES;
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
subview2.yoga.isEnabled = YES;
[subview1 addSubview:subview2];
[container.yoga applyLayout];
[subview2 removeFromSuperview];
[container.yoga applyLayout];
}
- (void)testPositionalPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.left = 1;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).value, 1);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.left, 1);
view.yoga.right = 2;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).value, 2);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.right, 2);
view.yoga.top = 3;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).value, 3);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.top, 3);
view.yoga.bottom = 4;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).value, 4);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.bottom, 4);
view.yoga.start = 5;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).value, 5);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.start, 5);
view.yoga.end = 6;
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).value, 6);
XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.end, 6);
}
- (void)testMarginPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.margin = 1;
XCTAssertEqual(view.yoga.marginLeft, 1);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginRight, 1);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginStart, 1);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginEnd, 1);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginTop, 1);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginBottom, 1);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertTrue(isnan(view.yoga.marginHorizontal));
XCTAssertTrue(isnan(view.yoga.marginVertical));
XCTAssertTrue(isnan(view.yoga.margin));
view.yoga.marginHorizontal = 2;
XCTAssertEqual(view.yoga.marginLeft, 2);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginRight, 2);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginStart, 2);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginEnd, 2);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertTrue(isnan(view.yoga.marginHorizontal));
view.yoga.marginVertical = 3;
XCTAssertEqual(view.yoga.marginTop, 3);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginBottom, 3);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertTrue(isnan(view.yoga.marginVertical));
view.yoga.marginLeft = 4;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 4);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginLeft, 4);
view.yoga.marginRight = 5;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 5);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginRight, 5);
view.yoga.marginTop = 6;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 6);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginTop, 6);
view.yoga.marginBottom = 7;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 7);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginBottom, 7);
view.yoga.marginStart = 8;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 8);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginStart, 8);
view.yoga.marginEnd = 9;
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 9);
XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.marginEnd, 9);
}
- (void)testPaddingPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.padding = 1;
XCTAssertEqual(view.yoga.paddingLeft, 1);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingRight, 1);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingStart, 1);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingEnd, 1);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingTop, 1);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingBottom, 1);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertTrue(isnan(view.yoga.paddingHorizontal));
XCTAssertTrue(isnan(view.yoga.paddingVertical));
XCTAssertTrue(isnan(view.yoga.padding));
view.yoga.paddingHorizontal = 2;
XCTAssertEqual(view.yoga.paddingLeft, 2);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingRight, 2);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingStart, 2);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingEnd, 2);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertTrue(isnan(view.yoga.paddingHorizontal));
view.yoga.paddingVertical = 3;
XCTAssertEqual(view.yoga.paddingTop, 3);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingBottom, 3);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertTrue(isnan(view.yoga.paddingVertical));
view.yoga.paddingLeft = 4;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 4);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingLeft, 4);
view.yoga.paddingRight = 5;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 5);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingRight, 5);
view.yoga.paddingTop = 6;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 6);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingTop, 6);
view.yoga.paddingBottom = 7;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 7);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingBottom, 7);
view.yoga.paddingStart = 8;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 8);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingStart, 8);
view.yoga.paddingEnd = 9;
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 9);
XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel);
XCTAssertEqual(view.yoga.paddingEnd, 9);
}
- (void)testBorderWidthPropertiesWork
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.yoga.borderWidth = 1;
XCTAssertEqual(view.yoga.borderLeftWidth, 1);
XCTAssertEqual(view.yoga.borderRightWidth, 1);
XCTAssertEqual(view.yoga.borderStartWidth, 1);
XCTAssertEqual(view.yoga.borderEndWidth, 1);
XCTAssertEqual(view.yoga.borderTopWidth, 1);
XCTAssertEqual(view.yoga.borderBottomWidth, 1);
XCTAssertTrue(isnan(view.yoga.borderWidth));
view.yoga.borderLeftWidth = 2;
XCTAssertEqual(view.yoga.borderLeftWidth, 2);
view.yoga.borderRightWidth = 3;
XCTAssertEqual(view.yoga.borderRightWidth, 3);
view.yoga.borderTopWidth = 4;
XCTAssertEqual(view.yoga.borderTopWidth, 4);
view.yoga.borderBottomWidth = 5;
XCTAssertEqual(view.yoga.borderBottomWidth, 5);
view.yoga.borderStartWidth = 6;
XCTAssertEqual(view.yoga.borderStartWidth, 6);
view.yoga.borderEndWidth = 7;
XCTAssertEqual(view.yoga.borderEndWidth, 7);
}
@end

17
YogaKit/UIView+Yoga.h Normal file
View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <UIKit/UIKit.h>
#import "YGLayout.h"
@interface UIView (Yoga)
@property (nonatomic, readonly, strong) YGLayout *yoga;
@end

30
YogaKit/UIView+Yoga.m Normal file
View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "UIView+Yoga.h"
#import "YGLayout+Private.h"
#import <objc/runtime.h>
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
@implementation UIView (YogaKit)
- (YGLayout *)yoga
{
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
if (!yoga) {
yoga = [[YGLayout alloc] initWithView:self];
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return yoga;
}
@end

View File

@@ -1,18 +1,19 @@
/**
* Copyright (c) 2014, Facebook, Inc.
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
/**
* POJO to hold the output of the measure function.
*/
public class MeasureOutput {
#import "YGLayout.h"
#import <yoga/Yoga.h>
public float width;
public float height;
}
@interface YGLayout ()
@property (nonatomic, assign, readonly) YGNodeRef node;
- (instancetype)initWithView:(UIView *)view;
@end

114
YogaKit/YGLayout.h Normal file
View File

@@ -0,0 +1,114 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <UIKit/UIKit.h>
#import <yoga/YGEnums.h>
@interface YGLayout : NSObject
/**
The property that decides if we should include this view when calculating layout. Defaults to YES.
*/
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
/**
The property that decides during layout/sizing whether or not styling properties should be applied. Defaults to NO.
*/
@property (nonatomic, readwrite, assign, setter=setEnabled:) BOOL isEnabled;
@property (nonatomic, readwrite, assign) YGDirection direction;
@property (nonatomic, readwrite, assign) YGFlexDirection flexDirection;
@property (nonatomic, readwrite, assign) YGJustify justifyContent;
@property (nonatomic, readwrite, assign) YGAlign alignContent;
@property (nonatomic, readwrite, assign) YGAlign alignItems;
@property (nonatomic, readwrite, assign) YGAlign alignSelf;
@property (nonatomic, readwrite, assign) YGPositionType position;
@property (nonatomic, readwrite, assign) YGWrap flexWrap;
@property (nonatomic, readwrite, assign) YGOverflow overflow;
@property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink;
@property (nonatomic, readwrite, assign) CGFloat flexBasis;
@property (nonatomic, readwrite, assign) CGFloat left;
@property (nonatomic, readwrite, assign) CGFloat top;
@property (nonatomic, readwrite, assign) CGFloat right;
@property (nonatomic, readwrite, assign) CGFloat bottom;
@property (nonatomic, readwrite, assign) CGFloat start;
@property (nonatomic, readwrite, assign) CGFloat end;
@property (nonatomic, readwrite, assign) CGFloat marginLeft;
@property (nonatomic, readwrite, assign) CGFloat marginTop;
@property (nonatomic, readwrite, assign) CGFloat marginRight;
@property (nonatomic, readwrite, assign) CGFloat marginBottom;
@property (nonatomic, readwrite, assign) CGFloat marginStart;
@property (nonatomic, readwrite, assign) CGFloat marginEnd;
@property (nonatomic, readwrite, assign) CGFloat marginHorizontal;
@property (nonatomic, readwrite, assign) CGFloat marginVertical;
@property (nonatomic, readwrite, assign) CGFloat margin;
@property (nonatomic, readwrite, assign) CGFloat paddingLeft;
@property (nonatomic, readwrite, assign) CGFloat paddingTop;
@property (nonatomic, readwrite, assign) CGFloat paddingRight;
@property (nonatomic, readwrite, assign) CGFloat paddingBottom;
@property (nonatomic, readwrite, assign) CGFloat paddingStart;
@property (nonatomic, readwrite, assign) CGFloat paddingEnd;
@property (nonatomic, readwrite, assign) CGFloat paddingHorizontal;
@property (nonatomic, readwrite, assign) CGFloat paddingVertical;
@property (nonatomic, readwrite, assign) CGFloat padding;
@property (nonatomic, readwrite, assign) CGFloat borderLeftWidth;
@property (nonatomic, readwrite, assign) CGFloat borderTopWidth;
@property (nonatomic, readwrite, assign) CGFloat borderRightWidth;
@property (nonatomic, readwrite, assign) CGFloat borderBottomWidth;
@property (nonatomic, readwrite, assign) CGFloat borderStartWidth;
@property (nonatomic, readwrite, assign) CGFloat borderEndWidth;
@property (nonatomic, readwrite, assign) CGFloat borderWidth;
@property (nonatomic, readwrite, assign) CGFloat width;
@property (nonatomic, readwrite, assign) CGFloat height;
@property (nonatomic, readwrite, assign) CGFloat minWidth;
@property (nonatomic, readwrite, assign) CGFloat minHeight;
@property (nonatomic, readwrite, assign) CGFloat maxWidth;
@property (nonatomic, readwrite, assign) CGFloat maxHeight;
// Yoga specific properties, not compatible with flexbox specification
@property (nonatomic, readwrite, assign) CGFloat aspectRatio;
/**
Get the resolved direction of this node. This won't be YGDirectionInherit
*/
@property (nonatomic, readonly, assign) YGDirection resolvedDirection;
/**
Perform a layout calculation and update the frames of the views in the hierarchy with the results
*/
- (void)applyLayout NS_SWIFT_NAME(applyLayout());
/**
Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
*/
@property (nonatomic, readonly, assign) CGSize intrinsicSize;
/**
Returns the number of children that are using Flexbox.
*/
@property (nonatomic, readonly, assign) NSUInteger numberOfChildren;
/**
Return a BOOL indiciating whether or not we this node contains any subviews that are included in Yoga's layout.
*/
@property (nonatomic, readonly, assign) BOOL isLeaf;
/**
Mark that a view's layout needs to be recalculated. Only works for leaf views.
*/
- (void)markDirty;
@end

405
YogaKit/YGLayout.m Normal file
View File

@@ -0,0 +1,405 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "YGLayout+Private.h"
#import "UIView+Yoga.h"
#define YG_PROPERTY(type, lowercased_name, capitalized_name) \
- (type)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(type)lowercased_name \
{ \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
}
#define YG_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (CGFloat)lowercased_name \
{ \
YGValue value = YGNodeStyleGet##capitalized_name(self.node); \
if (value.unit == YGUnitPixel) { \
return value.value; \
} else { \
return YGUndefined; \
} \
} \
\
- (void)set##capitalized_name:(CGFloat)lowercased_name \
{ \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name); \
}
#define YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
- (CGFloat)lowercased_name \
{ \
return YGNodeStyleGet##property(self.node, edge); \
}
#define YG_SHORTHAND_EDGE_PROPERTY_GETTER(lowercased_name) \
- (CGFloat)lowercased_name \
{ \
return YGUndefined; \
}
#define YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) \
- (void)set##capitalized_name:(CGFloat)lowercased_name \
{ \
YGNodeStyleSet##property(self.node, edge, lowercased_name); \
}
#define YG_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_SHORTHAND_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_SHORTHAND_EDGE_PROPERTY_GETTER(lowercased_name) \
YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGE_PROPERTY_GETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (CGFloat)objc_lowercased_name \
{ \
YGValue value = YGNodeStyleGet##c_name(self.node, edge); \
if (value.unit == YGUnitPixel) { \
return value.value; \
} else { \
return YGUndefined; \
} \
}
#define YG_VALUE_EDGE_PROPERTY_SETTER(objc_lowercased_name, objc_capitalized_name, c_name, edge) \
- (void)set##objc_capitalized_name:(CGFloat)objc_lowercased_name \
{ \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name); \
}
#define YG_VALUE_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_GETTER(lowercased_name, capitalized_name, property, edge) \
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name, capitalized_name, property, edge) \
YG_SHORTHAND_EDGE_PROPERTY_GETTER(lowercased_name) \
YG_VALUE_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
#define YG_VALUE_EDGES_PROPERTIES(lowercased_name, capitalized_name) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Left, capitalized_name##Left, capitalized_name, YGEdgeLeft) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Top, capitalized_name##Top, capitalized_name, YGEdgeTop) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Right, capitalized_name##Right, capitalized_name, YGEdgeRight) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Bottom, capitalized_name##Bottom, capitalized_name, YGEdgeBottom) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##Start, capitalized_name##Start, capitalized_name, YGEdgeStart) \
YG_VALUE_EDGE_PROPERTY(lowercased_name##End, capitalized_name##End, capitalized_name, YGEdgeEnd) \
YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name##Horizontal, capitalized_name##Horizontal, capitalized_name, YGEdgeHorizontal) \
YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name##Vertical, capitalized_name##Vertical, capitalized_name, YGEdgeVertical) \
YG_VALUE_SHORTHAND_EDGE_PROPERTY(lowercased_name, capitalized_name, capitalized_name, YGEdgeAll)
@interface YGLayout ()
@property (nonatomic, weak, readonly) UIView *view;
@end
@implementation YGLayout
@synthesize isEnabled=_isEnabled;
@synthesize isIncludedInLayout=_isIncludedInLayout;
@synthesize node=_node;
+ (void)initialize
{
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
}
- (instancetype)initWithView:(UIView*)view
{
if (self = [super init]) {
_view = view;
_node = YGNodeNew();
YGNodeSetContext(_node, (__bridge void *) view);
_isEnabled = NO;
_isIncludedInLayout = YES;
}
return self;
}
- (void)dealloc
{
YGNodeFree(self.node);
}
- (void)markDirty
{
if (self.isLeaf) {
YGNodeMarkDirty(self.node);
}
}
- (NSUInteger)numberOfChildren
{
return YGNodeGetChildCount(self.node);
}
- (BOOL)isLeaf
{
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
if (self.isEnabled) {
for (UIView *subview in self.view.subviews) {
YGLayout *const yoga = subview.yoga;
if (yoga.isEnabled && yoga.isIncludedInLayout) {
return NO;
}
}
}
return YES;
}
#pragma mark - Style
- (YGPositionType)position
{
return YGNodeStyleGetPositionType(self.node);
}
- (void)setPosition:(YGPositionType)position
{
YGNodeStyleSetPositionType(self.node, position);
}
YG_PROPERTY(YGDirection, direction, Direction)
YG_PROPERTY(YGFlexDirection, flexDirection, FlexDirection)
YG_PROPERTY(YGJustify, justifyContent, JustifyContent)
YG_PROPERTY(YGAlign, alignContent, AlignContent)
YG_PROPERTY(YGAlign, alignItems, AlignItems)
YG_PROPERTY(YGAlign, alignSelf, AlignSelf)
YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
YG_PROPERTY(YGOverflow, overflow, Overflow)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
YG_VALUE_PROPERTY(flexBasis, FlexBasis)
YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft)
YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop)
YG_VALUE_EDGE_PROPERTY(right, Right, Position, YGEdgeRight)
YG_VALUE_EDGE_PROPERTY(bottom, Bottom, Position, YGEdgeBottom)
YG_VALUE_EDGE_PROPERTY(start, Start, Position, YGEdgeStart)
YG_VALUE_EDGE_PROPERTY(end, End, Position, YGEdgeEnd)
YG_VALUE_EDGES_PROPERTIES(margin, Margin)
YG_VALUE_EDGES_PROPERTIES(padding, Padding)
YG_EDGE_PROPERTY(borderLeftWidth, BorderLeftWidth, Border, YGEdgeLeft)
YG_EDGE_PROPERTY(borderTopWidth, BorderTopWidth, Border, YGEdgeTop)
YG_EDGE_PROPERTY(borderRightWidth, BorderRightWidth, Border, YGEdgeRight)
YG_EDGE_PROPERTY(borderBottomWidth, BorderBottomWidth, Border, YGEdgeBottom)
YG_EDGE_PROPERTY(borderStartWidth, BorderStartWidth, Border, YGEdgeStart)
YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd)
YG_SHORTHAND_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll)
YG_VALUE_PROPERTY(width, Width)
YG_VALUE_PROPERTY(height, Height)
YG_VALUE_PROPERTY(minWidth, MinWidth)
YG_VALUE_PROPERTY(minHeight, MinHeight)
YG_VALUE_PROPERTY(maxWidth, MaxWidth)
YG_VALUE_PROPERTY(maxHeight, MaxHeight)
YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
#pragma mark - Layout and Sizing
- (YGDirection)resolvedDirection
{
return YGNodeLayoutGetDirection(self.node);
}
- (void)applyLayout
{
[self calculateLayoutWithSize:self.view.bounds.size];
YGApplyLayoutToViewHierarchy(self.view);
}
- (CGSize)intrinsicSize
{
const CGSize constrainedSize = {
.width = YGUndefined,
.height = YGUndefined,
};
return [self calculateLayoutWithSize:constrainedSize];
}
#pragma mark - Private
- (CGSize)calculateLayoutWithSize:(CGSize)size
{
NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main.");
NSAssert(self.isEnabled, @"Yoga is not enabled for this view.");
YGAttachNodesFromViewHierachy(self.view);
const YGNodeRef node = self.node;
YGNodeCalculateLayout(
node,
size.width,
size.height,
YGNodeStyleGetDirection(node));
return (CGSize) {
.width = YGNodeLayoutGetWidth(node),
.height = YGNodeLayoutGetHeight(node),
};
}
static YGSize YGMeasureView(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode)
{
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
.width = constrainedWidth,
.height = constrainedHeight,
}];
return (YGSize) {
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
};
}
static CGFloat YGSanitizeMeasurement(
CGFloat constrainedSize,
CGFloat measuredSize,
YGMeasureMode measureMode)
{
CGFloat result;
if (measureMode == YGMeasureModeExactly) {
result = constrainedSize;
} else if (measureMode == YGMeasureModeAtMost) {
result = MIN(constrainedSize, measuredSize);
} else {
result = measuredSize;
}
return result;
}
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
{
if (YGNodeGetChildCount(node) != subviews.count) {
return NO;
}
for (int i=0; i<subviews.count; i++) {
if (YGNodeGetChild(node, i) != subviews[i].yoga.node) {
return NO;
}
}
return YES;
}
static void YGAttachNodesFromViewHierachy(UIView *const view)
{
YGLayout *const yoga = view.yoga;
const YGNodeRef node = yoga.node;
// Only leaf nodes should have a measure function
if (yoga.isLeaf) {
YGRemoveAllChildren(node);
YGNodeSetMeasureFunc(node, YGMeasureView);
} else {
YGNodeSetMeasureFunc(node, NULL);
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView *subview in view.subviews) {
if (subview.yoga.isIncludedInLayout) {
[subviewsToInclude addObject:subview];
}
}
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
YGRemoveAllChildren(node);
for (int i=0; i<subviewsToInclude.count; i++) {
YGNodeInsertChild(node, subviewsToInclude[i].yoga.node, i);
}
}
for (UIView *const subview in subviewsToInclude) {
YGAttachNodesFromViewHierachy(subview);
}
}
}
static void YGRemoveAllChildren(const YGNodeRef node)
{
if (node == NULL) {
return;
}
while (YGNodeGetChildCount(node) > 0) {
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
}
}
static CGFloat YGRoundPixelValue(CGFloat value)
{
static CGFloat scale;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^(){
scale = [UIScreen mainScreen].scale;
});
return round(value * scale) / scale;
}
static void YGApplyLayoutToViewHierarchy(UIView *view)
{
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
const YGLayout *yoga = view.yoga;
if (!yoga.isIncludedInLayout) {
return;
}
YGNodeRef node = yoga.node;
const CGPoint topLeft = {
YGNodeLayoutGetLeft(node),
YGNodeLayoutGetTop(node),
};
const CGPoint bottomRight = {
topLeft.x + YGNodeLayoutGetWidth(node),
topLeft.y + YGNodeLayoutGetHeight(node),
};
view.frame = (CGRect) {
.origin = {
.x = YGRoundPixelValue(topLeft.x),
.y = YGRoundPixelValue(topLeft.y),
},
.size = {
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
},
};
if (!yoga.isLeaf) {
for (NSUInteger i=0; i<view.subviews.count; i++) {
YGApplyLayoutToViewHierarchy(view.subviews[i]);
}
}
}
@end

View File

@@ -0,0 +1,516 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
13687D481DF8748400E7C260 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D471DF8748400E7C260 /* main.m */; };
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4A1DF8748400E7C260 /* AppDelegate.m */; };
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D4D1DF8748400E7C260 /* ViewController.m */; };
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13687D521DF8748400E7C260 /* Assets.xcassets */; };
13687D781DF878C600E7C260 /* YGEnums.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5E1DF8778F00E7C260 /* YGEnums.h */; };
13687D791DF878C600E7C260 /* YGMacros.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D5F1DF8778F00E7C260 /* YGMacros.h */; };
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */ = {isa = PBXBuildFile; fileRef = 13687D631DF8778F00E7C260 /* Yoga.h */; };
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */ = {isa = PBXBuildFile; fileRef = 13687D691DF8778F00E7C260 /* UIView+Yoga.h */; };
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */ = {isa = PBXBuildFile; fileRef = 13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */; };
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D601DF8778F00E7C260 /* YGNodeList.c */; };
13687D821DF87CF200E7C260 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = 13687D621DF8778F00E7C260 /* Yoga.c */; };
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D841DF87D1E00E7C260 /* UIKit.framework */; };
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 13687D861DF87D2400E7C260 /* Foundation.framework */; };
638A94431E1EF5D000A726AD /* YGLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 638A94411E1EF5D000A726AD /* YGLayout.m */; };
638A94481E1F06D100A726AD /* SwiftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 638A94471E1F06D100A726AD /* SwiftViewController.swift */; };
638A945A1E215CD400A726AD /* YogaKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 638A94591E215CD400A726AD /* YogaKitTests.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
638A94541E215CC800A726AD /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 13687D3B1DF8748300E7C260 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 13687D421DF8748300E7C260;
remoteInfo = YogaKitSample;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
13687D771DF878A000E7C260 /* yoga */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = include/yoga;
dstSubfolderSpec = 16;
files = (
13687D781DF878C600E7C260 /* YGEnums.h in yoga */,
13687D791DF878C600E7C260 /* YGMacros.h in yoga */,
13687D7A1DF878C600E7C260 /* Yoga.h in yoga */,
);
name = yoga;
runOnlyForDeploymentPostprocessing = 0;
};
13687D7B1DF878CE00E7C260 /* YogaKit */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = include/YogaKit;
dstSubfolderSpec = 16;
files = (
13687D7C1DF878DD00E7C260 /* UIView+Yoga.h in YogaKit */,
);
name = YogaKit;
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
13687D431DF8748400E7C260 /* YogaKitSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YogaKitSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
13687D471DF8748400E7C260 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
13687D491DF8748400E7C260 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
13687D4A1DF8748400E7C260 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
13687D4C1DF8748400E7C260 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
13687D4D1DF8748400E7C260 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
13687D521DF8748400E7C260 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
13687D571DF8748400E7C260 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
13687D5E1DF8778F00E7C260 /* YGEnums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGEnums.h; sourceTree = "<group>"; };
13687D5F1DF8778F00E7C260 /* YGMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGMacros.h; sourceTree = "<group>"; };
13687D601DF8778F00E7C260 /* YGNodeList.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = YGNodeList.c; sourceTree = "<group>"; };
13687D611DF8778F00E7C260 /* YGNodeList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YGNodeList.h; sourceTree = "<group>"; };
13687D621DF8778F00E7C260 /* Yoga.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = Yoga.c; sourceTree = "<group>"; };
13687D631DF8778F00E7C260 /* Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Yoga.h; sourceTree = "<group>"; };
13687D691DF8778F00E7C260 /* UIView+Yoga.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+Yoga.h"; sourceTree = "<group>"; };
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+Yoga.m"; sourceTree = "<group>"; };
13687D841DF87D1E00E7C260 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
13687D861DF87D2400E7C260 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
638A94401E1EF5D000A726AD /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGLayout.h; sourceTree = "<group>"; };
638A94411E1EF5D000A726AD /* YGLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YGLayout.m; sourceTree = "<group>"; };
638A94421E1EF5D000A726AD /* YGLayout+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YGLayout+Private.h"; sourceTree = "<group>"; };
638A94461E1F06D100A726AD /* YogaKitSample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "YogaKitSample-Bridging-Header.h"; sourceTree = "<group>"; };
638A94471E1F06D100A726AD /* SwiftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftViewController.swift; sourceTree = "<group>"; };
638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YogaKitSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
638A94531E215CC800A726AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
638A94591E215CD400A726AD /* YogaKitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = YogaKitTests.m; path = ../../Tests/YogaKitTests.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
13687D401DF8748300E7C260 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
13687D871DF87D2400E7C260 /* Foundation.framework in Frameworks */,
13687D851DF87D1E00E7C260 /* UIKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
638A944C1E215CC800A726AD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
13687D3A1DF8748300E7C260 = {
isa = PBXGroup;
children = (
13687D5D1DF8778F00E7C260 /* yoga */,
13687D641DF8778F00E7C260 /* YogaKit */,
13687D451DF8748400E7C260 /* YogaKitSample */,
638A94501E215CC800A726AD /* YogaKitSampleTests */,
13687D441DF8748400E7C260 /* Products */,
13687D831DF87D1E00E7C260 /* Frameworks */,
);
sourceTree = "<group>";
};
13687D441DF8748400E7C260 /* Products */ = {
isa = PBXGroup;
children = (
13687D431DF8748400E7C260 /* YogaKitSample.app */,
638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
13687D451DF8748400E7C260 /* YogaKitSample */ = {
isa = PBXGroup;
children = (
13687D491DF8748400E7C260 /* AppDelegate.h */,
13687D4A1DF8748400E7C260 /* AppDelegate.m */,
13687D4C1DF8748400E7C260 /* ViewController.h */,
13687D4D1DF8748400E7C260 /* ViewController.m */,
638A94471E1F06D100A726AD /* SwiftViewController.swift */,
638A94461E1F06D100A726AD /* YogaKitSample-Bridging-Header.h */,
13687D521DF8748400E7C260 /* Assets.xcassets */,
13687D571DF8748400E7C260 /* Info.plist */,
13687D461DF8748400E7C260 /* Supporting Files */,
);
path = YogaKitSample;
sourceTree = "<group>";
};
13687D461DF8748400E7C260 /* Supporting Files */ = {
isa = PBXGroup;
children = (
13687D471DF8748400E7C260 /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
13687D5D1DF8778F00E7C260 /* yoga */ = {
isa = PBXGroup;
children = (
13687D5E1DF8778F00E7C260 /* YGEnums.h */,
13687D5F1DF8778F00E7C260 /* YGMacros.h */,
13687D601DF8778F00E7C260 /* YGNodeList.c */,
13687D611DF8778F00E7C260 /* YGNodeList.h */,
13687D621DF8778F00E7C260 /* Yoga.c */,
13687D631DF8778F00E7C260 /* Yoga.h */,
);
name = yoga;
path = ../../yoga;
sourceTree = "<group>";
};
13687D641DF8778F00E7C260 /* YogaKit */ = {
isa = PBXGroup;
children = (
13687D691DF8778F00E7C260 /* UIView+Yoga.h */,
13687D6A1DF8778F00E7C260 /* UIView+Yoga.m */,
638A94401E1EF5D000A726AD /* YGLayout.h */,
638A94421E1EF5D000A726AD /* YGLayout+Private.h */,
638A94411E1EF5D000A726AD /* YGLayout.m */,
);
name = YogaKit;
path = ..;
sourceTree = "<group>";
};
13687D831DF87D1E00E7C260 /* Frameworks */ = {
isa = PBXGroup;
children = (
13687D861DF87D2400E7C260 /* Foundation.framework */,
13687D841DF87D1E00E7C260 /* UIKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
638A94501E215CC800A726AD /* YogaKitSampleTests */ = {
isa = PBXGroup;
children = (
638A94591E215CD400A726AD /* YogaKitTests.m */,
638A94531E215CC800A726AD /* Info.plist */,
);
path = YogaKitSampleTests;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
13687D421DF8748300E7C260 /* YogaKitSample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */;
buildPhases = (
13687D771DF878A000E7C260 /* yoga */,
13687D7B1DF878CE00E7C260 /* YogaKit */,
13687D3F1DF8748300E7C260 /* Sources */,
13687D401DF8748300E7C260 /* Frameworks */,
13687D411DF8748300E7C260 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = YogaKitSample;
productName = YogaKitSample;
productReference = 13687D431DF8748400E7C260 /* YogaKitSample.app */;
productType = "com.apple.product-type.application";
};
638A944E1E215CC800A726AD /* YogaKitSampleTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */;
buildPhases = (
638A944B1E215CC800A726AD /* Sources */,
638A944C1E215CC800A726AD /* Frameworks */,
638A944D1E215CC800A726AD /* Resources */,
);
buildRules = (
);
dependencies = (
638A94551E215CC800A726AD /* PBXTargetDependency */,
);
name = YogaKitSampleTests;
productName = YogaKitSampleTests;
productReference = 638A944F1E215CC800A726AD /* YogaKitSampleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
13687D3B1DF8748300E7C260 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = facebook;
TargetAttributes = {
13687D421DF8748300E7C260 = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 0820;
ProvisioningStyle = Automatic;
};
638A944E1E215CC800A726AD = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
TestTargetID = 13687D421DF8748300E7C260;
};
};
};
buildConfigurationList = 13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 13687D3A1DF8748300E7C260;
productRefGroup = 13687D441DF8748400E7C260 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
13687D421DF8748300E7C260 /* YogaKitSample */,
638A944E1E215CC800A726AD /* YogaKitSampleTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
13687D411DF8748300E7C260 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13687D531DF8748400E7C260 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
638A944D1E215CC800A726AD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
13687D3F1DF8748300E7C260 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
638A94481E1F06D100A726AD /* SwiftViewController.swift in Sources */,
13687D801DF87CEC00E7C260 /* UIView+Yoga.m in Sources */,
13687D4E1DF8748400E7C260 /* ViewController.m in Sources */,
13687D4B1DF8748400E7C260 /* AppDelegate.m in Sources */,
13687D821DF87CF200E7C260 /* Yoga.c in Sources */,
13687D811DF87CF200E7C260 /* YGNodeList.c in Sources */,
13687D481DF8748400E7C260 /* main.m in Sources */,
638A94431E1EF5D000A726AD /* YGLayout.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
638A944B1E215CC800A726AD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
638A945A1E215CD400A726AD /* YogaKitTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
638A94551E215CC800A726AD /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 13687D421DF8748300E7C260 /* YogaKitSample */;
targetProxy = 638A94541E215CC800A726AD /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
13687D581DF8748400E7C260 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
13687D591DF8748400E7C260 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
13687D5B1DF8748400E7C260 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = YogaKitSample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "YogaKitSample/YogaKitSample-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
13687D5C1DF8748400E7C260 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = YogaKitSample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "YogaKitSample/YogaKitSample-Bridging-Header.h";
SWIFT_VERSION = 3.0;
};
name = Release;
};
638A94571E215CC800A726AD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
INFOPLIST_FILE = YogaKitSampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample";
};
name = Debug;
};
638A94581E215CC800A726AD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
INFOPLIST_FILE = YogaKitSampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.YogaKitSampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YogaKitSample.app/YogaKitSample";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
13687D3E1DF8748300E7C260 /* Build configuration list for PBXProject "YogaKitSample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13687D581DF8748400E7C260 /* Debug */,
13687D591DF8748400E7C260 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
13687D5A1DF8748400E7C260 /* Build configuration list for PBXNativeTarget "YogaKitSample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13687D5B1DF8748400E7C260 /* Debug */,
13687D5C1DF8748400E7C260 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
638A94561E215CC800A726AD /* Build configuration list for PBXNativeTarget "YogaKitSampleTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
638A94571E215CC800A726AD /* Debug */,
638A94581E215CC800A726AD /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 13687D3B1DF8748300E7C260 /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:YogaKitSample.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,16 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View File

@@ -0,0 +1,27 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [ViewController new];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
@end

View File

@@ -0,0 +1,48 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string></string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,40 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
import UIKit
class SwiftViewController: UIViewController {
override func viewDidLoad() {
let root = self.view!
root.backgroundColor = .red
root.yoga.isEnabled = true
root.yoga.width = self.view.bounds.size.width
root.yoga.height = self.view.bounds.size.height
root.yoga.alignItems = .center
root.yoga.justifyContent = .center
let child1 = UIView()
child1.backgroundColor = .blue
child1.yoga.isEnabled = true
child1.yoga.width = 100
child1.yoga.height = 10
let child2 = UIView()
child2.backgroundColor = .green
child2.frame = CGRect(x: 0, y: 0, width: 200, height: 100)
let child3 = UIView()
child3.backgroundColor = .yellow
child3.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
child2.addSubview(child3)
root.addSubview(child1)
root.addSubview(child2)
root.yoga.applyLayout()
}
}

View File

@@ -0,0 +1,15 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end

View File

@@ -0,0 +1,60 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import "ViewController.h"
#import <YogaKit/UIView+Yoga.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
UIView *root = self.view;
root.backgroundColor = [UIColor redColor];
root.yoga.isEnabled = YES;
root.yoga.width = self.view.bounds.size.width;
root.yoga.height = self.view.bounds.size.height;
root.yoga.alignItems = YGAlignCenter;
root.yoga.justifyContent = YGJustifyCenter;
UIView *child1 = [UIView new];
child1.backgroundColor = [UIColor blueColor];
child1.yoga.isEnabled = YES;
child1.yoga.width = 100;
child1.yoga.height = 100;
UIView *child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor];
child2.frame = (CGRect) {
.size = {
.width = 200,
.height = 100,
}
};
UIView *child3 = [UIView new];
child3.backgroundColor = [UIColor yellowColor];
child3.frame = (CGRect) {
.size = {
.width = 100,
.height = 100,
}
};
[child2 addSubview:child3];
[root addSubview:child1];
[root addSubview:child2];
[root.yoga applyLayout];
}
@end

View File

@@ -0,0 +1,10 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import "UIView+Yoga.h"
#import <yoga/Yoga.h>

View File

@@ -0,0 +1,16 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

27
benchmark/BUCK Normal file
View File

@@ -0,0 +1,27 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
include_defs('//YOGA_DEFS')
cxx_binary(
name = 'benchmark',
srcs = glob(['*.c']),
headers = subdir_glob([('', '*.h')]),
header_namespace = '',
compiler_flags = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-O3',
'-std=c11',
],
deps = [
yoga_dep(':yoga'),
],
visibility = ['PUBLIC'],
)

118
benchmark/YGBenchmark.c Normal file
View File

@@ -0,0 +1,118 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include "YGBenchmark.h"
#include <yoga/Yoga.h>
static YGSize _measure(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return (YGSize){
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
};
}
YGBENCHMARKS({
YGBENCHMARK("Stack with flex", {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
for (uint32_t i = 0; i < 10; i++) {
const YGNodeRef child = YGNodeNew();
YGNodeSetMeasureFunc(child, _measure);
YGNodeStyleSetFlex(child, 1);
YGNodeInsertChild(root, child, 0);
}
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
YGBENCHMARK("Align stretch in undefined axis", {
const YGNodeRef root = YGNodeNew();
for (uint32_t i = 0; i < 10; i++) {
const YGNodeRef child = YGNodeNew();
YGNodeStyleSetHeight(child, 20);
YGNodeSetMeasureFunc(child, _measure);
YGNodeInsertChild(root, child, 0);
}
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
YGBENCHMARK("Nested flex", {
const YGNodeRef root = YGNodeNew();
for (uint32_t i = 0; i < 10; i++) {
const YGNodeRef child = YGNodeNew();
YGNodeStyleSetFlex(child, 1);
YGNodeInsertChild(root, child, 0);
for (uint32_t ii = 0; ii < 10; ii++) {
const YGNodeRef grandChild = YGNodeNew();
YGNodeSetMeasureFunc(grandChild, _measure);
YGNodeStyleSetFlex(grandChild, 1);
YGNodeInsertChild(child, grandChild, 0);
}
}
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
YGBENCHMARK("Huge nested layout", {
const YGNodeRef root = YGNodeNew();
for (uint32_t i = 0; i < 10; i++) {
const YGNodeRef child = YGNodeNew();
YGNodeStyleSetFlexGrow(child, 1);
YGNodeStyleSetWidth(child, 10);
YGNodeStyleSetHeight(child, 10);
YGNodeInsertChild(root, child, 0);
for (uint32_t ii = 0; ii < 10; ii++) {
const YGNodeRef grandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandChild, 1);
YGNodeStyleSetWidth(grandChild, 10);
YGNodeStyleSetHeight(grandChild, 10);
YGNodeInsertChild(child, grandChild, 0);
for (uint32_t iii = 0; iii < 10; iii++) {
const YGNodeRef grandGrandChild = YGNodeNew();
YGNodeStyleSetFlexGrow(grandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandChild, 10);
YGNodeInsertChild(grandChild, grandGrandChild, 0);
for (uint32_t iii = 0; iii < 10; iii++) {
const YGNodeRef grandGrandGrandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandGrandChild, 10);
YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);
}
}
}
}
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
});

73
benchmark/YGBenchmark.h Normal file
View File

@@ -0,0 +1,73 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#pragma once
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUM_REPETITIONS 1000
#define YGBENCHMARKS(BLOCK) \
int main(int argc, char const *argv[]) { \
clock_t __start; \
clock_t __endTimes[NUM_REPETITIONS]; \
{ BLOCK } \
return 0; \
}
#define YGBENCHMARK(NAME, BLOCK) \
__start = clock(); \
for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \
{ BLOCK } \
__endTimes[__i] = clock(); \
} \
__printBenchmarkResult(NAME, __start, __endTimes);
int __compareDoubles(const void *a, const void *b) {
double arg1 = *(const double *) a;
double arg2 = *(const double *) b;
if (arg1 < arg2) {
return -1;
}
if (arg1 > arg2) {
return 1;
}
return 0;
}
void __printBenchmarkResult(char *name, clock_t start, clock_t *endTimes) {
double timesInMs[NUM_REPETITIONS];
double mean = 0;
clock_t lastEnd = start;
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
timesInMs[i] = (endTimes[i] - lastEnd) / (double) CLOCKS_PER_SEC * 1000;
lastEnd = endTimes[i];
mean += timesInMs[i];
}
mean /= NUM_REPETITIONS;
qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles);
double median = timesInMs[NUM_REPETITIONS / 2];
double variance = 0;
for (uint32_t i = 0; i < NUM_REPETITIONS; i++) {
variance += pow(timesInMs[i] - mean, 2);
}
variance /= NUM_REPETITIONS;
double stddev = sqrt(variance);
printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev);
}

269
csharp/.gitignore vendored Normal file
View File

@@ -0,0 +1,269 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
tests/Facebook.Yoga/NUnit-[0-9\.]*/
tests/Facebook.Yoga/YogaTest.dll
tests/Facebook.Yoga/YogaTest.dll.mdb
tests/Facebook.Yoga/libyoga.dylib
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

269
csharp/.hgignore Normal file
View File

@@ -0,0 +1,269 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
tests/Facebook.Yoga/NUnit-[0-9\.]*/
tests/Facebook.Yoga/YogaTest.dll
tests/Facebook.Yoga/YogaTest.dll.mdb
tests/Facebook.Yoga/libyoga.dylib
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

63
csharp/BUCK Normal file
View File

@@ -0,0 +1,63 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
include_defs('//YOGA_DEFS')
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11']
csharp_library(
name = 'yogalibnet46',
dll_name = 'Facebook.Yoga.dll',
framework_ver = 'net46',
srcs = glob(['**/*.cs']),
)
csharp_library(
name = 'yogalibnet45',
dll_name = 'Facebook.Yoga.dll',
framework_ver = 'net45',
srcs = glob(['**/*.cs']),
)
cxx_library(
name = 'yoganet',
soname = 'libyoga.$(ext)',
srcs = glob(['Yoga/YGInterop.cpp']),
compiler_flags = COMPILER_FLAGS,
link_style = 'static',
link_whole = True,
deps = [yoga_dep(':yoga')],
visibility = ['PUBLIC'],
)
with allow_unsafe_import():
import os
if os.path.isdir('/Applications/Xcode.app'):
yoganet_ios_srcs = []
for arch in ['iphonesimulator-x86_64', 'iphoneos-arm64', 'iphoneos-armv7']:
name = 'yoganet-' + arch
yoganet_ios_srcs.append(':' + name)
genrule(
name = name,
srcs = [
yoga_dep(':yoga#%s,static' % arch),
yoga_dep('YogaKit:YogaKit#%s,static' % arch),
yoga_dep('csharp:yoganet#%s,static' % arch),
],
out = 'libyoga-%s.a' % arch,
cmd = 'libtool -static -o $OUT $SRCS',
visibility = [yoga_dep('csharp:yoganet-ios')],
)
genrule(
name = 'yoganet-ios',
srcs = yoganet_ios_srcs,
out = 'libyoga.a',
cmd = 'lipo $SRCS -create -output $OUT',
visibility = ['PUBLIC'],
)

View File

@@ -0,0 +1,13 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public delegate float BaselineFunction(YogaNode node, float width, float height);
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
[System.Obsolete]
public class Border
{
public float? Top;
public float? Bottom;
public float? Left;
public float? Right;
public Border(
float? top = null,
float? bottom = null,
float? left = null,
float? right = null)
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
}
}

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>91c42d32-291d-4b72-90b4-551663d60b8b</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Facebook.Yoga.Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)BaselineFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Border.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MeasureFunction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MeasureOutput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Native.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Spacing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaAlign.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaBaselineFunc.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaConstants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaDimension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaDirection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaEdge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaExperimentalFeature.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaFlexDirection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaJustify.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaLogger.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaLogLevel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaMeasureFunc.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaMeasureMode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.Create.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.Spacing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaNode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaOverflow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaPositionType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaPrintOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaSize.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaUnit.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaValue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaValueExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaWrap.cs" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>91c42d32-291d-4b72-90b4-551663d60b8b</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Facebook.Yoga.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public delegate YogaSize MeasureFunction(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
}

View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public class MeasureOutput
{
public static YogaSize Make(float width, float height)
{
return new YogaSize { width = width, height = height};
}
}
}

View File

@@ -0,0 +1,326 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
internal static class Native
{
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
private const string DllName = "__Internal";
#else
private const string DllName = "yoga";
#endif
internal class YGNodeHandle : SafeHandle
{
private YGNodeHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
Native.YGNodeFree(this.handle);
GC.KeepAlive(this);
return true;
}
}
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGInteropSetLogger(
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YGNodeHandle YGNodeNew();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeFree(IntPtr node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeReset(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGNodeGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGSetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGIsExperimentalFeatureEnabled(
YogaExperimentalFeature feature);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeInsertChild(YGNodeHandle node, YGNodeHandle child, uint index);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeCalculateLayout(YGNodeHandle node,
float availableWidth,
float availableHeight,
YogaDirection parentDirection);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeMarkDirty(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool YGNodeIsDirty(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodePrint(YGNodeHandle node, YogaPrintOptions options);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeCopyStyle(YGNodeHandle dstNode, YGNodeHandle srcNode);
#region YG_NODE_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetMeasureFunc(
YGNodeHandle node,
[MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetBaselineFunc(
YGNodeHandle node,
[MarshalAs(UnmanagedType.FunctionPtr)] YogaBaselineFunc baselineFunc);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetHasNewLayout(YGNodeHandle node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool YGNodeGetHasNewLayout(YGNodeHandle node);
#endregion
#region YG_NODE_STYLE_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaDirection YGNodeStyleGetDirection(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlexDirection(YGNodeHandle node, YogaFlexDirection flexDirection);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetJustifyContent(YGNodeHandle node, YogaJustify justifyContent);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaJustify YGNodeStyleGetJustifyContent(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAlignContent(YGNodeHandle node, YogaAlign alignContent);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaAlign YGNodeStyleGetAlignContent(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAlignItems(YGNodeHandle node, YogaAlign alignItems);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaAlign YGNodeStyleGetAlignItems(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAlignSelf(YGNodeHandle node, YogaAlign alignSelf);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaAlign YGNodeStyleGetAlignSelf(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPositionType(YGNodeHandle node, YogaPositionType positionType);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaPositionType YGNodeStyleGetPositionType(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlexWrap(YGNodeHandle node, YogaWrap flexWrap);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaWrap YGNodeStyleGetFlexWrap(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetOverflow(YGNodeHandle node, YogaOverflow flexWrap);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaOverflow YGNodeStyleGetOverflow(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlex(YGNodeHandle node, float flex);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlexGrow(YGNodeHandle node, float flexGrow);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeStyleGetFlexGrow(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlexShrink(YGNodeHandle node, float flexShrink);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeStyleGetFlexShrink(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetFlexBasisPercent(YGNodeHandle node, float flexBasis);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidthPercent(YGNodeHandle node, float width);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeightPercent(YGNodeHandle node, float height);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node);
#endregion
#region YG_NODE_STYLE_EDGE_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMarginPercent(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeStyleGetBorder(YGNodeHandle node, YogaEdge edge);
#endregion
#region YG_NODE_LAYOUT_PROPERTY
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetLeft(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetTop(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetRight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetBottom(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern float YGNodeLayoutGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaDirection YGNodeLayoutGetDirection(YGNodeHandle node);
#endregion
}
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
[System.Obsolete]
public class Spacing
{
public YogaValue? Top;
public YogaValue? Bottom;
public YogaValue? Left;
public YogaValue? Right;
public Spacing(
YogaValue? top = null,
YogaValue? bottom = null,
YogaValue? left = null,
YogaValue? right = null)
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
}
}

View File

@@ -0,0 +1,21 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaAlign
{
Auto,
FlexStart,
Center,
FlexEnd,
Stretch,
Baseline,
}
}

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate float YogaBaselineFunc(IntPtr node, float width, float height);
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public static class YogaConstants
{
public const float Undefined = float.NaN;
public static bool IsUndefined(float value)
{
return float.IsNaN(value);
}
public static bool IsUndefined(YogaValue value)
{
return value.Unit == YogaUnit.Undefined;
}
}
}

View File

@@ -1,17 +1,17 @@
/**
* Copyright (c) 2014, Facebook, Inc.
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSAlign {
AUTO,
FLEX_START,
CENTER,
FLEX_END,
STRETCH,
namespace Facebook.Yoga
{
public enum YogaDimension
{
Width,
Height,
}
}

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaDirection
{
Inherit,
LTR,
RTL,
}
}

View File

@@ -0,0 +1,24 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaEdge
{
Left,
Top,
Right,
Bottom,
Start,
End,
Horizontal,
Vertical,
All,
}
}

View File

@@ -1,17 +1,17 @@
/**
* Copyright (c) 2014, Facebook, Inc.
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSJustify {
FLEX_START,
CENTER,
FLEX_END,
SPACE_BETWEEN,
SPACE_AROUND,
namespace Facebook.Yoga
{
public enum YogaExperimentalFeature
{
Rounding,
WebFlexBasis,
}
}

View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaFlexDirection
{
Column,
ColumnReverse,
Row,
RowReverse,
}
}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaJustify
{
FlexStart,
Center,
FlexEnd,
SpaceBetween,
SpaceAround,
}
}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaLogLevel
{
Error,
Warn,
Info,
Debug,
Verbose,
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
internal static class YogaLogger
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Func(YogaLogLevel level, string message);
private static bool _initialized;
private static Func _managedLogger = null;
public static Func Logger = null;
public static void Initialize()
{
if (!_initialized)
{
_managedLogger = (level, message) => {
if (Logger != null)
{
Logger(level, message);
}
if (level == YogaLogLevel.Error)
{
throw new InvalidOperationException(message);
}
};
Native.YGInteropSetLogger(_managedLogger);
_initialized = true;
}
}
}
}

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate YogaSize YogaMeasureFunc(
IntPtr node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
}

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaMeasureMode
{
Undefined,
Exactly,
AtMost,
}
}

View File

@@ -0,0 +1,234 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
namespace Facebook.Yoga
{
public partial class YogaNode
{
[Obsolete("use Object Initializer")]
public static YogaNode Create(
YogaDirection? styleDirection = null,
YogaFlexDirection? flexDirection = null,
YogaJustify? justifyContent = null,
YogaAlign? alignContent = null,
YogaAlign? alignItems = null,
YogaAlign? alignSelf = null,
YogaPositionType? positionType = null,
YogaWrap? wrap = null,
YogaOverflow? overflow = null,
float? flex = null,
float? flexGrow = null,
float? flexShrink = null,
YogaValue? flexBasis = null,
Spacing position = null,
Spacing margin = null,
Spacing padding = null,
Border border = null,
YogaValue? width = null,
YogaValue? height = null,
YogaValue? maxWidth = null,
YogaValue? maxHeight = null,
YogaValue? minWidth = null,
YogaValue? minHeight = null)
{
YogaNode node = new YogaNode();
if (styleDirection.HasValue)
{
node.StyleDirection = styleDirection.Value;
}
if (flexDirection.HasValue)
{
node.FlexDirection = flexDirection.Value;
}
if (justifyContent.HasValue)
{
node.JustifyContent = justifyContent.Value;
}
if (alignContent.HasValue)
{
node.AlignContent = alignContent.Value;
}
if (alignItems.HasValue)
{
node.AlignItems = alignItems.Value;
}
if (alignSelf.HasValue)
{
node.AlignSelf = alignSelf.Value;
}
if (positionType.HasValue)
{
node.PositionType = positionType.Value;
}
if (wrap.HasValue)
{
node.Wrap = wrap.Value;
}
if (overflow.HasValue)
{
node.Overflow = overflow.Value;
}
if (flex.HasValue)
{
node.Flex = flex.Value;
}
if (flexGrow.HasValue)
{
node.FlexGrow = flexGrow.Value;
}
if (flexShrink.HasValue)
{
node.FlexShrink = flexShrink.Value;
}
if (flexBasis.HasValue)
{
node.FlexBasis = flexBasis.Value;
}
if (position != null)
{
if (position.Top.HasValue)
{
node.Top = position.Top.Value;
}
if (position.Bottom.HasValue)
{
node.Bottom = position.Bottom.Value;
}
if (position.Left.HasValue)
{
node.Left = position.Left.Value;
}
if (position.Right.HasValue)
{
node.Right = position.Right.Value;
}
}
if (margin != null)
{
if (margin.Top.HasValue)
{
node.MarginTop = margin.Top.Value;
}
if (margin.Bottom.HasValue)
{
node.MarginBottom = margin.Bottom.Value;
}
if (margin.Left.HasValue)
{
node.MarginLeft = margin.Left.Value;
}
if (margin.Right.HasValue)
{
node.MarginRight = margin.Right.Value;
}
}
if (padding != null)
{
if (padding.Top.HasValue)
{
node.PaddingTop = padding.Top.Value;
}
if (padding.Bottom.HasValue)
{
node.PaddingBottom = padding.Bottom.Value;
}
if (padding.Left.HasValue)
{
node.PaddingLeft = padding.Left.Value;
}
if (padding.Right.HasValue)
{
node.PaddingRight = padding.Right.Value;
}
}
if (border != null)
{
if (border.Top.HasValue)
{
node.BorderTopWidth = border.Top.Value;
}
if (border.Bottom.HasValue)
{
node.BorderBottomWidth = border.Bottom.Value;
}
if (border.Left.HasValue)
{
node.BorderLeftWidth = border.Left.Value;
}
if (border.Right.HasValue)
{
node.BorderRightWidth = border.Right.Value;
}
}
if (width.HasValue)
{
node.Width = width.Value;
}
if (height.HasValue)
{
node.Height = height.Value;
}
if (minWidth.HasValue)
{
node.MinWidth = minWidth.Value;
}
if (minHeight.HasValue)
{
node.MinHeight = minHeight.Value;
}
if (maxWidth.HasValue)
{
node.MaxWidth = maxWidth.Value;
}
if (maxHeight.HasValue)
{
node.MaxHeight = maxHeight.Value;
}
return node;
}
}
}

View File

@@ -0,0 +1,551 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
namespace Facebook.Yoga
{
public partial class YogaNode
{
public YogaValue Left
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
}
set
{
SetStylePosition(YogaEdge.Left, value);
}
}
public YogaValue Top
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
}
set
{
SetStylePosition(YogaEdge.Top, value);
}
}
public YogaValue Right
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
}
set
{
SetStylePosition(YogaEdge.Right, value);
}
}
public YogaValue Bottom
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
}
set
{
SetStylePosition(YogaEdge.Bottom, value);
}
}
public YogaValue Start
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
}
set
{
SetStylePosition(YogaEdge.Start, value);
}
}
public YogaValue End
{
get
{
return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
}
set
{
SetStylePosition(YogaEdge.End, value);
}
}
private void SetStylePosition(YogaEdge edge, YogaValue value)
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value);
}
}
public YogaValue MarginLeft
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
}
set
{
SetStyleMargin(YogaEdge.Left, value);
}
}
public YogaValue MarginTop
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
}
set
{
SetStyleMargin(YogaEdge.Top, value);
}
}
public YogaValue MarginRight
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
}
set
{
SetStyleMargin(YogaEdge.Right, value);
}
}
public YogaValue MarginBottom
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
}
set
{
SetStyleMargin(YogaEdge.Bottom, value);
}
}
public YogaValue MarginStart
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
}
set
{
SetStyleMargin(YogaEdge.Start, value);
}
}
public YogaValue MarginEnd
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
}
set
{
SetStyleMargin(YogaEdge.End, value);
}
}
public YogaValue MarginHorizontal
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
}
set
{
SetStyleMargin(YogaEdge.Horizontal, value);
}
}
public YogaValue MarginVertical
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
}
set
{
SetStyleMargin(YogaEdge.Vertical, value);
}
}
public YogaValue Margin
{
get
{
return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
}
set
{
SetStyleMargin(YogaEdge.All, value);
}
}
private void SetStyleMargin(YogaEdge edge, YogaValue value)
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value);
}
}
public YogaValue PaddingLeft
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
}
set
{
SetStylePadding(YogaEdge.Left, value);
}
}
public YogaValue PaddingTop
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
}
set
{
SetStylePadding(YogaEdge.Top, value);
}
}
public YogaValue PaddingRight
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
}
set
{
SetStylePadding(YogaEdge.Right, value);
}
}
public YogaValue PaddingBottom
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
}
set
{
SetStylePadding(YogaEdge.Bottom, value);
}
}
public YogaValue PaddingStart
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
}
set
{
SetStylePadding(YogaEdge.Start, value);
}
}
public YogaValue PaddingEnd
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
}
set
{
SetStylePadding(YogaEdge.End, value);
}
}
public YogaValue PaddingHorizontal
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
}
set
{
SetStylePadding(YogaEdge.Horizontal, value);
}
}
public YogaValue PaddingVertical
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
}
set
{
SetStylePadding(YogaEdge.Vertical, value);
}
}
public YogaValue Padding
{
get
{
return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
}
set
{
SetStylePadding(YogaEdge.All, value);
}
}
private void SetStylePadding(YogaEdge edge, YogaValue value)
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value);
}
}
public float BorderLeftWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Left);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Left, value);
}
}
public float BorderTopWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Top);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Top, value);
}
}
public float BorderRightWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Right);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Right, value);
}
}
public float BorderBottomWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Bottom);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Bottom, value);
}
}
public float BorderStartWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Start);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Start, value);
}
}
public float BorderEndWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.End);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.End, value);
}
}
public float BorderWidth
{
get
{
return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.All);
}
set
{
Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.All, value);
}
}
public float LayoutMarginLeft
{
get
{
return Native.YGNodeLayoutGetMargin(_ygNode, YogaEdge.Left);
}
}
public float LayoutMarginTop
{
get
{
return Native.YGNodeLayoutGetMargin(_ygNode, YogaEdge.Top);
}
}
public float LayoutMarginRight
{
get
{
return Native.YGNodeLayoutGetMargin(_ygNode, YogaEdge.Right);
}
}
public float LayoutMarginBottom
{
get
{
return Native.YGNodeLayoutGetMargin(_ygNode, YogaEdge.Bottom);
}
}
public float LayoutMarginStart
{
get
{
return Native.YGNodeLayoutGetMargin(_ygNode, YogaEdge.Start);
}
}
public float LayoutMarginEnd
{
get
{
return Native.YGNodeLayoutGetMargin(_ygNode, YogaEdge.End);
}
}
public float LayoutPaddingLeft
{
get
{
return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Left);
}
}
public float LayoutPaddingTop
{
get
{
return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Top);
}
}
public float LayoutPaddingRight
{
get
{
return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Right);
}
}
public float LayoutPaddingBottom
{
get
{
return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Bottom);
}
}
public float LayoutPaddingStart
{
get
{
return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Start);
}
}
public float LayoutPaddingEnd
{
get
{
return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.End);
}
}
}
}

View File

@@ -0,0 +1,695 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace Facebook.Yoga
{
public partial class YogaNode : IEnumerable<YogaNode>
{
private Native.YGNodeHandle _ygNode;
private WeakReference _parent;
private List<YogaNode> _children;
private MeasureFunction _measureFunction;
private YogaMeasureFunc _ygMeasureFunc;
private BaselineFunction _baselineFunction;
private YogaBaselineFunc _ygBaselineFunc;
private object _data;
public YogaNode()
{
YogaLogger.Initialize();
_ygNode = Native.YGNodeNew();
if (_ygNode.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
}
public YogaNode(YogaNode srcNode)
: this()
{
CopyStyle(srcNode);
}
public void Reset()
{
_measureFunction = null;
_baselineFunction = null;
_data = null;
Native.YGNodeReset(_ygNode);
}
public bool IsDirty
{
get
{
return Native.YGNodeIsDirty(_ygNode);
}
}
public virtual void MarkDirty()
{
Native.YGNodeMarkDirty(_ygNode);
}
public bool HasNewLayout
{
get
{
return Native.YGNodeGetHasNewLayout(_ygNode);
}
}
public void MarkHasNewLayout()
{
Native.YGNodeSetHasNewLayout(_ygNode, true);
}
public YogaNode Parent
{
get
{
return _parent != null ? _parent.Target as YogaNode : null;
}
}
public bool IsMeasureDefined
{
get
{
return _measureFunction != null;
}
}
public bool IsBaselineDefined
{
get
{
return _baselineFunction != null;
}
}
public void CopyStyle(YogaNode srcNode)
{
Native.YGNodeCopyStyle(_ygNode, srcNode._ygNode);
}
public YogaDirection StyleDirection
{
get
{
return Native.YGNodeStyleGetDirection(_ygNode);
}
set
{
Native.YGNodeStyleSetDirection(_ygNode, value);
}
}
public YogaFlexDirection FlexDirection
{
get
{
return Native.YGNodeStyleGetFlexDirection(_ygNode);
}
set
{
Native.YGNodeStyleSetFlexDirection(_ygNode, value);
}
}
public YogaJustify JustifyContent
{
get
{
return Native.YGNodeStyleGetJustifyContent(_ygNode);
}
set
{
Native.YGNodeStyleSetJustifyContent(_ygNode, value);
}
}
public YogaAlign AlignItems
{
get
{
return Native.YGNodeStyleGetAlignItems(_ygNode);
}
set
{
Native.YGNodeStyleSetAlignItems(_ygNode, value);
}
}
public YogaAlign AlignSelf
{
get
{
return Native.YGNodeStyleGetAlignSelf(_ygNode);
}
set
{
Native.YGNodeStyleSetAlignSelf(_ygNode, value);
}
}
public YogaAlign AlignContent
{
get
{
return Native.YGNodeStyleGetAlignContent(_ygNode);
}
set
{
Native.YGNodeStyleSetAlignContent(_ygNode, value);
}
}
public YogaPositionType PositionType
{
get
{
return Native.YGNodeStyleGetPositionType(_ygNode);
}
set
{
Native.YGNodeStyleSetPositionType(_ygNode, value);
}
}
public YogaWrap Wrap
{
get
{
return Native.YGNodeStyleGetFlexWrap(_ygNode);
}
set
{
Native.YGNodeStyleSetFlexWrap(_ygNode, value);
}
}
public float Flex
{
set
{
Native.YGNodeStyleSetFlex(_ygNode, value);
}
}
public float FlexGrow
{
get
{
return Native.YGNodeStyleGetFlexGrow(_ygNode);
}
set
{
Native.YGNodeStyleSetFlexGrow(_ygNode, value);
}
}
public float FlexShrink
{
get
{
return Native.YGNodeStyleGetFlexShrink(_ygNode);
}
set
{
Native.YGNodeStyleSetFlexShrink(_ygNode, value);
}
}
public YogaValue FlexBasis
{
get
{
return Native.YGNodeStyleGetFlexBasis(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetFlexBasisPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetFlexBasis(_ygNode, value.Value);
}
}
}
[Obsolete("use Margin properties")]
public YogaValue GetMargin(YogaEdge edge)
{
return Native.YGNodeStyleGetMargin(_ygNode, edge);
}
[Obsolete("use Margin properties")]
public void SetMargin(YogaEdge edge, YogaValue value)
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value);
}
}
[Obsolete("use Padding properties")]
public YogaValue GetPadding(YogaEdge edge)
{
return Native.YGNodeStyleGetPadding(_ygNode, edge);
}
[Obsolete("use Padding properties")]
public void SetPadding(YogaEdge edge, YogaValue value)
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value);
}
}
[Obsolete("use BorderWidth properties")]
public float GetBorder(YogaEdge edge)
{
return Native.YGNodeStyleGetBorder(_ygNode, edge);
}
[Obsolete("use BorderWidth properties")]
public void SetBorder(YogaEdge edge, float border)
{
Native.YGNodeStyleSetBorder(_ygNode, edge, border);
}
[Obsolete("use Position properties")]
public YogaValue GetPosition(YogaEdge edge)
{
return Native.YGNodeStyleGetPosition(_ygNode, edge);
}
[Obsolete("use Position properties")]
public void SetPosition(YogaEdge edge, YogaValue value)
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value);
}
}
[Obsolete("use LayoutPadding properties")]
public float GetLayoutPadding(YogaEdge edge)
{
return Native.YGNodeLayoutGetPadding(_ygNode, edge);
}
public YogaValue Width
{
get
{
return Native.YGNodeStyleGetWidth(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetWidth(_ygNode, value.Value);
}
}
}
public YogaValue Height
{
get
{
return Native.YGNodeStyleGetHeight(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetHeight(_ygNode, value.Value);
}
}
}
public YogaValue MaxWidth
{
get
{
return Native.YGNodeStyleGetMaxWidth(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMaxWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMaxWidth(_ygNode, value.Value);
}
}
}
public YogaValue MaxHeight
{
get
{
return Native.YGNodeStyleGetMaxHeight(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMaxHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMaxHeight(_ygNode, value.Value);
}
}
}
public YogaValue MinWidth
{
get
{
return Native.YGNodeStyleGetMinWidth(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMinWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMinWidth(_ygNode, value.Value);
}
}
}
public YogaValue MinHeight
{
get
{
return Native.YGNodeStyleGetMinHeight(_ygNode);
}
set
{
if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMinHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMinHeight(_ygNode, value.Value);
}
}
}
public float StyleAspectRatio
{
get
{
return Native.YGNodeStyleGetAspectRatio(_ygNode);
}
set
{
Native.YGNodeStyleSetAspectRatio(_ygNode, value);
}
}
public float LayoutX
{
get
{
return Native.YGNodeLayoutGetLeft(_ygNode);
}
}
public float LayoutY
{
get
{
return Native.YGNodeLayoutGetTop(_ygNode);
}
}
public float LayoutWidth
{
get
{
return Native.YGNodeLayoutGetWidth(_ygNode);
}
}
public float LayoutHeight
{
get
{
return Native.YGNodeLayoutGetHeight(_ygNode);
}
}
public YogaDirection LayoutDirection
{
get
{
return Native.YGNodeLayoutGetDirection(_ygNode);
}
}
public YogaOverflow Overflow
{
get
{
return Native.YGNodeStyleGetOverflow(_ygNode);
}
set
{
Native.YGNodeStyleSetOverflow(_ygNode, value);
}
}
public object Data
{
get
{
return _data;
}
set
{
_data = value;
}
}
public YogaNode this[int index]
{
get
{
return _children[index];
}
}
public int Count
{
get
{
return _children != null ? _children.Count : 0;
}
}
public void MarkLayoutSeen()
{
Native.YGNodeSetHasNewLayout(_ygNode, false);
}
public bool ValuesEqual(float f1, float f2)
{
if (float.IsNaN(f1) || float.IsNaN(f2))
{
return float.IsNaN(f1) && float.IsNaN(f2);
}
return Math.Abs(f2 - f1) < float.Epsilon;
}
public void Insert(int index, YogaNode node)
{
if (_children == null)
{
_children = new List<YogaNode>(4);
}
_children.Insert(index, node);
node._parent = new WeakReference(this);
Native.YGNodeInsertChild(_ygNode, node._ygNode, (uint)index);
}
public void RemoveAt(int index)
{
var child = _children[index];
child._parent = null;
_children.RemoveAt(index);
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
}
public void Clear()
{
if (_children != null)
{
while (_children.Count > 0)
{
RemoveAt(_children.Count-1);
}
}
}
public int IndexOf(YogaNode node)
{
return _children != null ? _children.IndexOf(node) : -1;
}
public void SetMeasureFunction(MeasureFunction measureFunction)
{
_measureFunction = measureFunction;
_ygMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null;
Native.YGNodeSetMeasureFunc(_ygNode, _ygMeasureFunc);
}
public void SetBaselineFunction(BaselineFunction baselineFunction)
{
_baselineFunction = baselineFunction;
_ygBaselineFunc = baselineFunction != null ? BaselineInternal : (YogaBaselineFunc)null;
Native.YGNodeSetBaselineFunc(_ygNode, _ygBaselineFunc);
}
public void CalculateLayout()
{
Native.YGNodeCalculateLayout(
_ygNode,
YogaConstants.Undefined,
YogaConstants.Undefined,
Native.YGNodeStyleGetDirection(_ygNode));
}
private YogaSize MeasureInternal(
IntPtr node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode)
{
if (_measureFunction == null)
{
throw new InvalidOperationException("Measure function is not defined.");
}
return _measureFunction(this, width, widthMode, height, heightMode);
}
private float BaselineInternal(IntPtr node, float width, float height)
{
if (_baselineFunction == null)
{
throw new InvalidOperationException("Baseline function is not defined.");
}
return _baselineFunction(this, width, height);
}
public string Print(YogaPrintOptions options =
YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children)
{
StringBuilder sb = new StringBuilder();
YogaLogger.Func orig = YogaLogger.Logger;
YogaLogger.Logger = (level, message) => {sb.Append(message);};
Native.YGNodePrint(_ygNode, options);
YogaLogger.Logger = orig;
return sb.ToString();
}
public IEnumerator<YogaNode> GetEnumerator()
{
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
}
public static int GetInstanceCount()
{
return Native.YGNodeGetInstanceCount();
}
public static void SetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled)
{
Native.YGSetExperimentalFeatureEnabled(feature, enabled);
}
public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
{
return Native.YGIsExperimentalFeatureEnabled(feature);
}
}
}

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaOverflow
{
Visible,
Hidden,
Scroll,
}
}

View File

@@ -1,16 +1,17 @@
/**
* Copyright (c) 2014, Facebook, Inc.
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSFlexDirection {
COLUMN,
COLUMN_REVERSE,
ROW,
ROW_REVERSE
namespace Facebook.Yoga
{
public enum YogaPositionType
{
Relative,
Absolute,
}
}

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaPrintOptions
{
Layout = 1,
Style = 2,
Children = 4,
}
}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
[StructLayout(LayoutKind.Sequential)]
public struct YogaSize
{
public float width;
public float height;
}
}

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public enum YogaUnit
{
Undefined,
Pixel,
Percent,
}
}

View File

@@ -0,0 +1,87 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System.Runtime.InteropServices;
namespace Facebook.Yoga
{
[StructLayout(LayoutKind.Sequential)]
public struct YogaValue
{
private float value;
private YogaUnit unit;
public YogaUnit Unit
{
get
{
return unit;
}
}
public float Value
{
get
{
return value;
}
}
public static YogaValue Pixel(float value)
{
return new YogaValue
{
value = value,
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Pixel
};
}
public bool Equals(YogaValue other)
{
return Unit == other.Unit && (Value.Equals(other.Value) || Unit == YogaUnit.Undefined);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is YogaValue && Equals((YogaValue) obj);
}
public override int GetHashCode()
{
unchecked
{
return (Value.GetHashCode() * 397) ^ (int) Unit;
}
}
public static YogaValue Undefined()
{
return new YogaValue
{
value = YogaConstants.Undefined,
unit = YogaUnit.Undefined
};
}
public static YogaValue Percent(float value)
{
return new YogaValue
{
value = value,
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Percent
};
}
public static implicit operator YogaValue(float pixelValue)
{
return Pixel(pixelValue);
}
}
}

View File

@@ -0,0 +1,34 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.Yoga
{
public static class YogaValueExtensions
{
public static YogaValue Percent(this float value)
{
return YogaValue.Percent(value);
}
public static YogaValue Px(this float value)
{
return YogaValue.Pixel(value);
}
public static YogaValue Percent(this int value)
{
return YogaValue.Percent(value);
}
public static YogaValue Px(this int value)
{
return YogaValue.Pixel(value);
}
}
}

View File

@@ -1,14 +1,17 @@
/**
* Copyright (c) 2014, Facebook, Inc.
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSPositionType {
RELATIVE,
ABSOLUTE,
namespace Facebook.Yoga
{
public enum YogaWrap
{
NoWrap,
Wrap,
}
}

View File

@@ -0,0 +1,15 @@
{
"language": "en",
"version": "3.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"System.Runtime.Handles": "4.3.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{A24B3BA6-3143-4FFF-B8B8-1EDF166F5F4A}</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<Import Project="Facebook.YogaKit.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>{A24B3BA6-3143-4FFF-B8B8-1EDF166F5F4A}</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Facebook.YogaKit</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)YogaLayout.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IYogaLayout.cs" />
<Compile Include="$(MSBuildThisFileDirectory)YogaKit.cs" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,85 @@
using System;
using System.Drawing;
using Facebook.Yoga;
namespace Facebook.YogaKit
{
public interface IYogaLayout : IDisposable
{
bool IsEnabled { get; set; }
bool IsIncludeInLayout { get; set; }
//YogaDirection Direction { get; set; }
YogaFlexDirection FlexDirection { get; set; }
YogaJustify JustifyContent { get; set; }
YogaAlign AlignContent { get; set; }
YogaAlign AlignSelf { get; set; }
YogaAlign AlignItems { get; set; }
YogaPositionType Position { get; set; }
YogaWrap FlexWrap { get; set; }
YogaOverflow Overflow { get; set; }
float FlexGrow { get; set; }
float FlexShrink { get; set; }
float FlexBasis { get; set; }
float Left { get; set; }
float Top { get; set; }
float Right { get; set; }
float Bottom { get; set; }
float Start { get; set; }
float End { get; set; }
float MarginLeft { get; set; }
float MarginTop { get; set; }
float MarginRight { get; set; }
float MarginBottom { get; set; }
float MarginStart { get; set; }
float MarginEnd { get; set; }
float MarginHorizontal { get; set; }
float MarginVertical { get; set; }
float Margin { get; set; }
float PaddingLeft { get; set; }
float PaddingTop { get; set; }
float PaddingRight { get; set; }
float PaddingBottom { get; set; }
float PaddingStart { get; set; }
float PaddingEnd { get; set; }
float PaddingHorizontal { get; set; }
float PaddingVertical { get; set; }
float Padding { get; set; }
float BorderLeftWidth { get; set; }
float BorderTopWidth { get; set; }
float BorderRightWidth { get; set; }
float BorderBottomWidth { get; set; }
float BorderStartWidth { get; set; }
float BorderEndWidth { get; set; }
float BorderWidth { get; set; }
float Width { get; set; }
float Height { get; set; }
float MinWidth { get; set; }
float MinHeight { get; set; }
float MaxWidth { get; set; }
float MaxHeight { get; set; }
// Yoga specific properties, not compatible with flexbox specification
// Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
SizeF IntrinsicSize { get; }
float AspectRatio { get; set; }
// Get the resolved direction of this node. This won't be YGDirectionInherit
YogaDirection ResolvedDirection { get; }
// Returns the number of children that are using Flexbox.
int NumberOfChildren { get; }
// Return a BOOL indiciating whether or not we this node contains any subviews that are included in Yoga's layout.
bool IsLeaf { get; }
// Perform a layout calculation and update the frames of the views in the hierarchy with the results
void ApplyLayout();
// Mark that a view's layout needs to be recalculated. Only works for leaf views.
void MarkDirty();
}
}

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
using Facebook.Yoga;
namespace Facebook.YogaKit
{
public static partial class YogaKit
{
internal static Dictionary<YogaNode, object> Bridges = new Dictionary<YogaNode, object>();
}
}

View File

@@ -0,0 +1,888 @@
using System;
using Facebook.Yoga;
using System.Collections.Generic;
using System.Drawing;
#if __IOS__
using NativeView = UIKit.UIView;
#endif
namespace Facebook.YogaKit
{
public partial class YogaLayout : IYogaLayout
{
WeakReference<NativeView> _viewRef;
YogaNode _node;
internal YogaLayout(NativeView view)
{
_viewRef = new WeakReference<NativeView>(view);
_node = new YogaNode();
YogaKit.Bridges.Add(_node, view);
IsEnabled = false;
IsIncludeInLayout = true;
}
public new void MarkDirty()
{
if (IsLeaf)
_node.MarkDirty();
}
public bool IsLeaf
{
get
{
if (IsEnabled)
{
NativeView view = null;
if (_viewRef.TryGetTarget(out view))
{
foreach (NativeView subview in GetChildren(view))
{
var layout = subview.Yoga();
if (layout.IsEnabled && layout.IsIncludeInLayout)
{
return false;
}
}
}
}
return true;
}
}
public bool IsEnabled
{
get;
set;
}
public bool IsIncludeInLayout
{
get;
set;
}
public int NumberOfChildren => _node.Count;
public YogaDirection ResolvedDirection => _node.LayoutDirection;
public YogaFlexDirection FlexDirection
{
get
{
return _node.FlexDirection;
}
set
{
_node.FlexDirection = value;
}
}
public YogaAlign AlignItems
{
get
{
return _node.AlignItems;
}
set
{
_node.AlignItems = value;
}
}
public YogaJustify JustifyContent
{
get
{
return _node.JustifyContent;
}
set
{
_node.JustifyContent = value;
}
}
public YogaAlign AlignContent
{
get
{
return _node.AlignContent;
}
set
{
_node.AlignContent = value;
}
}
public YogaAlign AlignSelf
{
get
{
return _node.AlignSelf;
}
set
{
_node.AlignSelf = value;
}
}
public YogaPositionType Position
{
get
{
return _node.PositionType;
}
set
{
_node.PositionType = value;
}
}
public YogaWrap FlexWrap
{
get
{
return _node.Wrap;
}
set
{
_node.Wrap = value;
}
}
public YogaOverflow Overflow
{
get
{
return _node.Overflow;
}
set
{
_node.Overflow = value;
}
}
public float FlexGrow
{
get
{
return _node.FlexGrow;
}
set
{
_node.FlexGrow = value;
}
}
public float FlexShrink
{
get
{
return _node.FlexShrink;
}
set
{
_node.FlexShrink = value;
}
}
public float FlexBasis
{
get
{
return (float)_node.FlexBasis.Value;
}
set
{
_node.FlexBasis = value;
}
}
public float Left
{
get
{
return _node.Left.Value;
}
set
{
_node.Left = value;
}
}
public float Top
{
get
{
return _node.Top.Value;
}
set
{
_node.Top = value;
}
}
public float Right
{
get
{
return _node.Right.Value;
}
set
{
_node.Right = value;
}
}
public float Bottom
{
get
{
return _node.Bottom.Value;
}
set
{
_node.Bottom = value;
}
}
public float Start
{
get
{
return _node.Start.Value;
}
set
{
_node.Start = value;
}
}
public float End
{
get
{
return _node.End.Value;
}
set
{
_node.End = value;
}
}
public float MarginLeft
{
get
{
return _node.MarginLeft.Value;
}
set
{
_node.MarginLeft = value;
}
}
public float MarginTop
{
get
{
return _node.MarginTop.Value;
}
set
{
_node.MarginTop = value;
}
}
public float MarginRight
{
get
{
return _node.MarginRight.Value;
}
set
{
_node.MarginRight = value;
}
}
public float MarginBottom
{
get
{
return _node.MarginBottom.Value;
}
set
{
_node.MarginBottom = value;
}
}
public float MarginStart
{
get
{
return _node.MarginStart.Value;
}
set
{
_node.MarginStart = value;
}
}
public float MarginEnd
{
get
{
return _node.MarginEnd.Value;
}
set
{
_node.MarginEnd = value;
}
}
public float MarginHorizontal
{
get
{
return _node.MarginHorizontal.Value;
}
set
{
_node.MarginHorizontal = value;
}
}
public float MarginVertical
{
get
{
return _node.MarginVertical.Value;
}
set
{
_node.MarginVertical = value;
}
}
public float Margin
{
get
{
return _node.Margin.Value;
}
set
{
_node.Margin = value;
}
}
public float PaddingLeft
{
get
{
return _node.PaddingLeft.Value;
}
set
{
_node.PaddingLeft = value;
}
}
public float PaddingTop
{
get
{
return _node.PaddingTop.Value;
}
set
{
_node.PaddingTop = value;
}
}
public float PaddingRight
{
get
{
return _node.PaddingRight.Value;
}
set
{
_node.PaddingRight = value;
}
}
public float PaddingBottom
{
get
{
return _node.PaddingBottom.Value;
}
set
{
_node.PaddingBottom = value;
}
}
public float PaddingStart
{
get
{
return _node.PaddingStart.Value;
}
set
{
_node.PaddingStart = value;
}
}
public float PaddingEnd
{
get
{
return _node.PaddingEnd.Value;
}
set
{
_node.PaddingEnd = value;
}
}
public float PaddingHorizontal
{
get
{
return _node.PaddingHorizontal.Value;
}
set
{
_node.PaddingHorizontal = value;
}
}
public float PaddingVertical
{
get
{
return _node.PaddingVertical.Value;
}
set
{
_node.PaddingHorizontal = value;
}
}
public float Padding
{
get
{
return _node.Padding.Value;
}
set
{
_node.Padding = value;
}
}
public float BorderLeftWidth
{
get
{
return _node.BorderLeftWidth;
}
set
{
_node.BorderLeftWidth = value;
}
}
public float BorderTopWidth
{
get
{
return _node.BorderTopWidth;
}
set
{
_node.BorderTopWidth = value;
}
}
public float BorderRightWidth
{
get
{
return _node.BorderRightWidth;
}
set
{
_node.BorderRightWidth = value;
}
}
public float BorderBottomWidth
{
get
{
return _node.BorderBottomWidth;
}
set
{
_node.BorderBottomWidth = value;
}
}
public float BorderStartWidth
{
get
{
return _node.BorderStartWidth;
}
set
{
_node.BorderStartWidth = value;
}
}
public float BorderEndWidth
{
get
{
return _node.BorderEndWidth;
}
set
{
_node.BorderEndWidth = value;
}
}
public float BorderWidth
{
get
{
return _node.BorderWidth;
}
set
{
_node.BorderWidth = value;
}
}
public float Height
{
get
{
return _node.Height.Value;
}
set
{
_node.Height = value;
}
}
public float Width
{
get
{
return _node.Width.Value;
}
set
{
_node.Width = value;
}
}
public float MinWidth
{
get
{
return _node.MinWidth.Value;
}
set
{
_node.MinWidth = value;
}
}
public float MinHeight
{
get
{
return _node.MinHeight.Value;
}
set
{
_node.MinHeight = value;
}
}
public float MaxWidth
{
get
{
return _node.MaxWidth.Value;
}
set
{
_node.MaxWidth = value;
}
}
public float MaxHeight
{
get
{
return _node.MaxHeight.Value;
}
set
{
_node.MaxHeight = value;
}
}
public float AspectRatio
{
get
{
return _node.StyleAspectRatio;
}
set
{
_node.StyleAspectRatio = value;
}
}
public void ApplyLayout()
{
NativeView view = null;
if (_viewRef.TryGetTarget(out view))
{
float width = 0;
float height = 0;
GetWidthHeightOfNativeView(view, out width, out height);
CalculateLayoutWithSize(this, width, height);
ApplyLayoutToViewHierarchy(view);
}
}
public SizeF IntrinsicSize
{
get
{
return CalculateLayoutWithSize(this, float.NaN, float.NaN);
}
}
SizeF CalculateLayoutWithSize(YogaLayout layout, float width, float height)
{
//TODO : Check thread access
if (!layout.IsEnabled)
{
System.Diagnostics.Debug.WriteLine("Doesn't use Yoga");
}
NativeView view = null;
if (_viewRef.TryGetTarget(out view))
{
AttachNodesFromViewHierachy(view);
}
var node = layout._node;
node.Width = width;
node.Height = height;
node.CalculateLayout();
return new SizeF { Width = node.LayoutWidth, Height = node.LayoutHeight };
}
static YogaSize MeasureView(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode)
{
var constrainedWidth = (widthMode == YogaMeasureMode.Undefined) ? float.MaxValue : width;
var constrainedHeight = (heightMode == YogaMeasureMode.Undefined) ? float.MaxValue : height;
NativeView view = null;
if (YogaKit.Bridges.ContainsKey(node))
view = YogaKit.Bridges[node] as NativeView;
float sizeThatFitsWidth = 0;
float sizeThatFitsHeight = 0;
MeasureNativeView(view, constrainedWidth, constrainedHeight, out sizeThatFitsWidth, out sizeThatFitsHeight);
var finalWidth = SanitizeMeasurement(constrainedWidth, sizeThatFitsWidth, widthMode);
var finalHeight = SanitizeMeasurement(constrainedHeight, sizeThatFitsHeight, heightMode);
return MeasureOutput.Make(finalWidth, finalHeight);
}
static float SanitizeMeasurement(float constrainedSize, float measuredSize, YogaMeasureMode measureMode)
{
float result;
if (measureMode == YogaMeasureMode.Exactly)
{
result = (float)constrainedSize;
}
else if (measureMode == YogaMeasureMode.AtMost)
{
result = (float)Math.Min(constrainedSize, measuredSize);
}
else {
result = (float)measuredSize;
}
return result;
}
static bool NodeHasExactSameChildren(YogaNode node, NativeView[] subviews)
{
if (node.Count != subviews.Length)
return false;
for (int i = 0; i < subviews.Length; i++)
{
YogaLayout yoga = subviews[i].Yoga() as YogaLayout;
if (node[i] != yoga._node)
{
return false;
}
}
return true;
}
static void AttachNodesFromViewHierachy(NativeView view)
{
YogaLayout yoga = view.Yoga() as YogaLayout;
var node = yoga._node;
// Only leaf nodes should have a measure function
if (yoga.IsLeaf)
{
RemoveAllChildren(node);
node.SetMeasureFunction(MeasureView);
}
else
{
node.SetMeasureFunction(null);
// Create a list of all the subviews that we are going to use for layout.
var subviewsToInclude = new List<NativeView>();
foreach (var subview in view.Subviews)
{
if (subview.Yoga().IsIncludeInLayout)
{
subviewsToInclude.Add(subview);
}
}
if (!NodeHasExactSameChildren(node, subviewsToInclude.ToArray()))
{
RemoveAllChildren(node);
for (int i = 0; i < subviewsToInclude.Count; i++)
{
YogaLayout yogaSubview = subviewsToInclude[i].Yoga() as YogaLayout;
node.Insert(i, yogaSubview._node);
}
}
foreach (var subView in subviewsToInclude)
{
AttachNodesFromViewHierachy(subView);
}
}
}
static void RemoveAllChildren(YogaNode node)
{
if (node == null)
return;
if (node.Count > 0)
{
node.Clear();
}
}
static double RoundPixelValue(float value)
{
float scale = NativePixelScale;
return Math.Round(value * scale) / scale;
}
static void ApplyLayoutToViewHierarchy(NativeView view)
{
//TODO : "Framesetting should only be done on the main thread."
YogaLayout yoga = view.Yoga() as YogaLayout;
if (!yoga.IsIncludeInLayout)
return;
var node = yoga._node;
ApplyLayoutToNativeView(view, node);
if (!yoga.IsLeaf)
{
for (int i = 0; i < view.Subviews.Length; i++)
{
ApplyLayoutToViewHierarchy(view.Subviews[i]);
}
}
}
}
}

2
csharp/Mac/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
libyoga.dylib
*.userprefs

View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
using AppKit;
using Foundation;
using ObjCRuntime;
using CoreGraphics;
namespace Facebook.Yoga.Mac
{
// Xamarin.Mac binding projects allow you to include native libraries inside C# DLLs for easy consumption
// later. However, the binding project build files currently assume you are binding some objective-c API
// and that you need an ApiDefinition.cs for that. yoga is all C APIs, so just include this "blank" file so
// the dylib gets packaged
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CompileDependsOn>NativeLibrary;$(CompileDependsOn)</CompileDependsOn>
</PropertyGroup>
<Target Name="NativeLibrary" Outputs="$(ProjectDir)libyoga.dylib">
<Exec WorkingDirectory="$(ProjectDir)" Command="$(ProjectDir)buck-build.sh //csharp:yoganet#default,shared" />
<Copy SourceFiles="$(ProjectDir)..\..\buck-out\gen\csharp\yoganet#default,shared\libyoga.dylib" DestinationFiles="$(ProjectDir)libyoga.dylib" SkipUnchangedFiles="true" />
</Target>
</Project>

View File

@@ -0,0 +1,30 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
using AppKit;
using Foundation;
namespace Facebook.Yoga.Mac.Sample
{
[Register("AppDelegate")]
public class AppDelegate : NSApplicationDelegate
{
public AppDelegate()
{
}
public override void DidFinishLaunching(NSNotification notification)
{
}
public override void WillTerminate(NSNotification notification)
{
// Insert code here to tear down your application
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{64E0AB97-A904-4607-A535-EEA5A966C09E}</ProjectGuid>
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>Facebook.Yoga.Mac.Sample</RootNamespace>
<AssemblyName>Facebook.Yoga.Mac.Sample</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<Profiling>true</Profiling>
<HttpClientHandler>HttpClientHandler</HttpClientHandler>
<TlsProvider>Default</TlsProvider>
<LinkMode>None</LinkMode>
<XamMacArch>x86_64</XamMacArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>true</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<LinkMode>SdkOnly</LinkMode>
<HttpClientHandler>HttpClientHandler</HttpClientHandler>
<TlsProvider>Default</TlsProvider>
<XamMacArch></XamMacArch>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="ViewController.cs" />
<Compile Include="ViewController.designer.cs">
<DependentUpon>ViewController.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Facebook.Yoga.Mac.csproj">
<Project>{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}</Project>
<Name>Facebook.Yoga.Mac</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Facebook.Yoga.Mac.Sample</string>
<key>CFBundleIdentifier</key>
<string>com.facebook.facebook-yoga-mac-sample</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
<string>${AuthorCopyright}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
</dict>
</plist>

View File

@@ -0,0 +1,21 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
using AppKit;
namespace Facebook.Yoga.Mac.Sample
{
static class MainClass
{
static void Main(string[] args)
{
NSApplication.Init();
NSApplication.Main(args);
}
}
}

View File

@@ -0,0 +1,681 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="6198" systemVersion="14A297b" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6198" />
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="Facebook.Yoga.Mac.Sample" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Facebook.Yoga.Mac.Sample" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About Facebook.Yoga.Mac.Sample" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH" />
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW" />
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ" />
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5" />
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R" />
<menuItem title="Hide Facebook.Yoga.Mac.Sample" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68" />
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES" />
<connections>
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT" />
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT" />
<menuItem title="Quit Facebook.Yoga.Mac.Sample" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="File" id="dMs-cI-mzQ">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="File" id="bib-Uj-vzu">
<items>
<menuItem title="New" keyEquivalent="n" id="Was-JA-tGl">
<connections>
<action selector="newDocument:" target="Ady-hI-5gd" id="4Si-XN-c54" />
</connections>
</menuItem>
<menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9">
<connections>
<action selector="openDocument:" target="Ady-hI-5gd" id="bVn-NM-KNZ" />
</connections>
</menuItem>
<menuItem title="Open Recent" id="tXI-mr-wws">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
<items>
<menuItem title="Clear Menu" id="vNY-rz-j42">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="clearRecentDocuments:" target="Ady-hI-5gd" id="Daa-9d-B3U" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="m54-Is-iLE" />
<menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
<connections>
<action selector="performClose:" target="Ady-hI-5gd" id="HmO-Ls-i7Q" />
</connections>
</menuItem>
<menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV">
<connections>
<action selector="saveDocument:" target="Ady-hI-5gd" id="teZ-XB-qJY" />
</connections>
</menuItem>
<menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A">
<connections>
<action selector="saveDocumentAs:" target="Ady-hI-5gd" id="mDf-zr-I0C" />
</connections>
</menuItem>
<menuItem title="Revert to Saved" id="KaW-ft-85H">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="revertDocumentToSaved:" target="Ady-hI-5gd" id="iJ3-Pv-kwq" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="aJh-i4-bef" />
<menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES" />
<connections>
<action selector="runPageLayout:" target="Ady-hI-5gd" id="Din-rz-gC5" />
</connections>
</menuItem>
<menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS">
<connections>
<action selector="print:" target="Ady-hI-5gd" id="qaZ-4w-aoO" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="5QF-Oa-p0T">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
<items>
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
<connections>
<action selector="undo:" target="Ady-hI-5gd" id="M6e-cu-g7V" />
</connections>
</menuItem>
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
<connections>
<action selector="redo:" target="Ady-hI-5gd" id="oIA-Rs-6OD" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz" />
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
<connections>
<action selector="cut:" target="Ady-hI-5gd" id="YJe-68-I9s" />
</connections>
</menuItem>
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
<connections>
<action selector="copy:" target="Ady-hI-5gd" id="G1f-GL-Joy" />
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
<connections>
<action selector="paste:" target="Ady-hI-5gd" id="UvS-8e-Qdg" />
</connections>
</menuItem>
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES" />
<connections>
<action selector="pasteAsPlainText:" target="Ady-hI-5gd" id="cEh-KX-wJQ" />
</connections>
</menuItem>
<menuItem title="Delete" id="pa3-QI-u2k">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="delete:" target="Ady-hI-5gd" id="0Mk-Ml-PaM" />
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
<connections>
<action selector="selectAll:" target="Ady-hI-5gd" id="VNm-Mi-diN" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2" />
<menuItem title="Find" id="4EN-yA-p0u">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Find" id="1b7-l0-nxx">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="cD7-Qs-BN4" />
</connections>
</menuItem>
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES" />
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="WD3-Gg-5AJ" />
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="NDo-RZ-v9R" />
</connections>
</menuItem>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="HOh-sY-3ay" />
</connections>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="U76-nv-p5D" />
</connections>
</menuItem>
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
<connections>
<action selector="centerSelectionInVisibleArea:" target="Ady-hI-5gd" id="IOG-6D-g5B" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
<items>
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
<connections>
<action selector="showGuessPanel:" target="Ady-hI-5gd" id="vFj-Ks-hy3" />
</connections>
</menuItem>
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
<connections>
<action selector="checkSpelling:" target="Ady-hI-5gd" id="fz7-VC-reM" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="bNw-od-mp5" />
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleContinuousSpellChecking:" target="Ady-hI-5gd" id="7w6-Qz-0kB" />
</connections>
</menuItem>
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleGrammarChecking:" target="Ady-hI-5gd" id="muD-Qn-j4w" />
</connections>
</menuItem>
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleAutomaticSpellingCorrection:" target="Ady-hI-5gd" id="2lM-Qi-WAP" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Substitutions" id="9ic-FL-obx">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
<items>
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="orderFrontSubstitutionsPanel:" target="Ady-hI-5gd" id="oku-mr-iSq" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO" />
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleSmartInsertDelete:" target="Ady-hI-5gd" id="3IJ-Se-DZD" />
</connections>
</menuItem>
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleAutomaticQuoteSubstitution:" target="Ady-hI-5gd" id="ptq-xd-QOA" />
</connections>
</menuItem>
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleAutomaticDashSubstitution:" target="Ady-hI-5gd" id="oCt-pO-9gS" />
</connections>
</menuItem>
<menuItem title="Smart Links" id="cwL-P1-jid">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleAutomaticLinkDetection:" target="Ady-hI-5gd" id="Gip-E3-Fov" />
</connections>
</menuItem>
<menuItem title="Data Detectors" id="tRr-pd-1PS">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleAutomaticDataDetection:" target="Ady-hI-5gd" id="R1I-Nq-Kbl" />
</connections>
</menuItem>
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleAutomaticTextReplacement:" target="Ady-hI-5gd" id="DvP-Fe-Py6" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Transformations" id="2oI-Rn-ZJC">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
<items>
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="uppercaseWord:" target="Ady-hI-5gd" id="sPh-Tk-edu" />
</connections>
</menuItem>
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="lowercaseWord:" target="Ady-hI-5gd" id="iUZ-b5-hil" />
</connections>
</menuItem>
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="capitalizeWord:" target="Ady-hI-5gd" id="26H-TL-nsh" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Speech" id="xrE-MZ-jX0">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
<items>
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="startSpeaking:" target="Ady-hI-5gd" id="654-Ng-kyl" />
</connections>
</menuItem>
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="stopSpeaking:" target="Ady-hI-5gd" id="dX8-6p-jy9" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Format" id="jxT-CU-nIS">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Format" id="GEO-Iw-cKr">
<items>
<menuItem title="Font" id="Gi5-1S-RQB">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq">
<items>
<menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq" />
<menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27" />
<menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq" />
<menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S">
<connections>
<action selector="underline:" target="Ady-hI-5gd" id="FYS-2b-JAY" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="5gT-KC-WSO" />
<menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL" />
<menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST" />
<menuItem isSeparatorItem="YES" id="kx3-Dk-x3B" />
<menuItem title="Kern" id="jBQ-r6-VK2">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Kern" id="tlD-Oa-oAM">
<items>
<menuItem title="Use Default" id="GUa-eO-cwY">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="useStandardKerning:" target="Ady-hI-5gd" id="6dk-9l-Ckg" />
</connections>
</menuItem>
<menuItem title="Use None" id="cDB-IK-hbR">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="turnOffKerning:" target="Ady-hI-5gd" id="U8a-gz-Maa" />
</connections>
</menuItem>
<menuItem title="Tighten" id="46P-cB-AYj">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="tightenKerning:" target="Ady-hI-5gd" id="hr7-Nz-8ro" />
</connections>
</menuItem>
<menuItem title="Loosen" id="ogc-rX-tC1">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="loosenKerning:" target="Ady-hI-5gd" id="8i4-f9-FKE" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Ligatures" id="o6e-r0-MWq">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Ligatures" id="w0m-vy-SC9">
<items>
<menuItem title="Use Default" id="agt-UL-0e3">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="useStandardLigatures:" target="Ady-hI-5gd" id="7uR-wd-Dx6" />
</connections>
</menuItem>
<menuItem title="Use None" id="J7y-lM-qPV">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="turnOffLigatures:" target="Ady-hI-5gd" id="iX2-gA-Ilz" />
</connections>
</menuItem>
<menuItem title="Use All" id="xQD-1f-W4t">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="useAllLigatures:" target="Ady-hI-5gd" id="KcB-kA-TuK" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Baseline" id="OaQ-X3-Vso">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Baseline" id="ijk-EB-dga">
<items>
<menuItem title="Use Default" id="3Om-Ey-2VK">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="unscript:" target="Ady-hI-5gd" id="0vZ-95-Ywn" />
</connections>
</menuItem>
<menuItem title="Superscript" id="Rqc-34-cIF">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="superscript:" target="Ady-hI-5gd" id="3qV-fo-wpU" />
</connections>
</menuItem>
<menuItem title="Subscript" id="I0S-gh-46l">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="subscript:" target="Ady-hI-5gd" id="Q6W-4W-IGz" />
</connections>
</menuItem>
<menuItem title="Raise" id="2h7-ER-AoG">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="raiseBaseline:" target="Ady-hI-5gd" id="4sk-31-7Q9" />
</connections>
</menuItem>
<menuItem title="Lower" id="1tx-W0-xDw">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="lowerBaseline:" target="Ady-hI-5gd" id="OF1-bc-KW4" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="Ndw-q3-faq" />
<menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk">
<connections>
<action selector="orderFrontColorPanel:" target="Ady-hI-5gd" id="mSX-Xz-DV3" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="iMs-zA-UFJ" />
<menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES" />
<connections>
<action selector="copyFont:" target="Ady-hI-5gd" id="GJO-xA-L4q" />
</connections>
</menuItem>
<menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES" />
<connections>
<action selector="pasteFont:" target="Ady-hI-5gd" id="JfD-CL-leO" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Text" id="Fal-I4-PZk">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Text" id="d9c-me-L2H">
<items>
<menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1">
<connections>
<action selector="alignLeft:" target="Ady-hI-5gd" id="zUv-R1-uAa" />
</connections>
</menuItem>
<menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb">
<connections>
<action selector="alignCenter:" target="Ady-hI-5gd" id="spX-mk-kcS" />
</connections>
</menuItem>
<menuItem title="Justify" id="J5U-5w-g23">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="alignJustified:" target="Ady-hI-5gd" id="ljL-7U-jND" />
</connections>
</menuItem>
<menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4">
<connections>
<action selector="alignRight:" target="Ady-hI-5gd" id="r48-bG-YeY" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="4s2-GY-VfK" />
<menuItem title="Writing Direction" id="H1b-Si-o9J">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd">
<items>
<menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
<modifierMask key="keyEquivalentModifierMask" />
</menuItem>
<menuItem id="YGs-j5-SAR">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="makeBaseWritingDirectionNatural:" target="Ady-hI-5gd" id="qtV-5e-UBP" />
</connections>
</menuItem>
<menuItem id="Lbh-J2-qVU">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="makeBaseWritingDirectionLeftToRight:" target="Ady-hI-5gd" id="S0X-9S-QSf" />
</connections>
</menuItem>
<menuItem id="jFq-tB-4Kx">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="makeBaseWritingDirectionRightToLeft:" target="Ady-hI-5gd" id="5fk-qB-AqJ" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="swp-gr-a21" />
<menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
<modifierMask key="keyEquivalentModifierMask" />
</menuItem>
<menuItem id="Nop-cj-93Q">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="makeTextWritingDirectionNatural:" target="Ady-hI-5gd" id="lPI-Se-ZHp" />
</connections>
</menuItem>
<menuItem id="BgM-ve-c93">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="makeTextWritingDirectionLeftToRight:" target="Ady-hI-5gd" id="caW-Bv-w94" />
</connections>
</menuItem>
<menuItem id="RB4-Sm-HuC">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="makeTextWritingDirectionRightToLeft:" target="Ady-hI-5gd" id="EXD-6r-ZUu" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="fKy-g9-1gm" />
<menuItem title="Show Ruler" id="vLm-3I-IUL">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="toggleRuler:" target="Ady-hI-5gd" id="FOx-HJ-KwY" />
</connections>
</menuItem>
<menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES" />
<connections>
<action selector="copyRuler:" target="Ady-hI-5gd" id="71i-fW-3W2" />
</connections>
</menuItem>
<menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES" />
<connections>
<action selector="pasteRuler:" target="Ady-hI-5gd" id="cSh-wd-qM2" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="H8h-7b-M4v">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES" />
<connections>
<action selector="toggleToolbarShown:" target="Ady-hI-5gd" id="BXY-wc-z0C" />
</connections>
</menuItem>
<menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="runToolbarCustomizationPalette:" target="Ady-hI-5gd" id="pQI-g3-MTW" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe" />
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs" />
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM" />
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask" />
<connections>
<action selector="arrangeInFront:" target="Ady-hI-5gd" id="DRN-fu-gQh" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask" />
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="Facebook.Yoga.Mac.Sample Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="Ady-hI-5gd" id="y7X-2Q-9no" />
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m" />
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="" />
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder" />
</objects>
<point key="canvasLocation" x="75" y="0.0" />
</scene>
<!--Window Controller - Window-->
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" />
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES" />
<rect key="contentRect" x="196" y="240" width="480" height="270" />
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027" />
</window>
<connections>
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM" />
</connections>
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder" />
</objects>
<point key="canvasLocation" x="75" y="250" />
</scene>
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270" />
<autoresizingMask key="autoresizingMask" />
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder" />
</objects>
<point key="canvasLocation" x="75" y="655" />
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,137 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
//#define DEBUG_LAYOUT
using System;
using AppKit;
using Foundation;
using CoreGraphics;
namespace Facebook.Yoga.Mac.Sample
{
public static class NSViewYogaExtensions
{
public static void ApplyYogaLayout (this NSView view, YogaNode n, bool root = true)
{
#if DEBUG_LAYOUT
Console.WriteLine ($"ApplyYogaLayout {view.ToolTip}, {n.LayoutX}, {n.LayoutY}, {n.LayoutWidth}, {n.LayoutHeight}");
#endif
// A bit of gross special casing
// This really should mostly go away if/when the UIView+Yoga.m magic gets ported to AppKit
if (root)
view.Frame = new CGRect (n.LayoutX, n.LayoutY, n.LayoutWidth, n.LayoutHeight);
#if DEBUG_LAYOUT
Console.WriteLine ($"Setting {view.ToolTip} frame to {view.Frame}");
#endif
// This assumes your YogaNode and NSView children were inserted in same order
for (int i = 0; i < n.Count; ++i) {
YogaNode childNode = n[i];
// Cocoa coord space is from bottom left not top left
view.Subviews[i].Frame = new CGRect (childNode.LayoutX, n.LayoutHeight - childNode.LayoutY - childNode.LayoutHeight, childNode.LayoutWidth, childNode.LayoutHeight);
#if DEBUG_LAYOUT
Console.WriteLine ($"Setting {view.Subviews[i].ToolTip} frame to {view.Subviews[i].Frame}");
#endif
if (childNode.Count > 0){
#if DEBUG_LAYOUT
Console.WriteLine ($"Calling ApplyYogaLayout recursively on {view.Subviews[i].ToolTip}");
#endif
ApplyYogaLayout (view.Subviews[i], childNode, false);
}
}
}
}
public partial class ViewController : NSViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad ();
NSImage image = NSImage.ImageNamed (NSImageName.TrashFull);
NSView root = CreateViewHierarchy (image);
var rootNode = CalculateLayout (View.Frame, image.Size);
root.ApplyYogaLayout (rootNode);
View.AddSubview (root);
}
static NSView CreateViewHierarchy (NSImage image)
{
var root = new NSView () {
WantsLayer = true,
ToolTip = "Root"
};
root.Layer.BackgroundColor = NSColor.Red.CGColor;
NSView child1 = new NSView () {
WantsLayer = true,
ToolTip = "Child 1"
};
child1.Layer.BackgroundColor = NSColor.Blue.CGColor;
NSView child2 = new NSView () {
WantsLayer = true,
ToolTip = "Child 2"
};
child2.Layer.BackgroundColor = NSColor.Green.CGColor;
NSView child3 = new NSView () {
WantsLayer = true,
ToolTip = "Child 3"
};
child3.Layer.BackgroundColor = NSColor.Yellow.CGColor;
root.AddSubview (child1);
root.AddSubview (child2);
child2.AddSubview (child3);
return root;
}
static YogaNode CalculateLayout (CGRect rootFrame, CGSize imageSize)
{
var rootNode = new YogaNode () {
Width = (float)rootFrame.Width,
Height = (float)rootFrame.Height,
AlignItems = YogaAlign.Center,
JustifyContent = YogaJustify.Center
};
var child1Node = new YogaNode () {
Width = 100,
Height = 100
};
var child2Node = new YogaNode () {
Width = 200,
Height = 100
};
var child3Node = new YogaNode () {
Width = 100,
Height = 100
};
rootNode.Insert (0, child1Node);
rootNode.Insert (1, child2Node);
child2Node.Insert (0, child3Node);
rootNode.CalculateLayout ();
return rootNode;
}
}
}

View File

@@ -0,0 +1,18 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio to store outlets and
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using Foundation;
namespace Facebook.Yoga.Mac.Sample
{
[Register("ViewController")]
partial class ViewController
{
void ReleaseDesignerOutlets()
{
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9FCB6149-DFA8-4EAA-B4DB-2E91A5D8FF77}</ProjectGuid>
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>Facebook.Yoga.Mac.Tests</RootNamespace>
<AssemblyName>Facebook.Yoga.Mac.Tests</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<Profiling>true</Profiling>
<HttpClientHandler>HttpClientHandler</HttpClientHandler>
<TlsProvider>Default</TlsProvider>
<LinkMode>None</LinkMode>
<XamMacArch>x86_64</XamMacArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>true</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<LinkMode>SdkOnly</LinkMode>
<HttpClientHandler>HttpClientHandler</HttpClientHandler>
<TlsProvider>Default</TlsProvider>
<XamMacArch></XamMacArch>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Facebook.Yoga.Mac.csproj">
<Project>{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}</Project>
<Name>Facebook.Yoga.Mac</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems" Label="Shared" Condition="Exists('..\..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Facebook.Yoga.Mac.Tests</string>
<key>CFBundleIdentifier</key>
<string>com.facebook.facebook-yoga-mac-tests</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
<string>${AuthorCopyright}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
</dict>
</plist>

View File

@@ -0,0 +1,20 @@
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
*/
using System;
using System.Reflection;
namespace Facebook.Yoga.Mac.Tests
{
static class MainClass
{
static void Main(string[] args)
{
}
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.4" targetFramework="xamarinmac20" />
</packages>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}</ProjectGuid>
<ProjectTypeGuids>{810C163F-4746-4721-8B8E-88A3673A62EA};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Facebook.Yoga.Mac</RootNamespace>
<AssemblyName>Facebook.Yoga.Mac</AssemblyName>
<MacResourcePrefix>Resources</MacResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>__UNIFIED__;DEBUG;MONOMAC</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants>__UNIFIED__;MONOMAC</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<None Include="CustomBuildAction.targets" />
</ItemGroup>
<ItemGroup>
<NativeReference Include="libyoga.dylib">
<Kind>Dynamic</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
<Import Project="..\Facebook.Yoga\Facebook.Yoga.Shared.projitems" Label="Shared" Condition="Exists('..\Facebook.Yoga\Facebook.Yoga.Shared.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.ObjcBinding.CSharp.targets" />
<Import Project="CustomBuildAction.targets" />
</Project>

View File

@@ -0,0 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Mac", "Facebook.Yoga.Mac.csproj", "{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared", "..\Facebook.Yoga\Facebook.Yoga.Shared.shproj", "{91C42D32-291D-4B72-90B4-551663D60B8B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Mac.Sample", "Facebook.Yoga.Mac.Sample\Facebook.Yoga.Mac.Sample.csproj", "{64E0AB97-A904-4607-A535-EEA5A966C09E}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared.Tests", "..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.shproj", "{4EDC82D9-A201-4831-8FE0-98F468F8E4AE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9352A9B6-F93B-45DD-8BCE-4696A62B3789}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Mac.Tests", "Facebook.Yoga.Mac.Tests\Facebook.Yoga.Mac.Tests.csproj", "{9FCB6149-DFA8-4EAA-B4DB-2E91A5D8FF77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Release|Any CPU.Build.0 = Release|Any CPU
{64E0AB97-A904-4607-A535-EEA5A966C09E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64E0AB97-A904-4607-A535-EEA5A966C09E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64E0AB97-A904-4607-A535-EEA5A966C09E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64E0AB97-A904-4607-A535-EEA5A966C09E}.Release|Any CPU.Build.0 = Release|Any CPU
{9FCB6149-DFA8-4EAA-B4DB-2E91A5D8FF77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FCB6149-DFA8-4EAA-B4DB-2E91A5D8FF77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FCB6149-DFA8-4EAA-B4DB-2E91A5D8FF77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FCB6149-DFA8-4EAA-B4DB-2E91A5D8FF77}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{91C42D32-291D-4B72-90B4-551663D60B8B} = {9352A9B6-F93B-45DD-8BCE-4696A62B3789}
{4EDC82D9-A201-4831-8FE0-98F468F8E4AE} = {9352A9B6-F93B-45DD-8BCE-4696A62B3789}
EndGlobalSection
EndGlobal

6
csharp/Mac/buck-build.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
if buck --version >/dev/null 2>&1; then true; else
echo "SKIP: Need to install buck https://buckbuild.com/setup/getting_started.html"
exit 0
fi
buck build $1

3
csharp/Unity/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
Yoga
yoga.dll
yoga.unitypackage

64
csharp/Unity/pack.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/sh
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
set -e
cd "$( dirname "$0" )"
if [ \! -f yoga.dll ]; then
echo "Launch win.bat on Windows and copy yoga.dll to here"
exit 1
fi
function build {
buck build $1
echo "$root/`buck targets --show-output $1|tail -1|awk '{print $2}'`"
}
function copy {
mkdir -p $3
cp $1 $3/$2
}
rm -rf Yoga yoga.unitypackage
root=`buck root|tail -f`
mac=$(build '//csharp:yoganet#default,shared')
armv7=$(build '//csharp:yoganet#android-armv7,shared')
ios=$(build '//csharp:yoganet-ios')
win=yoga.dll
Unity -quit -batchMode -createProject Yoga
copy $win ${win##*/} Yoga/Assets/Facebook.Yoga/Plugins/x86_64
copy $mac yoga Yoga/Assets/Facebook.Yoga/Plugins/x86_64/yoga.bundle/Contents/MacOS
armv7path=Assets/Plugins/Android/libs/armeabi-v7a
copy $armv7 ${armv7##*/} Yoga/$armv7path
iospath=Assets/Plugins/iOS
copy $ios ${ios##*/} Yoga/$iospath
libs="$armv7path/${armv7##*/} $iospath/${ios##*/}"
scripts=Yoga/Assets/Facebook.Yoga/Scripts/Facebook.Yoga
mkdir -p $scripts
(cd ../Facebook.Yoga; tar cf - *.cs)|tar -C $scripts -xf -
tests=Yoga/Assets/Facebook.Yoga/Editor/Facebook.Yoga.Tests
mkdir -p $tests
(cd ../tests/Facebook.Yoga; tar cf - *.cs)|tar -C $tests -xf -
function onerror {
local xml=Yoga/EditorTestResults.xml
if [ -f $xml ]; then cat $xml|grep 'success="False"'; fi
}
trap onerror EXIT
Unity -quit -batchMode -projectPath `pwd`/Yoga -runEditorTests
pkg="`pwd`/yoga.unitypackage"
Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs $pkg
echo "Success: $pkg"

2
csharp/Unity/win.bat Executable file
View File

@@ -0,0 +1,2 @@
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" ..\Yoga\Yoga.vcxproj /p:configuration=Release /property:Platform=x64
xcopy "..\Yoga\bin\x64\Release\yoga.dll" %~dp0 /s /d /y

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NativeRootPath>$(SolutionDir)..\Yoga\bin\</NativeRootPath>
<NativeX86Path>$(NativeRootPath)x86\</NativeX86Path>
<NativeX64Path>$(NativeRootPath)x64\</NativeX64Path>
<NativeARMPath>$(NativeRootPath)ARM\</NativeARMPath>
<NativeDLLMoniker>Yoga</NativeDLLMoniker>
<CurrentPlatform Condition="$(PROCESSOR_ARCHITECTURE) =='AMD64' or $(PROCESSOR_ARCHITECTURE) == 'IA64' or $(PROCESSOR_ARCHITEW6432) == 'AMD64'">AMD64</CurrentPlatform>
<CurrentPlatform Condition="$(PROCESSOR_ARCHITECTURE) =='ARM'">ARM</CurrentPlatform>
</PropertyGroup>
<Choose>
<When Condition="$(Platform) == 'AnyCPU'">
<Choose>
<When Condition="$(Prefer32Bit) == 'true'">
<ItemGroup Condition="$(CurrentPlatform) == 'x86' Or $(CurrentPlatform) == 'AMD64'">
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition="$(CurrentPlatform) == 'ARM'">
<Content Include="$(NativeARMPath)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeARMPath)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup Condition="$(CurrentPlatform) == 'x86'">
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition="$(CurrentPlatform) == 'AMD64'">
<Content Include="$(NativeX64Path)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeX64Path)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition="$(CurrentPlatform) == 'ARM'">
<Content Include="$(NativeARMPath)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeARMPath)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</Otherwise>
</Choose>
</When>
<Otherwise>
<ItemGroup Condition="$(PlatformTarget) == 'x86'">
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition="$(PlatformTarget) == 'x64'">
<Content Include="$(NativeX64Path)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeX64Path)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
<ItemGroup Condition="$(PlatformTarget) == 'ARM'">
<!--<Content Include="$(NativeARMPath)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeARMPath)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>-->
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).dll">
<Link>$(NativeDLLMoniker).dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
<Content Include="$(NativeX86Path)$(Configuration)\$(NativeDLLMoniker).pdb">
<Link>$(NativeDLLMoniker).pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</Otherwise>
</Choose>
</Project>

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Facebook.Yoga</RootNamespace>
<AssemblyName>Facebook.Yoga.Desktop.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Facebook.Yoga\Facebook.Yoga.csproj">
<Project>{3aace384-fdec-4d91-a3b2-eeb21b46c9ad}</Project>
<Name>Facebook.Yoga</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\..\tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)Build\Facebook.Yoga.NativeInterop.targets" Condition="Exists('$(SolutionDir)Build\Facebook.Yoga.NativeInterop.targets')" Label="ImportNativeInteropTargets" />
<Target Name="EnsureNativeInteropImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references a native interop target that is missing. The missing build target is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)Build\Facebook.Yoga.NativeInterop.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)Build\Facebook.Yoga.NativeInterop.targets'))" />
</Target>
</Project>

Some files were not shown because too many files have changed in this diff Show More