Compare commits

..

552 Commits

Author SHA1 Message Date
David Aurelio
5bb2265083 Move native methods to a single class
Summary:
@public

Moving all native methods in a single class provides the benefit of not having to load native bindings eagerly when just creating config objects in the startup paths, or setting Java-only values on them.
Loading native bindings triggers additional class loads (`YogaConfig` / `YogaNode`), and can lead to problems in multi-dex scenarions.

Reviewed By: pasqualeanatriello

Differential Revision: D14560658

fbshipit-source-id: 14e31e3c3b560675b5a752a38ae75ab80a565ea1
2019-03-22 09:33:37 -07:00
David Aurelio
ab3bf40c7d Fix license headers
Summary:
@public

Yoga's Java license headers were not in the correct format.

Reviewed By: muraziz

Differential Revision: D14541087

fbshipit-source-id: 5b3cff398875bd59dadeaddbb43020700ef027e2
2019-03-21 04:56:49 -07:00
Sidharth Guglani
f273e80c77 created a new class YogaNodeJNI which extends YogaNodeJNIBase and using YogaNodeJNi for new object creation
Summary:
Added a child class of YogaNodeJNIBase which will be used to separate layout outputs transfer logic.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368098

fbshipit-source-id: e0f10fb61cd09ee47cf9ce41fb400f4cfb3dd795
2019-03-20 08:57:13 -07:00
David Aurelio
1471be54e3 JNI: Simplify node context
Summary:
@public
Contexts of nodes only hold a bit mask after we got rid of weak JNI refs.
We can simply store that data in a pointer-sized unsigned int.

Here, we replace all context heap allocations with usage of the node context (`void *`) as bitmask. We also add a couple of utility operators in order to keep the code comprehensible.

Reviewed By: fabiomassimo

Differential Revision: D14425742

fbshipit-source-id: f32c2184a1f09268c39dbb8cd09ac96517339674
2019-03-20 08:42:24 -07:00
Sidharth Guglani
f039835249 renamed YogaNodeJNI to YogaNodeJNIBase
Summary:
Renamed class from YogaNodeJNI to YogaNodeJNIBase.
This change set is for adding experiment for layout outputs batching using a float array where we will have two separate classes which will override how layout outputs are transferred to java YogaNode object.

We needed two separate classes because having everything in one class was causing memory issues as both the individual fields for width, height etc. and float array for batching needs to be present in code.

Reviewed By: davidaurelio

Differential Revision: D14368069

fbshipit-source-id: 0e98e28c8c7a9788345ccb92b2cd0f2cd4a53525
2019-03-20 07:53:48 -07:00
Yedidya Feldblum
f793ba2d6b Upgrade mobile BUCK and .bzl files to use C++14
Summary:
Upgrade mobile `BUCK` and `.bzl` files to use C++14.

Let's see what happens.

Reviewed By: mzlee

Differential Revision: D14223329

fbshipit-source-id: ff642ca017103d9415c4d7f5beaf5ded07ef7ff1
2019-03-16 02:25:21 -07:00
Peter van der Zee
9f72ad05ce Bump Prettier to 1.16.4
Summary:
@public
This bumps Prettier to v1.16.4
Only format source files were updated.

Reviewed By: mjesun

Differential Revision: D14454893

fbshipit-source-id: 72f9872fe764a79dbf0d9fab9bebb1456b039f2f
2019-03-14 07:00:56 -07:00
Eric Schlanger
14f3827491 Exclude logging functionality outside debug builds
Summary: Don't compile in YGNodePrint in production builds

Reviewed By: davidaurelio

Differential Revision: D14258269

fbshipit-source-id: 15b5e94d241a752fea74a45263aa343265071451
2019-03-13 07:52:26 -07:00
Sidharth Guglani
0d96098fd9 moved together the java object fields which are set always
Summary:
Moved all layout outputs fields which are set always on yoga node java object.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14355025

fbshipit-source-id: 371d9c49fcb631efa8a79b62f8051ba5a17c232c
2019-03-13 06:28:05 -07:00
Sidharth Guglani
42e3b78f04 change BOrder constant to 4 to set correct field bits
Summary: These constants are used for setting bit fields so they should be in power of 2

Reviewed By: davidaurelio

Differential Revision: D14384999

fbshipit-source-id: fa1f6994c874aff7a039ca98d5947cba317fa749
2019-03-13 03:20:25 -07:00
David Aurelio
3ad49d27d9 Remove configuration for avoiding JNI refs
Summary:
@public

Removes the configuration field to avoid weak JNI refs. It is no longer used.

Reviewed By: marco-cova

Differential Revision: D14424594

fbshipit-source-id: f0877022615a11ac5079354e0977c6893b7d58d7
2019-03-12 13:19:02 -07:00
David Aurelio
3331a9e480 No more weak JNI refs!
Summary:
@public

Completely removes the usage of weak JNI refs.

This is great, because node allocation and deallocation no longer go through a VM-global lock to access the weak reference table.
This is also great, because we can no longer overflow that ref table.
Performance is comparable to weak refs.

Reviewed By: marco-cova

Differential Revision: D14423068

fbshipit-source-id: 62003d2d6fd971e91460a26fb3477046f26e2ba5
2019-03-12 13:19:02 -07:00
David Aurelio
7890672ecc Fix Xcode Workspace
Summary: Turns out Xcode does not like document-level comments.

Reviewed By: SidharthGuglani

Differential Revision: D14301138

fbshipit-source-id: f515a1881daa109031963688c1556cb8ef42758f
2019-03-04 09:11:17 -08:00
Sidharth Guglani
d7bfbf3646 bump yoga version to 1.13.1-SNAPSHOT
Summary: Version bump to 1.13.1-SNAPSHOT

Reviewed By: davidaurelio

Differential Revision: D14300336

fbshipit-source-id: 2c0293d5eb95dc029d431133ce97e75fccd46897
2019-03-04 08:29:28 -08:00
Sidharth Guglani
6d271c05f6 update yoga version to 1.13.0
Summary: Bump yoga version to 1.13.0

Reviewed By: davidaurelio

Differential Revision: D14300306

fbshipit-source-id: 2865462731bcea7666ea14768dd6eb1a112944a9
2019-03-04 07:42:35 -08:00
David Aurelio
a9bddf87ff Fix problems with GCC < v8
Summary:
@public

GCC up until v7 flags our way of reading edges in `YGNodeSetStyleInputs` as unused variables. I managed to work around that by rearranging the casts a bit.

Reviewed By: SidharthGuglani

Differential Revision: D14299439

fbshipit-source-id: eec0266185504d1b790b9ef574bd4a83c0059d3a
2019-03-04 02:37:17 -08:00
David Aurelio
88994129ae 1.12.0-pre.1 (#865)
Summary:
Push version in podspec. We will use `-SNAPSHOT` for bintray
Pull Request resolved: https://github.com/facebook/yoga/pull/865

Differential Revision: D14299474

Pulled By: davidaurelio

fbshipit-source-id: e788479677e1b3c4155a24a336e625508e085f86
2019-03-04 01:34:36 -08:00
David Aurelio
888892885e Encapsulate all used java classes
Summary:
@public

Moves all Java classes used from C++ to their own header + implementation file. In `YGJNI.cpp`, we only call methods on these objects deriving from `jni::JavaClass`.

This is only a bit of cleanup, no functional change.

Reviewed By: SidharthGuglani

Differential Revision: D14261043

fbshipit-source-id: 2db1d81cb7f56a4cdc24b182b2166e1d7e24ba3c
2019-03-04 01:30:15 -08:00
David Aurelio
de79f2a1d4 for experimentation: configurable measure cache size
Summary:
@public

Allows to limit the number of measure cache entries used. This is purely for experimentation.

The measure cache uses about half of every `YGNode`. Reducing its size would allow us to reduce resident memory used by Yoga.

Reviewed By: SidharthGuglani

Differential Revision: D14279027

fbshipit-source-id: e0d22138230bee7fb129c193eb6e4085de02a36e
2019-03-02 12:43:01 -08:00
David Aurelio
6368416178 clean up config context
Summary: `YGConfigContext` was using `global_ref` instances for the config, leading to the config object never being freed. Since we no longer need it after getting rid of cloning, we can make the context a pointer to a `global_ref` to the logger.

Reviewed By: SidharthGuglani

Differential Revision: D14258571

fbshipit-source-id: cce632499839a680eef00a3854f61ab74ae2a87a
2019-03-01 05:45:15 -08:00
David Aurelio
a935a222b5 YGNode remove assignment operators
Summary:
@public

Having assignment operators for `YGNode` means that existing children on the node assigned to would have to be handled somehow.

Deallocating might be incorrect. Ignoring might leak.

Here, we `delete` copy assignment, and make move assignment private (it is used in `YGNode::reset()`).

Copy and move constructors *can* be implemented. The move constructor has to take ownership of the children, while the copy constructor leaves ownership untouched. Since children are copied lazily during layout, this does not expose true value semantics. We should consider removing the copy constructor, too.

Reviewed By: SidharthGuglani

Differential Revision: D14241663

fbshipit-source-id: 39ffdb07f1028bfcf2710c0674a06cdebf3bd650
2019-03-01 04:22:04 -08:00
Sidharth Guglani
7c4da0a341 added positive tests for all style inputs in batching API
Summary: Positive tests for all style input properties using JNI batching API

Reviewed By: davidaurelio

Differential Revision: D14207552

fbshipit-source-id: b7165c2115ace67bf131c76929d37df438921bf2
2019-02-28 12:52:01 -08:00
Sidharth Guglani
b047af25ca Setting flags for margin, padding, position and border
Summary:
We set flags to true when setting margin, padding, border, position individually
Doing the same for batching API

Reviewed By: davidaurelio

Differential Revision: D14207550

fbshipit-source-id: ddfdcd5056bea0dd76bd6762f47e90370e26c9e1
2019-02-28 12:52:01 -08:00
Sidharth Guglani
2abd9dd91b Added getters for flexWrap and flex style inputs in java bindings
Summary: Added getters fro flexWrap an flex style input properties in java bindings

Reviewed By: davidaurelio

Differential Revision: D14207517

fbshipit-source-id: e8d2ad17b5edbdf02e69011c6d95a4de076bd366
2019-02-28 12:52:01 -08:00
Sidharth Guglani
afadc5cf6b JNI batching API using float array
Summary:
Added a new API `YGNodeSetLayoutStyleInputs` to pass layout style inputs from java to native code.
All the style inputs are passed in a float array in [key1, key2, value2, key3, value3a, value3b .....] format over JNI layer.
There are three types of style inputs
- do not need any value to be passed along with them like WidthAuto, HeightAuto
- need one value to be passed like Width, Height
- need two values to be passed like Margin, Padding (edge value and actual margin, padding value)

Reviewed By: davidaurelio

Differential Revision: D14166948

fbshipit-source-id: 4bea64d6a429959c3962c87e337914dcd99199fd
2019-02-28 12:52:01 -08:00
Sidharth Guglani
8823cc357a added mEdgeSetFlags inside YogaNodeContext and using it YGJNI in getters/setters of margin, padding, border
Summary:
We have now create a yoga node context which consists of weak reference to java yoga node object and flag which tells us whether margin, padding , border are set or not.

This flag was initially in java layer and we have moved this to native layer as it will help us with enabling the bacthing API for setting style inputs.

Reviewed By: davidaurelio

Differential Revision: D14243378

fbshipit-source-id: fed935ef18c1abf2b07e5d69d9ca79ced51699f2
2019-02-28 12:52:01 -08:00
Sidharth Guglani
8b8d9a05b7 not setting flags when setting margin, padding, border and position on yoga node
Summary: We are now not setting flags when we set style inputs margin, padding, border and position on yoga node.

Reviewed By: davidaurelio

Differential Revision: D14224000

fbshipit-source-id: deef4c1ab1a60fbc4909183bc2aa59fa23939d43
2019-02-28 12:52:01 -08:00
David Aurelio
15668aceb6 Move reset logic to YGNode::reset()
Summary:
@public

Moving logic from free C functions to the C++ layer.

This will allow us to get rid of the dangerous copy / move assignment operators of `YGNode`.

Reviewed By: SidharthGuglani

Differential Revision: D14241564

fbshipit-source-id: aae9f2a7ffd23bb839f1747e4a0694578bae86ae
2019-02-28 06:31:34 -08:00
David Aurelio
e25fe994b3 Breaking remove YogaNode#clone
Summary:
@public

The cloning features of YogaNode don’t seem to be used. Let’s remove them.

Reviewed By: SidharthGuglani

Differential Revision: D14165624

fbshipit-source-id: 5b710964a4abf1b35f3bcc25b143ffc719a03cec
2019-02-27 04:43:34 -08:00
Chris Sarbora
47abe1c482 Rename makeCriticalNativeMethod to discourage over-use
Summary: "Critical" or "Fast" JNI methods are enticing by their name, but carry dangers that are not trivially visible.

Reviewed By: davidaurelio

Differential Revision: D14184560

fbshipit-source-id: 89ec70f53bb2cb89ff568d8b1fe222ede86c9824
2019-02-22 14:30:35 -08:00
David Aurelio
95169c3150 Don't call jni_YGNodeFree as fast native method
Summary:
@public

If `jni_YGNodeFree` is called while GC is running, the weak reference table lock is held by the GC, leading to deadlock.

Here, we revert the method to being a regular native method, solving that problem.

Reviewed By: SidharthGuglani

Differential Revision: D14184220

fbshipit-source-id: 2882fa10586617cea2df99550a7dd8885376d11e
2019-02-22 08:59:35 -08:00
David Aurelio
7331de78bd setBaseLine -> setBaseline
Summary:
@public

`setBaseLine` was the only place where we used a capitalised *L.* Fixed here.

Reviewed By: SidharthGuglani

Differential Revision: D14152320

fbshipit-source-id: abf54fe7d6088e03775968baa8421c4bf43d6a6e
2019-02-21 05:38:45 -08:00
David Aurelio
05f36a835a Allow to use JNI without global refs
Summary:
@public

Adds the ability to opt into avoiding global weak JNI refs via `YogaConfig`.

Note that only homogeneous trees are supported, i.e. **mixing weak-ref and non-weak-ref nodes will break!**

Not using JNI refs hopefully will help with avoiding JNI reference table overflows, and will help creating trees on multiple threads, as no lock has to be acquired at any time.

Reviewed By: SidharthGuglani

Differential Revision: D14151037

fbshipit-source-id: 56d94713d39aee080d54be4cb4cdf5e3eccb473a
2019-02-21 05:38:45 -08:00
Michael Lee
dcd9438488 Clean up unnecessary header glob
Reviewed By: davidaurelio

Differential Revision: D13509119

fbshipit-source-id: 35d32c82b4fbaf7529828982e69b15e1c61b9e25
2019-02-20 16:53:40 -08:00
David Aurelio
d38db1292c Use YGNodeRemoveAllChildren where appropriate
Summary:
@public

`YGNodeRemoveAllChildren` can be used instead of removing children of a yoga node in a loop.

Reviewed By: zats

Differential Revision: D14131679

fbshipit-source-id: 6ee31f1e288b9b161c641b5bca4f2c1156d58c38
2019-02-20 12:35:27 -08:00
David Aurelio
4463fe0856 Add config for avoiding JNI refs
Summary:
@public

Adds `YogaConfig#avoidGlobalJNIRefs` to control whether nodes created with a config will use weak global JNI refs. Used for experimentation.

Reviewed By: SidharthGuglani

Differential Revision: D14149982

fbshipit-source-id: c777c8b3af2167d96154db5aa6afec1476dac35b
2019-02-20 12:01:15 -08:00
David Aurelio
2156de5fb5 Add support for context-aware cloning functions
Summary:
@public

Context-aware cloning functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to cloning functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14149470

fbshipit-source-id: 1d11106e65f9d872d10f191763da001f8d158a61
2019-02-20 12:01:14 -08:00
David Aurelio
b1c749075d Clone children only during layout, allow mixing shared + owned children
Summary:
@public

Limit child cloning to layout calculation. This also allows for mixing shared and owned children.

Rationale:
We do allow for shared children if the caller manages themselves. The single known use case is React Native.

So far, we have cloned children eagerly whenever child lists are mutated, or layout is run. This was to allow for a quick check of the owner of any first child, assuming that either *all* or *no* child of a node are shared.

For Yoga/Java, we want to get rid of global weak JNI refs, and these are also used to invoke clone callbacks. We can achieve that goal by switching to an alternative approach, passing additional data to the layout pass. This additional data has to be passed to any configured cloning callback. Therefore, it is desirable to **only call cloning functions during the layout pass.**

The obvious solution seems to be to not uphold the invariant of the first child determining shared/owned state of all siblings, and allow for a mix of shared and own children.

Reviewed By: shergin

Differential Revision: D14136223

fbshipit-source-id: 34490cfeeb2170c99d6ed1b9bdcbcedb316813af
2019-02-20 12:01:14 -08:00
David Aurelio
367a93de88 Move node cloning to YGConfig
Summary:
@public

Encapsulates node cloning within `YGConfig`.
This is necessary for allowing for context-aware cloning functions, which will ultimately allow for removal of weak global JNI references.

Reviewed By: shergin

Differential Revision: D14132608

fbshipit-source-id: 0dec114c8e172b1e34a4b7fd146c43f13c151ade
2019-02-20 12:01:14 -08:00
David Aurelio
2643b96589 Extract abstract class YogaNode
Summary:
@public

Here, we extract an abstract class from `YogaNode`, in order to allow for experimentation with different implementations.

The reason for not choosing an interface is to keep ABI compatibility for `YogaNode.create()`.

Reviewed By: pasqualeanatriello

Differential Revision: D14044990

fbshipit-source-id: f8eb246338b55f34f0401198c0655abfcb7c9f37
2019-02-19 11:19:10 -08:00
David Aurelio
016a10df26 Switch to YogaNode.create()
Summary:
@public

Switches instance creation from `new YogaNode()` to `YogaNode.create()`.

This allows for experimentation with different implementations, while maintaining API + ABI compatibility internally at FB, as well as for dependent projects in open source and elsewhere.

Reviewed By: amir-shalem

Differential Revision: D14122975

fbshipit-source-id: f194b146b7cd693dba1a7dafdf92d350e54cb179
2019-02-19 11:19:10 -08:00
David Aurelio
cbcf07f08a Add support for context-aware print functions
Summary:
@public

Context-aware print functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14131098

fbshipit-source-id: 7a9da307274ceccba9f7debba581b70c1ebf2c98
2019-02-19 09:58:43 -08:00
David Aurelio
59bcac3289 Make node printing private
Summary:
@public

Removes `YGNodeGetPrintFunc`, and encapsulates node printing within `YGNode`.
This is necessary for allowing for context-aware callback functions, which will ultimately allow for removal of weak global JNI references.

On a side node, the printing logic does not seem to be well thought through: print functions print as a side effect to whatever output they choose. Printing that uses callbacks is printing to different output streams or strings, though.

We need to consolidate Yoga debugging, and make it all more stringent.

Reviewed By: SidharthGuglani

Differential Revision: D14131024

fbshipit-source-id: 68704682dab3e7dfba61930bb03003d7d4723b80
2019-02-19 09:58:43 -08:00
David Aurelio
bd90192df9 Allow to calculate layout with context
Summary:
publc

Adds the ability to calculate layout with a context pointer set.

The context is passed through to measure and baseline functions of individual nodes.

This will be used to remove the necessity of holding weak global JNI references for each node.

Reviewed By: SidharthGuglani

Differential Revision: D14101426

fbshipit-source-id: 25047e1e44af48feb22ea686285d70803e8961bb
2019-02-19 09:58:42 -08:00
David Aurelio
e7fcf1ee65 Add support for context-aware measure and baseline functions
Summary:
@public

Context-aware measure and baseline functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14100509

fbshipit-source-id: acf4a030549b2e38d5ce0cd5dbe837864e5ffd81
2019-02-19 09:58:42 -08:00
David Aurelio
f86c74ce7e Call measure and baseline fns within YGNode
Summary:
@public

Stricter encapsulation of baseline and measure callbacks withing `YGNode`.

Instead of invoking these callbacks directly (`node->getBaseline()(...)`), they are invoked via methods on `YGNode` (`node->baseline(...)`).

This change will allow us to add the concept of a *Layout Context,* where measure and baseline functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows.

Changed API:

- `YGNodeGetMeasureFunc()` -> `YGNodeHasMeasureFunc()`
- `YGNodeGetBaselineFunc()` -> `YGNodeHasBaselineFunc()`
- `YGNode::getMeasure()` -> `YGNode::hasMeasureFunc()` + `YGNode::measure()`
- `YGNpde::getBaseline()` -> `YGNode::hasBaselineFunc()` + `YGNode::baseline()`

Reviewed By: SidharthGuglani

Differential Revision: D14099550

fbshipit-source-id: 2653ab36acc252a9747986bc88d21dac22d8c91b
2019-02-19 09:58:42 -08:00
David Aurelio
d5ad51bccc Add support for context-aware logging functions
Summary:
@public

Context-aware logging functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14123482

fbshipit-source-id: 8ba3b6c493bf79fe09831f22d2b6da44f09e3d95
2019-02-19 09:58:42 -08:00
David Aurelio
0bdf36f5d1 Call logger from within YGConfig
Summary:
@public

Stricter encapsulation of logging callbacks within `YGConfig`.

Instead of invoking the logging callback directly (`node->logger(...)`), callers now have to go through `YGConfig::log()`.

This change will allow us to add the concept of a *Layout Context,* where logging functions will be able to receive an additional `void *` argument if configured accordingly. This API will be used internally for Yoga’s JNI bindings, to avoid storing a weak JNI reference for each node, and avoid reference table overflows.

Changed API:

- `YGConfig::logger()` -> `YGConfig::log()`

Reviewed By: SidharthGuglani

Differential Revision: D14123483

fbshipit-source-id: 87b8bb7de0e4346b6a41e57a70ac4eb8d79b24af
2019-02-19 09:58:42 -08:00
David Aurelio
1b9053bc5d Make logging private
Summary:
@public

Makes logging implementation internal to Yoga.

Breaking changes: removed  `YGLog` and `YGLogWithConfig`.

The upcoming changes to the JNI layer (removal of weak global refs for each node) requires adding additional parameters to the logging functions that will only be available when calculating layout.

Reviewed By: SidharthGuglani

Differential Revision: D14123390

fbshipit-source-id: 468e4a240c190342868ffbb5f8beb92324cdfdd6
2019-02-19 09:58:42 -08:00
Yuichi ONO
446101a168 flexWrap should be kebab-case inside inline-style (#761)
Summary:
Inside css inline style, it should be spelled as `flex-wrap`.
Pull Request resolved: https://github.com/facebook/yoga/pull/761

Reviewed By: davidaurelio

Differential Revision: D14100508

Pulled By: SidharthGuglani

fbshipit-source-id: 65ebc984d959555107d58ad16ca27b2b8b4d0874
2019-02-19 04:56:36 -08:00
Leandro Ostera
f0324035bf Fix small typos (#784)
Summary:
Hello! Just found some typos on the docs. Fixing them here :)
Pull Request resolved: https://github.com/facebook/yoga/pull/784

Reviewed By: davidaurelio

Differential Revision: D14100968

Pulled By: SidharthGuglani

fbshipit-source-id: 1462216a0d5315075871f2fb11b6b1279ae0097a
2019-02-19 04:48:35 -08:00
David Aurelio
a2f94cbf9a Add -SNAPSHOT to version
Summary: Adds the `-SNAPSHOT` specifier back to the version number in `gradle.properties`

Reviewed By: SidharthGuglani

Differential Revision: D14123308

fbshipit-source-id: e5d4c4dd9552557dc42440f0892c1452dd0195a5
2019-02-18 05:35:54 -08:00
David Aurelio
d21fa68033 Bump version to 1.12.0
Summary:
@public

For `YogaNode.create()`

Reviewed By: amir-shalem

Differential Revision: D14122976

fbshipit-source-id: 5e2fe4f2039d700be6eefff2401b4333fdca3dd2
2019-02-18 03:08:14 -08:00
David Aurelio
5a6d84abc9 Add YogaNode.create()
Summary:
Adds a factory method to `YogaNode`.

While this is purely redundant at the moment, it will allow experimentation in follow-up diffs. We will have concrete implementations deriving from `YogaNode` (which will be abstract).

Going through `YogaNode.create()` means that we can maintain ABI compatibility.

Reviewed By: amir-shalem

Differential Revision: D14122974

fbshipit-source-id: 15d92f296d91cc8bbd79a196f370d2dbb69b3f92
2019-02-18 03:08:14 -08:00
Sidharth Guglani
61ae484316 Pin cmake version to 3.6
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/861

Reviewed By: davidaurelio

Differential Revision: D14081865

Pulled By: SidharthGuglani

fbshipit-source-id: 98bce25cfdd397f48beee64f114c85460b6d81fe
2019-02-14 09:35:02 -08:00
Sidharth Guglani
42657017bd bump version to 1.11.1-SNAPSHOT
Summary: bump version 1.11.1-SNAPSHOT

Reviewed By: davidaurelio

Differential Revision: D14042030

fbshipit-source-id: 0d9ef91013454311d038c23124571d1093471c9b
2019-02-12 06:17:36 -08:00
Sidharth Guglani
9b9a344934 updated gradle build tool version to 3.1.0 and gradle to 4.6
Summary: Upgraded gradle build tool version to 3.1.0 to solve issue "No toolchains found in the NDK toolchains folder for ABI with prefix: mips-linux-android"

Reviewed By: davidaurelio

Differential Revision: D14042022

fbshipit-source-id: c615127fa296f30f589b183bffc8f2a95f7b943b
2019-02-12 05:35:32 -08:00
Sidharth Guglani
5f92ba49a7 yoga bump version 1.11.0
Summary: Yoga release 1.11.0

Reviewed By: davidaurelio

Differential Revision: D14025465

fbshipit-source-id: e76c79898ed212ad8450f261822ed0d84a6ca14b
2019-02-12 04:39:22 -08:00
Pritesh Nandgaonkar
2e564c21cd Fixed the build issue for oss
Summary:
Our OSS build was failing with the latest version of cocoapods(1.6.0). The reason was that the `post_install` script of adding a `SWIFT_VERSION` was not getting applied while building the project. So I added a `swift_version` in the YogaKit pod itself. So with this change we no longer need the `post_install` script to add `SWIFT_VERSION`.

I have also released a new version of YogaKit(1.10.0) on the CocoaPods. Usually the swift pods should specify the swift_version which is being used to develop it.Due to unknown reason, it was never mentioned in the podspec.

Reviewed By: jknoxville

Differential Revision: D13990363

fbshipit-source-id: 3c2f814765c03683fbedd17b3607ff0e6cdef566
2019-02-07 12:52:34 -08:00
David Aurelio
ca7d4d1633 Change compiler flag to -O2
Summary:
@public

Changes compiler flag from `-O3` to `-O2`

Saves 5.3 KiB compressed / 12 KiB uncompressed on 32bit Android.

Java on-device benchmarks show a slight improvement.

Reviewed By: astreet

Differential Revision: D13916987

fbshipit-source-id: e6bc474889e24a90ec473c8ae8c5029224c97eba
2019-02-04 12:52:57 -08:00
David Aurelio
3645f43cea Make == operator for YGStyle free function
Summary:
@public

Makes it work nicely with gtest.

Also allows rhs *and* lhs to offer `operator(YGStyle)()`.

Reviewed By: SidharthGuglani

Differential Revision: D13942573

fbshipit-source-id: ff8b3a9aa6f05ca1b0572eb97d0ad23b09d77871
2019-02-04 10:25:18 -08:00
David Aurelio
9378a7a439 User-defined literals for YGValue
Summary:
@public

Adds `_pt` and `_percent` user defined literals to create `YGValue` instances.

This allows to create `YGValue`s in the following form:

```
use namespace facebook::yoga::literals;

auto a = 123_pt; // == YGValue{123.0f, YGUnitPoint}
auto b = -12.5_percent; // == YGValue{-12.5f, YGUnitPercent}
```

Reviewed By: SidharthGuglani

Differential Revision: D13942100

fbshipit-source-id: ce1e2f9431c3e2a99c6e11896a712539cc535e0d
2019-02-04 10:25:18 -08:00
David Aurelio
d3e02b15fa Compile JNI bindings with -Os
Summary:
@public

Compiles Yoga’s JNI bindings with `-Os`. This doesn’t have perf implications. Compressed APK size ~ -4KB, uncompressed ~ -40KB

Reviewed By: astreet

Differential Revision: D13862404

fbshipit-source-id: 43402478ab2b932f0ca79711c35dfb507bab818b
2019-02-01 10:45:26 -08:00
Pablo Sichert
80d527814e Allow Yoga Pod to be built on any platform (#821)
Summary:
Currently the CocoaPod for Yoga explicitly states platform requirements.

Since the Yoga implementation doesn't depend on any platform features, it would be safe to build it on any platform.

That can be configured by omitting the `platform`/`platforms` key:

> The platform on which this Pod is supported. Leaving this blank means the Pod is supported on all platforms.
>
> http://guides.cocoapods.org/syntax/podspec.html#platform

Among others, that would allow to use the pod in macOS projects
Pull Request resolved: https://github.com/facebook/yoga/pull/821

Reviewed By: passy

Differential Revision: D13848153

Pulled By: davidaurelio

fbshipit-source-id: 5a3e81d81ca97b120f2711bafd3c8b9e0c3f8088
2019-02-01 05:10:13 -08:00
David Aurelio
5121fef5d8 Marker for baseline callbacks
Summary:
@public

Wraps baseline callbacks with a marker.

Reviewed By: SidharthGuglani

Differential Revision: D13896861

fbshipit-source-id: 848ec697977a0a68b9943f1159f6562d54724f89
2019-02-01 03:34:11 -08:00
David Aurelio
0d026bd1a0 Marker for measure callbacks
Summary:
@public

Wraps measure callbacks with a marker.

Reviewed By: SidharthGuglani

Differential Revision: D13896745

fbshipit-source-id: d6e14fe93f666b06516be1aef7f8e1bfe45440a7
2019-02-01 03:34:11 -08:00
Diego Muracciole
719fa3cca3 Add react-pdf to open source adoption list
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/857

Reviewed By: SidharthGuglani

Differential Revision: D13915577

Pulled By: davidaurelio

fbshipit-source-id: 55a9cbe96712c4fe7475665c907f650b4b2a8fb3
2019-02-01 02:55:24 -08:00
Eric Rozell
307cf09434 Adds fixes for react-native-windows UWP (#848)
Summary:
Specifically, updates the UWP .vcxproj for MSBuild and also exposes the UseLegacyStretchBehaviour API for use with react-native-windows.
Pull Request resolved: https://github.com/facebook/yoga/pull/848

Reviewed By: SidharthGuglani

Differential Revision: D13848609

Pulled By: davidaurelio

fbshipit-source-id: eab046ff3c47e49706f515e209d8aaf750c2198f
2019-01-31 16:50:38 -08:00
Reinier Hartog
8691cdaed6 Expose dirtied func in Javascript bindings (#842)
Summary:
Yoga currently has the concept of a 'dirtied func', which is called when a Node becomes dirty, which can be useful to trigger a repaint. This PR exposes that functionality in the Javascript bindings.
Pull Request resolved: https://github.com/facebook/yoga/pull/842

Reviewed By: SidharthGuglani

Differential Revision: D13847093

Pulled By: davidaurelio

fbshipit-source-id: 41913abd6eedc46ee7d66929140e08a084f23972
2019-01-31 16:50:38 -08:00
David Aurelio
4a6b1e19b8 InstrumentationTest: allow to record multiple markers
Summary:
@public

Extends `InstrumentationTest` with the ability to record more than one marker.
Instead of overwriting any previously recorder marker, we collect them in a `std::deque`.

`std::deque` was chosen, because it keeps pointers to elements stable.

Reviewed By: SidharthGuglani

Differential Revision: D13880777

fbshipit-source-id: f6f6606ac8625bdd90c06459fdb967c3478265e7
2019-01-31 16:50:38 -08:00
David Aurelio
31ce3ab866 Add license header to fb_native_wrapper.bzl
Summary:
Github and fbsource got out of sync, we have a PR to fix this: https://github.com/facebook/yoga/pull/843

This updates the internal-only file to match the PR, so that we can merge it without hassle.

Reviewed By: cuva

Differential Revision: D13879526

fbshipit-source-id: f83115617e580e118a5f4e0f37e877db38a8fcac
2019-01-31 16:50:38 -08:00
David Aurelio
0846439c8e Bring github and internal back in sync 2019-01-31 22:59:19 +01:00
David Aurelio
000d1436b4 Merge pull request #843 from rmhartog/add_fb_native_wrapper
Add fb_native_wrapper.bzl to fix Travis CI
2019-01-30 16:40:08 +00:00
David Aurelio
1bc97a5e48 Track how much measure cache entries are used
Summary:
@public

Adds the maximum number of measure cache entries in use to the metrics for `YGMarkerLayout`

Reviewed By: SidharthGuglani

Differential Revision: D13844731

fbshipit-source-id: fa66dbf1b7a1799494f72ecc17dfaef04d0b56e4
2019-01-29 15:53:32 -08:00
CangZhu
68f7001ed4 feat: expose flex prop to YogaKit (#844)
Summary:
This exposes `yoga` property to `YogaKit`
Pull Request resolved: https://github.com/facebook/yoga/pull/844

Reviewed By: SidharthGuglani

Differential Revision: D13849076

Pulled By: davidaurelio

fbshipit-source-id: 560986c2235dfd28d287f61b2e784c9eef6c5eda
2019-01-29 13:06:12 -08:00
David Aurelio
59446294b3 count cache hits
Summary:
@public

Adds cache hit counts to layout stats.

Reviewed By: SidharthGuglani

Differential Revision: D13844022

fbshipit-source-id: 906b4ec5fe3314287911cee2c37d77c4aac76455
2019-01-29 11:42:37 -08:00
David Aurelio
460370b7d3 More readable instrumentation test
Summary:
@public

Evolves setup and helpers in `InstrumentationTest` to avoid repetition across test cases, and allow for more readable test by hiding default values where they don’t matter.

Reviewed By: SidharthGuglani

Differential Revision: D13839521

fbshipit-source-id: 7f7ad49fec84e0bbb09ad746dd8c28bd34de25b2
2019-01-29 11:42:37 -08:00
David Aurelio
cbea5d44b8 Layout marker metadata
Summary:
@public

Adds marker meta data to `YGMarkerLayout`: the number of measures, and the numbers of layouts for all nodes in the tree.

Reviewed By: SidharthGuglani

Differential Revision: D13838975

fbshipit-source-id: d575c26a3d5a4f0b66834eb6bedecadc3f3ca265
2019-01-29 11:42:37 -08:00
David Aurelio
b4b009c2d8 Pass layout marker data along
Summary:
pubic

Passes layout marker data through the recursive calls of the layout algorithm, in order to allow for collecting metrics.

Reviewed By: SidharthGuglani

Differential Revision: D13819444

fbshipit-source-id: cdca04964fba6a03ca3eeaca4d169107019ba457
2019-01-29 11:42:37 -08:00
David Aurelio
74dd627495 Introduce first marker
Summary: @public Adds a marker section for a complete layout pass

Reviewed By: SidharthGuglani

Differential Revision: D13819447

fbshipit-source-id: 21a80f0fe3d325d804a968508761d115c50d3dc1
2019-01-29 11:42:37 -08:00
David Aurelio
58f0cca7c7 Add MarkerSection
Summary:
@public

Adds a class for triggering markers.

This calls `startMarker()` on construction, and `endMarker()` on destruction, thus being usable like a "scope guard": the object is instantiated, and automatically destroyed when going out of scope.

Reviewed By: SidharthGuglani

Differential Revision: D13817589

fbshipit-source-id: fd88884af970c1c0933d9ca6843f3f8f5d28b9e6
2019-01-29 11:42:36 -08:00
David Aurelio
3de3575ac4 Remove unused constexpr
Summary:
@public

Removes unused constexpr variables from YGStyle. Not polluting the global namespace is a good thing.

Reviewed By: SidharthGuglani

Differential Revision: D13816817

fbshipit-source-id: e4c27a8f2de466ccb759bbe52cdaea6fe451b961
2019-01-29 04:11:15 -08:00
David Aurelio
390fade8c0 Add function to set marker callbacks
Summary:
@public

Adds a function to allow to configure markers. The function is declared in `YGMarker.h`

Reviewed By: SidharthGuglani

Differential Revision: D13819111

fbshipit-source-id: f9158b3d4e5727da4e151c84b523c7c7e8158620
2019-01-29 03:51:16 -08:00
David Aurelio
96dfe068ee Add YGMarkerLayout
Summary: @public adds a first `YGMarker`, and the accompanying data type.

Reviewed By: SidharthGuglani

Differential Revision: D13817588

fbshipit-source-id: 6007eb09d19cf4021989bad5b5e880adb16364a0
2019-01-29 03:51:16 -08:00
David Aurelio
e0eb37fce0 Rename YGMarkerType to YGMarker
Summary:
@public

this will lead to nicer enum member names.

Reviewed By: SidharthGuglani

Differential Revision: D13817587

fbshipit-source-id: 85355328f7977b4fb29a9474532f2d578a3cbf79
2019-01-29 03:51:16 -08:00
Cameron Rollheiser
79355ab72d Spelling Fix (#851)
Summary:
Corrects the spelling of `corss-compiled` to `cross-compiled`.
Pull Request resolved: https://github.com/facebook/yoga/pull/851

Reviewed By: SidharthGuglani

Differential Revision: D13848545

Pulled By: davidaurelio

fbshipit-source-id: 84b7d2a738f0faf863717818e8784acd5b5c8156
2019-01-29 03:14:15 -08:00
David Aurelio
5a9f29debb Delete functionality for shared childen
Summary:
@public

Removes `YGNodeInsertSharedChild` / `addSharedChildAt`.

This functionality is unused, and can cause memory leaks.

Reviewed By: SidharthGuglani

Differential Revision: D13711105

fbshipit-source-id: 86206c05393b3f1a497e6b046006f94ead88c6ce
2019-01-24 06:33:06 -08:00
Amir Shalem
8b8932811e Make Yoga's libfb code to be gcc7 compatible
Summary: Make the libfb jni code to be compatible with gcc7 compiler

Reviewed By: davidaurelio

Differential Revision: D13711390

fbshipit-source-id: 9a378a3ee4feb7e928dd97dae7d79a41f0658992
2019-01-17 07:36:09 -08:00
Eduardo Roman
604a9a98a9 guard against INF values in CompactValue
Summary:
After this diff D13403925 that got rid of `-ffast-math` we started to have a very odd behavior on Yoga when using release builds.

After digging a while we found that certain set of conditions on O2 and O3 optimization levels was causing Origami to set some `INFINITE` values on Yoga.

We found the root of the problem and fix it on Origami side. But I'm wondering if guarding agains `INFINITE` on Yoga side would be good too. Since now Yoga it's not using `-ffast-math` anymore, and I think infinite is not a a valid value anywhere on Yoga side, it seems to support the reason to guard against it.

I'm happy to abandon this diff if you guys think this is not a good solution.

Reviewed By: davidaurelio

Differential Revision: D13679319

fbshipit-source-id: 061448fea9d1a8496362ff07dc46b546e7f1ffa3
2019-01-16 12:28:51 -08:00
David Aurelio
71321f763a Reflow comments
Summary:
@public

Repeated application and alternation of Clang Format rules has lead to unfortunate block comment formatting.

Here, we reflow comments

Reviewed By: SidharthGuglani

Differential Revision: D13677242

fbshipit-source-id: 3f1f5e38693eb15e9705f24fd363fc1618c78974
2019-01-16 08:47:48 -08:00
David Aurelio
7fa0816d81 Fix URLs to CSS spec in comments
Summary:
@public

These URLs probably have been changed when CSSLayout was renamed to Yoga by search & replacing

Reviewed By: SidharthGuglani

Differential Revision: D13690829

fbshipit-source-id: 44dbd8fe256fc286006d164390609a7c3de6c4e6
2019-01-16 08:47:48 -08:00
David Aurelio
4840495d3f Remove enum count macros
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.

Same as D13597449, working around a defect in clang < 3.9

Reviewed By: amir-shalem

Differential Revision: D13634622

fbshipit-source-id: 344dc70e167b0caf746fe396cedd200f54e52219
2019-01-11 03:11:33 -08:00
Amir Shalem
866bf101b2 Revert D13597449: [Yoga][cleanup] Remove enum count macros
Differential Revision:
D13597449

Original commit changeset: edcee225ada4

fbshipit-source-id: 1afc24833c8657a8a198bc4529d98c8f605b7fbd
2019-01-10 23:51:03 -08:00
Taras Tsugrii
3467308874 Reformat xplat build files according to new formatting rules.
Summary: drop-conflicts

Reviewed By: zertosh

Differential Revision: D13610808

fbshipit-source-id: 52c2a90bba3d9b0ac383f6e4a76b4fb3e60bf382
2019-01-10 20:01:02 -08:00
David Aurelio
ef2c693b05 Remove enum count macros
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.

Reviewed By: shergin

Differential Revision: D13597449

fbshipit-source-id: edcee225ada4058e94f3a727246763e3cc45873d
2019-01-10 07:38:43 -08:00
Marko Novakovic
efac22a508 Using ENUM_BITFIELDS_NOT_SUPPORTED for enum bitfields
Reviewed By: davidaurelio

Differential Revision: D13556160

fbshipit-source-id: e6d373a4e1dd702509b5d63606c08fae9cdb5498
2019-01-08 16:22:28 -08:00
David Aurelio
4b97375524 Remove repetition in YGEnums.h
Summary:
@public

Wraps enum definition in a single macro.

Down the line, this will allow us to add more functionality:
- Replace manual counts with `yoga::enums::count<YG...>()`
- `yoga::enums::max<YG...>()`
- A bitfield implementation with known memory layout using `max<>()`

Reviewed By: SidharthGuglani

Differential Revision: D13597259

fbshipit-source-id: 543a11a53090bedf1474d00328565ed57d059e23
2019-01-08 12:50:41 -08:00
David Aurelio
ab9d06abf5 Apply clang-format rules
Summary:
@public

Formats Yoga's source according to our clang-format configuration

Reviewed By: SidharthGuglani

Differential Revision: D13596650

fbshipit-source-id: c3722d4eafd63b7596a8b1e85c0197e9d2d6cb7d
2019-01-08 12:50:41 -08:00
David Aurelio
5ee32fbefc Add .clang-format
Summary:
@public

Add `.clang-format` for automatic formatting of our C++ code.

Reviewed By: SidharthGuglani

Differential Revision: D13596651

fbshipit-source-id: c3f866ad552cd7a1d5824f43b093f45842a2142e
2019-01-08 12:50:41 -08:00
David Aurelio
899664dddd Remove stray file
Summary:
@public

Remove accidental copy of `Yoga-internal.h`

Reviewed By: SidharthGuglani

Differential Revision: D13596615

fbshipit-source-id: c137b45caa9c55f75f9bd199be535f1b08977249
2019-01-08 09:47:05 -08:00
Sidharth Guglani
b66642cb86 fixed a csharp test case
Summary: Using default logger in test case

Reviewed By: davidaurelio

Differential Revision: D13565071

fbshipit-source-id: 93cee223a7f366e3e965fde2d5cdc7d4b27e310f
2019-01-04 06:08:24 -08:00
Reinier Hartog
b9ae948ce9 Add fb_native_wrapper.bzl to fix CI 2018-12-31 13:36:31 +01:00
David Aurelio
138521ccc2 Test YogaNode#getLayoutDirection()
Summary:
@public

Previously untested. Allows us to ship with more confidence

Reviewed By: SidharthGuglani

Differential Revision: D13534350

fbshipit-source-id: a2e7577befdeeb7a27148e16624eeb7a347efd87
2018-12-21 04:25:52 -08:00
David Aurelio
5514722ce2 Add tests for YogaNode#hasNewLayout() / #markLayoutSeen()
Summary:
@public

Adds test for the `hasNewLayout()` and `markLayoutSeen()` methods of `YogaNode`. The behavior of these methods wasn't previously covered by a test. This will allow us to change the implementation with confidence.

Reviewed By: SidharthGuglani

Differential Revision: D13534351

fbshipit-source-id: 23a9f9b70df18fd7c34023fd77b9df9fbd733f61
2018-12-21 04:25:51 -08:00
Taras Tsugrii
56e133ab4c Do not use glob for static paths.
Summary:
```
>>> Lint for xplat/yoga/csharp/BUCK:

   Warning  (BUILDIFIERLINT2) constant-glob
    Glob pattern `Yoga/YGInterop.cpp` has no wildcard ('*'). Constant
    patterns can be error-prone, move the file outside the glob.
    (https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#constant-glob)

              30
              31 yoga_cxx_library(
              32     name = "yoganet",
    >>>       33     srcs = glob(["Yoga/YGInterop.cpp"]),
              34     compiler_flags = COMPILER_FLAGS,
              35     link_style = "static",
              36     link_whole = True,
```

Differential Revision: D13521382

fbshipit-source-id: 744368e7818370c8ec68f332caaf766cad635e7a
2018-12-19 15:17:07 -08:00
David Aurelio
f6415889ca Use bitfields for YGLayout and YGNode
Summary:
@public

Further heap size reductions by using bitfields in `YGLayout` and `YGNode`.

Reviewed By: SidharthGuglani

Differential Revision: D13466325

fbshipit-source-id: ddcef0a1b3822e7449fe485d99c920d54139c893
2018-12-18 08:27:12 -08:00
David Aurelio
885b4cbdfb Switch storage in YGStyle to CompactValue
Summary:
@public

Switches the storage in `facebook::yoga::detail::Values` from `YGValue` to `facebook::yoga::detail::CompactValue`.
This cuts heap size for arrays of values in half.

Reviewed By: SidharthGuglani

Differential Revision: D13465586

fbshipit-source-id: 49a4d6d29a73bdd44843b1f3c57bf746050c94d6
2018-12-18 08:27:12 -08:00
David Aurelio
8461aeaef0 Remove cast from detail::Values to std::array<YGValue
Summary:
@public

When switching to `CompactValue`, casting edges or dimensions to `std::array<YGValue, ...>` will do actual work.
In order to avoid that from happening implicitely, we remove the casting operator.

Reviewed By: SidharthGuglani

Differential Revision: D13464292

fbshipit-source-id: 217065b001a63cfa8adde715063682c583007a4d
2018-12-14 09:22:53 -08:00
David Aurelio
3df41aefdb Encapsulate arrays of YGValue within YGStyle
Summary:
@public

Enforce more encapsulation of arrays of `YGValue` in `YGSty;e`.
This will allow us to use `CompactValue` in `YGStyle` while (mostly) retaining API compatibility.

Reviewed By: SidharthGuglani

Differential Revision: D13452042

fbshipit-source-id: 382b1c7245c4bea4280126ab1413e7e931b62eaa
2018-12-14 09:22:53 -08:00
David Aurelio
8bc89651d6 Introduce CompactValue
Summary:
@public

`CompactValue` represents a `YGValue` in 32bits instead of 64. This comes at the cost of a range limitation, as one exponent bit is borrowed for the unit.

*Undefined* and *Auto* have no magnitude, and are represented as *NaN* values.

The data structure is meant to be used as a field type on `YGStyle` to save memory.

This is header-only for efficient inlining.

Reviewed By: jackerghan, aCorrado

Differential Revision: D13187211

fbshipit-source-id: 16e3ffad592e38e2493e4f7c8b952d372e449846
2018-12-14 09:22:52 -08:00
David Aurelio
c5f2444048 Don't use default in exhaustive switch
Summary:
@public
removes the `default` case from an already exhaustive switch.

Reviewed By: SidharthGuglani

Differential Revision: D13451869

fbshipit-source-id: 32727330c7fce013963f5c83c95a73b230d5c938
2018-12-13 10:42:16 -08:00
David Aurelio
130a9a2aa2 Don't pass std::string by pointer
Summary:
@public

Pass strings by mutable ref rather than pointer.

Reviewed By: SidharthGuglani

Differential Revision: D13439613

fbshipit-source-id: ea889abe0fe8ec44ae02f13c1d9a10c0dbfdbcf1
2018-12-13 07:16:56 -08:00
David Aurelio
dd97fcc968 Use bitfields for enum members of YGStyle
Summary:
@public

Puts all enum fields of `YGStyle` into bitfields. This saves 36 bytes (> 3%) per node.

Reviewed By: SidharthGuglani

Differential Revision: D13439606

fbshipit-source-id: b60a5444762041bc6f8cc5e04757034cb6893b30
2018-12-13 07:16:55 -08:00
David Aurelio
4f51871fa8 Remove templates for setting/getting style properties
Summary:
@public

Replaces the `StyleProp` template with a simple setter macro / inlined getter code.

The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.

Reviewed By: SidharthGuglani

Differential Revision: D13439612

fbshipit-source-id: 36f6a86917d035be6891cb736d1f288d8e02f5cf
2018-12-13 07:16:55 -08:00
David Aurelio
e96d14395c YGNodeBoundAxisWithinMinAndMax accepts YGFloatOptional
Summary:
@public

Saves some calls to `.unwrap()`

Reviewed By: SidharthGuglani

Differential Revision: D13439600

fbshipit-source-id: ce0f6bad9a0709e9d64e23d8349bc2423b9b2ad4
2018-12-13 07:16:55 -08:00
David Aurelio
852db1d885 Remove unnecessary static keyword
Summary:
@public

Header-declared inline functions shouldn’t be decleared `static`

Reviewed By: SidharthGuglani

Differential Revision: D13439607

fbshipit-source-id: 89555bb19a3fff6e29ca4afc10fe15fecca8fa17
2018-12-13 07:16:55 -08:00
David Aurelio
3f79439718 Get rid of static_cast in YGResolveValue
Summary:
@public

Removes `static_cast` from `YGResolveValue`

Reviewed By: SidharthGuglani

Differential Revision: D13439605

fbshipit-source-id: 8736541c8e1d43fd698d368cb4f3211ffd929364
2018-12-13 07:16:54 -08:00
David Aurelio
96d93f2982 Inline YGFloatOptional completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13439609

fbshipit-source-id: 3f3c6c3a15e05ac55da2af30eb629f786ecb90a9
2018-12-13 07:16:54 -08:00
David Aurelio
236bcc1a39 Pass YGFloatOptional by value, not reference
Summary:
@public

`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.

Reviewed By: SidharthGuglani

Differential Revision: D13439603

fbshipit-source-id: e12539ad5b3cccbd5bc27869866ca66c023b24a7
2018-12-13 07:16:54 -08:00
David Aurelio
4b5ae211da Eliminate YGFloatOptional::getValue()
Summary:
@public

Replace `YGFloatOptional::getValue()` with `YGFloatOptional::unwrap()`.

`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.

Here, we eliminate the method, and just call `.unwrap()` everywhere.

Reviewed By: shergin

Differential Revision: D13439608

fbshipit-source-id: 5ae82b170537d0a10c301412567a7a66fd50bab4
2018-12-13 07:16:54 -08:00
David Aurelio
aaa018bbea Remove YGUnwrapFloatOptional
Summary:
Replaces `YGUnwrapFloatOptional` with `YGFloatOptional::unwrap`.

This leads to more idiomatic C++, and to less function call nesting, thus increasing readability.

Reviewed By: SidharthGuglani

Differential Revision: D13439604

fbshipit-source-id: 33b43c08d725c253c359959e7cbbd83fd6bd9ba4
2018-12-13 07:16:53 -08:00
David Aurelio
6bdd39d0ed Store YGFloatOptional in 32 bits
Summary:
@public

After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.

Reviewed By: SidharthGuglani

Differential Revision: D13439611

fbshipit-source-id: 93e90f72f0415edb228b4e7d145e1fae35cc6b43
2018-12-13 07:16:53 -08:00
David Aurelio
da678ef971 Add tests for YGFloatOptional
Summary:
@public

Adds tests for `YGFloatOptional`, to ease refactorings.

Reviewed By: SidharthGuglani

Differential Revision: D13439610

fbshipit-source-id: e29da7f85ccedc46520b59f6c893bad521d35417
2018-12-13 07:16:53 -08:00
David Aurelio
e9078374c9 Make equality operator for YGValue inlineable
Summary:
@public

Makes `operator==` for `YGValue` an inline function.

Reviewed By: SidharthGuglani

Differential Revision: D13439601

fbshipit-source-id: c5dd1f35c40f0ffa8224ee2f40ac7cc3cd8e3cf9
2018-12-13 07:16:53 -08:00
David Aurelio
f23a669ed0 Move out YGValue
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13439602

fbshipit-source-id: 68eef2c391b6c9810f3c995b86fff7204ebe6511
2018-12-13 07:16:53 -08:00
David Aurelio
9ddda3c630 Roll back -ffast-math
Summary:
@public

`-ffast-math` does not have measurable performance benefits.

By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.

Reviewed By: astreet

Differential Revision: D13403925

fbshipit-source-id: b13d026bf556f24ab4699e65fb450af13a70961b
2018-12-13 07:16:52 -08:00
David Aurelio
8ab01fde6e Back out "[yoga][PR] Fix aspect ratio when stretching with main axis margin"
Summary: Original commit changeset: 6970e6072e79

Reviewed By: mdvacca

Differential Revision: D13437552

fbshipit-source-id: 65a55d716da6b6582e38efa906d3f540e58418bf
2018-12-12 16:18:56 -08:00
Sidharth Guglani
440c719190 added baseline and setIsReferenceBaseline doc in yoga website
Summary: Added docs for align-items BASELINE property and yoga node setIsReferenceBaseline property in yoga website

Reviewed By: davidaurelio

Differential Revision: D13359436

fbshipit-source-id: 34cbb1087c70d44ec6462048cc2a819daf5951e0
2018-12-12 05:58:11 -08:00
Emil Sjölander
e522b2dee4 Fix aspect ratio when stretching with main axis margin (#834)
Summary:
I've noticed that when a child's size is determined by `align-items: stretch` in combination with `aspect-ratio` its size is wrongly calculated to account for margin in the main axis when there is more than enough space.

See playground: https://goo.gl/tgW6cD

I've yet to figure out exactly how to solve this but i've started by writing a failing test when can be seen in the first commit here.

I assumed I had found the bug here https://github.com/facebook/yoga/blob/master/yoga/Yoga.cpp#L1838 where margin is being subtracted from the desired width even though the measure mode tells it to measure to exactly that size. However, if we don't remove this margin from the available width then 15 tests fail (including the one I just added) not quite figured out why yet. I'm also a bit confused at to why this would only happen for nodes with `aspect-ratio` and not for nodes where an explicit height and width is set.
Pull Request resolved: https://github.com/facebook/yoga/pull/834

Reviewed By: astreet

Differential Revision: D13223579

Pulled By: davidaurelio

fbshipit-source-id: 6970e6072e79f3bb6f9097355ab6e441441bfd88
2018-12-10 09:23:03 -08:00
David Aurelio
b26e637c81 Back out Stack D13119110..D13236159
Summary: backout, causes failures

Reviewed By: adityasharat

Differential Revision: D13376210

fbshipit-source-id: 1fa8823f2dce601c47738f34ddb2674288197e79
2018-12-07 13:01:06 -08:00
David Aurelio
6b7f6980f9 Don't pass std::string by pointer
Summary:
@public

Pass strings by mutable ref rather than pointer.

Reviewed By: SidharthGuglani

Differential Revision: D13236159

fbshipit-source-id: 04fd35e8a9e106ba8cdd71cfab31e8d90edaac9e
2018-12-06 07:46:25 -08:00
David Aurelio
4248fd9d4c Use bitfields for enum members of YGStyle
Summary:
@public

Puts all enum fields of `YGStyle` into bitfields. This saves 36 bytes (> 3%) per node.

Reviewed By: SidharthGuglani

Differential Revision: D13233686

fbshipit-source-id: 3ef7e0d6913f0254806acb942d9a9f5b78a5af9c
2018-12-06 07:46:25 -08:00
David Aurelio
5a65261a55 Remove templates for setting/getting style properties
Summary:
@public

Replaces the `StyleProp` template with a simple setter macro / inlined getter code.

The template was introduced to replace more extensive macros that would generate function signatures, too.
Here, we keep the spirit of that change by only generating function bodies.

Reviewed By: SidharthGuglani

Differential Revision: D13233687

fbshipit-source-id: 218a7d5edb489b43a66c8c9d6156f74feefd2227
2018-12-06 07:46:25 -08:00
David Aurelio
5719132f58 YGNodeBoundAxisWithinMinAndMax accepts YGFloatOptional
Summary:
@public

Saves some calls to `.unwrap()`

Reviewed By: SidharthGuglani

Differential Revision: D13209153

fbshipit-source-id: 5658586e91496085f39b3522db6364aaeafcfe2f
2018-12-06 07:46:24 -08:00
David Aurelio
10b316f315 inline YGUnwrapFloatOptional
Summary:
@public
Replaces C-style function call with C++ method invokation.

Reviewed By: SidharthGuglani

Differential Revision: D13209154

fbshipit-source-id: 14e650af4655efb3a659f3cd949a11df773aabcf
2018-12-06 07:46:24 -08:00
David Aurelio
b6498987fa Remove unnecessary static keyword
Summary:
@public

Header-declared inline functions shouldn’t be decleared `static`

Reviewed By: SidharthGuglani

Differential Revision: D13209156

fbshipit-source-id: e2d643a67e6f6c33c96dc71b0a90d00bd9b6f36f
2018-12-06 07:46:24 -08:00
David Aurelio
9680ae98a6 Get rid of static_cast in YGResolveValue
Summary:
@public

Removes `static_cast` from `YGResolveValue`

Reviewed By: SidharthGuglani

Differential Revision: D13209155

fbshipit-source-id: 76c27c89f6217af9dfef9e2620d639c9f3e212f5
2018-12-06 07:46:24 -08:00
David Aurelio
59755d2874 Inline YGFloatOptional completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13209151

fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
2018-12-06 07:46:24 -08:00
David Aurelio
64c37767c2 Pass YGFloatOptional by value, not reference
Summary:
@public

`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.

Reviewed By: SidharthGuglani

Differential Revision: D13209150

fbshipit-source-id: c7b937a640258256c97e082ba2f832754e191b9a
2018-12-06 07:46:24 -08:00
David Aurelio
50ec35575f Eliminate YGFloatOptional::getValue()
Summary:
@public

`YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined.
That forces `x.isUndefined() ? fallback : x.getValue()` as access pattern.

Here, we replace that by introducing `YGFloatOptional::orElse(float)` which encapsulates that pattern. Other additions are `orElseGet([] { … })` and some extra operators.

Reviewed By: SidharthGuglani

Differential Revision: D13209152

fbshipit-source-id: 4e5deceaaaaf8eaed44846a8c152cc8b235e815c
2018-12-06 07:46:24 -08:00
David Aurelio
ed3b54b603 Store YGFloatOptional in 32 bits
Summary:
@public

After removing `-ffast-math`, `NaN` can again be used to represent `undefined`. That allows us to remove the additional flag from `YGFloatOptional`, and reduce memory usage.

Reviewed By: SidharthGuglani

Differential Revision: D13209157

fbshipit-source-id: 21b83c837a78f924a4ec23a9236ca2440b3c8606
2018-12-06 07:46:24 -08:00
David Aurelio
ed5c5a799f Make equality operator for YGValue inlineable
Summary:
@public

Makes `operator==` for `YGValue` an inline function.

Reviewed By: SidharthGuglani

Differential Revision: D13189356

fbshipit-source-id: 7fe61035acf635e22ebb1a1071925d6b3dad0616
2018-12-06 07:46:23 -08:00
David Aurelio
d19da9e528 Move out YGValue
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13172444

fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
2018-12-06 07:46:23 -08:00
David Aurelio
0962c5220c Roll back -ffast-math
Summary:
@public

`-ffast-math` does not have measurable performance benefits.

By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits.
This will also enable us to store `YGValue` (or a variant of it) in 32 bits.

Reviewed By: SidharthGuglani

Differential Revision: D13119110

fbshipit-source-id: 4e6964240bf74ebc22d8783107b89d536a1a0842
2018-12-06 07:46:23 -08:00
David Aurelio
b9972cee6e Adjust yearless format for MIT license
Summary:
@public

Adjust license headers throughout the project

Reviewed By: SidharthGuglani

Differential Revision: D13255691

fbshipit-source-id: 98be2aa372a94e7a54a65e3d64e5c6a436b18083
2018-11-29 11:37:52 -08:00
David Aurelio
98c1c180af Remove extraneous file
Summary:
@public

This file shouldn’t be here

Reviewed By: SidharthGuglani

Differential Revision: D13255658

fbshipit-source-id: 1b40ab674bbf451d04797516a24c3bd2fef7222d
2018-11-29 11:37:52 -08:00
Eddie Zhang
6f6e0ce339 Fix typo in Yoga Layout documentation
Summary: Found and fixed typo on https://yogalayout.com/docs/justify-content/

Reviewed By: danielbuechele

Differential Revision: D13199988

fbshipit-source-id: 029cf812f09c48822ec11b054bf0c987f718191d
2018-11-29 11:17:20 -08:00
Taras Tsugrii
bdae838516 Sort build file loads.
Summary: drop-conflicts

Reviewed By: passy

Differential Revision: D13176350

fbshipit-source-id: 0f875a6c0f1eca2f992026bb2b2d0851f90f5d2f
2018-11-27 15:16:12 -08:00
Tnarita0000
6d8ee77791 Fix typo 'laid our' to 'laid out' (#833)
Summary:
I've fixed typo `laid our` to `laid out` in [`website/contents/properties/layout-direction.md`].
Pull Request resolved: https://github.com/facebook/yoga/pull/833

Differential Revision: D13196468

Pulled By: passy

fbshipit-source-id: 8b51e0d93fd0b6b131b7ea9446fff28ffeca9764
2018-11-27 03:42:00 -08:00
Tomas Reimers
9725d5b21b Create a recursive free with cleanup function
Reviewed By: davidaurelio

Differential Revision: D13119307

fbshipit-source-id: 162bb4fd6d7620f61cbac010d0dc236d81738b71
2018-11-26 16:04:16 -08:00
Sidharth Guglani
8e48edaa0b calling markDirtyAndPropogate when setting isReferenceBaseline value
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed

Reviewed By: davidaurelio

Differential Revision: D13147742

fbshipit-source-id: 3bbff1cfceeadfbf77380519e4638f2984fc2009
2018-11-26 07:28:37 -08:00
David Aurelio
89394a2dd6 Data types for marker API
Summary:
@public

Adds types for a marker API in Yoga.

This will allow us to register callbacks that Yoga can use to log performance data without hard-coding the backend system for that.

Reviewed By: SidharthGuglani

Differential Revision: D13118830

fbshipit-source-id: b42a42c609f0cf66212186f7f20ee572522d59e3
2018-11-24 16:28:49 -08:00
David Aurelio
02a2309b2a YGNodeComputeFlexBasisForChildren: remove output param
Summary:
@public

`YGNodeComputeFlexBasisForChildren` was using an output parameter (`float&`) that is always initialised to `0.0f`.
Here, we move the initialisation inside `YGNodeComputeFlexBasisForChildren`, and simply return the result.

Reviewed By: astreet

Differential Revision: D13167509

fbshipit-source-id: cbea20e2deb82ec75a1c158b16c94f4a3e5e4c99
2018-11-22 08:08:30 -08:00
David Aurelio
8f181c7259 Pass enums by value
Summary:
@public

passes all enum values by value, not by reference.

Reviewed By: astreet

Differential Revision: D13156390

fbshipit-source-id: 56aea66c16ab3325594f67b9017afa18a678d281
2018-11-22 08:08:29 -08:00
David Aurelio
339c5574b8 Dealloc JNI implementation experiment
Summary:
@public

Remove ability to configure Yoga to run with/without JNI fast calls on dalvik / art.
This switches to always run with fast calls.

Reviewed By: astreet

Differential Revision: D13144652

fbshipit-source-id: 091aab0cd1290d46346323d3e26a11dd0bb17187
2018-11-22 04:01:06 -08:00
David Aurelio
8d5bbecd3d Pass primitives by value
Summary:
@public

Passes all `float`, `bool`, etc. by value, not by reference.

Reviewed By: astreet

Differential Revision: D13153500

fbshipit-source-id: 95529bc2efcff144044e2c25087915b2b7ede179
2018-11-22 03:50:02 -08:00
Amir Shalem
dd12907632 Add getUndefined() method to obtain the undefined value
Summary:
Add getUndefined() method to obtain the undefined value.
This would allow to obtain the Yoga undefined value in runtime, and not just in compile time

Reviewed By: davidaurelio

Differential Revision: D13136972

fbshipit-source-id: aa198aa1ea65bb6b7302abeba6f9f5d483a45ff3
2018-11-22 02:37:05 -08:00
David Aurelio
7d7d9a7ef0 Back to yearless format for MIT license
Summary:
@public

Restores the yearless format of the MIT license.

Reviewed By: SidharthGuglani

Differential Revision: D13082510

fbshipit-source-id: f5a849b06652cedf68547d4a7963398b2627915f
2018-11-15 08:28:16 -08:00
Sidharth Guglani
63570613d3 added basic java, csharp and javascript tests for reference baseline feature
Summary:
@public
We added a functionality using which child node can tell parent node to use it as a reference baseline.
Added some tests for java, csharp, javascript language bindings.

Reviewed By: davidaurelio

Differential Revision: D12997442

fbshipit-source-id: 4717167d2b3862bf2af87b663bda82f9c1eae33e
2018-11-14 04:02:31 -08:00
Sidharth Guglani
4e2011c381 added functionality using which child node can tell parent node to use it as a reference baseline
Summary:
@public
Currently only parent can tell the layout to align its children based on baseline. But if one of the children is a column or row then basealign does not work as expected.

We have added an api setReferenceBaseline which when set to true would mean that it's baseline would be considered as the reference baseline for parent amongst its siblings. If there are more than one siblings with referenceBaseline set, the first one would be considered.

Reviewed By: davidaurelio

Differential Revision: D12883323

fbshipit-source-id: 19beccfc47d98bb38f81f5b66ba764e83680f821
2018-11-14 02:52:20 -08:00
David Aurelio
7a60399b2b Add Yoga JNI bindings to libcoldstart
Summary:
Yoga's JNI bindings are usually loaded during class loading, and can stall the UI thread.

Here, we try to mitigate the problem by adding the bindings to libcoldstart.

Reviewed By: michalgr

Differential Revision: D12956818

fbshipit-source-id: 9dda5cb6d26c2bae64606bc2d7c98ab8f7c05a30
2018-11-07 09:35:32 -08:00
Daniel Hood
a0b3586fb3 Fix build error caused by -Werror=class-memaccess (#823)
Summary:
OS: Arch Linux
GCC Version: gcc (GCC) 8.2.1 20180831
Clang Version: 6.0.1 (tags/RELEASE_601/final)

Build Log Before Fix:

command: `buck build //:yoga`
```
Not using buckd because watchman isn't installed.
yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’:
yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess]
   memset(&(node->getLayout()), 0, sizeof(YGLayout));
                                                   ^
In file included from yoga/YGNode.h:11,
                 from yoga/Utils.h:9,
                 from yoga/Yoga.cpp:13:
yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here
 struct YGLayout {
        ^~~~~~~~
cc1plus: all warnings being treated as errors
Build failed: Command failed with exit code 1.
stderr: yoga/Yoga.cpp: In function ‘void YGZeroOutLayoutRecursivly(YGNodeRef)’:
yoga/Yoga.cpp:1854:51: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct YGLayout’; use assignment or value-initialization instead [-Werror=class-memaccess]
   memset(&(node->getLayout()), 0, sizeof(YGLayout));
                                                   ^
In file included from yoga/YGNode.h:11,
                 from yoga/Utils.h:9,
                 from yoga/Yoga.cpp:13:
yoga/YGLayout.h:12:8: note: ‘struct YGLayout’ declared here
 struct YGLayout {
        ^~~~~~~~
cc1plus: all warnings being treated as errors
    When running <c++ preprocess_and_compile>.
    When building rule //:yoga#compile-Yoga.cpp.o9b5477b5,default.
Parsing buck files: finished in 0.8 sec (100%)
Building: finished in 2.2 sec (100%) 10/10 jobs, 1 updated
  Total time: 3.3 sec
```

Build Log After Fix

command: `buck build //:yoga`
```
Not using buckd because watchman isn't installed.
Parsing buck files: finished in 0.8 sec (100%)
Building: finished in 0.6 sec (100%) 1/1 jobs, 0 updated
  Total time: 1.6 sec
```

All tests are passing
Pull Request resolved: https://github.com/facebook/yoga/pull/823

Reviewed By: davidaurelio

Differential Revision: D10486023

Pulled By: passy

fbshipit-source-id: e9de734c3ce6c45ea4a8edd5d78206901d85ca84
2018-11-07 08:53:41 -08:00
Sidharth Guglani
a2ef8978cd flex_shrink_flex_grow_row and flex_shrink_flex_grow_child_flex_shrink_other_child tests were directly added in YGFlexTest.cpp, Added these in YGFlexTest.html so that they can generated accordingly in all different langauges via gentest ruby script
Summary:
@public
`flex_shrink_flex_grow_row` and `flex_shrink_flex_grow_child_flex_shrink_other_child` tests were present in YGFlexTest.cpp.

When running ruby script to generate tests, these were getting removed since they were not added in YGFlexTest.html using which tests are generated.
This diff adds tests in YGFlexTest.html and contains corresponding generated test cases for different languages.

Reviewed By: priteshrnandgaonkar

Differential Revision: D12838701

fbshipit-source-id: 5e92716d94fa392230db2c0ec3b8c131a089c55a
2018-10-31 13:12:00 -07:00
Scott Rice
d02f4a94de Use fb_native_wrapper for all targets
Differential Revision: D12868694

fbshipit-source-id: 0dfc7d05cc0ee6b15a2534f17260e340038a1041
2018-10-31 12:05:41 -07:00
Sidharth Guglani
b7890fa2a8 adding missing generated test cases in csharp, java, js
Summary:
@public
gentest.rb script generates tests in different languages cpp, java, csharp, js from html files.
Some tests were missing from csharp, java and js test files. This diff adds those in all the test files

Reviewed By: priteshrnandgaonkar

Differential Revision: D10853971

fbshipit-source-id: 11d7cee5889dd1f5a7440f6802fca78cea17aa4d
2018-10-31 10:16:47 -07:00
Sidharth Guglani
1e4d0abc66 using TestParametrization.NodeFactory in gentest-java.js to generate java tests
Summary:
@public

Our tests were manually parametrized, without adding the necessary code to the test case generation script.

This commit makes the necessary changes so that test generation won’t overwrite the parametrization.

Reviewed By: davidaurelio

Differential Revision: D10853163

fbshipit-source-id: b5e41755df16a6a296cf2061fbb89c3f27f8574d
2018-10-29 04:30:20 -07:00
Sidharth Guglani
eb2aeb3adb corrected copyright header in gentest.js
Summary:
@public

We have changed Yoga’s license to a yearless format, but this was not reflected in the test generation script.
This commit changes the corresponding template/.

Reviewed By: davidaurelio

Differential Revision: D10852787

fbshipit-source-id: 0b79e253be6174a218f9dc8de942fc2496a425c8
2018-10-29 03:09:30 -07:00
Sidharth Guglani
fad2ee1a64 Replaced default constructors with member assignments
Reviewed By: davidaurelio

Differential Revision: D10466125

fbshipit-source-id: ed92d1e054a8b5b9a6c8c09035173b11da45c368
2018-10-25 08:03:48 -07:00
Sidharth Guglani
ba9bd4eae3 Added Copyright Header
Reviewed By: davidaurelio

Differential Revision: D10462700

fbshipit-source-id: edef1f6f5825835bbdb613a1934bf7bfe86d0ee6
2018-10-24 03:11:40 -07:00
Pascal Hartig
e12b78f99b Fix Android snapshot version
Summary:
The current snapshot version is not in line with the standard versioning
scheme.

Tried to export this as PR first, but GitHub is having a day.

Reviewed By: muraziz

Differential Revision: D10486037

fbshipit-source-id: d5b08bd5dd2a7d382681ee198e040451a1c2aa11
2018-10-22 06:41:59 -07:00
Alexey Kozhevnikov
5d1cee2bf0 Exclude cpp equality operators from extern "C"
Summary:
`extern "C"` disables name mangling, hence input parameter types does not influence the name. That makes it impossible to have several equality operators with `extern "C"` linkage (for different types).

One such operator is defined in Windows SDK, in `guiddef.h`. It in turn is included in `winnt.h` inside `extern "C" { ... }` block. Trying to compile file which both is dependent both on `winnt.h` and `Yoga.h` results in:
```
Yoga.h(50): error C2733: 'operator ==': second C linkage of overloaded function not allowed
guiddef.h(192): note: see declaration of 'operator =='
```

In general it doesn't make much sense to have cpp specific operator to have `extern "C"` linkage, so the change doesn't introduce any controlling flag (mangling on/off).

Note that it's breaking binary compatibility and yoga library should be rebuilt if those operators are used.

Reviewed By: milend

Differential Revision: D10418395

fbshipit-source-id: 2f1cccff26165e638b9a07eece07d94fccfa5e5a
2018-10-18 08:47:16 -07:00
Adam Comella
5c711a7076 When paddingStart is 0, it should override paddingHorizontal (#816)
Summary:
Fixes #815

Imagine a node with this style: `{ paddingHorizontal: 10, paddingStart: 0 }`.

After running layout on this node, we expect its computed `paddingStart` to be `0`. However, it is actually `10`.

Consider the expression `paddingEdgeStart.getValue() > 0.0f` in [`getLeadingPadding`](328ec7dc4d/yoga/YGNode.cpp (L461)). Why is `0` handled like a negative number rather than a positive number? I suspect this should be `>=` so `0` is handled like the positive numbers (this is how `getTrailingPadding` works).

It looks like 3a82d2b1a8 (diff-07b4949bf42749fde386e769ff08a124) changed the operator from `>=` to `>` in `getLeadingPadding`. I suspect it was a mistake. `getTrailingPadding` still uses `>=`.

I manually verified this using the code in #815 and added some unit tests to catch this bug and other similar issues.

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/816

Reviewed By: priteshrnandgaonkar

Differential Revision: D10282617

Pulled By: shergin

fbshipit-source-id: 2ab2874ae39d9454308a020a960ace85573fe777
2018-10-12 15:08:18 -07:00
Pavel Mazurin
838ef47847 Fixes #606 (#610)
Summary:
Fixes #606.

If there are no subviews in `UIView`, yoga assumes that `sizeThatFits:` returns `CGSizeZero`. However, according to [the documentation](https://developer.apple.com/documentation/uikit/uiview/1622625-sizethatfits), `UIView` returns current size if there are no subviews.

This diff adds a check - if there are no subviews, `sizeThatFits:` doesn't get called, and CGSizeZero is returned.
Pull Request resolved: https://github.com/facebook/yoga/pull/610

Reviewed By: davidaurelio

Differential Revision: D6807406

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 9189cf14c393f840122bc365d3827881bf03548c
2018-10-12 14:09:32 -07:00
Adam Comella
786ccddd7b Fix rounding of negative numbers (#825)
Summary:
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example:

```
YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0
```

However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`.

There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works.

A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see https://github.com/facebook/yoga/issues/824.

Fixes #824

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/yoga/pull/825

Reviewed By: priteshrnandgaonkar

Differential Revision: D10282064

Pulled By: shergin

fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
2018-10-11 18:21:49 -07:00
Adam Comella
b747286c1d Fix C# unit tests (#818)
Summary:
This consists of several fixes:
  - Some of the C++ functions called by the tests were missing `WIN_EXPORT`
  - It looks like Yoga was changed to round up after `TestMeasureFuncWithFloat` was written. Here's the function call that results in the rounding: 357ca78f9f/yoga/Yoga.cpp (L4019-L4026)
  - The format of the result of the `Print` method was changed after `TestPrint` was written.
Pull Request resolved: https://github.com/facebook/yoga/pull/818

Differential Revision: D10282902

Pulled By: shergin

fbshipit-source-id: a5fd732a7dbff1a704cbafbfc95ae3e0c0a0cdd8
2018-10-09 18:14:43 -07:00
Adam Comella
bb3c2b2498 C#: Change NaN with large number (#817)
Summary:
This PR is the C# version of 3a82d2b1a8

The above change moved Yoga away from NaN to facilitate usage of the `-ffast-math` compiler flag. However, that commit forgot to update the C# implementation.
Pull Request resolved: https://github.com/facebook/yoga/pull/817

Differential Revision: D10282642

Pulled By: shergin

fbshipit-source-id: 51681ce12344bc421f346ccc30e2950f4f39dbc6
2018-10-09 17:33:43 -07:00
Emily Janzer
36e732aabd Update copyright for yoga files
Summary: Appeasing lint

Reviewed By: hramos

Differential Revision: D9819535

fbshipit-source-id: 0080f17a62291291a0ea90942af4b38588e9057f
2018-10-05 18:46:14 -07:00
Pritesh Nandgaonkar
d6517ae288 Update version name with snapshot as a suffix
Summary: Adds snapshot as a suffix

Reviewed By: passy

Differential Revision: D10217480

fbshipit-source-id: 0208663b55ff2e403ff94adb98c374cdadefe2ba
2018-10-05 13:15:52 -07:00
Pritesh Nandgaonkar
93d327acfb Yoga Release v1.10.0
Summary:
Updated the build number.
Removed armeabi from build.gradle, as gradle was complaining that it doesn't support armeabi.

Reviewed By: passy

Differential Revision: D10145261

fbshipit-source-id: ab04e2d709cb6faf8bce02a53b7c865c342edefe
2018-10-05 08:39:17 -07:00
Pritesh Nandgaonkar
01c6c79efb Remove armeabi target
Summary: While releasing android yoga release, gradle compained that armeabi is not supported, thus removing it

Reviewed By: passy

Differential Revision: D10194155

fbshipit-source-id: ddb03ae0fe41d5b338c9207ac066090f7e7748a9
2018-10-05 08:39:15 -07:00
David Aurelio
357ca78f9f Set up Yoga experiment
Reviewed By: priteshrnandgaonkar

Differential Revision: D9943869

fbshipit-source-id: 6b6550f453ab4e0ab8305401b299f2d0ed415f72
2018-09-25 16:03:16 -07:00
David Aurelio
6e46eec58f Adapt methods for fast calls
Summary:
Changes all possible native JNI methods to critical methods.

For now, this only changes Android up and including v7. In order to be prepared for the `CriticalNative` annotation in Android v8, the following restrictions apply:

- Qualifying methods must be static (this is also enforced for Dalvik / Android v4)
- Method implementations can only consume primitive JNI types (`boolean`, jchar`, etc.)

Reviewed By: priteshrnandgaonkar

Differential Revision: D9943868

fbshipit-source-id: 728817eb37822b717fd3daf94cd9f02b42c17db6
2018-09-25 16:03:16 -07:00
David Aurelio
554d8cdf76 Make native method binding configurable
Summary:
Moves binding of native methods into a separate native method that can be parameterized.

This will be used to experiment with JNI-related technology.

Reviewed By: priteshrnandgaonkar

Differential Revision: D9943870

fbshipit-source-id: 661f15537d5bbf7a3eef7717e3d99fed2de23904
2018-09-25 16:03:15 -07:00
David Aurelio
328ec7dc4d Support !-style fast calls for Android
Summary:
Adds support for `!`-style fast calls in Android versions < 8.

For now, this comes with the following restrictions:

- has to be enabled with a macro
- only supports native functions that return and accept primitive Java types (`jint`, `jdouble`, etc.), and `void`
- this is supposed to map to `CriticalNative` as described in https://source.android.com/devices/tech/dalvik/improvements#faster-native-methods.

Inline documentation in art: http://androidxref.com/6.0.1_r10/xref/art/runtime/jni_internal.cc#2110

Possible follow ups:
- don’t prefix when the Android runtime is too new (to avoid the warning, and future error, see http://androidxref.com/8.1.0_r33/xref/art/runtime/jni_internal.cc#2355)
- shim `CriticalNative` (see https://android.googlesource.com/platform/libcore/+/master/dalvik/src/main/java/dalvik/annotation/optimization/CriticalNative.java)
- test whether we can use `CriticalNative` at all (docs claim classes must be on bootclasspath)
- suppport `FastNative`, i.e. instance methods that can also receive and return `jobject`

Reviewed By: cjhopman

Differential Revision: D9630538

fbshipit-source-id: 0ae86c909b192429d60f8eddb15528cc38610379
2018-09-19 18:04:09 -07:00
Philip Jameson
2e66f8d828 Format bzl files with new buildifier
Summary: Build file formatting

Reviewed By: ttsugriy

Differential Revision: D9778749

fbshipit-source-id: 4ee3743fabdbb9202b1fe1334fd255e9734352e2
2018-09-11 17:13:12 -07:00
Héctor Ramos
e224a29d1c Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:53:35 -07:00
Taras Tsugrii
238d7ba98f Remove unused loads from build files.
Summary: Unused loads hurt readability and take time to process.

Reviewed By: hramos

Differential Revision: D9494120

fbshipit-source-id: 455b56efadab1cb976344cffcb427772bfda2f71
2018-08-31 17:59:37 -07:00
Pritesh Nandgaonkar
d6ba8326d1 Expose printTree property of YGConfig to jni
Summary: Exposes printTree property of YGConfig to jni

Reviewed By: IanChilds

Differential Revision: D9561097

fbshipit-source-id: 1bf86a63ad5e9baa107e36d429209b9061e6676d
2018-08-30 04:45:23 -07:00
Pritesh Nandgaonkar
f7df575746 Expose logging capablities in Yoga header
Summary: Exposes a bool in the config which will help log the yoga hierarchy. Also added a test case

Reviewed By: IanChilds

Differential Revision: D9560577

fbshipit-source-id: ef4998107ed51ea374853bab7cbe09e3232caa0c
2018-08-30 04:45:23 -07:00
Jonathan Kim
2b52c73d70 Move yoga_defs.bzl
Reviewed By: mzlee

Differential Revision: D9546736

fbshipit-source-id: ff0c19a33cc72a330bac1e266ad0bb6d7c440e60
2018-08-28 22:06:45 -07:00
Pritesh Nandgaonkar
7a45fb39bf Solve the bug related to baseline height
Summary:
This diff fixes the height calculation logic for the nodes with baseline. Before height calculation for baseline was done at wrong place.

The task was created due to the regression caused by D9219678.

Reviewed By: IanChilds

Differential Revision: D9421551

fbshipit-source-id: 3fbb738314130b346c4186ec45d00c9ea63bc9f4
2018-08-21 17:29:43 -07:00
Pritesh Nandgaonkar
1080cf22e3 Solve width bug when the size is less than min
Summary:
This diff updates the logic which reassigns `remainingFreeSpace` when the node's calculated dimension falls below min width of the node.

So we will have to update the `remainingFreeSpace` as there is more available space since the calculated nodes width is less than the min width.

I have also added comments at relevant places in the code so that it is clearer.

This diff solves the issue raised in litho support grp. The details can be found here T32199608. This diff also makes sure that it doesn't break fblite, as the earlier version broke it, details of which can be found here T32881750.

Reviewed By: IanChilds

Differential Revision: D9359026

fbshipit-source-id: 4168e385e962c168a9de9370220c75f14a6726a7
2018-08-20 06:29:38 -07:00
David Aurelio
1d09227374 Inline YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro
Reviewed By: astreet

Differential Revision: D8874733

fbshipit-source-id: 75c24b508f287f405fad09605f64d2bfb3ffa0a5
2018-08-17 03:59:46 -07:00
David Aurelio
85031baaf2 Replace percent setter in YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro with template code
Reviewed By: astreet

Differential Revision: D8874732

fbshipit-source-id: 46fdf851f19f16def0c7e2ab4c5f17a349dc7aee
2018-08-17 03:59:46 -07:00
David Aurelio
7f71cac3b0 Replace point setter in YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro with template code
Reviewed By: astreet

Differential Revision: D8874735

fbshipit-source-id: 77fa1ceb2eaff6a0e415ef939e55aa22bc3d6099
2018-08-17 03:59:45 -07:00
David Aurelio
48a8f883ba Replace getter in YG_NODE_STYLE_PROPERTY_UNIT_IMPL macro with template code
Reviewed By: astreet

Differential Revision: D8874734

fbshipit-source-id: ba94b4d0fd31e8344c7836b66a269d5f1f69e225
2018-08-17 03:59:45 -07:00
David Aurelio
6132a59772 Type alias for dimensions
Summary:
Aliases `std::array<YGValue, 2>` as `YGStyle::Dimensions` for increased readability.

This prepares a follow up, where the alias is used in `Yoga.cpp`.

Reviewed By: astreet

Differential Revision: D8874566

fbshipit-source-id: a7a7a1b02bff547d7d6b800c522c4785a62ad611
2018-08-17 03:59:45 -07:00
Pritesh Nandgaonkar
8309cfc976 Fix parent height calculation in case of baseline alignment
Summary:
Prior to this diff, if parents height was not set then the height of parent was deduced as max of childrens height(considering  line ht, padding, margin etc. ), but it didn't consider the baseline scenario where the previous logic will fail as then the parents height will be determined by the space taken by children above and below the reference baseline. I added a test case for the same.

Look at the diff D9088051 which shows the screenshot of the bug.
It is solved to https://pxl.cl/gvVk

Reviewed By: dsyang

Differential Revision: D9219678

fbshipit-source-id: f4a0b9f1452c33e78bd8c6cf39f6fcf538a04074
2018-08-16 06:28:37 -07:00
Roman Kushnarenko
abc9fdb37c Revert D9286928: [yoga] Solve width bug when the size is less than min
Differential Revision:
D9286928

Original commit changeset: 915269602cda

fbshipit-source-id: a4c23bf335b82fbbf3928a524a61374a6cf6ffb1
2018-08-16 03:14:16 -07:00
Pritesh Nandgaonkar
b872751d68 Solve width bug when the size is less than min
Summary:
Removed the faulty calculation of `remainingFreeSpace` from the code. `remainingFreeSpace` already had the correct value that special condition was not required.

Also added a test case for this issue

Reviewed By: IanChilds

Differential Revision: D9286928

fbshipit-source-id: 915269602cda2cc4515e6eab8184b2ea98d3e6d4
2018-08-15 14:29:37 -07:00
David Aurelio
8368338c93 Eliminate remaining YGStyle& locals
Summary:
@public

Replaces local references to `YGStyle` objects, and assignment to `YGValue` members with direct assignment from temporaries.

This should increase readability, and eliminate duplicated checks for *undefined* values.

Reviewed By: astreet

Differential Revision: D9083531

fbshipit-source-id: 11386be465352f5cb167b8195b7da432d0055d6f
2018-08-15 06:30:43 -07:00
David Aurelio
45c44d293c Eliminate unnecessary copies of node style objects
Summary:
@public

`YGNode.getStyle()` returns a reference to the enclosed `YGStyle` member. Assigning to a local copies unnecessarily.

Having eliminated the copy, we can also safely remove calls to `YGNode.setStyle()`, eliminating another copy.

Reviewed By: astreet

Differential Revision: D9083336

fbshipit-source-id: df8b603b5cc0b974cf5dd434c71956be4548e583
2018-08-15 06:30:43 -07:00
Amir Livneh
b4a889553c Fix typo
Summary:
Fix typo

Created from Diffusion's 'Open in Editor' feature.

Reviewed By: dshahidehpour

Differential Revision: D9295603

fbshipit-source-id: 0a105284592de4962acc672712cca14e157074f4
2018-08-13 15:31:08 -07:00
David Aurelio
78cdf3cadc Back to JNI storage
Summary:
@public

This reverts the Yoga/Java storage experiment. I will follow up with any learnings.

Reviewed By: pasqualeanatriello

Differential Revision: D9168405

fbshipit-source-id: fb227fb9353bd4c4e3bebbe9b04eec1132e532e8
2018-08-06 02:12:40 -07:00
David Aurelio
be78bfbd8c Add Unsafe based storage backend
Summary:
@public

Adds another version of property storage for `YogaNode`, using `sun.misc.Unsafe`.

Adopts the stub concept from Litho for `Unsafe`, as it is hidden by the Android SDK.

Reviewed By: pasqualeanatriello

Differential Revision: D9140103

fbshipit-source-id: a4b376eca341b724a00f873467ae8bf8eaac69f4
2018-08-05 16:45:31 -07:00
Pascal Hartig
c5d4485db3 Fix Travis build (#800)
Summary:
Fix the `Werror` failures and update JUnit to 4.12 as we're making use of `Parameterized` features which aren't available in whichever version we have here.
Pull Request resolved: https://github.com/facebook/yoga/pull/800

Reviewed By: jknoxville

Differential Revision: D9132106

Pulled By: passy

fbshipit-source-id: 5e6a130ba65e4a1ebd1d9ec506fdb126ecd0e44a
2018-08-02 10:43:03 -07:00
David Aurelio
71f1d99494 Fix behaviour of freeNatives()
Summary:
@public

Prevents repeated deallocation of weak references.

Reviewed By: pasqualeanatriello

Differential Revision: D9131551

fbshipit-source-id: bc79596e056ae0657a55146ad786422fd0f5badc
2018-08-02 04:00:50 -07:00
David Aurelio
0e99980206 Adapt micro benchmark
Summary:
- adds more property assignments
- reduces the number of layout roots that exist simultanously

Reviewed By: pasqualeanatriello

Differential Revision: D8989389

fbshipit-source-id: 6a0ac800a4caad61a2f4bf98caa314855b70875f
2018-08-02 04:00:50 -07:00
Pascal Hartig
292bfed102 Update CoC for various projects
Summary: The old link 404s. This is the new canonical location.

Reviewed By: IanChilds

Differential Revision: D9131447

fbshipit-source-id: 77b82a4184fff89faf1da76e922a5f1ce3de3314
2018-08-02 03:12:17 -07:00
David Aurelio
78d6988461 Add YogaNodeProperties implementation with ByteBuffer based setters
Summary:
@public
Adds an implementation of `YogaNodeProperties` that sets style properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.

Reviewed By: pasqualeanatriello

Differential Revision: D9042225

fbshipit-source-id: c7f2b24eaeddd1190755bec85a5034079bd2f492
2018-07-30 09:43:37 -07:00
David Aurelio
3499e2e0ef Add YogaNodeProperties implementation based on ByteBuffer
Summary:
@public
Adds an implementation of `YogaNodeProperties` that accesses style and layout properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.

This needs further cleanup after experimenting, e.g. to codegen the offsets.

Reviewed By: pasqualeanatriello

Differential Revision: D8911723

fbshipit-source-id: 3c24b57eb545155878896ebb5d64d4553eb6bedc
2018-07-30 09:43:37 -07:00
David Aurelio
b1821ab4cd move property storage into sub-object
Summary:
Here we introduce an abstraction over node property storage, in order to experiment with different approaches for Java/C integration.

- interface `YogaNodeProperties` as abstraction
- current JNI code factored into `YogaNodePropertiesJNI.java`
- `YogaNode` delegates all calls, no API changes

Reviewed By: astreet

Differential Revision: D8769448

fbshipit-source-id: e67327ce41fa047a51a986c652b3d59992a510e2
2018-07-30 09:43:37 -07:00
Amir Shalem
006f6460a9 Deallocate the YogaConfig memory with correct method
Summary: We've mistakenly used `free()` to free the memory, where `delete` should have been used

Reviewed By: davidaurelio

Differential Revision: D9042347

fbshipit-source-id: e15cec0f498409066521a6de1e3fe4b7404ec46c
2018-07-29 14:12:00 -07:00
Zhaojun Zhang
db5bc092aa Remove clang compiler warnings for Android: -Wno-unused-parameter
Summary: att

Reviewed By: gkmhub

Differential Revision: D8972835

fbshipit-source-id: c8b893eefec6ccb5d8506c959bcf5c3f43701e81
2018-07-27 10:59:16 -07:00
Nate Stedman
9fe20fd2fc Also ban +new on YGLayout
Summary: `-init` is marked unavailable, but `+new` does the same thing and is not.

Reviewed By: dshahidehpour

Differential Revision: D8957391

fbshipit-source-id: 42fcfe845db79726d8724efd9f6a4d37c19938ad
2018-07-24 06:59:03 -07:00
David Aurelio
7b87ded288 Add tests for style properties
Summary:
@public

The existing test suite does not check every single style property settable in Java for defaults, reads, and effect on layout.

Here, we add these test, in order to make evolving the Java/C++ bridge as safe as possible.

Reviewed By: pasqualeanatriello

Differential Revision: D8952470

fbshipit-source-id: a94933adff01c313b3f440eb5207d2cb6a54a85d
2018-07-23 14:58:36 -07:00
Valentin Shergin
eaaf0fdfe2 Implementation of operator== for YGValue
Summary:
@public
It's very useful sometimes for product code to compare `YGValue`s (e.g. in Fabric).

Reviewed By: priteshrnandgaonkar

Differential Revision: D8937594

fbshipit-source-id: b93e1ab4a6419ada6746f233b587e8c9cb32c6d4
2018-07-23 13:27:50 -07:00
David Aurelio
4caed8feb5 Replace YG_NODE_STYLE_PROPERTY_IMPL macro with template
Summary:
@public

Replacing the `YG_NODE_STYLE_PROPERTY_IMPL` macro with template code, in order to make code easier to edit and grep.

Reviewed By: astreet

Differential Revision: D8868184

fbshipit-source-id: f52537376fa8d4dd53aa98bb43e93279699dbdd5
2018-07-19 09:58:25 -07:00
David Aurelio
4be229059c Yoga.h: inline function declaring macros
Summary:
@public

Inlines macros used for declarations of `YGNodeStyle*` and `YGNodeLayout*` functions.
Benefits easier grepping and code base navigation.

Reviewed By: astreet

Differential Revision: D8868168

fbshipit-source-id: d6b1b70981a59a2214dc7d166435a1d1a844e1b7
2018-07-19 09:58:24 -07:00
David Aurelio
389f2fd85d Run lint on Yoga.cpp/Yoga.h
Summary:
@public

auto-fixes formatting for `Yoga.cpp`/`Yoga.h`.
Submitted separately to keep other diffs cleaner.

Reviewed By: astreet

Differential Revision: D8868179

fbshipit-source-id: d0667f8bb909bb5ada1263aac6e22b0a8f8875ad
2018-07-19 09:58:24 -07:00
David Aurelio
f95e3b49e9 inline trivial constructors / methods
Summary:
@public

inlines some trivial constructors, destructors, and methods.

Reviewed By: astreet

Differential Revision: D8912691

fbshipit-source-id: 79840ef3322676deebed99391390d6c1796963b5
2018-07-19 09:58:24 -07:00
David Aurelio
f172d5d41c auto-lint YGLayout.h YGNode.h YGStyle.cpp YGStyle.h
Summary:
@public

automatically applies lint fixes to  YGLayout.h YGNode.h YGStyle.cpp YGStyle.h

Reviewed By: astreet

Differential Revision: D8913432

fbshipit-source-id: 488bf25db041ddb527565c26c1762c6ee4cae736
2018-07-19 09:58:24 -07:00
Pascal Hartig
7be9fd1a79 1.9.1-SNAPSHOT
Summary: Reenable snapshot releases.

Reviewed By: muraziz

Differential Revision: D8914105

fbshipit-source-id: f9fcd74912f3ef2f9fb94ec832c41353e3f890bb
2018-07-19 09:14:45 -07:00
Pascal Hartig
5e1796505d v1.9.0
Summary: New release against soloader ~0.5.0.

Reviewed By: muraziz

Differential Revision: D8914103

fbshipit-source-id: b1eb3f608ac7cf3791fefe88e596383483ae3474
2018-07-19 09:14:45 -07:00
Pascal Hartig
51a4601e18 Update soloader to 0.5.1
Summary:
There's been a breaking change in 0.5 and old versions
are ABI-incompatible with new ones.

Reviewed By: muraziz

Differential Revision: D8913456

fbshipit-source-id: 89221c5ac95c7c2197083a5390403c72e7e33af1
2018-07-19 06:58:13 -07:00
Scott Wolchok
0bc4d23e2e Explicitly default YGNode copy ctor
Summary: No need to type out the old version. This is exactly equivalent (unless I've misread and the old version did something other than memberwise copy).

Reviewed By: davidaurelio

Differential Revision: D8842326

fbshipit-source-id: c575ea4cee6caef9ea15aaf5967597385ed26ec3
2018-07-18 15:59:02 -07:00
Scott Wolchok
4c47dcbd0f Delete YGNode ctor w/arg per member
Summary: It doesn't seem to be used internally, it hurts greppability, and there are setters for these properties as needed anyway.

Reviewed By: davidaurelio

Differential Revision: D8842084

fbshipit-source-id: f0275b490e585ea94df341c97c34b441ed91c4fb
2018-07-18 15:59:02 -07:00
David Aurelio
c1a9f6120a Make YGFloatIsUndefined inlineable
Summary:
@public

Makes `YGFloatIsUndefined` inlineable

Reviewed By: swolchok

Differential Revision: D8875520

fbshipit-source-id: 7ac653e002512b1a8d5f9c04e0a21381aeb02e67
2018-07-18 02:27:05 -07:00
David Aurelio
1b32c4f054 Lint Utils.cpp YGLayout.cpp YGNode.cpp Yoga-internal.h
Summary:
@public

Auto-fixes formatting of YGLayout.cpp YGNode.cpp Yoga-internal.h

Reviewed By: astreet

Differential Revision: D8875514

fbshipit-source-id: 38d709831349c4ad015f20451421aea89fc6f007
2018-07-18 01:17:22 -07:00
Taras Tsugrii
896cfbdfde Skylarkify yoga build defs.
Summary:
Top-level `if` statements are not allowed in a new Buck parser - Skylark.
https://buckbuild.com/concept/skylark.html

Reviewed By: grzmiel

Differential Revision: D8849590

fbshipit-source-id: 6648135f23e058adfeddf574932f8a98c7831fee
2018-07-14 00:27:17 -07:00
Scott Wolchok
910aa77c01 Remove some unnecessary const float & uses
Summary: Holding floats by reference is unnecessary at best and may be detrimental to performance.

Reviewed By: davidaurelio

Differential Revision: D8826496

fbshipit-source-id: 2391f8aa26ebfbb440f6e4b7d57975be688f791c
2018-07-13 12:43:19 -07:00
Scott Wolchok
2562c029b1 Tidy up YGFloatOptional further
Summary: I missed these two things: inline default ctor, getValue() should return a float.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8826640

fbshipit-source-id: e6324dea0268ef276e6fa1722e72dffb5241e676
2018-07-13 12:43:19 -07:00
Scott Wolchok
0b1780a081 YGNode::getChildren() should return const ref
Summary:
It's wasteful to do it by value. I'm fairly sure this is
safe, especially because
fbd332dee8 (diff-ade2a4bbd6582e2898cbd9e0fa142ab5R215)
shows that we did access by reference before.

Reviewed By: priteshrnandgaonkar, davidaurelio

Differential Revision: D8822697

fbshipit-source-id: 791bcf0fa37453f67795af727c85c8adce3b0f69
2018-07-13 12:43:18 -07:00
Scott Wolchok
e9e2ae28e0 Tidy up YGFloatOptional
Summary: Just some convention/weird style things. `float` should be passed by value, weird use of ?: operator instead of ||.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8804407

fbshipit-source-id: e0d67363ccde36ec5bccec7497ed0ffd364b3fcf
2018-07-12 08:42:41 -07:00
David Aurelio
4ed3dd4b82 Add YogaNodeProperties interface
Summary:
`YogaNodeProperties` will serve as abstraction over JNI adapters / storage backends in follow-ups.

@public

Reviewed By: IanChilds

Differential Revision: D8818805

fbshipit-source-id: 7998a56daebea60dd13b07228dffdf14be852554
2018-07-12 07:58:04 -07:00
Marc Terns
a7f430a5ef Feature podspec modules (#793)
Summary:
This PR adds support for using Yoga Swift dependents when Yoga is pulled as a static library.

Currently swift projects trying to pull static libraries are unable to import the module. The reason for that is because the `DEFINES_MODULES` build setting is set to`NO`.  If a Swift Framework is trying to `pod spec lint --use-libraries` with `Yoga` as a dependency, the validation will fail. With the `DEFINES_MODULE` enabled, the product will be treated as defining its own module. This enables automatic production of LLVM module map files when appropriate, and allows the product to be imported as a module.

A workaround to this issue would be passing the `:modular_headers` flag to the `Podfile`, but that would not fix the `pod spec lint` validation for framework/library dependencies, it would just allow consuming applications to build and run.

An example of this issue would be [SonarKit](https://github.com/facebook/Sonar/blob/master/iOS/SonarKit.podspec). `SonarKit` wasn't able to validate its podspec due to `YogaKit` (Swift Framework) depending on `Yoga` and SonarKit validating with the `--use-libraries` flag due to the c++ dependencies. We had to create a new version of [Yoga 1.9 podspec](https://github.com/facebook/Sonar/blob/master/Specs/Yoga/1.9/Yoga.podspec.json) and make sure to set the `DEFINES_MODULE` flag of the pod target. After that, we were able to `pod spec lint` `SonarKit.podspec` successfully.

After merging a new `tag` should be created and the new podspec should be pushed to cocoapods master repository.
Pull Request resolved: https://github.com/facebook/yoga/pull/793

Reviewed By: passy

Differential Revision: D8820126

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 98eae3c31ec67a03c0fe97e05ab9e79446fa9f78
2018-07-12 07:27:16 -07:00
Valentin Shergin
89ba4f282d Removed misleading comment in YGPersistenceTest
Summary:
Trivial... but quite confusing. :)

Created from Diffusion's 'Open in Editor' feature.

Reviewed By: priteshrnandgaonkar

Differential Revision: D7151891

fbshipit-source-id: d09a6434d6327736c2d5ce672b3e9c5b5573508a
2018-07-11 20:12:37 -07:00
David Aurelio
b6231ee0ed Lint java files
Summary:
@public

Applies lint auto-fixes to java files.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8803814

fbshipit-source-id: 2e4dc285b233091a9fbadf38fc22dd6e36f11f8e
2018-07-11 09:43:09 -07:00
Scott Wolchok
e384002878 Inline simple YGNode getters/setters
Summary: Simple getters/setters are usually inlined like this.

Reviewed By: priteshrnandgaonkar, davidaurelio

Differential Revision: D8793588

fbshipit-source-id: 436bd54880e41a5e403e3f4ae0d9dd4a413df79c
2018-07-11 09:02:36 -07:00
Scott Wolchok
9ceed4b601 Remove unused YGNode::*nextChild
Summary: This linked list was never used, and YGNodeDeepClone was doing scary things to maintain it.

Reviewed By: davidaurelio

Differential Revision: D8792864

fbshipit-source-id: c578fabe65c837f0791aa9ac3e18f31d93691abd
2018-07-11 09:02:36 -07:00
Scott Wolchok
765bb85d1e Fix warnings when building benchmark
Summary: There were a few missing prototypes and a -Wshadow violation. Merged YGBenchmark.h into YGBenchmark.c, added static where needed, fixed shadow violation.

Reviewed By: davidaurelio

Differential Revision: D8793124

fbshipit-source-id: c4b2dd348c38aa599169b5e9bea543c172439432
2018-07-11 09:02:34 -07:00
Pritesh Nandgaonkar
6548dddec3 Fix SingleFlex Child condition
Summary:
Fixes the improper `singleFlexChild` optimization. In the case when all the childs have `flex-grow:0 flex-grow:0` except one child with `flex-grow:1 flex-shrink:1`, then one can simply measure all the non-flexing children and then give the flexing child all the remaining space.

Also added a test case which reproduced the bug

Reviewed By: IanChilds

Differential Revision: D8782684

fbshipit-source-id: ffd4d35b6122f82111b987540efb23bd2a8da5a2
2018-07-11 06:01:35 -07:00
David Aurelio
966f5ece4a guards instead of nested if
Summary:
Replaces two nested if-blocks with guards. This is intended to help with restructuring this function in follow-ups.

@public

Reviewed By: priteshrnandgaonkar

Differential Revision: D8785659

fbshipit-source-id: 7b9d63e9814b83b999397c016ad67ad348bb0f72
2018-07-11 04:13:01 -07:00
David Aurelio
ede2888326 Lint / reformat YGJNI.cpp
Summary:
Run clangformat on `YGJNI.cpp`

@public

Reviewed By: priteshrnandgaonkar

Differential Revision: D8785660

fbshipit-source-id: 9748a5297e7b55e897de0280a79c2ea6ae1c1298
2018-07-11 04:13:00 -07:00
Daniel Büchele
2eda444bbf update dependencies
Summary:
Updates all dependencies of the website to their latest version. This is made due to CVE-2018-3728 and a vunerable version of `hoek` used in s transitive dependency of the website. This updates `hoek` to v 4.2.1 which is not affected.

allow-large-files

Reviewed By: astreet

Differential Revision: D8734272

fbshipit-source-id: 3e96ea5890190f7d7b83cc4c18121fc925411f69
2018-07-05 08:58:03 -07:00
Daniel Büchele
7c4319181b fixing landing page layout on server render
Summary:
On the first render the landing page was missing a CSS class. This ls probably related to https://github.com/gatsbyjs/gatsby/issues/5136
It is fixed by wrapping the page in a <div>

Reviewed By: priteshrnandgaonkar

Differential Revision: D8660801

fbshipit-source-id: dd1ac4145831f2556e2c7ceeaddb2a423447f833
2018-07-03 10:21:22 -07:00
David Vacca
f4d29e6f11 Avoid cleaning up Owner of YGNode during clonning
Summary:
This diff refactors the cloning mechanism for YogaNode used from Fabric UI renderer and RN iOS graphs.
Previously, we were cleaning the owner of the child's cloned node inside the C++ implementation of YogaNode. This was a mistake because this modified the last commited YogaTree, causing side effect in RN iOS graphs.

Reviewed By: shergin

Differential Revision: D8672627

fbshipit-source-id: c9902d00690e0361fd58aed84b506c42258bd995
2018-06-28 22:47:50 -07:00
Peter van der Zee
77ea79490f Upgrade Prettier to 1.13.6 on fbsource
Reviewed By: zertosh

Differential Revision: D8638504

fbshipit-source-id: c6991b2e884e14868ddc1d9047a78191219d673f
2018-06-27 03:28:16 -07:00
Pascal Hartig
46c96ee2cb Upgrade fbjni
Summary:
Sync fbjni with `libaries/fbjni`.

This includes a hack to fix a deadlock we found for cmake-debug variants only. This still gets us back in sync with other fbjni consumers which is going to save us trouble in the future if Yoga ever wants to make use of a newer feature.

Manual changes made in addition to the hand-crafted CMakeLists and cxx buck rules:

- `jni::isObjectRefType` has SDK lookup disabled.
- `fbjni/` path is changed back to `fb/` to retain compatibility with Yoga.

Reviewed By: priteshrnandgaonkar

Differential Revision: D8531991

fbshipit-source-id: 776f519e2e5f9bea37f55990348f7ed81c4860b4
2018-06-26 04:58:58 -07:00
Taras Tsugrii
a67c555320 Fix deprecated glob usage.
Summary: https://our.intern.facebook.com/intern/wiki/Buck/python-to-skylark/

Differential Revision: D8595731

fbshipit-source-id: 0e3046a7fd2a25e9b13462713ae9a008ad546770
2018-06-23 18:27:38 -07:00
David Vacca
cdb1ee21a0 Clean-up parent / owner reference of children during clonning
Summary: This diff cleans up the parent / owner references for children of ReactShadowNode / YogaNode during cloning. The reason of this behavior is to avoid retaining every generation of trees during cloning. This fixes a memory leak detected when running the ProgressBarExample.android.js in catalyst app

Reviewed By: fkgozali

Differential Revision: D8019894

fbshipit-source-id: b0d38f0c836ffec534f64fa1adbd7511ecf3473d
2018-06-22 11:44:14 -07:00
Oleksii Dykan
2ce219ef42 Fix componentkit generator (#785)
Summary:
Fixes some inconsistencies in yoga playground
Closes https://github.com/facebook/yoga/pull/785

Reviewed By: danielbuechele

Differential Revision: D8480993

Pulled By: alickbass

fbshipit-source-id: 395d77bae28462d3e03d666287bdc64137b84c68
2018-06-18 09:12:49 -07:00
Simon Egersand
c5f826de83 Use correct spelling ('then' -> 'than') (#782)
Summary:
Might be the smallest PR in the world, but it caught my eye reading the
docs so I figured I should fix it.
Closes https://github.com/facebook/yoga/pull/782

Reviewed By: emilsjolander

Differential Revision: D8351525

Pulled By: jknoxville

fbshipit-source-id: fc7a881f062e07d2e28b5ca2da8c52f20bad53be
2018-06-12 04:12:23 -07:00
Vince Mi
526ca42d04 Add back deprecated getParent methods for non-breaking API change (#775)
Summary:
I'm not totally sure what I'm doing so if this needs changes let me know.
Closes https://github.com/facebook/yoga/pull/775

Reviewed By: emilsjolander

Differential Revision: D8331892

Pulled By: passy

fbshipit-source-id: eb1023e666322d2472e4081fd4a4e72a7b43d049
2018-06-11 04:12:26 -07:00
Peter van der Zee
b47f0ce41a Bump Prettier to 1.13.4 on xplat
Summary:
@public

Bump Prettier to use version 1.13.4
All code changes are caused by running Prettier and should only affect files that have an `format` header.
All other changes caused by yarn.

Reviewed By: ryanmce

Differential Revision: D8251255

fbshipit-source-id: 0b4445c35f1269d72730f2000002a27c1bc35914
2018-06-06 05:44:55 -07:00
Andres Suarez
eb7cb11ffd Run buildifier over BUCK and TARGETS files
Reviewed By: scottrice

Differential Revision: D8163151

fbshipit-source-id: 700a77c09c6ab1bef8fd24a2a3133a4b50e3b3a3
2018-05-25 11:25:46 -07:00
Daniel Büchele
f9df990177 link to playground in embedded playgrounds
Summary:
The "copy share URL" button only works in the standalone playground, not the ones embedded on the landing page or the documentation, because, we don't want people to share a link to a modified documentation page.

This diff replaces the share URL button with a link to a standalone playground which then can be shared.

Reviewed By: astreet

Differential Revision: D8125135

fbshipit-source-id: 8b69b69caeadf5d598ed89b0abd9b742f5f07a9c
2018-05-24 12:25:52 -07:00
Andres Suarez
684dccb7b9 Run buildifier over all bzl files
Reviewed By: yfeldblum, ttsugriy

Differential Revision: D8087092

fbshipit-source-id: 3b298d0a81ed65454649df8c80bffca2ec5651de
2018-05-22 07:33:43 -07:00
Taras Tsugrii
6c51eb4f72 Re-format BUCK to use recommended style.
Summary:
This uses the latest version of `buildifier` that supports many
more Skylark syntax features.

Reviewed By: yfeldblum

Differential Revision: D8073585

fbshipit-source-id: 12322aebc09b89d5af9cc257b16c1bc0fbb066c1
2018-05-20 23:40:18 -07:00
Taras Tsugrii
ca485dfb50 Re-format .bzl to use recommended style.
Summary:
This is to make them `buildifier` compatible in order to start using
`buildifier` for all .bzl files.

Differential Revision: D8069457

fbshipit-source-id: f5bce02a3e6ba8dc4ccbf5bae70de224c30cbd64
2018-05-19 18:12:01 -07:00
Emil Sjölander
50e3714b21 bump pod version
Reviewed By: priteshrnandgaonkar

Differential Revision: D8025017

fbshipit-source-id: 187c4a3b0ec47bc7bcbc599049941bed069dc2f7
2018-05-16 08:44:29 -07:00
Pritesh Nandgaonkar
c52c7cdd1e Fix podspec issue
Summary: Fix yoga podspec issue. The newly released versiong of Yoga i.e 1.8.0 was not building on iOS. So fixing the bug. Want to use this pod in SonarKitLayout

Reviewed By: emilsjolander

Differential Revision: D8024641

fbshipit-source-id: c8d7279e654145199fbee6655909e1c10d8b2114
2018-05-16 07:19:15 -07:00
Daniel Büchele
11200f3d75 fixing playground responsive bahavior
Summary: The error message saying the playground is only available on bigger screens also was shown on big screens.

Reviewed By: emilsjolander

Differential Revision: D7989482

fbshipit-source-id: f444ca2d6608b868c4ff4d38fa6798d80b57c047
2018-05-14 10:22:41 -07:00
Daniel Büchele
5dbe3c128b adding support for min/max-width/height
Summary: Adding controls for min/max height/width to the playground

Reviewed By: emilsjolander

Differential Revision: D7988400

fbshipit-source-id: bae487e2504906788552d6c1a29ed74c39cb5ac0
2018-05-14 07:46:21 -07:00
Jonathan Kim
3564ccf6e4 Use wrapped cxx_binary
Summary: Introduce `yoga_cxx_binary`

Reviewed By: grzmiel

Differential Revision: D7809271

fbshipit-source-id: 1b66ce59a73e4a63b670f7d3bcadfbb6cbfbc220
2018-04-28 21:32:13 -07:00
Peter van der Zee
e1c19cecad Upgrade Prettier to v1.12.1 on fbsource
Summary:
Updates Prettier to v1.12.1, using `xplat/js/scripts/prettier-bump.js` based on the playbook by https://our.intern.facebook.com/intern/wiki/Prettier/upgrade-guide/

All changes related to upgrading or running Prettier

allow-many-files
allow-large-files
bypass-lint
drop-conflicts
ignore-conflict-markers
ignore-signed-source
ignore-nocommit

Reviewed By: benjaffe, ryanmce, yungsters

Differential Revision: D7652946

fbshipit-source-id: 396d45c675e93f2298cd2920d927630c81867447
2018-04-19 03:05:38 -07:00
Pascal Hartig
8e4f3a3084 Add getParent() method for easier migration
Summary:
External partners have asked us to provide an easier way to migrate and this was
a breaking change in the most recent release.

Reviewed By: emilsjolander

Differential Revision: D7654526

fbshipit-source-id: efe44807caa97f495c5e5691dedcf281760fa23e
2018-04-18 04:45:12 -07:00
Jakub Grzmiel
9b8323ff38 Clean up BUCK files for missing dependencies and tests
Summary: Several of dependencies and tests in repository are missing (e.g. because we don't support building certain library for MacOSX). Clean up those mistakes.

Differential Revision: D7625433

fbshipit-source-id: 332b7ff7eaed82cb52f459921f1ae67b702a1636
2018-04-14 15:35:24 -07:00
Jakub Grzmiel
5b7adda620 Unbreak the build
Summary: build-break

Differential Revision: D7629493

fbshipit-source-id: baf5ca7cec2078a8ba9e34afe84da76c2edbb3b3
2018-04-14 14:58:08 -07:00
Jakub Grzmiel
ba2a3b8c91 Clean up BUCK files for missing dependencies and tests
Summary: Several of dependencies and tests in repository are missing (e.g. because we don't support building certain library for MacOSX). Clean up those mistakes.

Differential Revision: D7618360

fbshipit-source-id: 421834892519998ad088a138b3fc3d96afe34d79
2018-04-14 13:17:59 -07:00
Jonathan Kim
eb15939c23 Make yoga wrapper macros start with yoga_
Summary: Rename macros

Reviewed By: mzlee

Differential Revision: D7606834

fbshipit-source-id: a2089260dbe46f30f49a207737c83472e2fb3c63
2018-04-14 12:43:03 -07:00
Pascal Hartig
b9fa60fd74 Re-enable matrix build for Java snapshots
Summary:
Change the travis platform to Java and install Node via nvm instead. This
manually reinstalls buck and then publishes a snapshot if it builds and tests
correctly.

Reviewed By: emilsjolander, danielbuechele

Differential Revision: D7567862

fbshipit-source-id: fabdbbb13117ab8ead4eb9f10402a71d30f29c12
2018-04-10 05:33:13 -07:00
Pascal Hartig
d397aa04d7 1.8.1-SNAPSHOT
Summary: Back to snapshot release.

Reviewed By: marco-cova

Differential Revision: D7550851

fbshipit-source-id: f98983799dc9ea2a44d658fd50a2676f1d6e31d5
2018-04-09 04:03:11 -07:00
Pascal Hartig
adb1b11055 1.8.0
Summary: New release.

Reviewed By: marco-cova

Differential Revision: D7550852

fbshipit-source-id: eac5662179daa88d9d62c55566b3a31428c4117a
2018-04-09 02:41:21 -07:00
David Vacca
2e234473ca [yoga re-add assertion to check for owner reference before adding child.
Summary: this diff re-add the assertion to check for owner reference before adding child that was removed by mistake in previous diff

Reviewed By: emilsjolander

Differential Revision: D7495417

fbshipit-source-id: b81174aeea3f2796d76ccdae4a8eddd0beace0aa
2018-04-04 10:57:52 -07:00
Lukas Wöhrl
6b08db68bb Fix compilation on MSVC by moving YGConfig to C++
Summary:
This PR fixes the compilation on MSVC. I moved the `YGConfig` creation to a C++ constructor.

Addionally it removes the "dot" notation on `YGValue`, I didn't want to change that type to a C++ constructor, because I think this will break the ABI.
Closes https://github.com/facebook/yoga/pull/746

Differential Revision: D7498141

Pulled By: emilsjolander

fbshipit-source-id: 5f5308ff838dcd803065785ddc08b2404524acb9
2018-04-04 09:55:45 -07:00
Pritesh Nandgaonkar
9550126f76 clean up experimental setup and keep using ffast-math flag
Summary: Remove experimental setup of fast-math and add `-ffast-math` as a compiler flag for yoga.

Reviewed By: emilsjolander

Differential Revision: D7414228

fbshipit-source-id: 320e1b1953f6af867b13e617af7872eb8999160e
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
bad262b961 Change the return type of getMarginForAxis to YGFloatOptional
Summary: Change the return type of getMarginForAxis to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7350337

fbshipit-source-id: dd1ee2fcd295ccd14f7d414ab0c24090b24e91e0
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
3c6c10075a Change the return type of getTrailingMargin to YGFloatOptional
Summary: Change the return type of getTrailingMargin to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7350221

fbshipit-source-id: 61a67364c1975ec6dd1883bc2cb4968b830c73df
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
6a77a6939e Changed the return type of getLeadingMargin to YGFloatOptional
Summary: Changed the return type of getLeadingMargin to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7349907

fbshipit-source-id: b20894fbc33fd5b29a28f3c9174d1b5f406774ab
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
b725a4a140 Refactored relativePosition private method to YGFloatOptional return type
Summary: Refactored relativePosition private method to YGFloatOptional return type

Reviewed By: emilsjolander

Differential Revision: D7344939

fbshipit-source-id: 72443d38426a211d3e84be814e6a61baf4d26703
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
2b714a5b5d Change the type of getTrailingPosition to YGFloatOptional
Summary: Change the type of getTrailingPosition to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7344710

fbshipit-source-id: eb4c422b6e0f55d90b083221aa8ff1ab797d58a8
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
572546088f Changed the type of return value of getLeadingPosition to YGFloatOptional
Summary: Changed the type of return value of getLeadingPosition to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7344367

fbshipit-source-id: 0f5a667ca357b2ce056c86763aa3e9e4c54b82f0
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
5b109578d3 Changed the type of computedFlexBasis to YGFloatOptional in YGLayout
Summary: Changed the type of computedFlexBasis to YGFloatOptional in YGLayout

Reviewed By: emilsjolander

Differential Revision: D7340413

fbshipit-source-id: 39247b2b582a682e602f49f58b4bbd2bf0c995af
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
77b720f9a5 Fixed types of getLeadingPaddingAndBorder and getTrailingPaddingAndBorder to YGFloatOptional
Summary: Fixed types of getLeadingPaddingAndBorder and getTrailingPaddingAndBorder to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7339998

fbshipit-source-id: aa24335c2db1cd895b9711214b72195add718c32
2018-04-04 08:29:43 -07:00
Pritesh Nandgaonkar
de954eb9cc Changed the return type of trailing padding to YGFloatOptional
Summary: Changed the return type of trailing padding to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7339712

fbshipit-source-id: 483c5886838c14b17cb731c81abb9fc80f519956
2018-04-04 08:29:42 -07:00
Pritesh Nandgaonkar
3e322e60e4 Updated the implementation of leading padding
Summary: Changed the arguments for the getter of leading padding to avoid copies. Added an assetion in getter of leading padding, as padding would always be defined even in the case when the user has not explicitly defined the value. In these cases it would take the default value of 0. So changing the type of `getLayoutPadding` to `YGFloatOptional`, doesn't make sense.

Reviewed By: emilsjolander

Differential Revision: D7336690

fbshipit-source-id: b2a2f010026f26fc2cc9fb35ad921da8f7017c9f
2018-04-04 08:29:42 -07:00
Pritesh Nandgaonkar
a3642541d0 Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional
Summary: Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7323382

fbshipit-source-id: 8e3eb4f3744b5f3f9e2b353f56184905f7557191
2018-04-04 08:29:42 -07:00
Pritesh Nandgaonkar
bb139d3f91 Remove the use of YGUnwrapOptional from YGConstrainedMaxSizeForMode
Summary: Remove the use of YGUnwrapOptional from YGConstrainedMaxSizeForMode

Reviewed By: emilsjolander

Differential Revision: D7322743

fbshipit-source-id: d825c60bcdc9ecdc0c784a215dc6b1b8a7a7860e
2018-04-04 08:29:42 -07:00
Pritesh Nandgaonkar
08743a42e2 Made the acccessors method to return const references
Summary: Made the acccessors method to return const references

Reviewed By: emilsjolander

Differential Revision: D7321801

fbshipit-source-id: 9fc4da724bc2f58a0d95824ca3c0b5bf1690bccf
2018-04-04 08:29:42 -07:00
Lukas Wöhrl
cb6e76973d Fix float type mismatch on endOfLineIndex and inside rounding
Summary:
This PR fixes a type mismatch on `endOfLineIndex` where it should be of type `uint32_t` while it is of type `float`

Additonally it fixes some `double` casting in the rounding methods.
Closes https://github.com/facebook/yoga/pull/745

Differential Revision: D7494519

Pulled By: emilsjolander

fbshipit-source-id: 30a86574ce163458a6888f61a902d0640c1874fb
2018-04-04 07:04:23 -07:00
Pritesh Nandgaonkar
4b760fa9bc Changed the return type of YGResolveValueMargin to YGFloatOptional
Summary: Changed the return type of YGResolveValueMargin to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7304090

fbshipit-source-id: cbec03a9367cf34976d083ad475d4da0b736e6d2
2018-04-03 15:12:07 -07:00
Pritesh Nandgaonkar
5730be093e Move equaltiy function from utils to an operator on YGFloatOptional
Summary: Move equaltiy function from utils to an operator on YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7303460

fbshipit-source-id: 41ec0076ace621ec1a5bdbab00b72eea57780fff
2018-04-03 15:12:05 -07:00
Pritesh Nandgaonkar
d85e2ee9c3 Change the type of aspect Ratio to YGFloatOptional
Summary: Change the type of aspect Ratio to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7302651

fbshipit-source-id: 53e3b4c9627207a379f927b1f3485e36a9c70601
2018-04-03 15:12:02 -07:00
Pritesh Nandgaonkar
fe433b012f Remove the usage of YGUndefined for kYGValueAuto and fix setter and getter of dimensions
Summary: Removes the use of YGUndefined from kYGValueAuto. Also fixed the setter and getter of dimensions. This diff also fixes a typo

Reviewed By: emilsjolander

Differential Revision: D7302453

fbshipit-source-id: e002a1ddd75bfc6fe142a7275e7913c064972e16
2018-04-03 15:11:58 -07:00
David Vacca
5e3ffb39a2 Extend Yoga to be able clone Yoga Node with new children
Summary:
This diff includes the following changes:

1 ) I extended the Java implementation of YogaNode to be able to get a full copy of a YogaNode object without copying the List of children of the original YogaNode. In other words, the new copy of the YogaNode will have the same data of the original YogaNode, but with an empty list of children.

2 ) We created a new method in Yoga.cpp called YGNodeInsertSharedChild. This new method is going to be used by Fabric in order to temporarily share a YogaNode between two "Yoga Trees" (the "current Yoga" tree and a partial "clone of the current Yoga tree"). We exposed this new functionality in the java implementation of Yoga (method addSharedChildAt)

I'm including sebmarkbage for more context.

Reviewed By: emilsjolander

Differential Revision: D7245421

fbshipit-source-id: 72578c8261f29e4a12fc6c72a91f2f891cd58d48
2018-04-01 18:35:13 -07:00
David Vacca
f0edefdbb7 Rename YogaNode.parent -> YogaNode.owner
Summary:
In the persistent version of Yoga, a YogaNode can be shared between two YogaTrees, that means that a YogaNode could have more than one Parent at one point in time. That's why the concept of Parent of a YogaNode is not a 1-1 relationship anymore.
This diff changes the semantic of Parent of a YogaNode to Owner of a Yoga Node. CC sebmarkbage and priteshrnandgaonkar for more context.

Technically this diff renames the field YogaNode.parent to YogaNode.owner (and every internal field, Getter and Setter that is related to parent)

Note that as part of this diff I also modified the CSSLayoutDEPRECATED version of Yoga in order to keep compatibility with the C++ implementation.

Reviewed By: priteshrnandgaonkar

Differential Revision: D7352778

fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
2018-04-01 18:35:13 -07:00
David Vacca
17901ea5c2 Refactor cloning of YogaNode
Summary: see Test Plan

Reviewed By: priteshrnandgaonkar

Differential Revision: D7339832

fbshipit-source-id: 2de6f47ae7601ac083d3b9fbe10ffaf6307ae760
2018-04-01 18:35:13 -07:00
Jonathan Dann
187fc54596 Add YGNodeSetChildren(), YGNodeTraversePreOrder()
Summary:
We had functions for inserting/removing a specific child, but not for simply replacing the child set with another list.

`YGNodeSetChildren()` will unhook child nodes from the parent that don't appear in the new set. We set the disconnected child node layouts to `YGLayout()` b/c that's what the rest of the code does.

`YGTraversePreOrder()` walks the tree and calls a labmda for each node. We could very easily add a post-order traversal and the ability to stop traversal if we ever want, but for now this is an MVP.

Reviewed By: Woody17

Differential Revision: D7360203

fbshipit-source-id: 32df8e1213ead03bc0a026ec4bf453bc799bb9ce
2018-03-25 13:59:44 -07:00
Pritesh Nandgaonkar
c951ad7c7b Push Yoga 1.8.0 to cocoapods
Summary:
Podspec to push yoga 1.8.0 to cocoapods. There is an issue with cocoapods and it fails to lint those projects with C++ in its header, which is the case with yoga too.

Follow this thread https://github.com/CocoaPods/CocoaPods/issues/5152. To make the lint pass, one would have to change `app_target_helper.rb` cocoapod source file in the local machine. Follow my [gist](https://gist.github.com/priteshrnandgaonkar/dcca9639a3bc0a3b9adecae3a2b3b0c4).

I am able to pass the lint, but not able to push the pod in cocoapods as I am not the admin. @[759512522:emilsj], please push it on Cocoapods or give me permission.

Podspec now also exposes public header explicitly.

Reviewed By: gkassabli

Differential Revision: D7375018

fbshipit-source-id: 4e82e1c0b6340c3f8d3b8a96ecadbcb711d4bcd8
2018-03-23 05:33:59 -07:00
Daniel Büchele
9785975f77 add documentation about JS library usage. fixes #733
Summary: Adds an example of how to use yoga from JavaScript to the documentation pages.

Reviewed By: priteshrnandgaonkar

Differential Revision: D7354390

fbshipit-source-id: 0dbc08e5341c06b621acd99bfb9ce7e789b67a45
2018-03-22 04:53:24 -07:00
Jonathan Dann
79281049f2 Mark more member functions as const
Summary: These don't mutate internal state.

Reviewed By: priteshrnandgaonkar

Differential Revision: D7291364

fbshipit-source-id: 2e7d96cfe0345692ffa411bb21a80eb7a859880b
2018-03-21 16:14:21 -07:00
Jonathan Dann
7d2b84aab6 Pass some constructor argumetns by const-reference
Summary: These don't need to be copied twice.

Reviewed By: priteshrnandgaonkar

Differential Revision: D7291363

fbshipit-source-id: 22e606d0b3fa1133d7e0334c8cf9f5f1f32fe64b
2018-03-21 16:14:21 -07:00
Jonathan Dann
cda328fa7e Pass-by-reference in YGNode::setStyle() ::setChildren() ::setLayout()
Summary: These shouldn't be copying the arguments when they pass by value. Instead these only get copied when assigning the value to the member.

Reviewed By: priteshrnandgaonkar

Differential Revision: D7291096

fbshipit-source-id: 7a4025831811d622050adbb5f86608855b94d68e
2018-03-21 16:14:20 -07:00
Pritesh Nandgaonkar
5d7b75a47a Moved YGFloatOptional from C struct to C++ struct
Summary:
Earlier `YGfloatOptional` was plain struct with no privacy around the variables. This diff adds privacy and also enforces checks when one tries to access value of an undefined `YGFloatOptional`

This diff also adds a behaviour in which when a value of an undefined YGFloatOptional is accessed, it will normally terminate(Several cleanup steps are performed).

Reviewed By: emilsjolander

Differential Revision: D7288555

fbshipit-source-id: f61cc92c8fd0d48d2fc1f4d0e6fcef155f19ff8a
2018-03-15 13:04:51 -07:00
Pritesh Nandgaonkar
ae86824636 Fixed a typo and added a test case
Summary: Fixed a typo of flexshrink and added a test case

Reviewed By: emilsjolander

Differential Revision: D7289221

fbshipit-source-id: 48ee9ccfac4adee51d515a366b5a11790f7236fc
2018-03-15 13:04:51 -07:00
Pritesh Nandgaonkar
0dde40ce0b Fix getters and setters if min and max Dimension
Summary: Fix getters and setters of min and max Dimension to behave exactly the same way as it was before fast math changes

Reviewed By: emilsjolander

Differential Revision: D7274807

fbshipit-source-id: 7c1a4c19e8d0552b089a410c3330392cb26a6a47
2018-03-15 07:27:55 -07:00
Pritesh Nandgaonkar
369c9ad12a Fix setter and getter of margin, position, border and padding
Summary:
This diff fixes the setter and getter of margin, position, border and padding to the previous behaviour of yoga, before floatoptional change

This diff also removes the unrequired `#define`

Reviewed By: emilsjolander

Differential Revision: D7274115

fbshipit-source-id: 942a91e6562ef789ae79102a828f397889468fa7
2018-03-15 07:27:55 -07:00
Pritesh Nandgaonkar
cfb9eeca20 Fix failing float max test
Summary:
Earlier YGUndefined was NAN, but recently it was replaced with 10E20 and the check for `isUndefined` is as follows

```
  public static boolean isUndefined(float value) {
    return (Float.compare(value, (float) 10E8) >= 0 || Float.compare(value, (float) -10E8) <= 0);
}
```

If the number is in (-inf, -10E8] and [10E8, inf) then it is considered as undefined. Failing test passed values in this range, so thats why the test was failing. Current diff fixes this issue, and passes a big number which is outside the range as the result of measure function.

Reviewed By: emilsjolander

Differential Revision: D7272325

fbshipit-source-id: 81a77117c65c5dc0cec920f50f0735ec0a7433d1
2018-03-14 09:21:15 -07:00
Pritesh Nandgaonkar
3dfb68887d Expose layout diffing flag to java
Summary:
This diff exposes `shouldDiffLayoutWithoutLegacyStretchBehaviour` from YGConfig and `doesLegacyStretchFlagAffectsLayout` from YGLayout to YogaConfig and YogaNode respectively

Also added a positive test case. Didn't find the negative test case example. @[508947467:ianc] or @[759512522:emilsj], can you suggest a negative test case example.

Reviewed By: emilsjolander

Differential Revision: D7272067

fbshipit-source-id: e67e82eb057e4c7124904c715f9dca4dcfea21ea
2018-03-14 08:43:01 -07:00
Pritesh Nandgaonkar
d567885070 Remove the use of YGUndefined for flex-basis
Summary: Remove the use of YGUndefined for default flex-basis value

Reviewed By: emilsjolander

Differential Revision: D7243924

fbshipit-source-id: 2bfaca1a5e3da40d5292a273cabf705f59c9d666
2018-03-14 04:36:53 -07:00
Pritesh Nandgaonkar
877c275a13 Change the type of flexShrink to YGFloatOptional
Summary: Change the type of flexShrink to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7232171

fbshipit-source-id: 3111119d3d74a7035c01132bff61b30cf44e120a
2018-03-14 04:36:53 -07:00
Pritesh Nandgaonkar
8aadae8ce4 Change the type of flexGrow to YGFloatOptional
Summary: Change the type of flexGrow to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7215355

fbshipit-source-id: 1298ee332551d44e4d070169a1e4103d005c4f43
2018-03-14 04:36:53 -07:00
Pritesh Nandgaonkar
2232d7603a Change the type of flex to YGFloatOptional
Summary: Change the type of flex to YGFloatOptional internally, but keeping the public facing API the same as before

Reviewed By: emilsjolander

Differential Revision: D7211327

fbshipit-source-id: 0d979b6ba00317317b98bbc6e63979c7f1feb2da
2018-03-14 04:36:52 -07:00
Pritesh Nandgaonkar
b3f8851bc2 Changed the return type of YGResolveValue
Summary: Changed the return type of YGResolveValue

Reviewed By: emilsjolander

Differential Revision: D7195099

fbshipit-source-id: 72c4163cd08691cf6e40df05394cc52e83b0de14
2018-03-14 04:36:52 -07:00
Pritesh Nandgaonkar
47ad3f63cf Remove the usage of YGUndefined in the default values of Border in YGStyle
Summary: Remove the usage of YGUndefined in the default values of Border in YGStyle. In the getter of Border function, YGUndefined is used just to keep it logically consistent. The proper solution would be to change the api in `Yoga.h` to accept `YGFloatOptional`, but that would require to change lot of the code in client of this library. Will make a separate diff for that.

Reviewed By: emilsjolander

Differential Revision: D7195115

fbshipit-source-id: e635cf55ac94d8a90caef6cafce281579da2cbfc
2018-03-14 04:36:52 -07:00
Tomer Shalev
c75adb0671 solves the Android pixel bug
Summary:
emilsjolander hi,
this PR solves the following common and probable layout pixel scenario:
the older code is presented for reference:

```java
view.measure(
    View.MeasureSpec.makeMeasureSpec(
        Math.round(node.getLayoutWidth()),
        View.MeasureSpec.EXACTLY),
    View.MeasureSpec.makeMeasureSpec(
        Math.round(node.getLayoutHeight()),
        View.MeasureSpec.EXACTLY));
view.layout(
    Math.round(xOffset + node.getLayoutX()),
    Math.round(yOffset + node.getLayoutY()),
    Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
    Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));

```

suppose now the following:
- `xOffset + node.getLayoutX() = 2.2`
- `node.getLayoutWidth() = 0.4` ==> `Math.round(node.getLayoutWidth()) = 0`
- `Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()) = Math.round(2.2 + 0.4) = 3`

this induces, the following measurements:
```java
view.measure(
    View.MeasureSpec.makeMeasureSpec(
        0,
        View.MeasureSpec.EXACTLY),
    View.MeasureSpec.makeMeasureSpec(
        Math.round(node.getLayoutHeight()),
        View.MeasureSpec.EXACTLY));
view.layout(
    2,
    Math.round(yOffset + node.getLayoutY()),
    3,
    Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));

```

the width measurement of the view is 0, while the layout is `(3 - 2 = 1)`.
my proposed solution is to measure the view the way it is now, but when layouting
I use the `#getMeasuredWidth/Height()` methods, this will stop this problem
from happening.

I also want to note that this bug happens with high probability.
Closes https://github.com/facebook/yoga/pull/712

Reviewed By: emilsjolander

Differential Revision: D7231798

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 171da519639dbecd75416a574bccc4456aa22f31
2018-03-13 03:13:00 -07:00
Héctor Ramos
178b8f5f64 Update config files to use LICENSE-examples
Summary: Use examples license in config files.

Reviewed By: sophiebits

Differential Revision: D7174444

fbshipit-source-id: 50c2369b18abd9d7fff9b4a66788fd67a5b40a0c
2018-03-08 10:21:51 -08:00
Michael Lee
a874992e7c Set missing header_namespace
Summary: When we don't explicitly set header_namespace, we can get differing behavior between Android and iOS. Even when it is not explicitly necessary, we are going to try to enforce this properly.

Reviewed By: scottrice

Differential Revision: D7141155

fbshipit-source-id: 74d1488c3909f89ad9d6d0ee0de335b789dc2ccd
2018-03-02 17:05:25 -08:00
Héctor Ramos
31fc287d35 Check PATENTS does not creep into files
Summary:
Some files have crept into the repo with the old license header. These are usually from PRs that were opened prior to the re-licensing of the project.

Let the script run, prior to fixing the errant files. The script outputs the following:

```
PATENTS crept into some new files?
 --- /dev/fd/63	2018-03-01 01:42:48.250153746 +0000
+++ /dev/fd/62	2018-03-01 01:42:48.250153746 +0000
@@ -1 +1,9 @@
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.h
+Libraries/NativeAnimation/Nodes/RCTTrackingAnimatedNode.m
+ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+ReactAndroid/src/main/java/com/facebook/react/views/text/CustomLetterSpacingSpan.java
+ReactCommon/yoga/yoga/YGLayout.cpp
+ReactCommon/yoga/yoga/YGLayout.h
+ReactCommon/yoga/yoga/YGStyle.cpp
+ReactCommon/yoga/yoga/YGStyle.h
 scripts/circleci/check_license.sh
Exited with code 1
```

Fix the headers in these files and run the script again. No output, exit code 0.
Closes https://github.com/facebook/react-native/pull/18143

Reviewed By: sophiebits

Differential Revision: D7119356

Pulled By: hramos

fbshipit-source-id: d238e4d4a3ae320a2c8e625c2fa29690057a4814
2018-03-01 08:35:23 -08:00
Daniel Büchele
892913a69d Google analytics tracking
Summary:
Adds tracking for:
- short URL created
- value in interactive documentation changed

Reviewed By: priteshrnandgaonkar

Differential Revision: D7123493

fbshipit-source-id: 2fc19fa6c9b5614043af508a82e898b3ccefcbaa
2018-03-01 06:42:01 -08:00
Marcus Wu
99026e42a9 Fixed min-max docs typo
Summary:
Fixed `Max / Min Width and Height` docs typo.
Closes https://github.com/facebook/yoga/pull/720

Reviewed By: emilsjolander

Differential Revision: D7110855

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 253d96e5d1208b94b6248ffab5f59caaef6ada2b
2018-03-01 06:19:41 -08:00
Pritesh Nandgaonkar
3a82d2b1a8 Change NaN with large number
Summary:
Changed NaN with large number to support `-ffast-math` compiler flag.For  `-ffast-math` to work, all floating point numbers should be finite. Reason for not going with `FLT_MAX`, is that, it may cause number overflow during math operations. So thats why I opted for big number smaller than `FLT_MAX`.  Earlier we used NaN, while NaN is involved in comparision the comparision operator behaves differently, it always returns false. Also operators like, fmaxf,fminf etc. have wierd beahviours. This diff takes care of those things as far as possible, and all tests are passing.

Running ./instrumentation_tests/run instrumentation_tests/com/facebook/feed/ctacoalescing:ctacoalescing --class AttachmentCallToActionSelectorBenchmarkTest --benchmark --extra-arg iterations=100 shows the perf gain of 13-15%

Reviewed By: emilsjolander

Differential Revision: D6969537

fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
2018-03-01 04:03:19 -08:00
Pritesh Nandgaonkar
b28292e454 Make two separate yoga targets for QE
Summary: Setup QE for yoga perf changes

Reviewed By: emilsjolander

Differential Revision: D7059278

fbshipit-source-id: dd11b018edc8ea930d5eba09c6c01e349bb8b63c
2018-03-01 04:03:18 -08:00
Daniel Büchele
2ff18bc948 remove old docs folder
Summary: removing the old `docs` folder as we are switching to `gh-pages` branch.

Reviewed By: emilsjolander

Differential Revision: D7110147

fbshipit-source-id: a27e6fc3a115f2f62b8a0dd5833d872e24698021
2018-02-28 03:43:27 -08:00
Daniel Büchele
d0bee487e0 add tracking for code generators
Summary: Tracks a Google Analytics event once the code generator is opened.

Reviewed By: emilsjolander

Differential Revision: D7097182

fbshipit-source-id: 637a96db981f5e90c9f7ce155ba8669b8dac98fa
2018-02-27 07:13:53 -08:00
Daniel Büchele
419e29c5a6 adding --ignore-scripts flag to yarn
Summary: Travis builds for the website were failing. The problem was due to `yoga-layout` not compiling. However, we don't need to compile `yoga-layout` at all, because we are only using the asm.js version. This adds the `--ignore-scripts` flag to the `yarn` command, to ignore the post-install script which tries to compile yoga.

Reviewed By: emilsjolander

Differential Revision: D7097154

fbshipit-source-id: 3bf9efda0e2ae6166181dad66621cf6fc9586e88
2018-02-27 06:11:55 -08:00
Daniel Büchele
295d111f0e travis node version
Summary: Travis defaults to node version 0.10 (!). Explicitly setting the node version to 8.

Reviewed By: emilsjolander

Differential Revision: D7056888

fbshipit-source-id: f6e31cc75009dc4f322c1750c2ce540afdd641ce
2018-02-23 02:27:00 -08:00
Daniel Büchele
da5eb2db67 Remove travis builds
Summary: Removes travis build as they were currently not in use and prevented website from being deployed.

Reviewed By: emilsjolander

Differential Revision: D7055369

fbshipit-source-id: f227b1da1fea748c526b9faeedef063f9eeff61f
2018-02-22 08:19:56 -08:00
Daniel Büchele
3408e4d4fa adding travis deploy
Summary: Adds a deploy step to travis.yml file to depoly the docs to github pages.

Reviewed By: emilsjolander

Differential Revision: D7028804

fbshipit-source-id: bb91c6b1ad2a306a6957a48679f164128c5b1be1
2018-02-21 09:47:08 -08:00
Pascal Hartig
6d7eca8e42 Fix typo in docs
Summary:
"feature" should be "features" but it's already used twice in that paragraph so
I replaced it with "showcases" instead.

Reviewed By: emilsjolander

Differential Revision: D7042770

fbshipit-source-id: 0287f8746feca5c9f651950c8e9c24d2e86d55e9
2018-02-21 09:13:31 -08:00
Michael Lee
5726a71b62 Specify a platform argument for //yoga/java:jni
Summary: Specify that the jni rule is really for android

Reviewed By: emilsjolander

Differential Revision: D7015911

fbshipit-source-id: 5fbff4bb15d2d1256261b13417653b68bb6dc5aa
2018-02-20 15:02:21 -08:00
Kazuki Sakamoto
f73b5057ac Fix native build
Summary:
- Fix OSS build regarding is_apple_platform
- Update buck
- Drop 32bit build for Apple target

Reviewed By: ttsugriy

Differential Revision: D7032331

fbshipit-source-id: bb6a24bd404a107729a30b5ac4b419c238f7d42e
2018-02-20 14:13:39 -08:00
Pritesh Nandgaonkar
51051aad7f Added default constructor for YGCachedMeasurement
Summary: Added default constructor for YGCachedMeasurement. This diff uses the default initialiser to get rid off the older designated initializer syntax. This diff also addresses https://github.com/facebook/yoga/pull/700

Reviewed By: emilsjolander

Differential Revision: D7020337

fbshipit-source-id: e084e234bf6a2ae22e53e739959683abca169b88
2018-02-20 06:22:21 -08:00
Pritesh Nandgaonkar
91d3c08248 Add constructor in YGLayout
Summary: Add default constructor in YGLayout and moved to separate file. This diff also addresses https://github.com/facebook/yoga/pull/700

Reviewed By: emilsjolander

Differential Revision: D7019653

fbshipit-source-id: 5a2655626db0915fcebe7d4517e2d0b2e2484460
2018-02-20 06:22:21 -08:00
Pritesh Nandgaonkar
52f2cf319a Move YGStyle to seperate file and add constructors
Summary: Moved YGStyle to separate file and added default constructor to it. This diff also gets rid off of the default values, which were earlier declared in Yoga-interna.h and instead uses default constructor. This diff also addresses https://github.com/facebook/yoga/pull/700

Reviewed By: emilsjolander

Differential Revision: D7016575

fbshipit-source-id: eb28df0ffb4cc813b23edaff80d7d4ebc56ce6af
2018-02-20 06:22:17 -08:00
Emil Sjölander
bbdb62e654 Use absolute paths in links
Summary: allow-large-files

Reviewed By: danielbuechele

Differential Revision: D7023260

fbshipit-source-id: a797d09b61530b13da10e02c21acef13c508470c
2018-02-19 02:57:52 -08:00
Daniel Büchele
e024943c4b bugfixes
Summary:
- adds favicon
- adds page titles
- fixes bug in react native code gen

allow-large-files

Reviewed By: emilsjolander

Differential Revision: D7013492

fbshipit-source-id: d29a56a7caddf0da4fb19a0ba443c6906ccfff56
2018-02-19 02:38:16 -08:00
Sophie Alpert
7f44ec512e Update to MIT license
Summary: Manual changes.

Reviewed By: TheSavior, yungsters

Differential Revision: D7012152

fbshipit-source-id: de7459be3db13c687868b45059856f125c4f2eb1
2018-02-16 18:27:33 -08:00
Sophie Alpert
a2b6ddb7b1 Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:27:33 -08:00
Emil Sjölander
bdc37b0797 shipit
Reviewed By: danielbuechele

Differential Revision: D7010371

fbshipit-source-id: 9a111010755ee134bded7500c461342b944b4d62
2018-02-16 09:58:06 -08:00
Joel Marcey
82aaebfea2 Delete CNAME 2018-02-16 09:48:03 -08:00
Pritesh Nandgaonkar
48d82224ee Add redirect documentation
Summary: Add redirect documentation

Reviewed By: emilsjolander

Differential Revision: D7010032

fbshipit-source-id: fc370bc84e3afa0508ad38f910cf2bc20e991d84
2018-02-16 08:02:53 -08:00
Daniel Büchele
100afcfdb0 Add Yoga logo
Summary: Yoga logo was hotlinked from the old pages. This adds the logo to the sources

Reviewed By: emilsjolander

Differential Revision: D7009804

fbshipit-source-id: d913223e042b1bd9cf2ddab7c74d864e482d94b3
2018-02-16 07:22:06 -08:00
Daniel Büchele
b3436d5eba Default position to NaN
Summary: The position record defaulted to 0, which was wrong. No it defaults to NaN, which is the same as not having a value at all.

Reviewed By: emilsjolander

Differential Revision: D7009783

fbshipit-source-id: 83810da87e983f8d4d3e428f1f5fab0928bce58d
2018-02-16 07:22:06 -08:00
Daniel Büchele
c5371aca64 select value on focus
Summary: select the value of any input element once the field gets focus.

Reviewed By: emilsjolander

Differential Revision: D7009723

fbshipit-source-id: e1bc0f4b219958d8bdb79ef1a583cad86157b050
2018-02-16 07:22:06 -08:00
Pritesh Nandgaonkar
269619a419 Fixed Playground References for examples
Summary: Fixed Playground References for examples

Reviewed By: emilsjolander

Differential Revision: D7009922

fbshipit-source-id: 3025aebb383fb8e2be81e8ff59c0a071ce0860cb
2018-02-16 07:22:06 -08:00
Emil Sjölander
9b3104577c Tweak playground on landing page
Reviewed By: danielbuechele

Differential Revision: D7009909

fbshipit-source-id: a2734466efed6b9dc21f047be011b427bf67f830
2018-02-16 07:22:05 -08:00
Emil Sjölander
a1697d2307 Tweak landing page text
Reviewed By: danielbuechele

Differential Revision: D7009832

fbshipit-source-id: 69f7f68cc8d4f435f27c121bef4899c92f98a7a8
2018-02-16 07:22:05 -08:00
Emil Sjölander
056b75858c Tweak documentation
Reviewed By: danielbuechele

Differential Revision: D7009695

fbshipit-source-id: 145eca292e5cf95413caf5bc81b033419adb67a1
2018-02-16 07:22:05 -08:00
Emil Sjölander
c84ed90272 Allow playground on lg screens not just xl
Summary: This is now possible with the changes to centering the content

Reviewed By: danielbuechele

Differential Revision: D7009506

fbshipit-source-id: e2ff11d25dd6c388c82983d615e2a4c50b992583
2018-02-16 07:22:05 -08:00
Emil Sjölander
b21dd9891a Final tweaks
Reviewed By: danielbuechele

Differential Revision: D7009456

fbshipit-source-id: 65304f648141407bc15484840647050e712e89df
2018-02-16 07:22:05 -08:00
Emil Sjölander
bba81781af Copy review
Reviewed By: danielbuechele

Differential Revision: D7009457

fbshipit-source-id: d5053751a2bde369a65a740c03ace5bbd2eec02f
2018-02-16 07:22:05 -08:00
Pritesh Nandgaonkar
0c74a72fac Fix playground references
Summary: Fix playground references

Reviewed By: emilsjolander

Differential Revision: D7009698

fbshipit-source-id: 276fa1e5b98f05db281e101c90d6f19a1af77752
2018-02-16 06:42:02 -08:00
Daniel Büchele
1822bc5eaf Copy generated code to clipboard
Summary: Generated code modal now has a copy to clipboard button

Reviewed By: emilsjolander

Differential Revision: D7009716

fbshipit-source-id: 7a9b083d7067aa66ffa5b9d9c23741321547c4f6
2018-02-16 06:12:21 -08:00
Daniel Büchele
01ffe10c2f display NaN values as undefined
Summary: NaN values now display a placeholder saying undefined.

Reviewed By: emilsjolander

Differential Revision: D7009509

fbshipit-source-id: a3af360cc5c9d93e95a9e10368270f053a9b2c08
2018-02-16 05:51:22 -08:00
Daniel Büchele
7f99a547f5 hover on nodes
Summary: Adds a hover background color to nodes.

Reviewed By: emilsjolander

Differential Revision: D7009467

fbshipit-source-id: 1e1fb4d00086a6664ad8a53a0e8dbec075987a19
2018-02-16 05:51:22 -08:00
Daniel Büchele
0e5651fb80 Relative values in code generators
Summary: Code generators now can handle percentage and auto values as well as numeric values (DIP)

Reviewed By: emilsjolander

Differential Revision: D7009344

fbshipit-source-id: 64ddcb61a2dce01e68e38a16e4d5865d8e4c6d5b
2018-02-16 03:58:39 -08:00
Emil Sjölander
0ca44f3001 Document layout direction
Reviewed By: priteshrnandgaonkar

Differential Revision: D7000393

fbshipit-source-id: 2e5ae6a3fb69386920655bdfeee71a11f1775c2a
2018-02-16 03:49:48 -08:00
Pritesh Nandgaonkar
3f85763797 Documentation for Writing documentation
Summary: Documentation for "Writing documentation"

Reviewed By: emilsjolander

Differential Revision: D7000294

fbshipit-source-id: 633389a5e32ddd54be8f09b0945db5b9198d9552
2018-02-16 03:18:58 -08:00
Daniel Büchele
b318c4c5c9 upgrade yoga-layout
Summary:
- upgraded to yoga-layout@1.9.3
- set default values correctly
- catch errors

Reviewed By: emilsjolander

Differential Revision: D7001154

fbshipit-source-id: 49527576c61ce109ba0af0f50c981cf5c2c7d41a
2018-02-15 17:10:33 -08:00
Daniel Büchele
ae9703712a v1.9.3
Summary:
- fixes a but where `auto` was passed to properties that don't support auto as a value
- fixes errors in flow typing
- Re-adds accidentally removed scripts to package.json

Reviewed By: emilsjolander, arcanis

Differential Revision: D6999447

fbshipit-source-id: df66976c74c4af082a1ca0527e3e1ce54bdeb732
2018-02-15 09:48:39 -08:00
Emil Sjölander
d617ab6662 Tweak footer styling
Reviewed By: priteshrnandgaonkar

Differential Revision: D6999652

fbshipit-source-id: 93f4e43894388bb607112691a0b97e2e12a7df23
2018-02-15 09:12:34 -08:00
Daniel Büchele
4c3eebd3e5 Remove standalone playground
Summary: This is an older version of the standalone playground which is outdated and not used anymore

Reviewed By: emilsjolander

Differential Revision: D6998970

fbshipit-source-id: a27bee81b6f85f70c35a8d3e7ea7b06486c52626
2018-02-15 08:36:40 -08:00
Daniel Büchele
10061af491 enum title display
Summary: lower case and centerd

Reviewed By: emilsjolander

Differential Revision: D6998485

fbshipit-source-id: c06472afa4ccaa25ebf7c3c791d697b1fdc7732c
2018-02-15 08:36:40 -08:00
Daniel Büchele
91621641e6 visually center root node
Summary: root node is now centerwed between edge and editor

Reviewed By: emilsjolander

Differential Revision: D6989159

fbshipit-source-id: ce2621402d380843125fabc43452c64ea3b563dd
2018-02-15 08:36:40 -08:00
Pritesh Nandgaonkar
35c6931ade Remove unwanted footer items
Summary: Remove unwanted footer items

Reviewed By: emilsjolander

Differential Revision: D6999348

fbshipit-source-id: e1ff13b8a5a497bfc54e04294994eddef48bbf94
2018-02-15 08:13:40 -08:00
Yuichi ONO
44622912a2 Fix main size calculation from the aspect ratio
Summary:
When the following conditions are met, the main size become smaller by the margins in the main axis.
* The aspect ratio is defined
* The main size is not defined
* The cross size is defined
* The main margin is defined

This is because the main margin size is not included when calculating the main size from the aspect ratio.
Closes https://github.com/facebook/yoga/pull/715

Reviewed By: emilsjolander

Differential Revision: D6998988

Pulled By: priteshrnandgaonkar

fbshipit-source-id: f6f69c47ece17bd7c5e41517b96032bf0c149356
2018-02-15 07:40:34 -08:00
Pritesh Nandgaonkar
aac40cf89b Footer implementation
Summary: Footer Implementation

Reviewed By: emilsjolander

Differential Revision: D6998645

fbshipit-source-id: db637f2d9fe1cdbcaa8366e0cc03f2bf67e2543a
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
d4b20f5793 Documentation for absolute/relative layout
Summary: Documentation for absolute/relative layout

Reviewed By: emilsjolander

Differential Revision: D6998594

fbshipit-source-id: 25dacbb87e067ab8abd555fd24611776b0332047
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
89df2d9475 Google Analytics added
Summary: Google analytics added

Reviewed By: emilsjolander

Differential Revision: D6998583

fbshipit-source-id: 3886964407ec32454da4770b0fe80185e8e18881
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
79fa6f8d58 Documentation for min/max
Summary: Documentation for min/max

Reviewed By: emilsjolander

Differential Revision: D6998539

fbshipit-source-id: 65a0c1713fb5a01e41e0afcfbefa1b0280c82ed5
2018-02-15 06:21:01 -08:00
Pritesh Nandgaonkar
69242938f7 Add min/max in YogaRecord
Summary: Add min/max in YogaRecord

Reviewed By: emilsjolander

Differential Revision: D6998533

fbshipit-source-id: 4613c99bd3a4cb3b8fbe577909157b25f3bef9c7
2018-02-15 06:21:00 -08:00
Pritesh Nandgaonkar
1b66b5d941 Documentation added for width and height
Summary: Width and height documentation

Reviewed By: emilsjolander

Differential Revision: D6978015

fbshipit-source-id: f62972acaf70be2b6df5056b5deed2a893c10b4c
2018-02-15 06:21:00 -08:00
Emil Sjölander
fb30f7ddcb Responsify
Reviewed By: danielbuechele

Differential Revision: D6998697

fbshipit-source-id: ea15f1b1ce3f518c194dc66169413a92e0d870bc
2018-02-15 06:21:00 -08:00
David Vacca
747c2a4208 Make Java YogaNode cloneable
Summary:
This diff exposes the YogaNode clone operation to JNI in order to be able to clone Java YogaNode objects.

The clone method performs a shallow copy of the java YogaNode.

I made YogaNode to implement Cloneable, I know that this might not be a good idea but in this case it simplifies the cloning mechanism. I am open to suggestions.

IMPORTANT NOTES:
- The current implementation IS NOT making a deep copy of the mData instance variable.
- The mParent Java instance variable will reference the parent of the original Java YogaNode, is that ok sebmarkbage?

Reviewed By: priteshrnandgaonkar

Differential Revision: D6935971

fbshipit-source-id: a2008f1eb849b5074585b48699b7de56d5ac90d4
2018-02-14 18:12:34 -08:00
Daniel Büchele
43fda26275 add share and code buttons
Summary: Adds code and share buttons to the editor

Reviewed By: emilsjolander

Differential Revision: D6989097

fbshipit-source-id: 67478fe0810a0af43524f24458c520acf2999219
2018-02-14 11:03:59 -08:00
David Vacca
b1222bf83e Expose methods of persistent yoga for Java
Summary: This diff extends the JNI version of yoga in order to allow Java instances of the YogaConfig class to receive a callback when a Yoga node is cloned.

Reviewed By: priteshrnandgaonkar

Differential Revision: D6918605

fbshipit-source-id: e424c78680c04e21154ebe21405671c4e90f6529
2018-02-14 09:41:52 -08:00
Emil Sjölander
3ec41b656f Markdown redirect frontmatter
Reviewed By: danielbuechele

Differential Revision: D6987631

fbshipit-source-id: 8b3431fa885fb94d4a87119b5a5199db0b36b20c
2018-02-14 08:49:37 -08:00
Daniel Büchele
740ef6cd9e flexWrap, alignContent, initialPlayground
Summary: Adds `initialPlayground` to the markdown header. Adds contents fro alignContent and flexWrap.

Reviewed By: emilsjolander

Differential Revision: D6987513

fbshipit-source-id: 41de309d427a9f42e09477170fb8512ce1e7a816
2018-02-14 08:17:21 -08:00
Daniel Büchele
8c5cbf698b Inline controls for docs
Summary:
Adding inline controls in markdown using:
```
<controls prop="flexWrap"></controls>
```

Reviewed By: emilsjolander

Differential Revision: D6987150

fbshipit-source-id: 28def12df702ba5d5d5b6a83dd1cb907716d1b1c
2018-02-14 08:17:21 -08:00
Emil Sjölander
5f2cf6623f Bump size of documentation sidebar
Reviewed By: danielbuechele

Differential Revision: D6978450

fbshipit-source-id: c82da40e2ef44b360cb98e1cc0a28b516aa2e573
2018-02-13 11:43:04 -08:00
Emil Sjölander
4b7efb73d7 Change some default playground styling
Reviewed By: danielbuechele

Differential Revision: D6977989

fbshipit-source-id: 64975685490b8a2230d4effc8791c028b680d2b7
2018-02-13 11:43:04 -08:00
Emil Sjölander
a6b7e34187 Go over property descriptions and add documentation links
Reviewed By: danielbuechele

Differential Revision: D6977090

fbshipit-source-id: cc8a6acda8b9b7f007ad0a2f83249d4e6037bb0f
2018-02-13 11:43:04 -08:00
Emil Sjölander
e50308e823 Tweak styling of list and code in docs
Reviewed By: danielbuechele

Differential Revision: D6976762

fbshipit-source-id: 6decc7af180773193e3811253ada7f8d543c6cc8
2018-02-13 11:43:04 -08:00
Emil Sjölander
b6a13ce43a Mark selected page in toolbar
Reviewed By: danielbuechele

Differential Revision: D6976597

fbshipit-source-id: 280623b4dbf18eb008da846077fc8f5277eccc09
2018-02-13 11:43:03 -08:00
Daniel Büchele
96a87a811d Shorten playground URL
Summary: Shorten URL using Google's URL shortner and display URL for copying.

Reviewed By: emilsjolander

Differential Revision: D6976973

fbshipit-source-id: cc791ffbf9e01a8dc2e0a40d05bce5022a3957bc
2018-02-13 09:45:06 -08:00
Emil Sjölander
025ee03cb1 Add copywrite headers to css files
Reviewed By: danielbuechele

Differential Revision: D6976529

fbshipit-source-id: 7f0c3fdd70105cbe055fa49f10eac3bdaf84b5c2
2018-02-13 09:16:03 -08:00
Emil Sjölander
c06ee92251 Add standalone docs
Reviewed By: danielbuechele

Differential Revision: D6976384

fbshipit-source-id: 329dd6b5997ab83d408fb330421624cf85e3f09e
2018-02-13 07:42:41 -08:00
Emil Sjölander
3aca5965dc Fix sizing of playground in landing page
Reviewed By: danielbuechele

Differential Revision: D6976272

fbshipit-source-id: e9cf8582aa4f8d97190b40d5b7cf219ff1ef8ae5
2018-02-13 07:42:41 -08:00
Emil Sjölander
cac77e5ffa Add contributing docs
Reviewed By: danielbuechele

Differential Revision: D6976258

fbshipit-source-id: 71b3d0ab4a071ce0c4a9c1241cd6295aa6d52b8e
2018-02-13 07:31:58 -08:00
Emil Sjölander
49f1d7b5f6 Add external doc links for Litho, ComponentKit, and React Native
Reviewed By: danielbuechele

Differential Revision: D6976131

fbshipit-source-id: 83f5f59cb839d0c2f291621f9f88678261077082
2018-02-13 06:55:33 -08:00
Emil Sjölander
82e44dbf04 Handle external doc links
Reviewed By: danielbuechele

Differential Revision: D6976132

fbshipit-source-id: 56bd33816a312af12ba9a0f088c9f49a42ef9913
2018-02-13 06:55:33 -08:00
Emil Sjölander
9b501dd9eb Scroll doc sidebar not whole page
Reviewed By: danielbuechele

Differential Revision: D6976133

fbshipit-source-id: 7807aa4e2ab0ed013fbd1f4bbef2ee1b8098dff6
2018-02-13 06:55:33 -08:00
Emil Sjölander
8ba663f6f4 Document margins, paddings, and borders
Reviewed By: danielbuechele

Differential Revision: D6976134

fbshipit-source-id: dcf870d9a88478ed1aef68e9840e7b17467b87bb
2018-02-13 06:55:32 -08:00
Emil Sjölander
8f35484262 Document flexing
Reviewed By: danielbuechele

Differential Revision: D6976135

fbshipit-source-id: e9051b1e583d909aefe76f7aa9505467890a0d4c
2018-02-13 06:55:32 -08:00
Emil Sjölander
1e3143656d Document aspect ratio
Reviewed By: danielbuechele

Differential Revision: D6976130

fbshipit-source-id: caf3cc1d1d1c00fee03ca26966fb57d1796e1604
2018-02-13 06:55:32 -08:00
Daniel Büchele
699b1f5012 Fixing playground editing
Summary: editing numerical values didn't work. this fixes it and cleans up the API of the playground

Reviewed By: emilsjolander

Differential Revision: D6976128

fbshipit-source-id: 9b1ace9d93ba8e597bdfb4842ed6adcaf8b77fd9
2018-02-13 06:16:12 -08:00
Daniel Büchele
9c877a621e fix inserting/deleting children
Summary: Inserting or deleting nodes threw an error, due to some changes I made earlier. This fixes the error.

Reviewed By: emilsjolander

Differential Revision: D6975950

fbshipit-source-id: d04df08260ab8ab248726809329e69f4d264decd
2018-02-13 06:16:12 -08:00
Daniel Büchele
a3144150e0 fix Yoga imports for build script
Summary: The bundling of gatsby is done in node. This caused the node-libs from yoga being loaded. This directly imports the browser version.

Reviewed By: emilsjolander

Differential Revision: D6975779

fbshipit-source-id: 0257a86733c5552259b171309e59cc676786621e
2018-02-13 06:16:12 -08:00
Daniel Büchele
c830083df3 Website readme
Summary: Updating readme

Reviewed By: emilsjolander

Differential Revision: D6975778

fbshipit-source-id: c27a074c8d512e72de63ffa1d2f06f18a4f8e2c5
2018-02-13 06:16:12 -08:00
Emil Sjölander
9eb03b1bcd playground doc page first draft
Reviewed By: danielbuechele

Differential Revision: D6968725

fbshipit-source-id: 588018a347a723b32e4dcab407c4da2db0d85130
2018-02-13 04:01:04 -08:00
Emil Sjölander
7e3136c347 non-playground doc page first draft
Reviewed By: danielbuechele

Differential Revision: D6968540

fbshipit-source-id: c5d408adb1d11c429d72a0f180ce3154ae0922a6
2018-02-13 04:01:04 -08:00
Emil Sjölander
c3de8016c0 Move footer to only landing page
Reviewed By: danielbuechele

Differential Revision: D6968277

fbshipit-source-id: ec01d6e0de6a76ab9235378a1c1a29dcf7903ae3
2018-02-13 04:01:04 -08:00
Emil Sjölander
af45863f8e Docs page first draft
Reviewed By: danielbuechele

Differential Revision: D6968201

fbshipit-source-id: f08104428188b8b3225b2803c9f2165ee653a0b6
2018-02-13 04:01:04 -08:00
Emil Sjölander
08d7d1673e Add documentation placeholders
Reviewed By: danielbuechele

Differential Revision: D6968199

fbshipit-source-id: 433d81b6367d1376224e0b3516be65132c091a34
2018-02-13 04:01:03 -08:00
Emil Sjölander
e7c56ccd1e Landing page first draft
Reviewed By: danielbuechele

Differential Revision: D6964899

fbshipit-source-id: ea9fed66ba0376a5cd2efda4d631cc14e591e666
2018-02-12 10:46:04 -08:00
Emil Sjölander
de8cab8e60 Footer design
Reviewed By: danielbuechele

Differential Revision: D6964900

fbshipit-source-id: 68831f101ef2112613cd170cb90bdd9235441c9d
2018-02-12 10:46:04 -08:00
Emil Sjölander
9e0f751464 Toolbar design
Reviewed By: danielbuechele

Differential Revision: D6964901

fbshipit-source-id: c052449d0ae3da91bec64c8f9da867244022ccf1
2018-02-12 10:46:03 -08:00
Daniel Büchele
951a429ac5 Template for docs pages
Summary:
- Dynamic loading of documentation pages
- code highlighting for markdown files
- editing playground from sidebar

Reviewed By: emilsjolander

Differential Revision: D6964951

fbshipit-source-id: 1c7f36afa8d23215471d5b9a9c01bd2241c2008e
2018-02-12 10:46:03 -08:00
Daniel Büchele
e43bb9da19 website v2 skeleton
Summary:
Sets up a skeleton for the new yoga website using gatsby static site generator

allow-large-files

Reviewed By: emilsjolander

Differential Revision: D6952326

fbshipit-source-id: 7579bc80bec21552689da5b78f3d960910ff13bb
2018-02-12 09:39:22 -08:00
Pritesh Nandgaonkar
b08bd572ef Add flag in YGConfig for running experiments
Summary: Add flag in YGConfig for running experiments

Reviewed By: emilsjolander

Differential Revision: D6948702

fbshipit-source-id: 009fe2d64b6098f8c3a0289f0e6939dea5ce0d37
2018-02-09 06:45:11 -08:00
Pritesh Nandgaonkar
402ee11273 Fix memory leak by not duplicating the YGConfig
Summary:
YGConfig isn't owned by the YGNode, and thus isn't freed when freeing the node (`YGNodeFreeRecursive`)

This fixes a memory leak caused by D6856812

Reviewed By: emilsjolander

Differential Revision: D6945022

fbshipit-source-id: 5fd3c3e2ac1cd94d459d5aa06e0daa8f107779ac
2018-02-09 05:00:13 -08:00
Pritesh Nandgaonkar
6e38a26f32 Expose a function which marks all descendants dirty
Summary: Expose a function which marks all descendants dirty

Reviewed By: emilsjolander

Differential Revision: D6911869

fbshipit-source-id: e0a3abcf5653f921297edfdca473d83b947cc627
2018-02-08 05:23:46 -08:00
Pritesh Nandgaonkar
d66239bea8 call margin method on child instead of node
Summary: While moving a function as a method in YGNode, there was an error in which I mistakenly called a method on node, whereas I had to call it on child.

Reviewed By: emilsjolander

Differential Revision: D6918367

fbshipit-source-id: cee90e015f9e45a717a7307f59fd3b9ef6f399b6
2018-02-07 17:27:22 -08:00
Pritesh Nandgaonkar
7eb8df2777 Fix screenshot test due main axis justification refactor
Summary: There was a slight error in main axis justification which caused the regression

Reviewed By: emilsjolander

Differential Revision: D6923178

fbshipit-source-id: d8f81b06d9127c75daecffb73b5e6c5abbad8ade
2018-02-07 08:53:08 -08:00
Joel Marcey
75473fd924 Create CNAME 2018-02-06 09:32:58 -08:00
Joel Marcey
c94ade8ffd Update config for yogalayout.com
Summary: Closes https://github.com/facebook/yoga/pull/710

Reviewed By: emilsjolander

Differential Revision: D6912211

Pulled By: JoelMarcey

fbshipit-source-id: 8ccadc1a4845fb8a6fdc756077bfad01f0de7aac
2018-02-06 09:31:34 -08:00
Pritesh Nandgaonkar
61afbd43c9 Moved margin axis function as a method in YGNode
Summary: Moved margin axis function as a method in YGNode

Reviewed By: emilsjolander

Differential Revision: D6900003

fbshipit-source-id: a42da3bcd3126bf8c432c6740987b5ec0b572172
2018-02-06 08:44:46 -08:00
Pritesh Nandgaonkar
64f6ea37bd Moved trailing padding and border function as a method on YGNode
Summary: Moved trailing padding and border function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6899571

fbshipit-source-id: 7f686e8771d5a94aae502191516557b20c557d7c
2018-02-06 08:44:46 -08:00
Pritesh Nandgaonkar
dc0609d153 Moved out main axis justification logic to seperate function
Summary: Moved out main axis justification logic to seperate function

Reviewed By: emilsjolander

Differential Revision: D6845997

fbshipit-source-id: fdb64e00de39427ce1d66d4fbfd06c23c0d32bcf
2018-02-06 08:44:45 -08:00
Daniel Büchele
bd46344a4e Fix ComponentKit code generation
Summary: Fixes ComponentKit code generation to outpput valid code.

Reviewed By: emilsjolander

Differential Revision: D6902924

fbshipit-source-id: f03a69268d22084f30aea46297b59aec28ba68d2
2018-02-06 08:27:42 -08:00
Joel Marcey
7199902316 Delete CNAME 2018-02-06 08:16:40 -08:00
Joel Marcey
250873abf2 Create CNAME 2018-02-06 08:12:21 -08:00
Pritesh Nandgaonkar
1e775ecb83 Fixed failing snapshot test
Summary: Fixed failing snapshot test

Reviewed By: emilsjolander

Differential Revision: D6901242

fbshipit-source-id: 7391d6a34fa28e9f92f4ff834755a89dd876fdad
2018-02-06 07:23:56 -08:00
Daniel Büchele
9718c517d9 add playground
Summary:
This adds a web-based playground to try out Yoga. The playground uses yogas javascript bindings to use yoga within the browser. The layout tree can be modified and shared. Code generators for litho, ComponentKit and React Native allow the layout to be copied into any app.

allow-large-files

Reviewed By: emilsjolander

Differential Revision: D6871601

fbshipit-source-id: 3b97c87e91d6bafe8e1c38b8b7eca8d372324c0b
2018-02-05 07:11:57 -08:00
Pritesh Nandgaonkar
afc215aa66 Made a separate function for resolving flexible length
Summary: Made a separate function for resolving flexible length

Reviewed By: emilsjolander

Differential Revision: D6834269

fbshipit-source-id: 954bc7fe8eb9256d353cdda27e5c64c076808e25
2018-02-05 06:42:52 -08:00
Pritesh Nandgaonkar
5df8157863 Seperate function for second pass
Summary: Added a separate function which does the second pass to distribute the free space amongst the views which can be flexed.

Reviewed By: emilsjolander

Differential Revision: D6833635

fbshipit-source-id: 7680a67db8bfe22f8fb86407159888882f3a3353
2018-02-05 06:42:52 -08:00
Pritesh Nandgaonkar
802fe6bb29 Replaced first pass with a function
Summary: Added a function which does the first pass to determine the free space based on flex items whose min and max constraints are triggered

Reviewed By: emilsjolander

Differential Revision: D6819719

fbshipit-source-id: e5e77c21d1dca2255433da3388887d9db3f7b642
2018-02-05 06:42:51 -08:00
Pritesh Nandgaonkar
27d2ad198e Moved out logic to calculate size consumed on a line into seperate function
Summary: Moved out logic to calculate size consumed on a line into seperate function

Reviewed By: emilsjolander

Differential Revision: D6797640

fbshipit-source-id: ad9757e7d603c0ce57f452b1e5c404037605bed9
2018-02-05 06:42:51 -08:00
Pritesh Nandgaonkar
63be3ff84c Remove the use of legacy flag and log the diff if its used
Summary: Check if the layout tree is different if we do not use legacy flags. If they are different then report to the client

Reviewed By: emilsjolander

Differential Revision: D6856812

fbshipit-source-id: e4724d80702cc75c1894e348e137b24e663573d2
2018-02-02 07:43:26 -08:00
Mark Wang
66045bd13d Use delete instead of free
Summary: Since a `YGNodeRef` is created with `new`, it needs to be deleted using `delete` instead of `free`.

Reviewed By: richardjrossiii

Differential Revision: D6866064

fbshipit-source-id: a44828cedb5045b6c97179fb30ffd8c8dafcbfbe
2018-01-31 18:12:55 -08:00
Pritesh Nandgaonkar
f5f8105b57 Made logging logic dynamic to log string length
Summary: Previously the logging logic assumed fixed number of characters in the string to be logged. With this diff the logging logic is made dynamic, catering to variable length of the string to be logged

Reviewed By: emilsjolander

Differential Revision: D6784491

fbshipit-source-id: 26e4520a84be355ff992b808297ce7a95b3d09e3
2018-01-23 06:41:41 -08:00
Pritesh Nandgaonkar
4f92ae46ef Yoga android news feed benchmark tests
Summary: Added a benchmark tests along with the usual gentest in yoga for a complex yoga android news feed view.

Reviewed By: emilsjolander

Differential Revision: D6753544

fbshipit-source-id: 23b8da9785990a86248ff4708ac61e12411eb489
2018-01-22 04:30:26 -08:00
Pascal Hartig
80f8aa3c7e Mark model fields final
Summary: These are already considered immutable, but not marked in their class.

Reviewed By: emilsjolander

Differential Revision: D6759564

fbshipit-source-id: 810dc8a9730fb330760d2aedecafcea81cf25cb1
2018-01-22 02:56:53 -08:00
Daniel Büchele
42778f687b Release version 1.9.0
Summary:
- Fixes bindings
- Fixes benchmarks and test calls
- version 1.9.0

Reviewed By: arcanis, priteshrnandgaonkar

Differential Revision: D6759438

fbshipit-source-id: 0ea58e607e0b518aaa907cbfa82d2baea7bc1ed5
2018-01-19 11:28:44 -08:00
Daniel Büchele
7b27a58b97 NPM release v1.8.1
Summary: Package is already published via NPM. This is just the version bump.

Reviewed By: emilsjolander

Differential Revision: D6750224

fbshipit-source-id: 6add1ce71714e58e4afacd095265b3e770bc558e
2018-01-19 11:28:44 -08:00
Daniel Büchele
a40ba9d350 update JavaScript bindings
Summary:
- adds flow types
- transpiles bundle using babel
- cleans and formats code

Reviewed By: emilsjolander

Differential Revision: D6748362

fbshipit-source-id: fcb5fdde73df6e0062eff1e5038bb5fe0532f997
2018-01-18 08:27:03 -08:00
Pritesh Nandgaonkar
9ecdff14fa Use vector instead of linked list
Summary: Currently in the flexbox algorithm we were using linked list for maintaining the nodes which had relative/absolute position types, this diff uses STL vector instead of linked list.

Reviewed By: emilsjolander

Differential Revision: D6722959

fbshipit-source-id: 4e81176802b9a9319bc5f385c824a06be14a83a2
2018-01-16 09:42:13 -08:00
Pritesh Nandgaonkar
288adc49c9 Fix for failing screenshot tests
Summary: Fixes failing screenshot tests

Reviewed By: emilsjolander

Differential Revision: D6726745

fbshipit-source-id: 99f91aabe2337b23953724545f97695238f2124e
2018-01-16 09:20:09 -08:00
Valentin Shergin
b8c2428b31 Exposing setDirtiedFunc as plain C function YGNodeSetDirtiedFunc
Summary:
@public
Trivial. Those lines were lost during rebasing of the original commit.

Reviewed By: priteshrnandgaonkar

Differential Revision: D6717696

fbshipit-source-id: a5dce25427c8977352b3ae7ea01e546a540e0c13
2018-01-15 15:52:29 -08:00
Pritesh Nandgaonkar
92bfcbafc0 Moved leadingpaddingnandborder function as a method on YGNode
Summary: Moved leadingpaddingnandborder function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711991

fbshipit-source-id: 41ad7191bf8df6fe3131106436dc0c87e9dee297
2018-01-15 10:15:14 -08:00
Pritesh Nandgaonkar
130b5beca2 Move trailing padding function as a method on YGNode
Summary: Move trailing padding function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711897

fbshipit-source-id: fa2e1a8e31242358a6e94aef51368e2c2c58b79d
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
adb2e0fdd6 Moved leading padding function as a method on YGNode
Summary: Moved leading padding function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711830

fbshipit-source-id: d2f6f55ec23b007bb51f8a91385e02236f46dc7b
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
0a04bd7f2f Resolve direction function is now as a method on YGNode
Summary: Resolve direction function is now as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711755

fbshipit-source-id: a0e80596e10f0c7fb7a31b75377da4db846c4bbb
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
9d6af5b314 Move trailing border function as a method on YGNode
Summary: Move trailing border function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711666

fbshipit-source-id: fe4fdfc2db59d03beb763317e1a6f9de52f851d4
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
6efb4b90d4 Move leading border function as a method on YGNode
Summary: Move leading border function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711523

fbshipit-source-id: 76e90083a9dd0728dc9557cc3b0a1f431f3afd5d
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
5806f1728c Moved YGNodeIsFlex as a method on YGNode
Summary: Moved YGNodeIsFlex as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6711536

fbshipit-source-id: e60be7da55e3e8d254eb253c141d219a37a76087
2018-01-15 10:15:13 -08:00
Pritesh Nandgaonkar
a9dd527748 Refactored step3 of flexbox algorithm
Summary: Previously flexbasis calculation was doing more than one task of accumulating absolutelypositioned child and flexbasis calculation. So this diff refactors the logic and moves out absolutely positioned child calculation to our step 1(which is calculating the variables which are required for rest of the algorithm). This diff also moves the flexbasis logic into separate function

Reviewed By: emilsjolander

Differential Revision: D6702749

fbshipit-source-id: 15dcc94ae30ac185e4d1c7d6e3744a40cfa47317
2018-01-15 10:15:12 -08:00
Pritesh Nandgaonkar
db3d20b7b7 Refactored the flexbox step to determine available space in main and cross dim
Summary: Refactored the logic to calculate available main and cross dimensions

Reviewed By: emilsjolander

Differential Revision: D6693777

fbshipit-source-id: d6c87670e74bdc22b32916c2d77fe423d831b378
2018-01-15 05:41:56 -08:00
Semen Zhydenko
acd4e01aaf Typos in comments and log messages
Summary:
No code changes, no testing required.

alligned -> aligned
allignment -> alignment
completly -> completely
conseptually -> conceptually
decendents -> descendants
indefinetly -> indefinitely
dimention -> dimension
doesnt -> doesn't
safegaurd -> safeguard
intialization -> initialization
hierachy -> hierarchy
happend -> happened
gaurd -> guard
programatically -> programmatically
initalized -> initialized
immidiately -> immediately
occured -> occurred
unkown -> unknown
neccessary -> necessary
neccesarily -> necessarily
occuring -> occurring
comoponent -> component
propogate -> propagate
recieved -> received
referece -> reference
perfomance -> performance
recieving -> receiving
subsquently -> subsequently
scoll -> scroll
suprisingly -> surprisingly
targetting -> targeting
tranform -> transform
symetrical -> symmetrical
wtih -> with
Closes https://github.com/facebook/react-native/pull/17578

Differential Revision: D6718791

Pulled By: shergin

fbshipit-source-id: 4ab79c1131ec5971d35a0c7199eba7ec0a0918ad
2018-01-12 22:16:32 -08:00
Attila Jakabfi
b217f23ba5 Spacing
Summary: Add spacing type to Yoga Config

Differential Revision: D6683074

fbshipit-source-id: a76bc5028962d738bb931a997752f6ba194bd8ed
2018-01-12 05:13:40 -08:00
Pritesh Nandgaonkar
76875af207 Moved setPosition as a method on YGNode
Summary: Moved setPosition as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683387

fbshipit-source-id: 83f64101faa700933771c69b222056ec2a6b8d1e
2018-01-11 04:59:02 -08:00
Pritesh Nandgaonkar
f2ba14c309 Moved trailingmargin function as a method on YGNode
Summary: Moved trailingmargin function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683313

fbshipit-source-id: 5ee458c2f4698768724901df0e3f5d8805c7c8f5
2018-01-11 04:59:02 -08:00
Pritesh Nandgaonkar
a65b79a944 Moved getLeadingMargin as a function on YGNode
Summary: Moved getLeadingMargin as a function on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683270

fbshipit-source-id: a26663006419e13cb783e9849183e3c665f59b3c
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
681b580fd8 Moved getTrailingPosition function as a method on YGNode
Summary: Moved getTrailingPosition function as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683205

fbshipit-source-id: d30003d90d634c644d92c833e58165b073d4d13e
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
b985b6c377 Moved is isTrailingPos defined as a method on YGNode
Summary: Moved is isTrailingPos defined as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6683190

fbshipit-source-id: c37e57d02cc4475eb8181a2bb003c555bdb0aaea
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
92eda21e78 Moved isLeadingPos defined as a method on YGNode
Summary: Moved isLeadingPos defined as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6682956

fbshipit-source-id: 31c60e0eae906e1434a6969f3cd786fcaf9097a5
2018-01-11 04:59:01 -08:00
Pritesh Nandgaonkar
0cfdb50477 Moved YGNodeLeading position as a method on YGNode
Summary: Moved YGNodeLeading position as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6682929

fbshipit-source-id: 3607aab1544b62b1126c5d75b2f6fb8f5ca2d45f
2018-01-11 04:59:01 -08:00
Valentin Shergin
1eb9a5edd9 Tests for YGNodeSetDirtiedFunc
Summary: testallthethings

Reviewed By: gkassabli

Differential Revision: D6687460

fbshipit-source-id: bebae3604212cb10e7ac43d10cfebd4978834d69
2018-01-10 10:09:38 -08:00
Valentin Shergin
383b881748 Introducing on-dirty handler (aka YGNodeSetDirtiedFunc)
Summary:
@public
Currently, we can dirty leaf nodes with `measure` function, we also can get `dirty` status for any node, but we cannot handle a moment when this change happen. This diff introduces a new call-back-manner handler for it.
We need this to plug Yoga inside and outside other layout systems without maintaining own dirty propagation infrastructure.
Consider using Yoga for flex-box layout in React Native where we can have deeply nested layout like `<View><Text><View><Text/></View></Text></View>` where all content of all <Text> nodes are laid out using native text/inline (not flex-box!) layout system. In this case, when some change dirties some deeply nested Yoga node, we have to propagate the dirty state down to outer one. Having this handler makes possible to wire up `on-dirty` handler on the root node and `setDirtied` for the leaf node.
Removing custom dirting mechanism from React Native should drastically simplify rendering layer and bring a huge performance win.

Reviewed By: emilsjolander

Differential Revision: D6597856

fbshipit-source-id: 6588cd712f9c1dede4af32f3d326f90103e48ff0
2018-01-10 10:09:38 -08:00
Pritesh Nandgaonkar
47543c8fba Move utility functions to utils file
Summary: Move utility functions to utils file

Reviewed By: emilsjolander

Differential Revision: D6682933

fbshipit-source-id: 0fd90fdaf5ca4f9b7a11cbd15d8c54c7d0ce8a03
2018-01-10 05:03:52 -08:00
Pritesh Nandgaonkar
dc6ed89bfa Fix warnings of casting and null pointer handling
Summary: There were warnings of castings and null pointer handling in yoga.cpp. This diff fixes the warnings. The issue was brought up here https://github.com/facebook/react-native/issues/17274

Reviewed By: emilsjolander

Differential Revision: D6675111

fbshipit-source-id: 884659fabb05033b4d43d3aa6629e22481d39b7e
2018-01-09 04:27:01 -08:00
Pritesh Nandgaonkar
348dd368b5 Move YGNodeResolveFlexShrink to a method on YGNode
Summary: Move YGNodeResolveFlexShrink to a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6611418

fbshipit-source-id: 6e5ba39b555d313a967800589891027920112c15
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
40eeefd4f7 Moved YGResolveFlexGrow as a method on YGNode
Summary: Moved YGResolveFlexGrow as a method on YGNode

Reviewed By: emilsjolander

Differential Revision: D6611385

fbshipit-source-id: 71660946c469fac77c5ffa0284c793e6adc9db7b
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
47892c17ce Move markDirtyInternal as a method in YGNode
Summary: Moved YGNodeMarkDirtyInternal as a method in YGNode

Reviewed By: emilsjolander

Differential Revision: D6611287

fbshipit-source-id: 54402145d51ea717553ea136be739b9880a79817
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
f2a369fb73 Move YGCloneChildrenIfNeeded as a method on YGNode
Summary:
- Removed the default() static method, instead of this, its zero argument initialiser is used
  - Moved `YGCloneChildrenIfNeeded` to `cloneChildrenIfNeeded` as a method on `YGNode`.

Reviewed By: emilsjolander

Differential Revision: D6611155

fbshipit-source-id: 463723a363e0fbd2c7686f65226eca73236bd07e
2018-01-08 03:00:46 -08:00
Pritesh Nandgaonkar
61dc10ef66 Optimize the performance of Origami
Summary: With this flag the the workflow successfully passed.

Reviewed By: emilsjolander

Differential Revision: D6619293

fbshipit-source-id: c1632efd97f47696b7f8bb1b3e763de92c707287
2017-12-22 06:55:20 -08:00
Pritesh Nandgaonkar
7d01f4d8b1 Do not set FB_ASSERTION_ENABLED
Summary: Currently whenever `Yoga.h` is imported by someone we set `FB_ASSERTION_ENABLED`. The use case of this flag is to use assert calls of `FBAssert.h`, since we do not use it anymore, there is no need to set this flag.

Reviewed By: emilsjolander

Differential Revision: D6611904

fbshipit-source-id: f01ac144159c1b333d8deb8cbb5ba0288e4bf7a4
2017-12-21 04:56:09 -08:00
Pritesh Nandgaonkar
c7a5e1e290 Fix typo in YogaKit's YGDimensionFlexibility
Summary: Fix typo in `YGDimensionFlexibility` enum

Reviewed By: emilsjolander

Differential Revision: D6601679

fbshipit-source-id: 3a7d98322de3383de65ff5164d4c7a632ac6916f
2017-12-20 03:11:46 -08:00
Pritesh Nandgaonkar
fbd332dee8 Make YGNode as c++ struct with properties exposed through accessors
Summary: Moved c implementation of `YGNode` to C++ struct. Not moving to C++ class as the React Classes dependent on `Yoga.h` assume it to be C. Thats why keeping `Yoga.h` C compatible. Sorry for the long diff, didn't thought that it will turn out to be this much big.Will keep an eye on number of lines next time 😉

Reviewed By: emilsjolander

Differential Revision: D6592257

fbshipit-source-id: 641e8b9462ad00731a094511f9f5608b23a6bb21
2017-12-19 11:33:07 -08:00
Pritesh Nandgaonkar
dbf6a12134 Hide init of YGLayout
Summary:
Make default init unavailable, as it will not initialise `YGNode` which is required for the setters
 and getters of YGLayout's properties to work properly. In setters and getters we call the corresponding `YGNode`'s setters and getters. Thus the following code will crash

```
let layout = YGLayout()
layout.flexDirection = .row
```

Reviewed By: emilsjolander

Differential Revision: D6597796

fbshipit-source-id: 653d275d7314bfdd7a1106884fa3fbc0a13e1be7
2017-12-19 07:48:35 -08:00
Amir Shalem
dbc47ae383 Disable assert code in release builds (define DNDEBUG)
Summary:
Disable assert code in release builds (define DNDEBUG).
This disables assertions in Facebook JNI library - which checks that our references to Yoga JNI objects are correct.
This saves CPU time, since those checks are costly.

Reviewed By: emilsjolander

Differential Revision: D6592023

fbshipit-source-id: eaf869c7990cab3a72ae2bbdc67e709153f5020c
2017-12-18 11:32:36 -08:00
Amir Shalem
f22cfd52e0 Add buck mode/opt compile file to support release compilation mode
Summary:
Currently we have `-O3` hardcoded inside our BUCK target files, this will allow us afterwards to remove that.
Follow up commit will also add `-DNDEBUG` which will disable `assert` in release builds.

Reviewed By: emilsjolander

Differential Revision: D6592024

fbshipit-source-id: f541ee8728ff44db8e31885f2085dc036a400f70
2017-12-18 11:32:36 -08:00
Jonathan Kim
2a10337344 Consolidate mobile yoga into top-level xplat
Reviewed By: emilsjolander

Differential Revision: D6494379

fbshipit-source-id: f6b78d8a1b3d4bcdeef350ad7bd097cdbe5d15b1
2017-12-13 15:08:03 -08:00
Greg McGary
836eaa62df Explicitly #define isnan __builtin_isnan for Android clang-5 to mimic gcc's default behavior
Summary:
GCC internally aliases isnan and a dozen other math.h primitives to their `__builtin_` counterparts, which compile straight to assembler. Clang does not do this, so calls to `isnan` compile to a function call. The Android libc does not define `isnan` because it assumes all application code compiled `__builtin_isnan` and has no need for the function `isnan`.

This is a temporary kludge: Starting with NDK r16, the math.h header has appropriate `#defines` to alias primitives to their `__builtin_` counterparts. Upon upgrade to NDK r16, this can be reverted.

Reviewed By: passy

Differential Revision: D6527499

fbshipit-source-id: 65d9e43c7e7d973a6c92e9863ebe469b35a24ac8
2017-12-12 16:56:48 -08:00
Taras Tsugrii
a01c7adcfb Skylarkify default_platform_defs macros.
Reviewed By: adamjernst

Differential Revision: D6527119

fbshipit-source-id: 1e31b9491d2cf501f348d544482c025096fd81b1
2017-12-09 10:28:47 -08:00
Ben Nham
5133faa1ad Revert D6155682: Use clang-5.0 -Oz
Summary:
This reverts commit 2f64e742f4dc44be171274c2ad0a41fb1e7079d7

bypass-lint

Differential Revision: D6155682

fbshipit-source-id: 9139ed14e0d24784bf25b2783e364a511173ab83
2017-12-08 09:42:21 -08:00
Emil Sjölander
6a8c2960ad New javascript release
Summary: https://www.npmjs.com/package/yoga-layout

Reviewed By: arcanis

Differential Revision: D6496634

fbshipit-source-id: 2d834edcfce6c1e3d3f481822b3ccd22b39e1a13
2017-12-07 19:02:32 -08:00
Greg McGary
0c98e89fdb Use clang-5.0 -Oz
Summary:
Use clang-5.0 -Oz as default NDK compiler for android.
It does 3 good things:
* brings us into compliance with deprecation of gcc for android NDKs since r13
* yields slightly smaller native code, on the order of many-10s-to-small-100s of KB
* slight improvement in startup performance, on the order of 10s of ms

Reviewed By: mzlee

Differential Revision: D6155682

fbshipit-source-id: 2f64e742f4dc44be171274c2ad0a41fb1e7079d7
2017-12-07 13:27:20 -08:00
Yaroslav Pavlov
5f78181911 Round size geometry for Button and RichText components.
Summary:
ComponentKit requires all size geometry provided to be rounded to pixel grid. This ensures
that layout will not truncate provided sizes.

Reviewed By: cuva

Differential Revision: D6466875

fbshipit-source-id: 62a480411e7d2354a6879917c42bbf0ee96cdadd
2017-12-06 16:27:45 -08:00
Pritesh Nandgaonkar
03dd1d23fa vector instead of YGNodeList
Summary: Replaced YGNodeList with std::vector

Reviewed By: jonathandann, emilsjolander

Differential Revision: D6442379

fbshipit-source-id: d2d48ef0676351d2eeaa2d427dcd72e082cd15a1
2017-12-05 08:28:54 -08:00
Luc Dion
91683be798 YogaKit: Changes so we are able to reset properties to their initial value
Summary:
Changes so we are able to reset properties to their initial value.
This is required to reset these properties.

Add the support of YGUnitUndefined to many properties:
* minWidth
* maxWidth
* minHeight
* maxHeight

Also, these properties must be reset to YGUnitAuto.
* width
* height
* flexBasis

This now matches completely how these properties are initialized in Yoga.cpp
Closes https://github.com/facebook/yoga/pull/672

Reviewed By: dshahidehpour

Differential Revision: D6407908

Pulled By: emilsjolander

fbshipit-source-id: ac20c7b2c06349115aea7d31240204d17e2f1b44
2017-12-04 04:26:46 -08:00
Cory Reed
109cb1a562 Fix Android comment and docblock typos
Summary:
👋 Hello! Thanks for react-native, it’s a great project.

I was digging into the Android implementation in _ReactAndroid_ and noticed a couple typos in the documentation. I went through and tried to fix all the typos I could find using [aspell](http://aspell.net).

Not applicable: these changes are only to comments, and CI should be skipped.

[ANDROID][ENHANCEMENT][*] - Correct comment and docblock typos
Closes https://github.com/facebook/react-native/pull/17049

Differential Revision: D6472182

Pulled By: shergin

fbshipit-source-id: 7e62cab118609596b483d1cf16c3abf651d6753b
2017-12-03 20:15:49 -08:00
Lukas Wöhrl
ad1240e276 Fix min/max percentage constraints on measured nodes
Summary:
Fix min/max percentage constraints on measured nodes. Currently we passed in the available size instead of the parent size.
Fixes #611
Closes https://github.com/facebook/yoga/pull/649

Reviewed By: priteshrnandgaonkar

Differential Revision: D6408019

Pulled By: emilsjolander

fbshipit-source-id: 18be5056dbc0dc179970ec231ab8b4e2cdba65c5
2017-11-30 08:02:05 -08:00
Emil Sjölander
2e468d9c8c Update watir
Summary: We were using a very out-dated version of watir which did not run with latest ruby

Reviewed By: priteshrnandgaonkar

Differential Revision: D6447029

fbshipit-source-id: ff4ccb8c96947811ff09f7e87cb504e3e7cb834e
2017-11-30 07:01:32 -08:00
Huge Rocker
6caa94b779 Fix can not find source files in CMakeLists.txt
Summary:
Because the source files are *.cpp, not *.c. This fixes building issue with gradle.
Closes https://github.com/facebook/yoga/pull/676

Reviewed By: emilsjolander

Differential Revision: D6446545

Pulled By: priteshrnandgaonkar

fbshipit-source-id: 809229057db26665b2d97b3002ade73632dd9117
2017-11-30 07:01:31 -08:00
Lukas Wöhrl
429a7eeee3 Suppress unused warnings on YGDefaultLog
Summary:
Suppresses the unused warnings on ```YGDefaultLog```. It uses a more generic macro which simply casts the variable to ```(void)```. This is the simples approach to make mutiple different compilers happy. Fixes #650
Closes https://github.com/facebook/yoga/pull/651

Differential Revision: D6407999

Pulled By: emilsjolander

fbshipit-source-id: 19fd78dd8b84eafdbb48875dd003d506a98c4807
2017-11-28 10:26:07 -08:00
Taras Tsugrii
dec1172f38 Migrate yoga defs to Skylark syntax.
Summary: https://our.intern.facebook.com/intern/dex/buck/python-to-skylark/

Reviewed By: adamjernst

Differential Revision: D6411822

fbshipit-source-id: 2abe2c183d1b1a28349d0c7bd765754688ec4441
2017-11-27 14:00:52 -08:00
Lukas Wöhrl
afaafb4126 Measure nodes which have margin: auto and align-item: stretch
Summary:
If you have a measurable node and set ```marign-left: auto``` + ```align-item:stretch``` on it, it won't get measured and they get a width/height of ```-(nan)```. This change fixes that behaviour. Fixes #644.
Closes https://github.com/facebook/yoga/pull/645

Differential Revision: D6413512

Pulled By: emilsjolander

fbshipit-source-id: 755febeb33bb0d4520ca6b3c28d56ac333e4a14d
2017-11-27 05:36:48 -08:00
Jake Larson
e566fcca08 Fix invalid value check for entry-common.js
Summary:
`!Object.prototype.hasOwnProperty.call(methods, unit))` doesn't correctly return `true` when an unsupported value is passed into `setMaxWidth` within an Automator (macOS) javascript/cocoascript environment.

This PR fixes the issue and also adds the `value` information to the returned error to help with debugging
Closes https://github.com/facebook/yoga/pull/643

Differential Revision: D6413569

Pulled By: emilsjolander

fbshipit-source-id: a42a66710a3ca578b5c25ecef8722f9c3f082b73
2017-11-27 05:12:37 -08:00
vincentriemer
c7f7ba250c Add Config::setPointScaleFactor to JavaScript binding
Summary:
Needed for a project I'm working on to properly render on high dpi screens. I've manually tested against my project to confirm it works.
Closes https://github.com/facebook/yoga/pull/612

Differential Revision: D6413517

Pulled By: emilsjolander

fbshipit-source-id: c298d7f6b58dc45aaaede2bb995df8615911a4a9
2017-11-27 04:59:53 -08:00
Lukas Wöhrl
7e3be21811 Add justify-content: space-evenly
Summary:
Adds new ```space-evenly``` for ```justify-content```.

Also adds a typofix in one of the other justify-content tests.

Fixes #657
Closes https://github.com/facebook/yoga/pull/658

Differential Revision: D6407996

Pulled By: emilsjolander

fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
2017-11-27 03:47:23 -08:00
Lukas Wöhrl
5e39f1a57c Fix shrinking in non strech alignments while retaining legacy behaviour
Summary:
This fixes shrinking of elements which are in a non stretch alignment, but keeps the legacy stretch behaviour in place. Additionally this adds a testcase for ```useLegacyStretchBehaviour```

Fixes #633
Closes https://github.com/facebook/yoga/pull/635

Differential Revision: D6408037

Pulled By: emilsjolander

fbshipit-source-id: 377ab0308dd3a75a148a0af31ab5eb3ffb5b5d83
2017-11-27 03:14:59 -08:00
Lukas Wöhrl
5aa0f44a9b Do not mark node as dirty if, new and old values are undefined
Summary:
If we have a values already set to undefined and set it to undefined again, we invalidate the layout. This change takes this case into account and keeps the layout valid.
Fixes #630
Closes https://github.com/facebook/yoga/pull/648

Differential Revision: D6408013

Pulled By: emilsjolander

fbshipit-source-id: dc2a848d84d3de9f4650fac9e41d7c8169446406
2017-11-27 03:14:54 -08:00
Jake Teton-Landis
55c767ba7f Fix assertion preventing YGNodeLayoutGet* with YGEdgeEnd
Summary:
Expected to be able to call `YGNodeLayoutGetMargin(node, YGEdgeEnd)`, but instead, the program aborts with `"Cannot get layout properties of multi-edge shorthands"`.

This bug seems to incorrectly prevent properties from YGEdgeEnd for all Layout properties.
Closes https://github.com/facebook/yoga/pull/632

Differential Revision: D6408060

Pulled By: emilsjolander

fbshipit-source-id: 4ab3b2ffb2f1bb6fd3a27f780caf0123abcdb230
2017-11-27 03:00:05 -08:00
Taras Tsugrii
5502a97f7f Replace include_defs with load.
Summary: https://our.intern.facebook.com/intern/dex/buck/python-to-skylark/

Reviewed By: adamjernst

Differential Revision: D6411777

fbshipit-source-id: 5553d75a650d906a280a61b38492e20d7bc7081a
2017-11-26 21:30:14 -08:00
Taras Tsugrii
8ab1d81917 Do not use isdir in build files.
Summary: This leads to slow, non-reproducible builds.

Reviewed By: adamjernst

Differential Revision: D6411750

fbshipit-source-id: 566424fa813edd20813da15101e6640d6c8fff19
2017-11-26 21:05:54 -08:00
Alexander Sarkisov
942543f6a5 Add default block attribute.
Summary:
It is very inconvenient to enter block attribute name for each view in Objective-C.
Closes https://github.com/facebook/yoga/pull/618

Differential Revision: D6408138

Pulled By: emilsjolander

fbshipit-source-id: 71fe8eadda7233e5055560667d0fc3840ab7259b
2017-11-24 08:12:33 -08:00
Lukas Wöhrl
a69545a6ae Fix justify content with min/max constraint parent
Summary:
The min/max inner width shouldn't take the margins into account.
Adds a test for both cases.

Fixes #664
Closes https://github.com/facebook/yoga/pull/665

Differential Revision: D6407982

Pulled By: emilsjolander

fbshipit-source-id: ffa549a06f802263e3b8488e90756aa3f722d52d
2017-11-24 07:24:51 -08:00
Lukas Wöhrl
0b13a0c168 Fix generation of license header for java
Summary:
If you run ```enums.py``` it will revert the changes from 835b2bb . This changes the license header for java to  not be a javadocs comment.
Closes https://github.com/facebook/yoga/pull/660

Differential Revision: D6407985

Pulled By: emilsjolander

fbshipit-source-id: 49efe555fecb8d740675c6b4631dce2a64f10417
2017-11-24 06:57:23 -08:00
Yury Zholobov
d8341ca3b0 Fix horizontally to vertically in FlexDirection=Column doc
Summary: Closes https://github.com/facebook/yoga/pull/663

Differential Revision: D6407915

Pulled By: emilsjolander

fbshipit-source-id: 03e2896b9b98cf476a92e7c87fd8dc3f7cef9047
2017-11-24 06:26:37 -08:00
Pritesh Nandgaonkar
34ac314101 Refactor and move YGNodeToString implementation to different file
Summary: Refactored the `YGNodeToString` function from c to c++.

Reviewed By: emilsjolander

Differential Revision: D6397372

fbshipit-source-id: 79e701efe7f19db6dac1aea6328ebf0ac84a7ac3
2017-11-23 09:42:21 -08:00
Pritesh Nandgaonkar
02c00f2711 Change c files to cpp
Summary: Changed the extensions of c files to cpp and made the project build successfully

Reviewed By: gkassabli

Differential Revision: D6271299

fbshipit-source-id: 66c0e54ccf019d72d1fd0b4d117826e4e84fdc89
2017-11-21 10:28:51 -08:00
Flarnie Marchan
15231c3304 Add Code of Conduct
Summary:
**what is the change?:**
Adding a document linking to the Facebook Open Source Code of Conduct,
for visibility and to meet Github community standards.

**why make this change?:**
Facebook Open Source provides a Code of Conduct statement for all
projects to follow.

Exposing the COC via a separate markdown file is a standard being
promoted by Github via the Community Profile in order to meet their Open
Source Guide's recommended community standards.

As you can see, adding this file will complete [Yoga's Community Profile](https://github.com/facebook/yoga/community)
checklist and increase the visibility of our COC.

We also added a link to the COC in the CONTRIBUTING doc because folks may miss the separate CODE_OF_CONDUCT document.

**test plan:**
Viewing it on my branch -
![screen shot 2017-11-20 at 6 02 25 pm](https://user-images.githubusercontent.com/1114467/33051133-4dc293e6-ce1d-11e7-9b0a-776cad6211f5.png)
![screen shot 2017-11-20 at 6 02 33 pm](https://user-images.githubusercontent.com/1114467/33051135-4dee35fa-ce1d-11e7-9077-a2d6d6f2ed3e.png)

**issue:**
internal task t23481323
Closes https://github.com/facebook/yoga/pull/670

Reviewed By: emilsjolander

Differential Revision: D6384655

Pulled By: flarnie

fbshipit-source-id: 6c5557094719cc8f1b08deb4d477ab56603caf39
2017-11-21 05:27:53 -08:00
Pritesh Nandgaonkar
d98e5aef97 Deleted YGSetMemoryFucs as it is unused
Summary: Removed YGSetMemoryFuncs, as it is not used internally and barely externally.

Reviewed By: emilsjolander

Differential Revision: D6374147

fbshipit-source-id: 8c896dce23571268a1a52df5cc72486af9d66df7
2017-11-21 03:43:23 -08:00
Pritesh Nandgaonkar
5b0dfa471f Use internal clang format settings
Summary: Use internal linting rules instead of the custom once.

Differential Revision: D6284667

fbshipit-source-id: 65aae336f1d7f14dfefed7391b0f5b89b333495e
2017-11-20 03:17:53 -08:00
Pritesh Nandgaonkar
26481a6553 Replace printf with YGLog calls
Summary: Replace printf calls with YGLog

Reviewed By: gkassabli

Differential Revision: D6297015

fbshipit-source-id: 6a67bdf33ef121785ac14938f5d3ed6e9d6f2656
2017-11-16 05:43:23 -08:00
Pascal Hartig
64e08aa98b v1.7.1-SNAPSHOT
Summary: Back to snapshot releases.

Reviewed By: emilsjolander

Differential Revision: D6284123

fbshipit-source-id: 30ec356d0da63e7bf6c33cbc20d446aea7be5a05
2017-11-16 03:15:52 -08:00
Pascal Hartig
0c3168f150 v1.7.0
Summary: Version bumps.

Reviewed By: emilsjolander

Differential Revision: D6284124

fbshipit-source-id: 08f6116bb0237791210847976533206055376f1a
2017-11-16 03:15:52 -08:00
Pascal Hartig
40861c699e Modernize Android build system, bump dependencies
Summary:
- Build against Android SDK 26
- Upgrade to Gradle 4
- Upgrade to Android Plugin 3.0, adjust dependency management accordingly
- Upgrade Maven deployment plugin

Reviewed By: emilsjolander

Differential Revision: D6272007

fbshipit-source-id: b198b4c8e1a94e2ee031ad26193fdfdf5b52adf1
2017-11-08 09:47:26 -08:00
Daniel Tsuan
d8fee24778 Set link_whole true for YogaKit and IGListKit
Summary: For our -objc efforts we'll be excluding vendorlibs from these changes for now and then working on getting them to not have to be fully linked as a second effort. The way -objc flag works is its an all or nothing flag for the app and thus for any library we still want to link completely we'll have to add a link_whole = True to the BUCK file. (Otherwise we'll have crashes in these libraries :P).

Reviewed By: kastiglione

Differential Revision: D6252740

fbshipit-source-id: fe074977a11b70c4aa63a4c69cb7518906c98eb9
2017-11-07 14:36:48 -08:00
Richard Ross
5c617a5947 Mirror AsyncExecutor, yoga, and nanosvg to fbcode.
Summary: We'll need these libraries for rainbow, and none of them exist in fbcode.

Reviewed By: mzlee

Differential Revision: D5897801

fbshipit-source-id: c379b76fef2ab204555ceded0834efc6ba932f90
2017-11-01 16:42:21 -07:00
Chandra Patni
ff0a3f39d9 use > || YGFloatsEqual instead of >= for computing round value to pixel grid
Summary: YGRoundValueToPixelGrid does not handle float point values correctly. It causes layout bugs in arm 32 devices. The way values are rounded to pixel grid is the following: if value is close to the left pixel - discard error and set it equal to left pixel. If value is close to right pixel - set it equal to the right pixel. Otherwise if value is closer to the left - set it equal to the left, closer to the right - set it equal to the right. The problem is when values are close to the middle. Old implementation could produce either left or right boundaries. This patch moves all values that are close to the middle to right boundary. This way results are consistent.

Reviewed By: emilsjolander

Differential Revision: D6202484

fbshipit-source-id: bb80235452208caec388775574cc4f07bfd649c4
2017-11-01 15:52:49 -07:00
Georgiy Kassabli
bfb4dabf0c Fixing the edge case in Yoga with percentage absolute position and infinite constraint
Summary: Yoga has an edge case that cause layout to return NaN. This happened when we used absolute position with percentage and infinite constraint in that dimension. This diff fixes that case to default to border+padding

Reviewed By: emilsjolander

Differential Revision: D6199731

fbshipit-source-id: f40ddf00614b2f507848fb35f348a9dfef14b323
2017-11-01 06:40:10 -07:00
Pritesh Nandgaonkar
58d14ee557 Reverting the dirty child optimization
Summary: Reverting D6134754

Reviewed By: emilsjolander

Differential Revision: D6203290

fbshipit-source-id: 8e42abb70e55f0fac90faaa21ecdbe0fbb76ce6b
2017-10-31 23:23:01 -07:00
Pritesh Nandgaonkar
c5182c4bf5 Used hasDirtyChildren tag for the optimization
Summary:
More fine grained dirty marking

Currently a node's dirty flag propagates to the root of the tree ensuring that when any node is invalidated its whole subtree will be re-calculated. This is often times not needed. There are many properties which only effects a node's children and would not need to propagate all the way to the root such as align-items. Also in cases where the style does change layout it may not need to propagate all the way to the root but can often stop at the nearest position: absolute parent.

This change has the potential of greatly improving performance of re-calculating a tree.

This might require adding a second dirty flag named hasDirtyDescendants ensuring that traversal still works even though a parent is not marked as dirty.

Reviewed By: emilsjolander

Differential Revision: D6134754

fbshipit-source-id: bbcfee14058140b946401de756a3f130de0f51cd
2017-10-31 08:22:29 -07:00
Jonathan Keljo
132b016bae Automated fixups for Instagram
Summary:
Source-only ABIs are a new feature of Buck that allows massive parallelism
by generating ABI jars from just the source code (without looking at most
dependencies). Because dependencies are not available, the generator
makes assumptions about how we write Java code. This commit updates
Instagram's code to conform to those assumptions.

These changes were generated by Buck's automatic migration script.

Reviewed By: dreiss

Differential Revision: D6168048

fbshipit-source-id: 0e51319d93fd697db01ea3933f48cd06a6ffac12
2017-10-27 01:14:24 -07:00
Sebastian Markbage
4785e95a0c Persistent Yoga
Summary:
This is meant to show a possible route format for a persistent form of Yoga. Where previous layouts can remain intact while still taking advantage of incremental layout by reusing previous subtrees.

```c
YGNodeRef YGNodeClone(const YGNodeRef node);
```

The core of this functionality is a new API to clone an existing node. This makes a new detached node with all the same values as the previous one. Conceptually this makes the original node "frozen" from that point on. It's now immutable. (This is not yet enforced at runtime in this PR but something we should add.)

Since the original is frozen, we reuse the children set from the original node. Their parent pointers still point back to the original tree though.

The cloned node is still mutable. It can have its styles updated, and nodes can be inserted or deleted. If an insertion/deletion happens on a cloned node whose children were reused, it'll first shallow clone its children automatically.

As a convenience I also added an API to clear all children:

```c
void YGNodeRemoveAllChildren(const YGNodeRef node);
```

During insert/delete, or as a result of layout a set of reused children may need to be first cloned. A kind of copy-on-write. When that happens, the host may want to respond. E.g. by updating the `context` such as by cloning any wrapper objects and attaching them to the new node.

```c
typedef void (*YGNodeClonedFunc)(YGNodeRef oldNode,
                                 YGNodeRef newNode,
                                 YGNodeRef parent,
                                 int childIndex);

void YGConfigSetNodeClonedFunc(YGConfigRef config,
                               YGNodeClonedFunc callback);
```

This PR doesn't change any existing semantics for trees that are not first cloned.

It's possible for a single node to exist in two trees at once and be used by multiple threads. Therefore it's not safe to recursively free a whole tree when you use persistence. To solve this, any user of the library has to manually manage ref counting or tracing GC. E.g. by replicating the tree structure in a wrapper.

In a follow up we could consider moving ref counting into Yoga.
Closes https://github.com/facebook/yoga/pull/636

Reviewed By: emilsjolander

Differential Revision: D5941921

Pulled By: sebmarkbage

fbshipit-source-id: c8e93421824c112d09c4773bed4e3141b6491ccf
2017-10-17 01:11:11 -07:00
Pascal Hartig
be94a5ef8d Fix NDK download in Travis
Summary:
After about 500MB, Travis seems to kill the TLS connection. Could be a traffic
limit, could be a timeout. I've only seen this for their MacOS boxes. We're now
retrying a few times with curl, which seems to work.

Reviewed By: emilsjolander

Differential Revision: D6051024

fbshipit-source-id: feb73bfb9fd81b2a8b9b4d33d4e9f230a9899a66
2017-10-13 06:56:18 -07:00
Pascal Hartig
208b70a93c Fix license check
Summary: This seems to have changed upstream.

Reviewed By: emilsjolander

Differential Revision: D6050471

fbshipit-source-id: b453831c1d5a5974572265a78da40b0612b1d1f2
2017-10-13 03:56:35 -07:00
Pascal Hartig
6c3155ae3b Download right NDK for Travis
Summary:
I'm a big dummy.

https://travis-ci.org/facebook/yoga/jobs/257605319

Reviewed By: emilsjolander

Differential Revision: D6040274

fbshipit-source-id: e73225e6e2e1e899c25326030ac522d5a7aa06a5
2017-10-12 08:41:55 -07:00
Pascal Hartig
32f071c2ad Fix NDK download
Summary: Fix NDK download for Travis.

Reviewed By: emilsjolander

Differential Revision: D6020352

fbshipit-source-id: c7523c0afb18d675fc2443e133d5ab63109fec7b
2017-10-11 08:19:51 -07:00
Pascal Hartig
fdd1dbe3a9 Update buildScript deps
Summary:
The native-dependencies plugin seems unused. Upgrade to the latest
gradle-bintray-plugin version that's supported for the current Gradle version.

I'll hold back the upgrade to Gradle 4 until the Gradle Android Plugin for the
version hits stable.

Reviewed By: IanChilds

Differential Revision: D5986549

fbshipit-source-id: d26aa19e9eba40a2b30b20d5ffa9d2b006450f95
2017-10-06 02:26:15 -07:00
Pascal Hartig
1ca5bb694d Use NDK 15c
Summary: To match internal config.

Reviewed By: emilsjolander

Differential Revision: D5986514

fbshipit-source-id: b0e7dbc060c106f17f8e1c5e54e5b951d9e3e350
2017-10-06 02:26:15 -07:00
Marko Novakovic
b4cfaa916c Un-inline-ing a method declared as export
Reviewed By: compnerd

Differential Revision: D5909847

fbshipit-source-id: 7108dd88271e640e1881b20c0cbf1ad28bbf63c9
2017-09-26 19:12:42 -07:00
Michael Lee
fc6c85996e Reformat BUCK files
Summary: Reformat BUCK files to better conform with style.

Reviewed By: zertosh

Differential Revision: D5901515

fbshipit-source-id: 93e8c56450f65b691af9017d880e6cf2a2cdb7af
2017-09-25 10:16:22 -07:00
Andrew Gallagher
969f055f47 Deprecate older API uses of prebuilt_cxx_library
Summary:
Use the `deprecated_prebuilt_cxx_library` wrapper instead of the deprecated
API of `prebuilt_cxx_library`.

Reviewed By: ttsugriy

Differential Revision: D5878523

fbshipit-source-id: 2c8c1fd1d19597ff7459bbd527c89573520db74b
2017-09-22 13:27:32 -07:00
Bin Yu
58328d01ef Add 'useYoga' property to indicate whether UIView uses Yoga for layout or not
Summary: Now developer could check whether UIView uses Yoga for layout.

Reviewed By: emilsjolander

Differential Revision: D5881242

fbshipit-source-id: 4d1cf0b489b759ff0b9c5091cc51534fd12dcf60
2017-09-21 10:18:52 -07:00
Mingwei Pan
d90914f3dc Improve formatting of YogaNode.print() on Android
Summary:
The Android logger adds newline automatically, which makes the log ugly on Android.
To avoid that, wrap the android logger, print to a memory buffer.  Call __android_log_write() when '\n' is detected.

Reviewed By: emilsjolander

Differential Revision: D5842889

fbshipit-source-id: 8ecc829dc43614934c47fd3a68317259e403325a
2017-09-21 07:41:37 -07:00
Emil Sjolander
3a0a86788e Revert D5874862: [yoga][PR] Fix shrinking in non strech alignments
Summary:
This reverts commit 1426aa6b60f6ba42c2be702e6f24cea935ab7acb

bypass-lint

Differential Revision: D5874862

fbshipit-source-id: 24517d26b18c11fb9f75c6d3b5faae360711ea9e
2017-09-21 03:41:19 -07:00
Lukas Wöhrl
a77aa9a41e Fix shrinking in non strech alignments
Summary:
This fixes shrinking of elements which are in a non stretch alignment

Fixes #633
Closes https://github.com/facebook/yoga/pull/634

Differential Revision: D5874862

Pulled By: emilsjolander

fbshipit-source-id: 1426aa6b60f6ba42c2be702e6f24cea935ab7acb
2017-09-20 13:30:39 -07:00
Shaddix
7217471427 fix build, correctly size UIScrollViews
Summary: Closes https://github.com/facebook/yoga/pull/626

Reviewed By: emilsjolander

Differential Revision: D5824425

Pulled By: splhack

fbshipit-source-id: e1a8dda5e86e2705afa7f6630a6757491a94c6d6
2017-09-19 09:41:41 -07:00
Mingwei Pan
bcc36cc1b2 Zero out all fields in YGZeroOutLayoutRecursivly using memset
Summary:
Add a new test named YGZeroOutLayoutRecursivlyTest, which verifies that padding and margin of a child node should be set to 0 when the display is set to none.
Modify YGZeroOutLayoutRecursivly function, use memset to clear the layout struct of the node.

Reviewed By: emilsjolander

Differential Revision: D5842351

fbshipit-source-id: d2c2b6f829588a200525b7ccbdb63003cb4dcc4e
2017-09-15 08:32:36 -07:00
Amir Shalem
16052085d0 Fix YogaLogger leakage when removing it from YogaConfig
Summary: -

Reviewed By: emilsjolander

Differential Revision: D5802035

fbshipit-source-id: 79c1f8c3cc5ddf3abd51206f23e076f2410cfc0c
2017-09-11 03:14:11 -07:00
Lukas Wöhrl
c20f2864ab Only add UIView nodes to Yoga where they are enabled
Summary:
Only add UIView nodes to Yoga where they are enabled.

We check for it in `isLeaf` but I think we should also check for them in the check for sub views.
Closes https://github.com/facebook/yoga/pull/609

Reviewed By: emilsjolander

Differential Revision: D5643387

Pulled By: dshahidehpour

fbshipit-source-id: a85c62b6b2e0120b2913e7f2df8b094d43ca49a6
2017-08-23 15:46:51 -07:00
Lukas Wöhrl
4185a44393 Fix const declaration mismatch and double/float mix
Summary:
This PR fixes a declaration mismatch for `YGNodeCanUseCachedMeasurement` where the last argument is declared non `const` in `.h` and `const` in `.c`.

Additionally it uses explicit `float` for fraction calculation do avoid usage of `double` assignment.
Closes https://github.com/facebook/yoga/pull/607

Differential Revision: D5677931

Pulled By: emilsjolander

fbshipit-source-id: 502da957089e4439ed956987ff8dec10bd033ba3
2017-08-23 03:02:16 -07:00
Scott Wolchok
c79c5e3c9d Make gYGNodeDefaults const
Summary: At least one compiler seems to care about it.

Reviewed By: emilsjolander

Differential Revision: D5675518

fbshipit-source-id: 72a6e208263dde0b6bb46a78fedb2796d0e0a600
2017-08-22 11:56:21 -07:00
Emil Sjolander
35a9f33abb BREAKING: Change aspect ratio behavior
Summary:
@public

== Before ==
- Aspect ratio would do its best to fit within it's parent constraints
- Aspect ratio would prioritize `alignItems: stretch` over other sizing properties.

== After ==
- Aspect ratio is allowed to make a node grow past its parent constraints. This matches many other aspects of flexbox where parent constraints are not treated as hard constraints but rather as suggestions.
- Aspect ratio only takes `alignItems: stretch` into account if no other size definition is defined. This matches the interaction of other properties with `alignItems: stretch`.

== Updating your code ==

**You probably don't need to do anything** but in case something does break in your product it should be as easy as  adding `{width: '100%', height: '100%', flexShrink: 1}` to the style declaring the `aspectRatio`.

Reviewed By: gkassabli

Differential Revision: D5639187

fbshipit-source-id: 603e8fcc3373f0b7f2461da2dad1625ab59dcb19
2017-08-21 03:12:00 -07:00
Hoa Dinh
32f128640b Revert D5643382: [yoga][PR] Fix a typo in YogaKit,
Summary:
This reverts commit 127b0c11dbfd76d298db823e65fd2f6e365642e7

bypass-lint

Differential Revision: D5643382

fbshipit-source-id: f25b04680428bcd4515c44741ed72a004be43ef1
2017-08-17 15:48:47 -07:00
Luc Dion
18d19af7ec Fix a typo in YogaKit,
Summary:
`YGDimensionFlexibilityFlexibleHeight` it was wrongly spelled `YGDimensionFlexibilityFlexibleHeigth`.

[X] Test suite passes
[X] Contributor License Agreement
Closes https://github.com/facebook/yoga/pull/605

Reviewed By: amonshiz

Differential Revision: D5643382

Pulled By: dshahidehpour

fbshipit-source-id: 127b0c11dbfd76d298db823e65fd2f6e365642e7
2017-08-17 14:42:03 -07:00
Levi McCallum
2ee2dd439f Fix link to YGLayout header in docs
Summary: Closes https://github.com/facebook/yoga/pull/595

Reviewed By: amonshiz

Differential Revision: D5643379

Pulled By: dshahidehpour

fbshipit-source-id: ae972f270ee26fe7755ba5dee4d357d150a27c2a
2017-08-17 13:56:37 -07:00
Lior Tubi
5edfb679e7 Add a java binary buck target
Summary: .

Reviewed By: amir-shalem

Differential Revision: D5619667

fbshipit-source-id: e956190be0c6a7ea573e5511231de28aab5586fe
2017-08-13 07:32:11 -07:00
Georgiy Kassabli
f45059e1e6 Fixing edge case issue in Yoga where text node was unnecessary rounded down
Summary: There was an uncovered edge case where number close to the whole was forced to round down because it was considered non-whole and had forced flooring. This diff covers that + adds a bunch of test cases to cover rounding function

Reviewed By: emilsjolander

Differential Revision: D5465632

fbshipit-source-id: 57e11092a97eba5dd76daad15fa8619535ff9c1b
2017-07-26 19:38:31 -07:00
Pascal Hartig
c9384762ee Fix NDK build, Take II
Summary:
There was one incorrect path and some caching problems. I hope this will take
care of it for good.

Reviewed By: emilsjolander

Differential Revision: D5470120

fbshipit-source-id: 17c9e783c952c92fa5c2ccfb18107a59d8a80e3d
2017-07-21 08:29:43 -07:00
Pascal Hartig
7ea50439ce Fix travis NDK setup
Summary:
Phew, this took a while. Buck had some changes in how it picks up SDK/NDK
configs.

In order to satisfy the new demands, I'm now installing the NDK manually and no
longer through the SDK manager. I'm also trying to cache as much as possible to
reduce the flakiness here.

Reviewed By: emilsjolander

Differential Revision: D5465206

fbshipit-source-id: 61a4b9006fe96fc9a99fb9d75b822589064a9d1a
2017-07-21 03:14:21 -07:00
Pascal Hartig
154e67adbc Bump to 1.6.1-SNAPSHOT
Summary:
Set to the next snapshot version so automatic snapshot publishing is reenabled.
We need those to keep in sync with the Litho snapshots.

Reviewed By: emilsjolander

Differential Revision: D5442493

fbshipit-source-id: ecb92071ec8edb9c3c6b625c08f5aad20368d0a3
2017-07-18 11:46:10 -07:00
Lukas Wöhrl
570a193b7e Update c# docs to use object initializer
Summary:
Updates the C# docs to use the object initializer instead of `Create` which doesn't exist anymore.

Fixes facebook/yoga#550.
Closes https://github.com/facebook/yoga/pull/601

Reviewed By: emilsjolander

Differential Revision: D5427217

Pulled By: splhack

fbshipit-source-id: 9a2f036335e5ab475d5c1ee8308701ccb5a3b4e4
2017-07-14 16:13:07 -07:00
Emil Sjolander
79e294c927 1.6.0 version bumps
Reviewed By: passy

Differential Revision: D5415450

fbshipit-source-id: cf3c42303c4a63adf114199618d42dabdb123c42
2017-07-13 08:27:10 -07:00
Georgiy Kassabli
5d75c7c4c8 Fixing the issue with node dimensions rounding in Yoga
Summary: Yoga had a bug in Rounding calculation that caused text nodes dimensions to be rounded up even when the dimensions didn't need rounding

Reviewed By: emilsjolander

Differential Revision: D5406211

fbshipit-source-id: df1d54ed0805dfc3abbd8f0ceae30f6d8c26d61a
2017-07-12 09:33:51 -07:00
vincentriemer
7c688cea68 Add babel processing to browser build to remove references to node builtins
Summary:
Currently the nbind asm.js output generates boilerplate code which can conditionally load node's `fs` and `path` modules. If this output is run directly in the browser there are no issues but if you run it through a bundler the build step will fail trying to resolve the node builtins.

Workarounds currently exist for bundlers like webpack (mentioned in #444) but this is not a safe assumption to make (for example such workarounds don't exist for `metro-bundler`).

I am by no means suggesting that this is the perfect solution but this might provide a stop-gap fix for people who are currently blocked by this issue (like I am).
Closes https://github.com/facebook/yoga/pull/585

Differential Revision: D5388660

Pulled By: emilsjolander

fbshipit-source-id: d3a51eb852df35e3d0610158fe7d9f5754e4e684
2017-07-10 12:00:37 -07:00
Lukas Wöhrl
7640cd667f Reset the hadOverflow flag at the beginning of the algorithm
Summary:
This fixes the case where we change the layout, so that it doesn't overflow anymore.

This also improves the readability by using `|=` instead of referencing the value twice.
Closes https://github.com/facebook/yoga/pull/587

Differential Revision: D5388657

Pulled By: emilsjolander

fbshipit-source-id: ce1b1ded1feed7314a2c16bf695f62b866c19ea0
2017-07-10 12:00:37 -07:00
622 changed files with 40632 additions and 15857 deletions

View File

@@ -1,9 +1,10 @@
[cxx] [cxx]
gtest_dep = //lib/gtest:gtest gtest_dep = //lib/gtest:gtest
[android] [android]
target = android-23 target = android-25
build_tools_version = 26.0.2
[ndk] [ndk]
ndk_version = 13.1.3345770 ndk_version = 15.2.4203891
compiler = clang compiler = clang
app_platform = android-21 app_platform = android-21
cpu_abis = arm64, armv7, x86, x86_64 cpu_abis = arm64, armv7, x86, x86_64

56
.clang-format Normal file
View File

@@ -0,0 +1,56 @@
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyReturnTypeOnItsOwnLine: 2000
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
Standard: Cpp11
UseTab: Never

1
.clang-format-ignore Normal file
View File

@@ -0,0 +1 @@
^lib/.*

View File

@@ -1,132 +1,76 @@
# Copyright (c) 2014-present, Facebook, Inc. language: java
# All rights reserved. os: linux
# addons:
# This source code is licensed under the BSD-style license found in the apt:
# LICENSE file in the root directory of this source tree. An additional grant sources:
# of patent rights can be found in the PATENTS file in the same directory. - llvm-toolchain-trusty-6.0
- ubuntu-toolchain-r-test
os: osx packages:
osx_image: xcode8.2 - clang-6.0
language: cpp
compiler: clang
cache:
directories:
- $HOME/Library/Caches/Homebrew
env: env:
- TARGET=c - TARGET: website
- TARGET=java - TARGET: android
- TARGET=net
- TARGET=ios install:
- TARGET=js - cd website
- TARGET=android - yarn --ignore-scripts
- cd ..
cache:
directories:
- $HOME/buck
- $HOME/.gradle
before_install: before_install:
- | - |
if [[ -n "$encrypted_d27e803291ff_iv" ]]; then if [[ -n "$encrypted_d27e803291ff_iv" ]]; then
openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties; openssl aes-256-cbc -K $encrypted_d27e803291ff_key -iv $encrypted_d27e803291ff_iv -in scripts/setup-keys.enc -d >> gradle.properties;
fi fi
- brew update > /dev/null
- brew install --HEAD facebook/fb/buck
# Java
- |
if [[ $TARGET = "java" ]]; then
brew cask install java &&
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) &&
export PATH=$JAVA_HOME/bin:$PATH
fi
# .NET
- |
if [[ $TARGET = "net" ]]; then
brew install mono
fi
# iOS
- |
if [[ $TARGET = "ios" ]]; then
brew outdated xctool || brew upgrade xctool;
gem install xcpretty --no-document --quiet;
gem install cocoapods --pre --no-document --quiet;
pod repo update --silent;
pod install --project-directory=YogaKit/YogaKitSample/;
fi
# Emscripten (used for js tests)
# Note: cannot be ran on Linux (because it will compile Clang from its sources :|)
- |
if [[ $TARGET = "js" ]]; then
wget -O /tmp/emsdk-portable.tar.gz https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz &&
tar xf /tmp/emsdk-portable.tar.gz -C /tmp/ &&
/tmp/emsdk-portable/emsdk install latest 2>&1 | grep -v '^x ' &&
/tmp/emsdk-portable/emsdk activate latest
fi
# Android # Android
- | - |
if [[ $TARGET = "android" ]]; then if [[ $TARGET = "android" ]]; then
brew cask install java; pushd $HOME
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8); git clone --depth 1 https://github.com/facebook/buck.git
export PATH=$JAVA_HOME/bin:$PATH; cd buck
export TERMINAL=dumb; ant
popd
export PATH=$PATH:$HOME/buck/bin/
buck --version
export TERMINAL=dumb
source scripts/android-setup.sh && installAndroidSDK source scripts/android-setup.sh && installAndroidSDK
export ANDROID_SDK=$ANDROID_HOME export ANDROID_SDK=$ANDROID_HOME
export ANDROID_NDK_REPOSITORY=$HOME/android-ndk
export ANDROID_NDK_HOME=$ANDROID_NDK_REPOSITORY/android-ndk-r15c
fi fi
# Website
# JavaScript
- | - |
if [[ $TARGET = "js" ]]; then ( if [[ $TARGET = "website" ]]; then
cd javascript && nvm install 8
npm install && nvm use 8
unset CC && unset CXX && unset LINK && fi
source /tmp/emsdk-portable/emsdk_env.sh &&
npm run build:browser
) fi
script: script:
# C
- |
if [[ $TARGET = "c" ]]; then
buck test --verbose 0 //:yoga &&
buck run --verbose 0 //benchmark:benchmark &&
git checkout HEAD^ &&
buck run --verbose 0 //benchmark:benchmark
fi
# Java
- |
if [[ $TARGET = "java" ]]; then
buck test --verbose 0 //java:java
fi
# .NET
- |
if [[ $TARGET = "net" ]]; then
sh csharp/tests/Facebook.Yoga/test_macos.sh
fi
# iOS
- |
if [[ $TARGET = "ios" ]]; then
buck test --verbose 0 //YogaKit:YogaKitTests --config cxx.default_platform=iphonesimulator-x86_64 &&
set -o pipefail &&
xcodebuild build -workspace YogaKit/YogaKitSample/YogaKitSample.xcworkspace -scheme YogaKitSample -sdk iphonesimulator | xcpretty -c
fi
# Android
- | - |
if [[ $TARGET = "android" ]]; then if [[ $TARGET = "android" ]]; then
buck build --verbose 0 //android/sample:sample && ./gradlew testDebugUnit && scripts/publish-snapshot.sh
./gradlew testDebugUnit && fi
scripts/publish-snapshot.sh - |
if [[ $TARGET = "website" ]]; then
pushd website
yarn build
popd
fi fi
# JavaScript deploy:
- | provider: pages
if [[ $TARGET = "js" ]]; then ( skip-cleanup: true
cd javascript && github-token: $GITHUB_TOKEN
npm run test:all && fqdn: yogalayout.com
npm run bench local-dir: website/public
) fi email: yogabot@fb.com
name: Yoga-bot
keep-history: true
on:
branch: master
condition: $TARGET = website

47
BUCK
View File

@@ -1,11 +1,8 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory. load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep")
include_defs("//YOGA_DEFS")
GMOCK_OVERRIDE_FLAGS = [ GMOCK_OVERRIDE_FLAGS = [
# gmock does not mark mocked methods as override, ignore the warnings in tests # gmock does not mark mocked methods as override, ignore the warnings in tests
@@ -13,33 +10,51 @@ GMOCK_OVERRIDE_FLAGS = [
] ]
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [ COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
"-std=c11", "-std=c++1y",
] ]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ["-std=c++11"] TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
"-std=c++1y",
"-DDEBUG",
]
cxx_library( yoga_cxx_library(
name = "yoga", name = "yoga",
srcs = glob(["yoga/*.c"]), srcs = glob(["yoga/*.cpp"]),
compiler_flags = COMPILER_FLAGS,
exported_headers = subdir_glob([("", "yoga/*.h")]),
header_namespace = "", header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = COMPILER_FLAGS,
soname = "libyogacore.$(ext)", soname = "libyogacore.$(ext)",
tests = [":YogaTests"], tests = [":YogaTests"],
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [] if THIS_IS_FBOBJC else [ deps = [
yoga_dep("lib/fb:ndklog"), yoga_dep("lib/fb:ndklog"),
], ],
) )
cxx_test( yoga_cxx_library(
name = "yogaForDebug",
srcs = glob(["yoga/*.cpp"]),
header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]),
compiler_flags = TEST_COMPILER_FLAGS,
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
yoga_dep("lib/fb:ndklog"),
],
)
yoga_cxx_test(
name = "YogaTests", name = "YogaTests",
srcs = glob(["tests/*.cpp"]), srcs = glob(["tests/*.cpp"]),
headers = subdir_glob([("", "yoga/**/*.h")]),
compiler_flags = TEST_COMPILER_FLAGS, compiler_flags = TEST_COMPILER_FLAGS,
contacts = ["emilsj@fb.com"], contacts = ["emilsj@fb.com"],
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [ deps = [
":yoga", ":yogaForDebug",
GTEST_TARGET, GTEST_TARGET,
], ],
) )

View File

@@ -1,17 +1,15 @@
# #
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory.
# #
cmake_minimum_required(VERSION 3.4.1) cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB yogacore_SRC yoga/*.c) file(GLOB yogacore_SRC yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC}) add_library(yogacore STATIC ${yogacore_SRC})
target_link_libraries(yogacore android log) target_link_libraries(yogacore android log)

3
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,3 @@
# Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.

View File

@@ -2,6 +2,10 @@
We want to make contributing to this project as easy and transparent as We want to make contributing to this project as easy and transparent as
possible. possible.
## Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.
## Pull Requests ## Pull Requests
We actively welcome your pull requests. We actively welcome your pull requests.
1. Fork the repo and create your branch from `master`. 1. Fork the repo and create your branch from `master`.
@@ -25,9 +29,6 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue. outlined on that page and do not file a public issue.
## Coding Style
* format.sh
## License ## License
By contributing to yoga, you agree that your contributions will be licensed By contributing to yoga, you agree that your contributions will be licensed
under its BSD license. under its MIT license.

43
LICENSE
View File

@@ -1,30 +1,21 @@
BSD License MIT License
For yoga software Copyright (c) Facebook, Inc. and its affiliates.
Copyright (c) 2014-present, Facebook, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without modification, The above copyright notice and this permission notice shall be included in all
are permitted provided that the following conditions are met: copies or substantial portions of the Software.
* Redistributions of source code must retain the above copyright notice, this THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
list of conditions and the following disclaimer. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* Redistributions in binary form must reproduce the above copyright notice, AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
this list of conditions and the following disclaimer in the documentation LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
and/or other materials provided with the distribution. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

33
PATENTS
View File

@@ -1,33 +0,0 @@
Additional Grant of Patent Rights Version 2
"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
(subject to the termination provision below) license under any Necessary
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
transfer the Software. For avoidance of doubt, no license is granted under
Facebook's rights in any patent claims that are infringed by (i) modifications
to the Software made by you or any third party or (ii) the Software in
combination with any software or other technology.
The license granted hereunder will terminate, automatically and without notice,
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
directly or indirectly, or take a direct financial interest in, any Patent
Assertion: (i) against Facebook or any of its subsidiaries or corporate
affiliates, (ii) against any party if such Patent Assertion arises in whole or
in part from any software, technology, product or service of Facebook or any of
its subsidiaries or corporate affiliates, or (iii) against any party relating
to the Software. Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.
A "Necessary Claim" is a claim of a patent owned by Facebook that is
necessarily infringed by the Software standing alone.
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.

View File

@@ -1,15 +1,5 @@
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg)](http://cocoapods.org/pods/YogaKit) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![bintray](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga:yoga.svg)](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [![NuGet](https://img.shields.io/nuget/v/Facebook.Yoga.svg)](https://www.nuget.org/packages/Facebook.Yoga) # Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/YogaKit.svg)](http://cocoapods.org/pods/YogaKit) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![bintray](https://img.shields.io/bintray/v/facebook/maven/com.facebook.yoga:yoga.svg)](https://bintray.com/facebook/maven/com.facebook.yoga%3Ayoga/_latestVersion) [![NuGet](https://img.shields.io/nuget/v/Facebook.Yoga.svg)](https://www.nuget.org/packages/Facebook.Yoga)
[![C Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=c&label=C)](https://travis-ci.org/facebook/yoga)
[![Java Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=java&label=Java)](https://travis-ci.org/facebook/yoga)
[![iOS Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=ios&label=iOS)](https://travis-ci.org/facebook/yoga)
[![.NET Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=net&label=.NET)](https://travis-ci.org/facebook/yoga)
[![JavaScript Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=js&label=JavaScript)](https://travis-ci.org/facebook/yoga)
[![Android Status](https://badges.herokuapp.com/travis/facebook/yoga?env=TARGET=android&label=Android)](https://travis-ci.org/facebook/yoga)
[![Visual Studio Team services](https://img.shields.io/vso/build/rumar/fe6d27b5-e424-4f61-b8f6-e2ec2f8755fb/1.svg?label=vsts-windows)]()
[![Visual Studio Team services](https://img.shields.io/vso/build/rumar/fe6d27b5-e424-4f61-b8f6-e2ec2f8755fb/2.svg?label=vsts-osx)]()
## Building ## 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. 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.
@@ -18,7 +8,7 @@ For testing we rely on [gtest](https://github.com/google/googletest) as a submod
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`. For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following. Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generate a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.
```html ```html
<div id="my_test" style="width: 100px; height: 100px; align-items: center;"> <div id="my_test" style="width: 100px; height: 100px; align-items: center;">
@@ -33,9 +23,6 @@ You may need to install the latest watir-webdriver gem (`gem install watir-webdr
### .NET ### .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`. .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.
## Benchmarks ## 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. 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.
@@ -59,5 +46,3 @@ This will now only run the standalone webpack build upon install.
| node | Builds node js version. | | node | Builds node js version. |
| standalone | Runs webpack. | | standalone | Runs webpack. |
| none | Does nothing. You can use the prepackaged libs. | | none | Does nothing. You can use the prepackaged libs. |

View File

@@ -1,47 +0,0 @@
YOGA_ROOTS = ['//...']
JAVA_TARGET = '//java:java'
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/proguard-annotations/src/main/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'
FBJNI_JAVA_TARGET = '//lib/fb/src/main/java/com/facebook/jni:jni'
APPCOMPAT_TARGET = '//lib/appcompat:appcompat'
ANDROID_SUPPORT_TARGET = '//lib/android-support:android-support'
ANDROID_TARGET = '//android:android'
ANDROID_JAVA_TARGET = '//android/src/main/java/com/facebook/yoga/android:android'
ANDROID_RES_TARGET = '//android:res'
ANDROID_SAMPLE_JAVA_TARGET = '//android/sample/java/com/facebook/samples/yoga:yoga'
ANDROID_SAMPLE_RES_TARGET = '//android/sample:res'
THIS_IS_FBOBJC = False
CXX_LIBRARY_WHITELIST = [
'//:yoga',
'//lib/fb:fbjni',
'//java:jni',
]
BASE_COMPILER_FLAGS = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-O3',
]
LIBRARY_COMPILER_FLAGS = BASE_COMPILER_FLAGS + [
'-fPIC',
]
def yoga_dep(dep):
return '//' + dep
with allow_unsafe_import():
import os.path
def isdir(filename):
return os.path.isdir(filename)

View File

@@ -1,9 +1,15 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
Pod::Spec.new do |spec| Pod::Spec.new do |spec|
spec.name = 'Yoga' spec.name = 'Yoga'
spec.version = '1.5.0' spec.version = '1.12.0-pre.1'
spec.license = { :type => 'BSD', :file => "LICENSE" } spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/' spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/c/' spec.documentation_url = 'https://yogalayout.com/docs'
spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.' spec.summary = 'Yoga is a cross-platform layout engine which implements Flexbox.'
spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.' spec.description = 'Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.'
@@ -11,18 +17,23 @@ Pod::Spec.new do |spec|
spec.authors = 'Facebook' spec.authors = 'Facebook'
spec.source = { spec.source = {
:git => 'https://github.com/facebook/yoga.git', :git => 'https://github.com/facebook/yoga.git',
:tag => '1.5.0', :tag => spec.version.to_s,
} }
spec.platforms = { :ios => "4.3", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" }
spec.module_name = 'yoga' spec.module_name = 'yoga'
spec.requires_arc = false spec.requires_arc = false
spec.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES'
}
spec.compiler_flags = [ spec.compiler_flags = [
'-fno-omit-frame-pointer', '-fno-omit-frame-pointer',
'-fexceptions', '-fexceptions',
'-Wall', '-Wall',
'-Werror', '-Werror',
'-std=c11', '-std=c++1y',
'-fPIC' '-fPIC'
] ]
spec.source_files = 'yoga/**/*.{c,h}' spec.source_files = 'yoga/**/*.{c,h,cpp}'
spec.public_header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h'
end end

View File

@@ -1,7 +1,13 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
podspec = Pod::Spec.new do |spec| podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit' spec.name = 'YogaKit'
spec.version = '1.5.0' spec.version = '1.12.0'
spec.license = { :type => 'BSD', :file => "LICENSE" } spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://facebook.github.io/yoga/' spec.homepage = 'https://facebook.github.io/yoga/'
spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/' spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/'
@@ -11,17 +17,18 @@ podspec = Pod::Spec.new do |spec|
spec.authors = 'Facebook' spec.authors = 'Facebook'
spec.source = { spec.source = {
:git => 'https://github.com/facebook/yoga.git', :git => 'https://github.com/facebook/yoga.git',
:tag => '1.5.0', :tag => spec.version.to_s,
} }
spec.platform = :ios spec.platform = :ios
spec.ios.deployment_target = '8.0' spec.ios.deployment_target = '8.0'
spec.ios.frameworks = 'UIKit' spec.ios.frameworks = 'UIKit'
spec.dependency 'Yoga', '~> 1.5' spec.dependency 'Yoga', '~> 1.9'
spec.source_files = 'YogaKit/Source/*.{h,m,swift}' spec.source_files = 'YogaKit/Source/*.{h,m,swift}'
spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h' spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h'
spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h' spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'
spec.swift_version = '3.0'
end end
# See https://github.com/facebook/yoga/pull/366 # See https://github.com/facebook/yoga/pull/366

View File

@@ -1,11 +1,8 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory. load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_apple_library", "yoga_apple_test", "yoga_dep")
include_defs("//YOGA_DEFS")
COMPILER_FLAGS = [ COMPILER_FLAGS = [
"-fobjc-arc", "-fobjc-arc",
@@ -27,22 +24,31 @@ COMPILER_FLAGS = [
"-Wunused-value", "-Wunused-value",
] ]
apple_library( yoga_apple_library(
name = "YogaKit", name = "YogaKit",
srcs = glob(["Source/**/*.m"]), srcs = glob(["Source/**/*.m"]),
header_namespace = "",
exported_headers = subdir_glob(
[
("", "Source/**/*.h"),
("Source", "**/*.h"),
],
prefix = "YogaKit",
),
compiler_flags = COMPILER_FLAGS, compiler_flags = COMPILER_FLAGS,
exported_headers = glob(["Source/**/*.h"]),
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/UIKit.framework", "$SDKROOT/System/Library/Frameworks/UIKit.framework",
], ],
header_path_prefix = "",
link_whole = True,
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [ deps = [
yoga_dep(":yoga"), yoga_dep(":yoga"),
], ],
) )
apple_test( yoga_apple_test(
name = "YogaKitTests", name = "YogaKitTests",
srcs = glob(["Tests/**/*.m"]), srcs = glob(["Tests/**/*.m"]),
compiler_flags = COMPILER_FLAGS, compiler_flags = COMPILER_FLAGS,

View File

@@ -8,7 +8,7 @@
YogaKit is available to install via [CocoaPods](https://cocoapods.org/). YogaKit is available to install via [CocoaPods](https://cocoapods.org/).
``` ```
pod 'YogaKit', '~> 1.5' pod 'YogaKit', '~> 1.7'
``` ```
## Getting Started ## Getting Started

View File

@@ -1,18 +1,15 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import "YGLayout.h" #import "YGLayout.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef void (^YGLayoutConfigurationBlock)(YGLayout *); typedef void (^YGLayoutConfigurationBlock)(YGLayout *layout);
@interface UIView (Yoga) @interface UIView (Yoga)
@@ -20,6 +17,10 @@ typedef void (^YGLayoutConfigurationBlock)(YGLayout *);
The YGLayout that is attached to this view. It is lazily created. The YGLayout that is attached to this view. It is lazily created.
*/ */
@property (nonatomic, readonly, strong) YGLayout *yoga; @property (nonatomic, readonly, strong) YGLayout *yoga;
/**
Indicates whether or not Yoga is enabled
*/
@property (nonatomic, readonly, assign) BOOL isYogaEnabled;
/** /**
In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend` In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend`

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import "UIView+Yoga.h" #import "UIView+Yoga.h"
@@ -26,6 +24,11 @@ static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
return yoga; return yoga;
} }
- (BOOL)isYogaEnabled
{
return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil;
}
- (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block - (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block
{ {
if (block != nil) { if (block != nil) {

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import "YGLayout.h" #import "YGLayout.h"
#import <yoga/Yoga.h> #import <yoga/Yoga.h>

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <yoga/YGEnums.h> #import <yoga/YGEnums.h>
#import <yoga/Yoga.h> #import <yoga/Yoga.h>
@@ -23,13 +20,28 @@ YG_EXTERN_C_END
typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) { typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
YGDimensionFlexibilityFlexibleWidth = 1 << 0, YGDimensionFlexibilityFlexibleWidth = 1 << 0,
YGDimensionFlexibilityFlexibleHeigth = 1 << 1, YGDimensionFlexibilityFlexibleHeight = 1 << 1,
}; };
@interface YGLayout : NSObject @interface YGLayout : NSObject
/** /**
The property that decides if we should include this view when calculating layout. Defaults to YES. Make default init unavailable, as it will not initialise YGNode which is
required for the setters and getters of YGLayout's properties to work properly.
*/
- (instancetype)init
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
Make default init unavailable, as it will not initialise YGNode which is
required for the setters and getters of YGLayout's properties to work properly.
*/
+ (instancetype)new
__attribute__((unavailable("you are not meant to initialise YGLayout")));
/**
The property that decides if we should include this view when calculating
layout. Defaults to YES.
*/ */
@property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout; @property (nonatomic, readwrite, assign, setter=setIncludedInLayout:) BOOL isIncludedInLayout;
@@ -50,6 +62,7 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) {
@property (nonatomic, readwrite, assign) YGOverflow overflow; @property (nonatomic, readwrite, assign) YGOverflow overflow;
@property (nonatomic, readwrite, assign) YGDisplay display; @property (nonatomic, readwrite, assign) YGDisplay display;
@property (nonatomic, readwrite, assign) CGFloat flex;
@property (nonatomic, readwrite, assign) CGFloat flexGrow; @property (nonatomic, readwrite, assign) CGFloat flexGrow;
@property (nonatomic, readwrite, assign) CGFloat flexShrink; @property (nonatomic, readwrite, assign) CGFloat flexShrink;
@property (nonatomic, readwrite, assign) YGValue flexBasis; @property (nonatomic, readwrite, assign) YGValue flexBasis;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import "YGLayout+Private.h" #import "YGLayout+Private.h"
@@ -30,6 +28,9 @@
- (void)set##capitalized_name:(YGValue)lowercased_name \ - (void)set##capitalized_name:(YGValue)lowercased_name \
{ \ { \
switch (lowercased_name.unit) { \ switch (lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPoint: \ case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \ YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \ break; \
@@ -41,6 +42,29 @@
} \ } \
} }
#define YG_AUTO_VALUE_PROPERTY(lowercased_name, capitalized_name) \
- (YGValue)lowercased_name \
{ \
return YGNodeStyleGet##capitalized_name(self.node); \
} \
\
- (void)set##capitalized_name:(YGValue)lowercased_name \
{ \
switch (lowercased_name.unit) { \
case YGUnitPoint: \
YGNodeStyleSet##capitalized_name(self.node, lowercased_name.value); \
break; \
case YGUnitPercent: \
YGNodeStyleSet##capitalized_name##Percent(self.node, lowercased_name.value); \
break; \
case YGUnitAuto: \
YGNodeStyleSet##capitalized_name##Auto(self.node); \
break; \
default: \
NSAssert(NO, @"Not implemented"); \
} \
}
#define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \ #define YG_EDGE_PROPERTY_GETTER(type, lowercased_name, capitalized_name, property, edge) \
- (type)lowercased_name \ - (type)lowercased_name \
{ \ { \
@@ -61,6 +85,9 @@ YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge)
- (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \ - (void)set##objc_capitalized_name:(YGValue)objc_lowercased_name \
{ \ { \
switch (objc_lowercased_name.unit) { \ switch (objc_lowercased_name.unit) { \
case YGUnitUndefined: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \
case YGUnitPoint: \ case YGUnitPoint: \
YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \ YGNodeStyleSet##c_name(self.node, edge, objc_lowercased_name.value); \
break; \ break; \
@@ -102,6 +129,7 @@ static YGConfigRef globalConfig;
@interface YGLayout () @interface YGLayout ()
@property (nonatomic, weak, readonly) UIView *view; @property (nonatomic, weak, readonly) UIView *view;
@property(nonatomic, assign, readonly) BOOL isUIView;
@end @end
@@ -126,6 +154,7 @@ static YGConfigRef globalConfig;
YGNodeSetContext(_node, (__bridge void *) view); YGNodeSetContext(_node, (__bridge void *) view);
_isEnabled = NO; _isEnabled = NO;
_isIncludedInLayout = YES; _isIncludedInLayout = YES;
_isUIView = [view isMemberOfClass:[UIView class]];
} }
return self; return self;
@@ -151,7 +180,7 @@ static YGConfigRef globalConfig;
// the measure function. Since we already know that this is a leaf, // the measure function. Since we already know that this is a leaf,
// this *should* be fine. Forgive me Hack Gods. // this *should* be fine. Forgive me Hack Gods.
const YGNodeRef node = self.node; const YGNodeRef node = self.node;
if (YGNodeGetMeasureFunc(node) == NULL) { if (YGNodeHasMeasureFunc(node)) {
YGNodeSetMeasureFunc(node, YGMeasureView); YGNodeSetMeasureFunc(node, YGMeasureView);
} }
@@ -200,9 +229,10 @@ YG_PROPERTY(YGWrap, flexWrap, FlexWrap)
YG_PROPERTY(YGOverflow, overflow, Overflow) YG_PROPERTY(YGOverflow, overflow, Overflow)
YG_PROPERTY(YGDisplay, display, Display) YG_PROPERTY(YGDisplay, display, Display)
YG_PROPERTY(CGFloat, flex, Flex)
YG_PROPERTY(CGFloat, flexGrow, FlexGrow) YG_PROPERTY(CGFloat, flexGrow, FlexGrow)
YG_PROPERTY(CGFloat, flexShrink, FlexShrink) YG_PROPERTY(CGFloat, flexShrink, FlexShrink)
YG_VALUE_PROPERTY(flexBasis, FlexBasis) YG_AUTO_VALUE_PROPERTY(flexBasis, FlexBasis)
YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft) YG_VALUE_EDGE_PROPERTY(left, Left, Position, YGEdgeLeft)
YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop) YG_VALUE_EDGE_PROPERTY(top, Top, Position, YGEdgeTop)
@@ -221,8 +251,8 @@ YG_EDGE_PROPERTY(borderStartWidth, BorderStartWidth, Border, YGEdgeStart)
YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd) YG_EDGE_PROPERTY(borderEndWidth, BorderEndWidth, Border, YGEdgeEnd)
YG_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll) YG_EDGE_PROPERTY(borderWidth, BorderWidth, Border, YGEdgeAll)
YG_VALUE_PROPERTY(width, Width) YG_AUTO_VALUE_PROPERTY(width, Width)
YG_VALUE_PROPERTY(height, Height) YG_AUTO_VALUE_PROPERTY(height, Height)
YG_VALUE_PROPERTY(minWidth, MinWidth) YG_VALUE_PROPERTY(minWidth, MinWidth)
YG_VALUE_PROPERTY(minHeight, MinHeight) YG_VALUE_PROPERTY(minHeight, MinHeight)
YG_VALUE_PROPERTY(maxWidth, MaxWidth) YG_VALUE_PROPERTY(maxWidth, MaxWidth)
@@ -254,7 +284,7 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio)
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) { if (dimensionFlexibility & YGDimensionFlexibilityFlexibleWidth) {
size.width = YGUndefined; size.width = YGUndefined;
} }
if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeigth) { if (dimensionFlexibility & YGDimensionFlexibilityFlexibleHeight) {
size.height = YGUndefined; size.height = YGUndefined;
} }
[self calculateLayoutWithSize:size]; [self calculateLayoutWithSize:size];
@@ -304,10 +334,20 @@ static YGSize YGMeasureView(
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height; const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
UIView *view = (__bridge UIView*) YGNodeGetContext(node); UIView *view = (__bridge UIView*) YGNodeGetContext(node);
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) { CGSize sizeThatFits = CGSizeZero;
.width = constrainedWidth,
.height = constrainedHeight, // The default implementation of sizeThatFits: returns the existing size of
}]; // the view. That means that if we want to layout an empty UIView, which
// already has got a frame set, its measured size should be CGSizeZero, but
// UIKit returns the existing size.
//
// See https://github.com/facebook/yoga/issues/606 for more information.
if (!view.yoga.isUIView || [view.subviews count] > 0) {
sizeThatFits = [view sizeThatFits:(CGSize){
.width = constrainedWidth,
.height = constrainedHeight,
}];
}
return (YGSize) { return (YGSize) {
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), .width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
@@ -361,7 +401,7 @@ static void YGAttachNodesFromViewHierachy(UIView *const view)
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count]; NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView *subview in view.subviews) { for (UIView *subview in view.subviews) {
if (subview.yoga.isIncludedInLayout) { if (subview.yoga.isEnabled && subview.yoga.isIncludedInLayout) {
[subviewsToInclude addObject:subview]; [subviewsToInclude addObject:subview];
} }
} }
@@ -385,9 +425,7 @@ static void YGRemoveAllChildren(const YGNodeRef node)
return; return;
} }
while (YGNodeGetChildCount(node) > 0) { YGNodeRemoveAllChildren(node);
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
}
} }
static CGFloat YGRoundPixelValue(CGFloat value) static CGFloat YGRoundPixelValue(CGFloat value)

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
postfix operator % postfix operator %

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
@@ -129,6 +127,15 @@
XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width); XCTAssertEqual(longTextLabelSize.width + textBadgeView.yoga.intrinsicSize.width, containerSize.width);
} }
- (void)testSizeThatFitsEmptyView {
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
view.yoga.isEnabled = YES;
const CGSize viewSize = view.yoga.intrinsicSize;
XCTAssertEqual(viewSize.height, 0);
XCTAssertEqual(viewSize.width, 0);
}
- (void)testPreservingOrigin - (void)testPreservingOrigin
{ {
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)]; UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,0,50,75)];
@@ -181,7 +188,9 @@
view.yoga.height = YGPointValue(100); view.yoga.height = YGPointValue(100);
[container addSubview:view]; [container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleHeigth]; [container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleHeight];
XCTAssertEqual(200, container.frame.size.width); XCTAssertEqual(200, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height); XCTAssertEqual(100, container.frame.size.height);
} }
@@ -197,7 +206,10 @@
view.yoga.height = YGPointValue(100); view.yoga.height = YGPointValue(100);
[container addSubview:view]; [container addSubview:view];
[container.yoga applyLayoutPreservingOrigin:YES dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth | YGDimensionFlexibilityFlexibleHeigth]; [container.yoga
applyLayoutPreservingOrigin:YES
dimensionFlexibility:YGDimensionFlexibilityFlexibleWidth |
YGDimensionFlexibilityFlexibleHeight];
XCTAssertEqual(100, container.frame.size.width); XCTAssertEqual(100, container.frame.size.width);
XCTAssertEqual(100, container.frame.size.height); XCTAssertEqual(100, container.frame.size.height);
} }

View File

@@ -4,9 +4,9 @@ PODS:
- IGListKit/Default (2.1.0): - IGListKit/Default (2.1.0):
- IGListKit/Diffing - IGListKit/Diffing
- IGListKit/Diffing (2.1.0) - IGListKit/Diffing (2.1.0)
- Yoga (1.5.0) - Yoga (1.7.0)
- YogaKit (1.5.0): - YogaKit (1.7.0):
- Yoga (~> 1.5) - Yoga (~> 1.7)
DEPENDENCIES: DEPENDENCIES:
- IGListKit (~> 2.1.0) - IGListKit (~> 2.1.0)

View File

@@ -1,3 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// !$*UTF8*$! // !$*UTF8*$!
{ {
archiveVersion = 1; archiveVersion = 1;

View File

@@ -1,3 +1,10 @@
<!--
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Workspace <Workspace
version = "1.0"> version = "1.0">

View File

@@ -1,13 +1,11 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory.
include_defs("//YOGA_DEFS") load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "yoga_android_aar", "yoga_android_resource")
android_aar( yoga_android_aar(
name = "android", name = "android",
manifest_skeleton = "src/main/AndroidManifest.xml", manifest_skeleton = "src/main/AndroidManifest.xml",
visibility = [ visibility = [
@@ -22,7 +20,7 @@ android_aar(
], ],
) )
android_resource( yoga_android_resource(
name = "res", name = "res",
package = "com.facebook.yoga.android", package = "com.facebook.yoga.android",
res = "src/main/res", res = "src/main/res",

View File

@@ -1,3 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
apply plugin: 'com.jfrog.bintray' apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'
@@ -22,7 +29,7 @@ android {
} }
dependencies { dependencies {
compile project(':yoga') api project(':yoga')
} }
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {

View File

@@ -1,3 +1,10 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#
GROUP=com.facebook.yoga.android GROUP=com.facebook.yoga.android
POM_NAME=YogaLayout POM_NAME=YogaLayout
POM_DESCRIPTION=YogaLayout POM_DESCRIPTION=YogaLayout

View File

@@ -4,9 +4,10 @@
# This source code is licensed under the license found in the # This source code is licensed under the license found in the
# LICENSE-examples file in the root directory of this source tree. # LICENSE-examples file in the root directory of this source tree.
include_defs("//YOGA_DEFS") load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "ANDROID_SAMPLE_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "yoga_android_binary", "yoga_android_resource")
android_binary( yoga_android_binary(
name = "sample", name = "sample",
keystore = ":debug_keystore", keystore = ":debug_keystore",
manifest = "AndroidManifest.xml", manifest = "AndroidManifest.xml",
@@ -16,7 +17,7 @@ android_binary(
], ],
) )
android_resource( yoga_android_resource(
name = "res", name = "res",
package = "com.facebook.samples.yoga", package = "com.facebook.samples.yoga",
res = "res", res = "res",
@@ -28,7 +29,7 @@ android_resource(
], ],
) )
keystore( fb_native.keystore(
name = "debug_keystore", name = "debug_keystore",
properties = "debug.keystore.properties", properties = "debug.keystore.properties",
store = "debug.keystore", store = "debug.keystore",

View File

@@ -1,13 +1,11 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE-examples file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory.
include_defs("//YOGA_DEFS") load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_JAVA_TARGET", "ANDROID_SAMPLE_RES_TARGET", "ANDROID_SUPPORT_TARGET", "APPCOMPAT_TARGET", "SOLOADER_TARGET", "yoga_android_library")
android_library( yoga_android_library(
name = "yoga", name = "yoga",
srcs = glob(["**/*.java"]), srcs = glob(["**/*.java"]),
visibility = [ visibility = [

View File

@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright (c) 2014-present, Facebook, Inc. Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the MIT license found in the
This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.
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.
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"

View File

@@ -1,13 +1,11 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory.
include_defs("//YOGA_DEFS") load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID_RES_TARGET", "INFER_ANNOTATIONS_TARGET", "JAVA_TARGET", "JSR_305_TARGET", "SOLOADER_TARGET", "yoga_android_library")
android_library( yoga_android_library(
name = "android", name = "android",
srcs = glob(["**/*.java"]), srcs = glob(["**/*.java"]),
visibility = [ visibility = [

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
@@ -35,7 +33,7 @@ public class VirtualYogaLayout extends ViewGroup {
final private List<View> mChildren = new LinkedList<>(); final private List<View> mChildren = new LinkedList<>();
final private Map<View, YogaNode> mYogaNodes = new HashMap<>(); final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
final private YogaNode mYogaNode = new YogaNode(); final private YogaNode mYogaNode = YogaNode.create();
public VirtualYogaLayout(Context context) { public VirtualYogaLayout(Context context) {
super(context); super(context);
@@ -75,7 +73,7 @@ public class VirtualYogaLayout extends ViewGroup {
return; return;
} }
YogaNode node = new YogaNode(); YogaNode node = YogaNode.create();
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params); YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
YogaLayout.applyLayoutParams(lp, node, child); YogaLayout.applyLayoutParams(lp, node, child);
node.setData(child); node.setData(child);

View File

@@ -1,17 +1,12 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import java.util.HashMap;
import java.util.Map;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@@ -23,9 +18,6 @@ import android.util.SparseArray;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.util.Log;
import com.facebook.yoga.android.R;
import com.facebook.yoga.YogaAlign; import com.facebook.yoga.YogaAlign;
import com.facebook.yoga.YogaConstants; import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaDirection; import com.facebook.yoga.YogaDirection;
@@ -37,10 +29,11 @@ import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaMeasureMode; import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput; import com.facebook.yoga.YogaMeasureOutput;
import com.facebook.yoga.YogaNode; import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaOverflow; import com.facebook.yoga.YogaOverflow;
import com.facebook.yoga.YogaPositionType; import com.facebook.yoga.YogaPositionType;
import com.facebook.yoga.YogaWrap; import com.facebook.yoga.YogaWrap;
import java.util.HashMap;
import java.util.Map;
/** /**
* A {@code ViewGroup} based on the Yoga layout engine. * A {@code ViewGroup} based on the Yoga layout engine.
@@ -53,14 +46,14 @@ import com.facebook.yoga.YogaWrap;
* <YogaLayout * <YogaLayout
* xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:android="http://schemas.android.com/apk/res/android"
* xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android" * xmlns:yoga="http://schemas.android.com/apk/com.facebook.yoga.android"
* android:layout_width="match_parent" * android:layout_width="match_owner"
* android:layout_height="match_parent" * android:layout_height="match_owner"
* yoga:flex_direction="row" * yoga:flex_direction="row"
* yoga:padding_all="10dp" * yoga:padding_all="10dp"
* > * >
* <TextView * <TextView
* android:layout_width="match_parent" * android:layout_width="match_owner"
* android:layout_height="match_parent" * android:layout_height="match_owner"
* android:text="Hello, World!" * android:text="Hello, World!"
* yoga:flex="1" * yoga:flex="1"
* /> * />
@@ -85,7 +78,7 @@ public class YogaLayout extends ViewGroup {
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) { public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
mYogaNode = new YogaNode(); mYogaNode = YogaNode.create();
mYogaNodes = new HashMap<>(); mYogaNodes = new HashMap<>();
mYogaNode.setData(this); mYogaNode.setData(this);
@@ -162,7 +155,7 @@ public class YogaLayout extends ViewGroup {
if(mYogaNodes.containsKey(child)) { if(mYogaNodes.containsKey(child)) {
childNode = mYogaNodes.get(child); childNode = mYogaNodes.get(child);
} else { } else {
childNode = new YogaNode(); childNode = YogaNode.create();
} }
childNode.setData(child); childNode.setData(child);
@@ -269,11 +262,11 @@ public class YogaLayout extends ViewGroup {
return; return;
} }
final YogaNode parent = node.getParent(); final YogaNode owner = node.getOwner();
for (int i = 0; i < parent.getChildCount(); i++) { for (int i = 0; i < owner.getChildCount(); i++) {
if (parent.getChildAt(i).equals(node)) { if (owner.getChildAt(i).equals(node)) {
parent.removeChildAt(i); owner.removeChildAt(i);
break; break;
} }
} }
@@ -293,6 +286,8 @@ public class YogaLayout extends ViewGroup {
if (view.getVisibility() == GONE) { if (view.getVisibility() == GONE) {
return; return;
} }
int left = Math.round(xOffset + node.getLayoutX());
int top = Math.round(yOffset + node.getLayoutY());
view.measure( view.measure(
View.MeasureSpec.makeMeasureSpec( View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutWidth()), Math.round(node.getLayoutWidth()),
@@ -300,11 +295,7 @@ public class YogaLayout extends ViewGroup {
View.MeasureSpec.makeMeasureSpec( View.MeasureSpec.makeMeasureSpec(
Math.round(node.getLayoutHeight()), Math.round(node.getLayoutHeight()),
View.MeasureSpec.EXACTLY)); View.MeasureSpec.EXACTLY));
view.layout( view.layout(left, top, left + view.getMeasuredWidth(), top + view.getMeasuredHeight());
Math.round(xOffset + node.getLayoutX()),
Math.round(yOffset + node.getLayoutY()),
Math.round(xOffset + node.getLayoutX() + node.getLayoutWidth()),
Math.round(yOffset + node.getLayoutY() + node.getLayoutHeight()));
} }
final int childrenCount = node.getChildCount(); final int childrenCount = node.getChildCount();
@@ -324,7 +315,7 @@ public class YogaLayout extends ViewGroup {
@Override @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) { protected void onLayout(boolean changed, int l, int t, int r, int b) {
// Either we are a root of a tree, or this function is called by our parent's onLayout, in which // Either we are a root of a tree, or this function is called by our owner's onLayout, in which
// case our r-l and b-t are the size of our node. // case our r-l and b-t are the size of our node.
if (!(getParent() instanceof YogaLayout)) { if (!(getParent() instanceof YogaLayout)) {
createLayout( createLayout(
@@ -708,7 +699,7 @@ public class YogaLayout extends ViewGroup {
/** /**
* Constructs a set of layout params, given width and height specs. In this case, we can set * Constructs a set of layout params, given width and height specs. In this case, we can set
* the {@code yoga:width} and {@code yoga:height} if we are given them explicitly. If other * the {@code yoga:width} and {@code yoga:height} if we are given them explicitly. If other
* options (such as {@code match_parent} or {@code wrap_content} are given, then the parent * options (such as {@code match_owner} or {@code wrap_content} are given, then the owner
* LayoutParams will store them, and we deal with them during layout. (see * LayoutParams will store them, and we deal with them during layout. (see
* {@link YogaLayout#createLayout}) * {@link YogaLayout#createLayout})
* *
@@ -782,9 +773,9 @@ public class YogaLayout extends ViewGroup {
* {@code View}'s measure function. * {@code View}'s measure function.
* *
* @param node The yoga node to measure * @param node The yoga node to measure
* @param width The suggested width from the parent * @param width The suggested width from the owner
* @param widthMode The type of suggestion for the width * @param widthMode The type of suggestion for the width
* @param height The suggested height from the parent * @param height The suggested height from the owner
* @param heightMode The type of suggestion for the height * @param heightMode The type of suggestion for the height
* @return A measurement output ({@code YogaMeasureOutput}) for the node * @return A measurement output ({@code YogaMeasureOutput}) for the node
*/ */

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;

View File

@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!-- <!--
Copyright (c) 2014-present, Facebook, Inc. Copyright (c) Facebook, Inc. and its affiliates.
All rights reserved.
This source code is licensed under the MIT license found in the
This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.
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.
--> -->
<resources> <resources>

View File

@@ -1,15 +1,14 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory. load("//tools/build_defs/oss:yoga_defs.bzl", "subdir_glob", "yoga_cxx_binary", "yoga_dep")
include_defs("//YOGA_DEFS") yoga_cxx_binary(
cxx_binary(
name = "benchmark", name = "benchmark",
srcs = glob(["*.c"]), srcs = glob(["*.c"]),
headers = subdir_glob([("", "*.h")]),
header_namespace = "",
compiler_flags = [ compiler_flags = [
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
"-fexceptions", "-fexceptions",
@@ -18,8 +17,6 @@ cxx_binary(
"-O3", "-O3",
"-std=c11", "-std=c11",
], ],
header_namespace = "",
headers = subdir_glob([("", "*.h")]),
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [ deps = [
yoga_dep(":yoga"), yoga_dep(":yoga"),

View File

@@ -1,21 +1,82 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#include <math.h>
#include "YGBenchmark.h" #include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static YGSize _measure(YGNodeRef node, #define NUM_REPETITIONS 1000
float width,
YGMeasureMode widthMode, #define YGBENCHMARKS(BLOCK) \
float height, int main(int argc, char const* argv[]) { \
YGMeasureMode heightMode) { 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);
static 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;
}
static 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);
}
static YGSize _measure(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return (YGSize){ return (YGSize){
.width = widthMode == YGMeasureModeUndefined ? 10 : width, .width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width, .height = heightMode == YGMeasureModeUndefined ? 10 : width,
@@ -23,7 +84,6 @@ static YGSize _measure(YGNodeRef node,
} }
YGBENCHMARKS({ YGBENCHMARKS({
YGBENCHMARK("Stack with flex", { YGBENCHMARK("Stack with flex", {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
@@ -99,9 +159,10 @@ YGBENCHMARKS({
YGNodeStyleSetHeight(grandGrandChild, 10); YGNodeStyleSetHeight(grandGrandChild, 10);
YGNodeInsertChild(grandChild, grandGrandChild, 0); YGNodeInsertChild(grandChild, grandGrandChild, 0);
for (uint32_t iii = 0; iii < 10; iii++) { for (uint32_t iiii = 0; iiii < 10; iiii++) {
const YGNodeRef grandGrandGrandChild = YGNodeNew(); const YGNodeRef grandGrandGrandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow); YGNodeStyleSetFlexDirection(
grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1); YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandGrandChild, 10); YGNodeStyleSetWidth(grandGrandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandGrandChild, 10); YGNodeStyleSetHeight(grandGrandGrandChild, 10);
@@ -114,5 +175,4 @@ YGBENCHMARKS({
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
}); });
}); });

View File

@@ -1,73 +0,0 @@
/**
* 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);
}

View File

@@ -1,14 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
repositories { repositories {
google()
jcenter() jcenter()
maven { url 'https://maven.google.com/' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.nabilhachicha:android-native-dependencies:0.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@@ -17,6 +25,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google()
jcenter() jcenter()
} }
} }
@@ -24,8 +33,8 @@ allprojects {
ext { ext {
minSdkVersion = 14 minSdkVersion = 14
targetSdkVersion = 25 targetSdkVersion = 25
compileSdkVersion = 25 compileSdkVersion = 26
buildToolsVersion = '25.0.2' buildToolsVersion = '26.0.2'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7 sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7 targetCompatibilityVersion = JavaVersion.VERSION_1_7
} }

View File

@@ -1,9 +1,8 @@
/** /**
* Copyright 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the license found in the * This source code is licensed under the MIT license found in the
* LICENSE-examples file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
using System.Reflection; using System.Reflection;

View File

@@ -1,31 +1,36 @@
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory.
include_defs("//YOGA_DEFS") load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load(
"//tools/build_defs/oss:yoga_defs.bzl",
"BASE_COMPILER_FLAGS",
"yoga_apple_binary",
"yoga_cxx_library",
"yoga_dep",
)
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++11"] COMPILER_FLAGS = BASE_COMPILER_FLAGS + ["-std=c++14"]
csharp_library( fb_native.csharp_library(
name = "yogalibnet46", name = "yogalibnet46",
srcs = glob(["**/*.cs"]), srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll", dll_name = "Facebook.Yoga.dll",
framework_ver = "net46", framework_ver = "net46",
) )
csharp_library( fb_native.csharp_library(
name = "yogalibnet45", name = "yogalibnet45",
srcs = glob(["**/*.cs"]), srcs = glob(["**/*.cs"]),
dll_name = "Facebook.Yoga.dll", dll_name = "Facebook.Yoga.dll",
framework_ver = "net45", framework_ver = "net45",
) )
cxx_library( yoga_cxx_library(
name = "yoganet", name = "yoganet",
srcs = glob(["Yoga/YGInterop.cpp"]), srcs = ["Yoga/YGInterop.cpp"],
compiler_flags = COMPILER_FLAGS, compiler_flags = COMPILER_FLAGS,
link_style = "static", link_style = "static",
link_whole = True, link_whole = True,
@@ -34,41 +39,4 @@ cxx_library(
deps = [yoga_dep(":yoga")], deps = [yoga_dep(":yoga")],
) )
if isdir('/Applications/Xcode.app'): yoga_apple_binary()
yoganet_ios_srcs = []
for arch in [
'iphonesimulator-x86_64', 'iphonesimulator-i386', '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'],
)
yoganet_macosx_target = 'csharp:yoganet#macosx-%s,dynamic'
genrule(
name = 'yoganet-macosx',
srcs = [
yoga_dep(yoganet_macosx_target % 'x86_64'),
yoga_dep(yoganet_macosx_target % 'i386'),
],
out = 'libyoga.dylib',
cmd = 'lipo $SRCS -create -output $OUT',
visibility = ['PUBLIC'],
)

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;
@@ -12,12 +10,6 @@ using System.Runtime.InteropServices;
namespace Facebook.Yoga namespace Facebook.Yoga
{ {
#if WINDOWS_UWP_ARM
using YogaValueType = IntPtr;
#else
using YogaValueType = YogaValue;
#endif
internal static class Native internal static class Native
{ {
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__ #if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
@@ -76,6 +68,14 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config); public static extern bool YGConfigGetUseWebDefaults(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetUseLegacyStretchBehaviour(
YGConfigHandle config,
bool useLegacyStretchBehavior);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGConfigGetUseLegacyStretchBehaviour(YGConfigHandle config);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigSetPointScaleFactor( public static extern void YGConfigSetPointScaleFactor(
YGConfigHandle config, YGConfigHandle config,
@@ -90,6 +90,14 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child); public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetIsReferenceBaseline(
YGNodeHandle node,
bool isReferenceBaseline);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern bool YGNodeIsReferenceBaseline(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeCalculateLayout( public static extern void YGNodeCalculateLayout(
YGNodeHandle node, YGNodeHandle node,
@@ -220,7 +228,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node); public static extern void YGNodeStyleSetFlexBasisAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetFlexBasis(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width); public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
@@ -232,7 +240,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node); public static extern void YGNodeStyleSetWidthAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetWidth(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height); public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
@@ -244,7 +252,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node); public static extern void YGNodeStyleSetHeightAuto(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetHeight(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth); public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
@@ -253,7 +261,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth); public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMinWidth(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight); public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
@@ -262,7 +270,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight); public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMinHeight(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth); public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
@@ -271,7 +279,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth); public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMaxWidth(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight); public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
@@ -280,7 +288,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight); public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMaxHeight(YGNodeHandle node); public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio); public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -299,7 +307,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position); public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin); public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
@@ -311,7 +319,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge); public static extern void YGNodeStyleSetMarginAuto(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding); public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
@@ -320,7 +328,7 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding); public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern YogaValueType YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border); public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;
@@ -119,6 +117,19 @@ namespace Facebook.Yoga
} }
} }
public bool UseLegacyStretchBehaviour
{
get
{
return Native.YGConfigGetUseLegacyStretchBehaviour(_ygConfig);
}
set
{
Native.YGConfigSetUseLegacyStretchBehaviour(_ygConfig, value);
}
}
public float PointScaleFactor public float PointScaleFactor
{ {
set set

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga
@@ -16,5 +14,6 @@ namespace Facebook.Yoga
FlexEnd, FlexEnd,
SpaceBetween, SpaceBetween,
SpaceAround, SpaceAround,
SpaceEvenly,
} }
} }

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga
@@ -15,7 +13,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left)); return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left);
} }
set set
@@ -28,7 +26,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top)); return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top);
} }
set set
@@ -41,7 +39,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right)); return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right);
} }
set set
@@ -54,7 +52,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom)); return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom);
} }
set set
@@ -67,7 +65,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start)); return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start);
} }
set set
@@ -80,7 +78,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End)); return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End);
} }
set set
@@ -105,7 +103,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left);
} }
set set
@@ -118,7 +116,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top);
} }
set set
@@ -131,7 +129,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right);
} }
set set
@@ -144,7 +142,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom);
} }
set set
@@ -157,7 +155,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start);
} }
set set
@@ -170,7 +168,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End);
} }
set set
@@ -183,7 +181,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal);
} }
set set
@@ -196,7 +194,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical);
} }
set set
@@ -209,7 +207,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All)); return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All);
} }
set set
@@ -238,7 +236,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left);
} }
set set
@@ -251,7 +249,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top);
} }
set set
@@ -264,7 +262,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right);
} }
set set
@@ -277,7 +275,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom);
} }
set set
@@ -290,7 +288,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start);
} }
set set
@@ -303,7 +301,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End);
} }
set set
@@ -316,7 +314,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal);
} }
set set
@@ -329,7 +327,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical);
} }
set set
@@ -342,7 +340,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All)); return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All);
} }
set set

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;
@@ -273,7 +271,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetFlexBasis(_ygNode)); return Native.YGNodeStyleGetFlexBasis(_ygNode);
} }
set set
@@ -297,7 +295,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetWidth(_ygNode)); return Native.YGNodeStyleGetWidth(_ygNode);
} }
set set
@@ -321,7 +319,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetHeight(_ygNode)); return Native.YGNodeStyleGetHeight(_ygNode);
} }
set set
@@ -345,7 +343,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxWidth(_ygNode)); return Native.YGNodeStyleGetMaxWidth(_ygNode);
} }
set set
@@ -365,7 +363,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMaxHeight(_ygNode)); return Native.YGNodeStyleGetMaxHeight(_ygNode);
} }
set set
@@ -385,7 +383,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinWidth(_ygNode)); return Native.YGNodeStyleGetMinWidth(_ygNode);
} }
set set
@@ -405,7 +403,7 @@ namespace Facebook.Yoga
{ {
get get
{ {
return YogaValue.MarshalValue(Native.YGNodeStyleGetMinHeight(_ygNode)); return Native.YGNodeStyleGetMinHeight(_ygNode);
} }
set set
@@ -521,6 +519,19 @@ namespace Facebook.Yoga
Native.YGNodeSetHasNewLayout(_ygNode, false); Native.YGNodeSetHasNewLayout(_ygNode, false);
} }
public bool IsReferenceBaseline
{
get
{
return Native.YGNodeIsReferenceBaseline(_ygNode);
}
set
{
Native.YGNodeSetIsReferenceBaseline(_ygNode, value);
}
}
public bool ValuesEqual(float f1, float f2) public bool ValuesEqual(float f1, float f2)
{ {
if (float.IsNaN(f1) || float.IsNaN(f2)) if (float.IsNaN(f1) || float.IsNaN(f2))
@@ -595,12 +606,14 @@ namespace Facebook.Yoga
Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline); Native.YGNodeSetBaselineFunc(_ygNode, _managedBaseline);
} }
public void CalculateLayout() public void CalculateLayout(
float width = YogaConstants.Undefined,
float height = YogaConstants.Undefined)
{ {
Native.YGNodeCalculateLayout( Native.YGNodeCalculateLayout(
_ygNode, _ygNode,
YogaConstants.Undefined, width,
YogaConstants.Undefined, height,
Native.YGNodeStyleGetDirection(_ygNode)); Native.YGNodeStyleGetDirection(_ygNode));
} }

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;
@@ -93,17 +91,5 @@ namespace Facebook.Yoga
{ {
return Point(pointValue); return Point(pointValue);
} }
#if WINDOWS_UWP_ARM
internal static YogaValue MarshalValue(IntPtr ptr)
{
return Marshal.PtrToStructure<YogaValue>(ptr);
}
#else
internal static YogaValue MarshalValue(YogaValue value)
{
return value;
}
#endif
} }
} }

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
namespace Facebook.Yoga namespace Facebook.Yoga

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
#if __IOS__ #if __IOS__
using NativeView = UIKit.UIView; using NativeView = UIKit.UIView;
using NativeScrollView = UIKit.UIScrollView;
#endif #endif
namespace Facebook.YogaKit namespace Facebook.YogaKit
@@ -699,12 +700,12 @@ namespace Facebook.YogaKit
{ {
get get
{ {
return _node.StyleAspectRatio; return _node.AspectRatio;
} }
set set
{ {
_node.StyleAspectRatio = value; _node.AspectRatio = value;
} }
} }
@@ -716,6 +717,17 @@ namespace Facebook.YogaKit
float width = 0; float width = 0;
float height = 0; float height = 0;
GetWidthHeightOfNativeView(view, out width, out height); GetWidthHeightOfNativeView(view, out width, out height);
if (view is NativeScrollView)
{
if (FlexDirection == YogaFlexDirection.Column || FlexDirection == YogaFlexDirection.ColumnReverse)
{
height = float.NaN;
}
else
{
width = float.NaN;
}
}
CalculateLayoutWithSize(this, width, height); CalculateLayoutWithSize(this, width, height);
ApplyLayoutToViewHierarchy(view); ApplyLayoutToViewHierarchy(view);
} }
@@ -743,9 +755,7 @@ namespace Facebook.YogaKit
var node = layout._node; var node = layout._node;
node.Width = width; node.CalculateLayout(width, height);
node.Height = height;
node.CalculateLayout();
return new SizeF { Width = node.LayoutWidth, Height = node.LayoutHeight }; return new SizeF { Width = node.LayoutWidth, Height = node.LayoutHeight };
} }
@@ -775,14 +785,14 @@ namespace Facebook.YogaKit
float result; float result;
if (measureMode == YogaMeasureMode.Exactly) if (measureMode == YogaMeasureMode.Exactly)
{ {
result = (float)constrainedSize; result = constrainedSize;
} }
else if (measureMode == YogaMeasureMode.AtMost) else if (measureMode == YogaMeasureMode.AtMost)
{ {
result = (float)Math.Min(constrainedSize, measuredSize); result = Math.Min(constrainedSize, measuredSize);
} }
else { else {
result = (float)measuredSize; result = measuredSize;
} }
return result; return result;
@@ -820,7 +830,7 @@ namespace Facebook.YogaKit
var subviewsToInclude = new List<NativeView>(); var subviewsToInclude = new List<NativeView>();
foreach (var subview in view.Subviews) foreach (var subview in view.Subviews)
{ {
if (subview.Yoga().IsIncludeInLayout) if (subview.Yoga().IsEnabled && subview.Yoga().IsIncludeInLayout)
{ {
subviewsToInclude.Add(subview); subviewsToInclude.Add(subview);
} }
@@ -856,7 +866,7 @@ namespace Facebook.YogaKit
static double RoundPointValue(float value) static double RoundPointValue(float value)
{ {
float scale = NativePointScale; float scale = NativePixelScale;
return Math.Round(value * scale) / scale; return Math.Round(value * scale) / scale;
} }

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -1,9 +1,8 @@
/** /**
* Copyright 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the license found in the * This source code is licensed under the MIT license found in the
* LICENSE-examples file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
using System; using System;

View File

@@ -1,2 +1,10 @@
#!/bin/sh #!/bin/sh
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
./csharp/Mac/Facebook.Yoga.Mac.Tests/bin/Release/Facebook.Yoga.Mac.Tests.app/Contents/MacOS/Facebook.Yoga.Mac.Tests

View File

@@ -1,10 +1,8 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2014-present, Facebook, Inc. # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# #
# This source code is licensed under the BSD-style license found in the # This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree.
# of patent rights can be found in the PATENTS file in the same directory.
set -e set -e

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System.Reflection; using System.Reflection;

View File

@@ -1,4 +1,4 @@
using System; using System;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Facebook.Yoga; using Facebook.Yoga;
@@ -206,8 +206,8 @@ namespace Facebook.Yoga.Universal.Tests
return MeasureOutput.Make(123.4f, 81.7f); return MeasureOutput.Make(123.4f, 81.7f);
}); });
node.CalculateLayout(); node.CalculateLayout();
Assert.AreEqual(123, node.LayoutWidth); Assert.AreEqual(124, node.LayoutWidth);
Assert.AreEqual(81, node.LayoutHeight); Assert.AreEqual(82, node.LayoutHeight);
} }
[TestMethod] [TestMethod]
@@ -268,7 +268,12 @@ namespace Facebook.Yoga.Universal.Tests
parent.Insert(0, child0); parent.Insert(0, child0);
parent.Insert(0, child1); parent.Insert(0, child1);
parent.CalculateLayout(); parent.CalculateLayout();
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); Assert.AreEqual(parent.Print(),
"<div layout=\"width: 100; height: 120; top: 0; left: 0;\" style=\"width: 100px; height: 120px; \" >\n" +
" <div layout=\"width: 35; height: 45; top: 0; left: 0;\" style=\"width: 35px; height: 45px; \" ></div>\n" +
" <div layout=\"width: 30; height: 40; top: 45; left: 0;\" style=\"width: 30px; height: 40px; \" ></div>\n" +
"</div>"
);
} }
[TestMethod] [TestMethod]
@@ -414,4 +419,4 @@ namespace Facebook.Yoga.Universal.Tests
} }
#endif #endif
} }
} }

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System.Reflection; using System.Reflection;

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#include "YGInterop.h" #include "YGInterop.h"
static YGInteropLogger gManagedLogger; static YGInteropLogger gManagedLogger;

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#pragma once #pragma once
#include <yoga/Yoga.h> #include <yoga/Yoga.h>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM"> <ProjectConfiguration Include="Debug|ARM">
@@ -33,47 +33,47 @@
<RootNamespace>Yoga</RootNamespace> <RootNamespace>Yoga</RootNamespace>
<AppContainerApplication>true</AppContainerApplication> <AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType> <ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.10240.0</WindowsTargetPlatformMinVersion> <WindowsTargetPlatformMinVersion>10.0.14393.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision> <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
@@ -116,7 +116,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<OutDir>bin\Universal\$(PlatformTarget)\$(Configuration)\</OutDir> <OutDir>bin\Universal\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>obj\$(PlatformTarget)\$(Configuration)\</IntDir> <IntDir>obj\Universal\$(PlatformTarget)\$(Configuration)\</IntDir>
<TargetName>yoga</TargetName> <TargetName>yoga</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -242,19 +242,31 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\yoga\Utils.h" />
<ClInclude Include="..\..\yoga\YGConfig.h" />
<ClInclude Include="..\..\yoga\YGEnums.h" /> <ClInclude Include="..\..\yoga\YGEnums.h" />
<ClInclude Include="..\..\yoga\Yoga.h" /> <ClInclude Include="..\..\yoga\YGFloatOptional.h" />
<ClInclude Include="..\..\yoga\YGLayout.h" />
<ClInclude Include="..\..\yoga\YGMacros.h" /> <ClInclude Include="..\..\yoga\YGMacros.h" />
<ClInclude Include="..\..\yoga\YGNodeList.h" /> <ClInclude Include="..\..\yoga\YGNode.h" />
<ClInclude Include="..\..\yoga\YGNodePrint.h" />
<ClInclude Include="..\..\yoga\YGStyle.h" />
<ClInclude Include="..\..\yoga\Yoga-internal.h" />
<ClInclude Include="..\..\yoga\Yoga.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="YGInterop.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" /> <ClInclude Include="targetver.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\yoga\YGEnums.c" /> <ClCompile Include="..\..\yoga\Utils.cpp" />
<ClCompile Include="..\..\yoga\Yoga.c" /> <ClCompile Include="..\..\yoga\YGConfig.cpp" />
<ClCompile Include="..\..\yoga\YGNodeList.c" /> <ClCompile Include="..\..\yoga\YGEnums.cpp" />
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp" />
<ClCompile Include="..\..\yoga\YGLayout.cpp" />
<ClCompile Include="..\..\yoga\YGNode.cpp" />
<ClCompile Include="..\..\yoga\YGNodePrint.cpp" />
<ClCompile Include="..\..\yoga\YGStyle.cpp" />
<ClCompile Include="..\..\yoga\Yoga.cpp" />
<ClCompile Include="YGInterop.cpp" /> <ClCompile Include="YGInterop.cpp" />
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
@@ -284,4 +296,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@@ -21,22 +21,40 @@
<ClInclude Include="targetver.h"> <ClInclude Include="targetver.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\Yoga.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGEnums.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGFloatOptional.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGLayout.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGMacros.h"> <ClInclude Include="..\..\yoga\YGMacros.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGNodeList.h"> <ClInclude Include="..\..\yoga\YGNode.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="YGInterop.h"> <ClInclude Include="..\..\yoga\YGNodePrint.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h"> <ClInclude Include="..\..\yoga\YGStyle.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGEnums.h"> <ClInclude Include="..\..\yoga\Yoga.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\Yoga-internal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGConfig.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@@ -47,16 +65,34 @@
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\yoga\Yoga.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGNodeList.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="YGInterop.cpp"> <ClCompile Include="YGInterop.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\yoga\YGEnums.c"> <ClCompile Include="..\..\yoga\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGEnums.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGLayout.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGNodePrint.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGStyle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\Yoga.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGConfig.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@@ -65,4 +101,4 @@
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -38,39 +38,39 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
@@ -227,19 +227,31 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\yoga\Yoga.h" /> <ClInclude Include="..\..\yoga\Utils.h" />
<ClInclude Include="..\..\yoga\YGConfig.h" />
<ClInclude Include="..\..\yoga\YGEnums.h" /> <ClInclude Include="..\..\yoga\YGEnums.h" />
<ClInclude Include="..\..\yoga\YGFloatOptional.h" />
<ClInclude Include="..\..\yoga\YGLayout.h" />
<ClInclude Include="..\..\yoga\YGMacros.h" /> <ClInclude Include="..\..\yoga\YGMacros.h" />
<ClInclude Include="..\..\yoga\YGNodeList.h" /> <ClInclude Include="..\..\yoga\YGNode.h" />
<ClInclude Include="..\..\yoga\YGNodePrint.h" />
<ClInclude Include="..\..\yoga\YGStyle.h" />
<ClInclude Include="..\..\yoga\Yoga-internal.h" />
<ClInclude Include="..\..\yoga\Yoga.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="YGInterop.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" /> <ClInclude Include="targetver.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\yoga\Yoga.c" /> <ClCompile Include="..\..\yoga\Utils.cpp" />
<ClCompile Include="..\..\yoga\YGEnums.c" /> <ClCompile Include="..\..\yoga\YGConfig.cpp" />
<ClCompile Include="..\..\yoga\YGNodeList.c" /> <ClCompile Include="..\..\yoga\YGEnums.cpp" />
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp" />
<ClCompile Include="..\..\yoga\YGLayout.cpp" />
<ClCompile Include="..\..\yoga\YGNode.cpp" />
<ClCompile Include="..\..\yoga\YGNodePrint.cpp" />
<ClCompile Include="..\..\yoga\YGStyle.cpp" />
<ClCompile Include="..\..\yoga\Yoga.cpp" />
<ClCompile Include="YGInterop.cpp" /> <ClCompile Include="YGInterop.cpp" />
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>

View File

@@ -21,19 +21,40 @@
<ClInclude Include="targetver.h"> <ClInclude Include="targetver.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\Yoga.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGEnums.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGFloatOptional.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGLayout.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGMacros.h"> <ClInclude Include="..\..\yoga\YGMacros.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\yoga\YGNodeList.h"> <ClInclude Include="..\..\yoga\YGNode.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="YGInterop.h"> <ClInclude Include="..\..\yoga\YGNodePrint.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h"> <ClInclude Include="..\..\yoga\YGStyle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\Yoga.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\Yoga-internal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\yoga\YGConfig.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@@ -44,15 +65,36 @@
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\yoga\Yoga.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGNodeList.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="YGInterop.cpp"> <ClCompile Include="YGInterop.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\yoga\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGEnums.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGFloatOptional.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGLayout.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGNodePrint.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGStyle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\Yoga.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\yoga\YGConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Yoga.rc"> <ResourceCompile Include="Yoga.rc">

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
// dllmain.cpp : Defines the entry point for the DLL application. // dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h" #include "stdafx.h"

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
// stdafx.cpp : source file that includes just the standard includes // stdafx.cpp : source file that includes just the standard includes
// Yoga.pch will be the pre-compiled header // Yoga.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information // stdafx.obj will contain the pre-compiled type information

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
// stdafx.h : include file for standard system include files, // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but // or project specific include files that are used frequently, but
// are changed infrequently // are changed infrequently

View File

@@ -1,12 +1,9 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the LICENSE
* LICENSE file in the root directory of this source tree. An additional grant * file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
#pragma once #pragma once
// Including SDKDDKVer.h defines the highest available Windows platform. // Including SDKDDKVer.h defines the highest available Windows platform.

View File

@@ -1,7 +1,15 @@
#!/bin/sh #!/bin/sh
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
cd `dirname "$0"` cd `dirname "$0"`
echo $ANDROID_SDK echo $ANDROID_SDK
BUCK_RELEASE=2017.05.09.01 BUCK_RELEASE=2018.02.16.01
echo "buck $BUCK_RELEASE" echo "buck $BUCK_RELEASE"
BUCK=lib/buck-$BUCK_RELEASE/bin/buck BUCK=lib/buck-$BUCK_RELEASE/bin/buck
if $BUCK --version >/dev/null 2>&1; then true; else if $BUCK --version >/dev/null 2>&1; then true; else
@@ -22,4 +30,3 @@ $BUCK build \
//csharp:yoganet-macosx \ //csharp:yoganet-macosx \
//csharp:yoganet#android-armv7,shared \ //csharp:yoganet#android-armv7,shared \
//csharp:yoganet#android-x86,shared //csharp:yoganet#android-x86,shared

View File

@@ -1,9 +1,8 @@
/** /**
* Copyright 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the license found in the * This source code is licensed under the MIT license found in the
* LICENSE-examples file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
using System; using System;

View File

@@ -1,9 +1,8 @@
/** /**
* Copyright 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the license found in the * This source code is licensed under the MIT license found in the
* LICENSE-examples file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
using System; using System;

View File

@@ -1,10 +1,8 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
* *
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree.
* of patent rights can be found in the PATENTS file in the same directory.
*/ */
using System; using System;

View File

@@ -22,8 +22,6 @@
<MtouchDebug>true</MtouchDebug> <MtouchDebug>true</MtouchDebug>
<MtouchFastDev>true</MtouchFastDev> <MtouchFastDev>true</MtouchFastDev>
<MtouchProfiling>true</MtouchProfiling> <MtouchProfiling>true</MtouchProfiling>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<IOSDebuggerPort>17481</IOSDebuggerPort> <IOSDebuggerPort>17481</IOSDebuggerPort>
<MtouchLink>None</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch> <MtouchArch>x86_64</MtouchArch>
@@ -39,8 +37,6 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey> <CodesignKey>iPhone Developer</CodesignKey>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchFloat32>true</MtouchFloat32> <MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink> <MtouchLink>SdkOnly</MtouchLink>
@@ -56,8 +52,6 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey> <CodesignKey>iPhone Developer</CodesignKey>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchLink>None</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch> <MtouchArch>x86_64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler> <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
@@ -76,8 +70,6 @@
<MtouchDebug>true</MtouchDebug> <MtouchDebug>true</MtouchDebug>
<MtouchFastDev>true</MtouchFastDev> <MtouchFastDev>true</MtouchFastDev>
<MtouchProfiling>true</MtouchProfiling> <MtouchProfiling>true</MtouchProfiling>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchFloat32>true</MtouchFloat32> <MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink> <MtouchLink>SdkOnly</MtouchLink>
@@ -102,6 +94,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="UnitTestAppDelegate.cs" /> <Compile Include="UnitTestAppDelegate.cs" />
<Compile Include="YogaKitNativeTest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Facebook.YogaKit.iOS\Facebook.YogaKit.iOS.csproj"> <ProjectReference Include="..\Facebook.YogaKit.iOS\Facebook.YogaKit.iOS.csproj">

View File

@@ -0,0 +1,51 @@
using System.Drawing;
using Facebook.Yoga;
using NUnit.Framework;
using System;
using UIKit;
using CoreGraphics;
namespace Facebook.YogaKit.iOS.Tests
{
[TestFixture]
public class YogaKitNativeTest
{
[Test]
public void ScrollViewVertical()
{
var view = new UIScrollView() {
Frame = new CGRect(0, 0, 100, 100),
};
view.Yoga().Overflow = YogaOverflow.Scroll;
var subview = new UIView();
subview.Yoga().Height = 1000;
subview.Yoga().IsEnabled = true;
view.AddSubview(subview);
view.Yoga().IsEnabled = true;
view.Yoga().ApplyLayout();
Assert.True(view.ContentSize.Height == 1000);
}
[Test]
public void NormalViewVertical()
{
var view = new UIView() {
Frame = new CGRect(0,0, 100, 100),
};
var subview = new UIView();
subview.Yoga().Height = 1000;
subview.Yoga().Width = 2;
subview.Yoga().IsEnabled = true;
view.AddSubview(subview);
view.Yoga().IsEnabled = true;
view.Yoga().ApplyLayout();
Assert.True(view.Bounds.Height == 100);
}
}
}

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