Compare commits

...

107 Commits

Author SHA1 Message Date
liukegang
19035c90e9 [bugfix] rm duplication process dimension 2019-06-11 21:15:29 +08:00
David Aurelio
19fd066507 Pass layout context for Event::LayoutPassStart
Summary: Adds the layout context pointer when publishing `Event::LayoutPassStart`.

Reviewed By: SidharthGuglani

Differential Revision: D15754425

fbshipit-source-id: 6295ae1ebec9eab72a79c43bc1cb0e05a6d7ae68
2019-06-11 01:41:22 -07:00
David Aurelio
204e849218 rm YogaEventListener
Reviewed By: SidharthGuglani

Differential Revision: D15742456

fbshipit-source-id: b90a221e177e936e141c582500dccf0ac38027c2
2019-06-11 01:41:22 -07:00
Aditya Sharat
8ff13c922a Back out "[litho] Adds check to unset a YogaNode's parent during reconciliation."
Summary: Removes `unsetOwner` from Yoga. This was temporarily for patching a crash.

Reviewed By: colriot

Differential Revision: D15737613

fbshipit-source-id: 8ab93ecf7ffb913df6207fe5db47a8cc93eded2c
2019-06-10 06:57:05 -07:00
Sidharth Guglani
af219f8836 add node layout event and pass it java layer
Summary: Listen to NodeLayout event and passes this event callback to java layer along with the information whether layout or measure was done in this pass

Reviewed By: davidaurelio

Differential Revision: D15696021

fbshipit-source-id: 8c5ca69330a9baca26b77052d4965cc67fe97c75
2019-06-10 01:51:53 -07:00
Aditya Sharat
e33123f955 Adds check to unset a YogaNode's parent during reconciliation.
Summary: Adds check to unset a YogaNode's parent during reconciliation.

Reviewed By: davidaurelio

Differential Revision: D15714899

fbshipit-source-id: 6e2c2a28106574d062fec722c9a051acea87d0b6
2019-06-07 09:28:24 -07:00
Sidharth Guglani
755fa07b39 add node measure event and passing the callback to java layer
Summary: Adds measure event and its listener initial code structure

Reviewed By: davidaurelio

Differential Revision: D15600738

fbshipit-source-id: d15764e0b64edb170fcb15e0912ecce5f7e53595
2019-06-06 21:03:24 -07:00
Sidharth Guglani
2701d80078 passing layout context and getting local reference from it
Summary: We are passing layout context from yoga as event data for Layout Pass End event and it is being then used to get the local reference of node so that we can pass it as method parameter to java layer

Reviewed By: davidaurelio

Differential Revision: D15619640

fbshipit-source-id: 5f6c29d9e6acb73a8d87f8e0cb1577d35a271aeb
2019-06-06 21:03:24 -07:00
Sidharth Guglani
c393ed1381 moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga

Reviewed By: davidaurelio

Differential Revision: D15619629

fbshipit-source-id: 1bf213efd38ec7bcac6a38070f21fa837c5f17da
2019-06-06 21:03:23 -07:00
Rain ⁣
a4bdd9cd9b standardize C-like MIT copyright headers throughout fbsource
Summary:
`/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3

In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf.

Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too.

Reviewed By: zertosh

Differential Revision: D15640366

fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
2019-06-06 19:44:16 -07:00
Joshua Gross
4a4325afb6 Revert D15602627: [yoga] moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Differential Revision:
D15602627

Original commit changeset: bb5bd5bbf8dc

fbshipit-source-id: 5ae08826eb706c3794c36738cb9625f82b58641e
2019-06-03 19:57:53 -07:00
Joshua Gross
586eb6102a Revert D15602923: [yoga] passing layout context and getting local reference from it
Differential Revision:
D15602923

Original commit changeset: 54b25956af09

fbshipit-source-id: 8ce26a7f00d76bd5ade18f32ad14d943118a6f31
2019-06-03 19:57:53 -07:00
Sidharth Guglani
b1e6793460 passing layout context and getting local reference from it
Summary: We are passing layout context from yoga as event data for Layout Pass End event and it is being then used to get the local reference of node so that we can pass it as method parameter to java layer

Reviewed By: davidaurelio

Differential Revision: D15602923

fbshipit-source-id: 54b25956af098700cea25c4f7f8ffe0b9117432c
2019-06-03 16:01:51 -07:00
Sidharth Guglani
8b17459254 moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga

Reviewed By: davidaurelio

Differential Revision: D15602627

fbshipit-source-id: bb5bd5bbf8dcb279f5f87a4fd7287909d4e895d8
2019-06-03 16:01:50 -07:00
David Aurelio
195c166efe Back out "[Yoga] Remove comparison to YGUndefined *and* 0.0f"
Summary: Original commit changeset: 13c8f24e1bc8

Reviewed By: fabiomassimo

Differential Revision: D15583502

fbshipit-source-id: efc6175f6c4925a383fea723195c073f49e2eff1
2019-05-31 15:56:50 -07:00
David Aurelio
0908d3a173 Data structure for exclusive writing
Summary:
Adds a data structure that holds a series of values that can be *borrowed* for exclusive writing.
That means, that only a single consumer can write to any value owned by the data structure.

In addition, the data structure exposes read access via iteration over all contained values.

A typical use case would be a counter with thread-local values that are accumulated by readers in other parts of a programm. The design carefully avoids the use of atomics or locks for reading and writing. This approach avoids cache flushes and bus sync between cores.

Borrowing and returning a value go through a central lock to guarantee the consistency of the underlying data structure.

Values are allocated in a `std::forward_list`, which typically should avoid two values in the same cache line -- in that case, writing to one value would still cause cache flushing on other cores. An alternative approach would be to allocate values continuously on cache line boundaries (with padding between them). We can still change the code if the current approach turns out to be too naive (non-deterministic).

Reviewed By: SidharthGuglani

Differential Revision: D15535018

fbshipit-source-id: 212ac88bba9682a4c9d4326b46de0ee2fb5d9a7e
2019-05-31 09:43:43 -07:00
David Aurelio
f304990656 Use atomic list for event subscribers
Summary:
Replace the *copy on write* vector with an atomic pointer to a linked list.

This allows to publish without locking a mutex, at the cost of the slower traversal of a linked list (a vector has better locality).

At the moment, the typical use case is to have one subscriber, meaning that the afforementioned slower traversal is not a problem.

Adding subscribers is implemented as atomic *compare and swap.*

Reviewed By: SidharthGuglani

Differential Revision: D15546964

fbshipit-source-id: 41bfa41f1ac6be5c9b6bf4288ea3271ee995877e
2019-05-31 01:26:42 -07:00
David Aurelio
cea3865c74 Deprecate YGNode::setConfig
Summary:
We want to phase out usage of config pointers on nodes. Setting configs is no longer needed, as a config is unly used during construction.

Here we deprecate the setter, as it is no longer working as it used to (e.g. changing `useWebDefaults` after a node is constructed).

Reviewed By: SidharthGuglani

Differential Revision: D15416474

fbshipit-source-id: a2cc06cad0c5148cecce056ece5f141b3defe9a9
2019-05-29 07:50:11 -07:00
David Aurelio
b74c0d4766 Remove comparison to YGUndefined *and* 0.0f
Summary: Removes a check introduced in D6969537, comparing `totalFlexGrowFactors` and `resolveFlexGrow` to both `0.0` *and* undefined.

Reviewed By: SidharthGuglani

Differential Revision: D15431425

fbshipit-source-id: 13c8f24e1bc8c49496097a6aa78e20ee5d3964a7
2019-05-22 09:44:36 -07:00
David Aurelio
54e863cef2 Remove YGNode::setAndPropogateUseLegacyFlag
Summary:
`YGNode::setAndPropogateUseLegacyFlag` was only used for debugging purposes.
Here, we replace it with a free function in `Yoga.cpp`.

Now that we have events, the diffing functionality should go into a separate debugging package and be implemented in terms of an event listener. Let's do that as soon as we can support multiple listeners.

Reviewed By: SidharthGuglani

Differential Revision: D15316863

fbshipit-source-id: db929eba7c2de8aa1550e362dd2c175929c0070e
2019-05-21 06:06:37 -07:00
David Aurelio
1938792517 YGNode: Field for web defaults
Summary:
In order to remove the config pointer from nodes, we have to keep track of whether the node is using web defaults.
This information fits into one bit that we can place in padding (i.e. no extra memory needed).

This allows us to get rid of config usage withing `YGNode` with some exceptions:

- `iterChildrenAfterCloningIfNeeded` -- this function will simply receive the configuration, or the cloning callback.
- `setAndPropogateUseLegacyFlag` -- will be removed in D15316863
- in `YGNode::reset` -- will go away utomatically once we remove the config pointer

Reviewed By: SidharthGuglani

Differential Revision: D15391536

fbshipit-source-id: 0fa0d0805c6862bd741fe4a7d9b637ed534f56a4
2019-05-20 10:51:38 -07:00
Sidharth Guglani
aa71dbb5bd mutex lock while accessing event subscribers vector for thread safety
Summary: Using Mutex lock_guard mechanism when writing to subscribers and when accessing them in publish to make a copy

Reviewed By: davidaurelio

Differential Revision: D15391679

fbshipit-source-id: 16713ff28ce1762a5ca4c48c152897a92417e80b
2019-05-19 23:34:41 -07:00
David Aurelio
8dc46c0a87 YGNode: one byte of private storage
Summary:
Adds one byte of private storage to `YGNode`, intended to be used by Yoga itself.

This is in previously unused alignment space, and won’t cause more memory to be allocated.

Reviewed By: SidharthGuglani

Differential Revision: D15296732

fbshipit-source-id: 3caf0a3cd506e4e324e51c31869c69be5781d476
2019-05-16 11:47:30 -07:00
David Aurelio
1180afed9c Fix style property bits
Summary: Style bits had overlap, because `dimensionBit` was set with an incorrect increment.

Reviewed By: SidharthGuglani

Differential Revision: D15335134

fbshipit-source-id: 370e1a73547d76b0e26bc6ab67acb96d33ddf180
2019-05-16 11:47:30 -07:00
Sidharth Guglani
1562bce9b4 use shared_ptr for subscribers vector in event system
Summary:
using shared_ptr for vector of subscribers
Further changes in commit stack support the mutiple subscribers in event system

Reviewed By: davidaurelio

Differential Revision: D15352512

fbshipit-source-id: fac7f4268abf9ca4277734aca2f21cd711eb7d6e
2019-05-15 09:01:06 -07:00
Sidharth Guglani
a9514513a7 use vector for subscribers in event system
Summary:
Replaced global event subscriber with a vector of subscriber functions
Further changes in commit stack support the mutiple subscribers in event system

Reviewed By: davidaurelio

Differential Revision: D15352451

fbshipit-source-id: 7ca6f0943735bf1f76a906c23e15e14ae3c5f42c
2019-05-15 09:01:04 -07:00
Sidharth Guglani
cf809b8e8b added listener in flipper plugin for yoga
Summary:
Adds YogaEventListener interface and it's implementation which will be used in flipper for events coming from Yoga
After this diff , we will start getting layout calculate events in flipper listener

Reviewed By: davidaurelio

Differential Revision: D15316928

fbshipit-source-id: da3a53374a52386037b553d460038d988b0162c2
2019-05-15 01:18:11 -07:00
Yadong Wen
d7ff5c0689 Remove c++1y compiler flag
Reviewed By: meyering

Differential Revision: D15326600

fbshipit-source-id: 837f454ccf27299bc9360174bf54e48e4209bb52
2019-05-14 13:48:02 -07:00
David Aurelio
e3156279fc Travis: Fix C++ compilation
Summary:
@public

Removes the usage of C++14 features, and enforces C++11 via compiler flags.

Reviewed By: SidharthGuglani

Differential Revision: D15334938

fbshipit-source-id: 011764b5f226fef6a35e0c7c1dd170a39ae2261e
2019-05-14 07:45:31 -07:00
gengjiawen
0ce42d83e0 add missing gradle script for windows
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/885

Differential Revision: D15334309

Pulled By: davidaurelio

fbshipit-source-id: c594c0216a967c776606443a50f14e81da228d64
2019-05-14 06:24:18 -07:00
Shawn Presser
afc1108659 Fix cmake build / update CMakeLists.txt to use C++11 (#887)
Summary:
On MacOS, the following steps result in build errors:

```
mkdir build
cd build
cmake ..
make
```

The problem is that yogacore uses C++11 features (`constexpr`) but C++11 isn't specified in CMakeLists.txt.

This PR solves the poblem by adding the following code to the bottom of CMakeLists.txt:

```
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)
```

This solution was derived from https://stackoverflow.com/questions/45688522/how-to-enable-c17-in-cmake
Pull Request resolved: https://github.com/facebook/yoga/pull/887

Differential Revision: D15334282

Pulled By: davidaurelio

fbshipit-source-id: a599d8a8f555f7f9cd8dc333e12dc2387d5b2d7a
2019-05-14 05:28:19 -07:00
David Aurelio
a15bf6e701 Publish events for layout pass
Summary:
Adds `LayoutPassStart` and `LayoutPassEnd` events.

The existing `NodeLayout` event in isolation is not as useful as it could be. Having events that mark start and end of a layout pass are a useful addition.

Differential Revision: D15305467

fbshipit-source-id: 14af6f65e698fb1e3112eb2ffd87a74d31df4840
2019-05-10 19:05:07 -07:00
Sidharth Guglani
74fc37efc8 move event files to yoga/events folder
Summary: Moved events files to yoga/events for better code structure

Reviewed By: davidaurelio

Differential Revision: D15198566

fbshipit-source-id: 74d451011841d59fae5a1c637f9c33a7d2d1f87e
2019-05-09 07:46:10 -07:00
David Aurelio
5824dbda66 Publish event when visiting nodes during layout
Summary:
@public

Publish an event when visiting nodes during layouts.

Reviewed By: SidharthGuglani

Differential Revision: D15206965

fbshipit-source-id: c201f084b1d4186bc64560b8033be965f2549236
2019-05-09 04:31:25 -07:00
David Aurelio
e96a09e5ff **breaking:** remove YGNodeGetInstanceCount
Summary:
@public

`YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments.

It was completely replaced with event-based counting for tests.

Here we remove public API around the counter, and the counter itself.

Reviewed By: SidharthGuglani

Differential Revision: D15174857

fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
2019-05-09 04:31:24 -07:00
David Aurelio
9e20dfeea1 Switch tests to test utility for counting nodes
Summary:
@public
replaces the global node counter with the event-based one for all tests.

Reviewed By: SidharthGuglani

Differential Revision: D15174856

fbshipit-source-id: f4401d502bdbaf3b6e4632a4d985aac260cb35a8
2019-05-09 04:31:24 -07:00
David Aurelio
6e04631862 Add test utilities for C++ and Java
Summary:
@public

Test utility on top of the new event system that maintains a counter of instantiated nodes. Meant to replace the global node counter.

Reviewed By: SidharthGuglani

Differential Revision: D15174855

fbshipit-source-id: 6998472f95a09b8da652257a26596164bdcf43d6
2019-05-09 04:31:23 -07:00
David Aurelio
88b23ebb3d Publish events for node allocation and deallocation
Summary:
@public

Publish two events, `NodeAllocation` and `NodeDeallocation`, in the same places where the global node counter is changed.

Reviewed By: SidharthGuglani

Differential Revision: D15174858

fbshipit-source-id: 6e4e9add88513b9e987189ca5035d76da2a1de55
2019-05-09 04:31:23 -07:00
David Aurelio
018916403e Reduce measure cache size to 8
Summary:
@public

Reduces measure cache size to a number that is enough for 95% of nodes, according to our (FB-internal) measurements.

Node size: 776b -> 584b

Reviewed By: SidharthGuglani

Differential Revision: D15183567

fbshipit-source-id: 9ae8cc78074271a015e7618b931ba0356de87a0c
2019-05-09 03:24:31 -07:00
Adrian Zgorzalek
af38fd31f8 Upgrade prettier to 1.17.0
Summary:
Run `js1 upgrade prettier 1.17.0` and `xplat/js/scripts/update-oss-yarn-lockfile.sh` and `hg revert -r .^ xplat/js/rome`

allow-large-files

Reviewed By: zackargyle, pvdz

Differential Revision: D15164375

fbshipit-source-id: 2fe68733dfa93ea64a67d170ba2f80c5af086917
2019-05-07 12:39:46 -07:00
David Aurelio
1e0ebdae2f Remove API to constrain measure cache size
Summary: We conducted an experiment with different measure cache sizes. This has now been deallocatedi (D15183473). Remove the necessary APIs.

Reviewed By: SidharthGuglani

Differential Revision: D15183486

fbshipit-source-id: a38fa5a3ab0321c2521265f7d1cd6b495efd76cf
2019-05-03 05:54:40 -07:00
David Aurelio
1adbafe950 Fix YGConfig constructors
Summary:
@public

`YGConfig::YGConfig(YGConfig*)` was not initializing the same fields as the default constructors.

Here, we make the default constructor delegate to the more specialized one to remove duplication.

Reviewed By: SidharthGuglani

Differential Revision: D15164599

fbshipit-source-id: 27247709091b7664386057d09ac67d481877871f
2019-05-03 05:01:32 -07:00
David Aurelio
e51ca95713 Add foundations for event system
Summary:
@public

We want to enable tooling, instrumentation, and statistics within Yoga without coupling these functionalities to our core code.

This commit introduces the foundations of a simple, global event system.
For the time being, we will only support a single subscriber. Should we require more than one, we can add support for it later.

Reviewed By: SidharthGuglani

Differential Revision: D15153678

fbshipit-source-id: 7d96f4c8def646a6a1b3908f946e7f81a6dba9c3
2019-05-01 17:08:02 -07:00
David Aurelio
a803421739 YGStyle: Make getters/setters template args of BitfieldRef
Summary:
@public

Makes bitfield getters/setters part of the bitfield ref template.
Since we introduced the tracking bit as template parameter in D14933022, every bitfield ref is an individual class anyway, and having function pointers doesn’t potentially lead to less code generation anyway.

Furthermore, this change can (in the absence of tracking bits) avoid less specialized templates dealing with refs, and to dynamic dispatch as a consequence.

Reviewed By: SidharthGuglani

Differential Revision: D15085495

fbshipit-source-id: 0dd70fa05e9d43a29e38a619cddb642c9ca3f7ab
2019-05-01 06:52:55 -07:00
David Aurelio
011c1964a0 Track which style properties have been set on YGStyle
Summary:
@public

In order to optimise property storage, we have to know how style properties are used in our apps.
Here, we add a bitmask that allows us to track which properties are set explicitely, and use that for our analysis.

Reviewed By: SidharthGuglani

Differential Revision: D14933022

fbshipit-source-id: 1ab8af562b14baba1d02057e527aa36d5c9a7823
2019-05-01 06:52:55 -07:00
David Aurelio
05d205cf89 Deduplicate updateStyle overloads
Summary:
@public

The extra overload of `updateStyle` introduced in D15078961 can also handle `BitfieldRef`.
That means that we can remove the more specific implementation previously introduced for `BitfieldRef`

Reviewed By: SidharthGuglani

Differential Revision: D15081069

fbshipit-source-id: 98f1f3478627974c5273c85d268ca07350f303d7
2019-05-01 06:52:54 -07:00
David Aurelio
0a4f7bd558 YGStyle: mutable accessors return Ref instances
Summary:
@public

Change style property accessors to return `Ref` instances instead of references to `CompactValue`.

This will allow to track assignments to properties later on, e.g. for instrumentation or dynamic property storage.

Reviewed By: SidharthGuglani

Differential Revision: D15078961

fbshipit-source-id: 259f05f7d30f093c04bf333c5bd4fb3601b8e933
2019-05-01 06:52:54 -07:00
David Aurelio
cea862a6bf Expose the value type used by YGStyle as ValueRepr
Summary:
@public

Adds `YGStyle::ValueRepr` to make code depending on the actual type easier to write.

So far, we have treated `yoga::detail::CompactValue` as an implementation detail, and that’s what it’s supposed to stay.

React Native Fabric has one value conversion overload that depends on that type, though, and used `decltype(YGStyle{}.margin()[0])` until now.
That’s problematic for two reasons:

- we want to constrain the parameter of `operator[](...)` to enum types, making the `0` unsuitable
- we want to return the non-const overload of the operator to return a custom `Ref` type, which is not the type needed by Fabric.

Making the storage type explicit allows to write more forward-compatible code.

Reviewed By: SidharthGuglani

Differential Revision: D15078960

fbshipit-source-id: 932c27ef2f2cdc6ce965b79894268170f0ccdce5
2019-04-29 09:23:18 -07:00
David Aurelio
cc02a20c9e More constness
Summary:
@public

Some `YGNode*` passed as `const YGNode*`, some const refs to sub-objects introduced.
This helps selecting the desired methods in more places, i.e. `const` overloads of accessors on `YGStyle`.

Reviewed By: SidharthGuglani

Differential Revision: D15078963

fbshipit-source-id: 5013721d6edcc68f42f4504f5c331da647a294bd
2019-04-29 09:23:17 -07:00
David Aurelio
98fda9c587 YGFloatOptional: Move binary operators to free functions
Summary:
@public

Having binary operators as member functions has disadvantages:

- the left hand side cannot be converted to `YGFloatOptional` implicitly (which we need for `YGStyle` refs)
- Operators are not necessarily commutative.

By moving these operators into free functions, and adding overloads for both variants if one operand is `float`, we get these properties.

Reviewed By: SidharthGuglani

Differential Revision: D15078962

fbshipit-source-id: 2e228a2ef90a8083c91788caa9eedfd4d140677f
2019-04-29 09:23:16 -07:00
David Aurelio
2eed95f3e4 YGNodeToString: take const ref to node style
Summary:
@public

Takes a const reference to the style of the printed node once, instead of using repeated calls to `node->getStyle()`.
Makes the code a bit shorter, and ensures that we are operating on `const YGStyle&`, which helps selecting the correct methods further up the stack.

Reviewed By: SidharthGuglani

Differential Revision: D14999094

fbshipit-source-id: 814f06b7e3179ac8cfb43d79fbec48ee4115d6e3
2019-04-26 02:15:06 -07:00
David Aurelio
e5d3baca81 Introduce YGNodeConstRef
Summary:
@public

Introduces `YGNodeConstRef` as `const YGNode*`, i.e. a pointer to a constant `YGNode`.
We also use it for all style getters, which will avoid casts to `const YGNode*` in diffs up the stack.

We should use this pointer type for all functions that do not modify the underlying node.

Reviewed By: SidharthGuglani

Differential Revision: D14999095

fbshipit-source-id: 61cc53bb35e787a12ae12e70438d84c0a4983752
2019-04-23 10:10:24 -07:00
David Aurelio
dee93017f7 YGStyle: wrap all fields into accessors
Summary:
@public

In order to encapsulate property access on `YGStyle`, as a first measure we wrap all fields with accessors.

This will e.g. enable dynamic property storage and instrumentation in the future.

All accessors have a `const` version that allows direct access via `const&`. For mutation, bit fields are wrapped with a custom reference object.

This style allows for the least amount of changes in client code. Property access simply needs appended parens, eg `style.direction` becomes `style.direction`.

Reviewed By: shergin

Differential Revision: D14999096

fbshipit-source-id: fbf29f7ddab520513d4618f5e70094c4f6330b30
2019-04-23 08:17:18 -07:00
David Aurelio
e167642672 Yoga.h: clean up const / extern
Summary:
@public

Remove unnecessary `const` and `extern` specifiers from `Yoga.h`.

- Function declarations are `extern` by default
- The removed `const` specifiers for pass-by-valye parameters are only meaningful for the *definition* of functions, not for the declaration.
In this specific case, I found `const YGNodeRef` particularly confusing, as it is a `typedef` for a pointer type. `const` does not refer to the pointed-to object, but to the parameter itself, i.e. `const YGNodeRef` is `YGNode * const`, and not `const YGNode *`.

Reviewed By: SidharthGuglani

Differential Revision: D14999097

fbshipit-source-id: 8350870cb67f4a34722f796c4f4a2fc7dde41b99
2019-04-23 08:17:16 -07:00
David Aurelio
e9bb1efb03 Code formatting: allow short inline methods on one line
Summary:
@public

This allows short methods defined in class declarations to occupy a single line.
The change makes class declarations more readable.

Reviewed By: SidharthGuglani

Differential Revision: D14950012

fbshipit-source-id: 1321949475184181c6cceb86613f730e430763e2
2019-04-16 07:12:58 -07:00
David Aurelio
3f7d03b443 Define all style getters/setters explicitely
Summary:
@public

For better grepping, we define all `YGNodeStyle...` accessors explicitely. This also replaces all macros with a set of templates that can easily be updated when we switch to style accessors on `YGNode`.

Transitioning to a consistent set of templates also allowed to end up with a single *needs update* / *do update* / *mark dirty* block.

The new template code also takes full advantage of the properties of `YGOptional` (constructor call with *not a number* creates an empty optional) and `detail::CompactValue` (conversions of *auto* and *undefined* are always well-formed) to get rid of some additional code:

Removed `NAN` check:
```
 _YGNodeStyleSetFlex:
 	pushq	%rbp
 	movq	%rsp, %rbp
 	movss	0x34(%rdi), %xmm1
 	ucomiss	%xmm0, %xmm1
 	jne	0x____
 	jnp	0x____
 	ucomiss	%xmm0, %xmm0
 	jnp	0x____
 	ucomiss	%xmm1, %xmm1
 	jnp	0x____
 	popq	%rbp
 	retq
-	ucomiss	%xmm0, %xmm0
-	movd	%xmm0, %eax
-	movl	$0x7fc00000, %ecx
-	cmovnpl	%eax, %ecx
-	movl	%ecx, 0x34(%rdi)
+	movss	%xmm0, 0x34(%rdi)
 	popq	%rbp
 	jmp	0x____
-	nopw	%cs:(%rax,%rax)
-	nop
+	nopw	(%rax,%rax)
```

Removed well-formedness check:
```
 _YGNodeStyleGetPosition:
 	pushq	%rbp
 	movq	%rsp, %rbp
 	movl	%esi, %eax
 	movl	0x68(%rdi,%rax,4), %ecx
+	xorl	%eax, %eax
 	movq	(%rip), %rcx
 	movl	(%rcx), %eax
 	movl	0x4(%rcx), %ecx
-	movq	%rcx, %rdx
-	shlq	$0x20, %rdx
+	shlq	$0x20, %rcx
 	movl	%eax, %eax
-	orq	%rdx, %rax
-	cmpl	$0x3, %ecx
-	je	0x____
-	testl	%ecx, %ecx
-	jne	0x____
-	movl	$0x7fc00000, %ecx
-	jmp	0x____
-	movq	%rax, %rcx
-	movabsq	$-0x100000000, %rdx
-	andq	%rax, %rdx
-	movl	%ecx, %eax
-	orq	%rdx, %rax
+	orq	%rcx, %rax
 	popq	%rbp
 	retq
 	nopw	(%rax,%rax)
```

Reviewed By: SidharthGuglani

Differential Revision: D14911973

fbshipit-source-id: db6eef65f8fdaf70875f7fe8799919ca88bd50ee
2019-04-15 10:51:44 -07:00
Sidharth Guglani
ffce716557 Use only 4 edges for margin, padding, border in YGLayout
Summary:
We were using four edges for margin, padding and border. This diff changes the array size in YGLayout for margin, padding, border to reduce YGNode size and corresponding changes while we are setting values in YGLayout.
Reduces the YGNode size by 24 bytes

Reviewed By: davidaurelio

Differential Revision: D14892666

fbshipit-source-id: 94013d5183ee869901267c4c9941fd94fa05d848
2019-04-15 05:41:59 -07:00
Andres Suarez
fcfb19e9cf Enable black for xplat/yoga
Summary:
This directory was excluded from Black formatting in D14888843 when Black
was turned on for all of `xplat/`. Since there aren't a lot of `.py` files in
this directory, the opt-out is being removed, and the outstanding issues fixed.

Reviewed By: d16r

Differential Revision: D14889104

fbshipit-source-id: 440077c1efcb4c653151bca1da5636212978add5
2019-04-11 05:24:34 -07:00
David Aurelio
c5f105a7b6 JNI: set language level to C++11
Summary:
@public

compiler flags were pushed to C++14, but we don’t currently have any code that requires it. Setting to `-std=c++11` in order to fix the OSS build.

Reviewed By: SidharthGuglani

Differential Revision: D14833737

fbshipit-source-id: df2cd7da8c7124e89863c90d7b77bcf86c495618
2019-04-09 03:12:32 -07:00
David Aurelio
b062d23947 Add -SNAPSHOT to gradle version
Summary:
@public

needed for snapshot releases off of master.

Reviewed By: colriot

Differential Revision: D14833415

fbshipit-source-id: f3b1fb1c41318a9b8f634cd16d37d5e2d050398f
2019-04-08 10:57:18 -07:00
David Aurelio
7fc6fcb38c v1.14.0
Summary:
@public

Push version to *1.14.0.*

This release contains some bug fixes around `align-content`.

Reviewed By: colriot

Differential Revision: D14833417

fbshipit-source-id: f653d5fbb36f307c92b14c091c3206290256f036
2019-04-08 10:57:17 -07:00
David Aurelio
bc7e504b29 Fix bugs around align-content
Summary:
@public

Regenerating the “golden master” tests with chrome surfaced different bugs around `align-content`:

- a misunderstanding that values in `align-content` only applied *if there is only one line.* In fact, it applies *every time* a container is set to `flex-wrap: wrap`. Chrome had this wrong, and as such our tests were generated with incorrect parameters.
- empty children growing to the cross axis size of the container, even when `align-content` is different from `stretch`. This was implemented incorrectly in Chrome as well. Here, we fix it with an extra check.

Reviewed By: SidharthGuglani

Differential Revision: D14725402

fbshipit-source-id: a45bebdadb9c694dc0eb7e27cb52b3d247f81c50
2019-04-08 03:20:27 -07:00
Daniel Büchele
3d8afa9e90 fixing playground links
Summary: Updating links to playgrounds

Reviewed By: davidaurelio

Differential Revision: D14775759

fbshipit-source-id: 8c5c30aa63f2ec2787c1a15a72d09f4e642dd672
2019-04-04 08:52:05 -07:00
Aditya Sharat
a1e47e37ae Add YogaNode.cloneWithoutChildren
Summary: Adding flat clone method back to YogaNode for reconciliation.

Reviewed By: davidaurelio

Differential Revision: D14683019

fbshipit-source-id: 08ed2ffbb16052cb11aa464f67a7ba9a64297985
2019-04-03 11:34:06 -07:00
David Aurelio
e0bc0ebe29 Move YGSetUsedCachedEntries to internal header
Summary:
@public

In order to get out of pre-releases again, we move `YGSetUsedCachedEntries` from `Yoga.h` to `Yoga-internal.h`.
This way, it’s obvious that the function is not public, and we can remove it from future versions without breaking semver contracts.

Reviewed By: SidharthGuglani

Differential Revision: D14726029

fbshipit-source-id: 8d7e747e843bf5c4b5e1d4cfbfa37ca9d240dffb
2019-04-03 08:44:14 -07:00
Pritesh Nandgaonkar
498c0ff4bf New yoga and yogakit pod released
Summary: I have released a new yoga and yogakit pod with 1.12.0-pre.2

Reviewed By: davidaurelio

Differential Revision: D14722676

fbshipit-source-id: 7b379ee41d04a15e25dcb2e992f361d9403269c4
2019-04-02 05:08:05 -07:00
Daniel Büchele
d42d43e90f use tinyURL
Summary: As of today, Google URL shortener is retired. Moving to tinyURL instead. However, tinyURL doesn't support CORS headers, therefore additionally adding a CORS proxy.

Reviewed By: davidaurelio

Differential Revision: D14722636

fbshipit-source-id: 2ec41bb43287102543f1ac31bb76df57d71ba134
2019-04-02 05:03:19 -07:00
Daniel Büchele
bfc6319daa use search instead of hash
Summary:
The state of the playground was stores in a hash appended to the URL. However, tinyURL ignores the hash part of the URL. For this reason, we are using the search part of the URL instead.

Before: `yogalayout.com/playground#ey...`
After: `yogalayout.com/playground?ey...`

Reviewed By: davidaurelio

Differential Revision: D14722638

fbshipit-source-id: ed135f60269e9136bb850c4c661bd88f8ee19323
2019-04-02 04:15:31 -07:00
Sidharth Guglani
74ce5afd9e added flag for useBatchingForLayoutOutputs experiment
Summary:
Using a config flag to switch between different implementations of transferring layout outputs
- YogaNodeJNI uses multiple access of java fields to pass all properties like width, height, margin etc...
- YogaNodeJNIBatching uses a float array to pass all the data in one java field access

Reviewed By: davidaurelio

Differential Revision: D14378301

fbshipit-source-id: 0da5b28e6a67ad8fd60eb7efe622d9b2deaf177f
2019-04-01 06:17:20 -07:00
Sidharth Guglani
c11faf2d56 Added implementation for YogaNodeJNIBatching and logic for passing array from c++ to java
Summary: This diff adds the logic to transfer layout outputs using a float array

Reviewed By: davidaurelio

Differential Revision: D14368120

fbshipit-source-id: d1f22283bcea051d15657f42c15b90edaa0a8a7a
2019-04-01 06:17:19 -07:00
Sidharth Guglani
5fad8008ab added test for reset method in YogaNodeJNI to verify all layout outputs are reset properly
Summary: This diff adds a test for reset method in YogaNodeJNI to verify all layout outputs are reset properly

Reviewed By: davidaurelio

Differential Revision: D14643926

fbshipit-source-id: fffbcd07ccb6d2df83fc0bf187d992ef194f3bd0
2019-04-01 06:17:19 -07:00
Sidharth Guglani
948ade4b1c moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14642995

fbshipit-source-id: 5d0bc7fa18c1985be7e216d7351f5eab2e03861d
2019-04-01 06:17:19 -07:00
David Aurelio
b1a7f2b4d9 gentest: Fix editing messup
Summary:
@public

Messed this one up when fixing the test generation script.

Reviewed By: SidharthGuglani

Differential Revision: D14684224

fbshipit-source-id: 2696ce9ff7d825d00c7ad1ab1627a5ffe56d123f
2019-03-29 10:22:31 -07:00
Pritesh Nandgaonkar
d44a6d936f Release a new version to cocoapods
Summary: Xcode 10.2 drops the support of swift version 3.0. Thus updated the swift version and also the yoga dependency.

Reviewed By: SidharthGuglani

Differential Revision: D14684332

fbshipit-source-id: d42e5979639c9fceec81627d4ac153566c2c0ab1
2019-03-29 10:08:10 -07:00
David Aurelio
1fc8472d35 gentest: allow for different default values
Summary:
@public

We use Chrome for generating test cases, which since v67 (or so) for `min-width` and `min-height` has a default value of either `0px` (CSS 2) or `auto` (CSS 3), depending on style properties.

Our setup only allowed for a single default value, and our test cases produce *both.*
This changes the test gen logic to allow for more than one value.

Reviewed By: SidharthGuglani

Differential Revision: D14682387

fbshipit-source-id: e76361f5cc0b88f9c2d74a5f3248c66abd6907a7
2019-03-29 06:32:21 -07:00
David Aurelio
c235301b52 gentest: remove empty line after license
Summary:
@public

This gets flagged by the linter. Remove it.

Reviewed By: SidharthGuglani

Differential Revision: D14682386

fbshipit-source-id: 612508b0906285e6420a553ac7a96d1024f1eac6
2019-03-29 06:32:20 -07:00
David Aurelio
2fb81500c1 gentest: adapt license
Summary:
@public

Adapts the license header text to the format we currently use.

Reviewed By: SidharthGuglani

Differential Revision: D14653591

fbshipit-source-id: f79446e4f85623326f770fe73482eab00edd9234
2019-03-28 04:47:56 -07:00
Alexander Vasyuk
68d9209dd9 Revert D14368107: [yoga] moved all the properties used for layout outputs to YogaNodeJNI
Differential Revision:
D14368107

Original commit changeset: 75ca330c1e7f

fbshipit-source-id: 9a9f5140bf8b1563c9ba85b3fe5f93fc6d8fdf41
2019-03-26 20:21:24 -07:00
Alexander Vasyuk
e91569cdad Revert D14368114: [yoga] removing unused const int
Differential Revision:
D14368114

Original commit changeset: f63b978813a0

fbshipit-source-id: 86a517b1483b0635f283702602712c42c3d51e20
2019-03-26 20:21:23 -07:00
Sidharth Guglani
f31917aa01 removing unused const int
Summary: Removed unused const int

Reviewed By: davidaurelio

Differential Revision: D14368114

fbshipit-source-id: f63b978813a01a37710fac299dc7ec9aff610844
2019-03-26 08:51:41 -07:00
Will Wilson
74202aecff Adds workspace for more efficient yoga development
Summary: This workspace should ease yoga development

Reviewed By: dinhviethoa

Differential Revision: D14600002

fbshipit-source-id: 49f6d36680acad5835fcf96e80bcd547b667c0c8
2019-03-26 07:43:30 -07:00
Sidharth Guglani
9c2108c69e moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368107

fbshipit-source-id: 75ca330c1e7f07adc0ab8e7a5927d93977088918
2019-03-26 07:35:17 -07:00
David Aurelio
3d2836a947 CompactValue overrides of YGResolveValue/YGValueEqual
Summary:
@public

I would like to get rid of implicit conversions between `YGValue` and `CompactValue`, because they don’t come for free.

That’s why I am adding `CompactValue` specific overrides for `YGResolveValue` and  `YGValueEqual`, that do explicit casts. Up the commit stack, we will be able mark both `CompactValue(const YGValue&)` and `CompactValue::operator YGValue()` as `explicit`.

Reviewed By: SidharthGuglani

Differential Revision: D14598447

fbshipit-source-id: 75dc15cefb2dddcf8def891c5fb37893cacd9d46
2019-03-26 05:21:35 -07:00
David Aurelio
e4856a2264 Remove duplicated function declaration
Summary:
@public

Just removes a duplicated function declaration.

Reviewed By: SidharthGuglani

Differential Revision: D14598446

fbshipit-source-id: b4d8fe192f9a07f512f6a346f27d9046bb3bae23
2019-03-26 05:21:35 -07:00
Sidharth Guglani
a2ee0f65bd fixed @Nullable missing infer errors
Summary: Fixed Nullable lint errors

Reviewed By: davidaurelio

Differential Revision: D14383930

fbshipit-source-id: 0847e19c50a0b8d4039199045b74aa86c96ac096
2019-03-25 06:36:28 -07:00
David Aurelio
85352c4e45 Automatic lint fixes
Summary:
@public
A round of automatic lint fixes.

Reviewed By: SidharthGuglani

Differential Revision: D14590396

fbshipit-source-id: f0b4a0ce503a1d9d46ea7ae788f9f2eac09c2ac7
2019-03-25 05:41:30 -07:00
David Aurelio
7d7b7b9e18 Sample workspace: remove XML comment
Summary:
@public

Xcode does not like it

Reviewed By: astreet

Differential Revision: D14580168

fbshipit-source-id: 6d26b3961b45a59ef9dc977b21493e60e3cf9396
2019-03-22 11:46:58 -07:00
David Aurelio
62d8a911ff Switch style getters to JNI fast calls
Summary:
@public

After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.

Reviewed By: pasqualeanatriello

Differential Revision: D14576815

fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
2019-03-22 10:36:56 -07:00
David Aurelio
ca46c67e9e Create YogaValue instances in Java, not C++
Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
2019-03-22 10:36:55 -07:00
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
243 changed files with 11058 additions and 3728 deletions

View File

@@ -9,7 +9,7 @@ AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None

View File

@@ -1 +1 @@
3.0 4.0

30
BUCK
View File

@@ -9,20 +9,31 @@ GMOCK_OVERRIDE_FLAGS = [
"-Wno-inconsistent-missing-override", "-Wno-inconsistent-missing-override",
] ]
COMPILER_FLAGS = LIBRARY_COMPILER_FLAGS + [
"-std=c++1y",
]
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [ TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
"-std=c++1y", "-DDEBUG",
"-DYG_ENABLE_EVENTS",
] ]
yoga_cxx_library( yoga_cxx_library(
name = "yoga", name = "yoga",
srcs = glob(["yoga/*.cpp"]), srcs = glob(["yoga/**/*.cpp"]),
header_namespace = "", header_namespace = "",
exported_headers = subdir_glob([("", "yoga/*.h")]), exported_headers = subdir_glob([("", "yoga/**/*.h")]),
compiler_flags = COMPILER_FLAGS, compiler_flags = LIBRARY_COMPILER_FLAGS,
soname = "libyogacore.$(ext)",
tests = [":YogaTests"],
visibility = ["PUBLIC"],
deps = [
yoga_dep("lib/fb:ndklog"),
],
)
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)", soname = "libyogacore.$(ext)",
tests = [":YogaTests"], tests = [":YogaTests"],
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
@@ -39,7 +50,8 @@ yoga_cxx_test(
contacts = ["emilsj@fb.com"], contacts = ["emilsj@fb.com"],
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [ deps = [
":yoga", ":yogaForDebug",
yoga_dep("testutil:testutil"),
GTEST_TARGET, GTEST_TARGET,
], ],
) )

View File

@@ -13,3 +13,4 @@ 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)
set_target_properties(yogacore PROPERTIES CXX_STANDARD 11)

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
# #
Pod::Spec.new do |spec| Pod::Spec.new do |spec|
spec.name = 'Yoga' spec.name = 'Yoga'
spec.version = '1.9.0' spec.version = '1.14.0'
spec.license = { :type => 'MIT', :file => "LICENSE" } spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.com/' spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://yogalayout.com/docs' spec.documentation_url = 'https://yogalayout.com/docs'
@@ -19,7 +19,7 @@ Pod::Spec.new do |spec|
:git => 'https://github.com/facebook/yoga.git', :git => 'https://github.com/facebook/yoga.git',
:tag => spec.version.to_s, :tag => spec.version.to_s,
} }
spec.platforms = { :ios => "4.3", :osx => "10.7", :tvos => "10.0", :watchos => "2.0" } spec.platforms = { :ios => "8.0", :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 = { spec.pod_target_xcconfig = {

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:YogaDev/YogaDev.xcodeproj">
</FileRef>
<FileRef
location = "group:ReactYoga.xcodeproj">
</FileRef>
</Workspace>

View File

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

View File

@@ -0,0 +1,350 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F892249476700CBB1EC /* YGMarker.cpp */; };
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F8B2249476700CBB1EC /* YGValue.cpp */; };
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F902249476700CBB1EC /* YGLayout.cpp */; };
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */; };
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F992249476800CBB1EC /* YGStyle.cpp */; };
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9A2249476800CBB1EC /* log.cpp */; };
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9B2249476800CBB1EC /* YGNode.cpp */; };
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9C2249476800CBB1EC /* Yoga.cpp */; };
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9D2249476800CBB1EC /* Utils.cpp */; };
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */; };
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D4C7FA32249476800CBB1EC /* YGConfig.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
6D4C7F76224945B200CBB1EC /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
6D4C7F78224945B200CBB1EC /* libYogaDev.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libYogaDev.a; sourceTree = BUILT_PRODUCTS_DIR; };
6D4C7F892249476700CBB1EC /* YGMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGMarker.cpp; path = ../yoga/YGMarker.cpp; sourceTree = "<group>"; };
6D4C7F8A2249476700CBB1EC /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../yoga/Utils.h; sourceTree = "<group>"; };
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGValue.cpp; path = ../yoga/YGValue.cpp; sourceTree = "<group>"; };
6D4C7F8C2249476700CBB1EC /* instrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = instrumentation.h; path = ../yoga/instrumentation.h; sourceTree = "<group>"; };
6D4C7F8D2249476700CBB1EC /* YGStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGStyle.h; path = ../yoga/YGStyle.h; sourceTree = "<group>"; };
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNodePrint.h; path = ../yoga/YGNodePrint.h; sourceTree = "<group>"; };
6D4C7F8F2249476700CBB1EC /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMarker.h; path = ../yoga/YGMarker.h; sourceTree = "<group>"; };
6D4C7F902249476700CBB1EC /* YGLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGLayout.cpp; path = ../yoga/YGLayout.cpp; sourceTree = "<group>"; };
6D4C7F912249476700CBB1EC /* YGEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGEnums.h; path = ../yoga/YGEnums.h; sourceTree = "<group>"; };
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNodePrint.cpp; path = ../yoga/YGNodePrint.cpp; sourceTree = "<group>"; };
6D4C7F932249476700CBB1EC /* YGMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGMacros.h; path = ../yoga/YGMacros.h; sourceTree = "<group>"; };
6D4C7F942249476700CBB1EC /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = log.h; path = ../yoga/log.h; sourceTree = "<group>"; };
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGFloatOptional.h; path = ../yoga/YGFloatOptional.h; sourceTree = "<group>"; };
6D4C7F962249476800CBB1EC /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGNode.h; path = ../yoga/YGNode.h; sourceTree = "<group>"; };
6D4C7F972249476800CBB1EC /* YGLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGLayout.h; path = ../yoga/YGLayout.h; sourceTree = "<group>"; };
6D4C7F982249476800CBB1EC /* CompactValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompactValue.h; path = ../yoga/CompactValue.h; sourceTree = "<group>"; };
6D4C7F992249476800CBB1EC /* YGStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGStyle.cpp; path = ../yoga/YGStyle.cpp; sourceTree = "<group>"; };
6D4C7F9A2249476800CBB1EC /* log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = log.cpp; path = ../yoga/log.cpp; sourceTree = "<group>"; };
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGNode.cpp; path = ../yoga/YGNode.cpp; sourceTree = "<group>"; };
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Yoga.cpp; path = ../yoga/Yoga.cpp; sourceTree = "<group>"; };
6D4C7F9D2249476800CBB1EC /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Utils.cpp; path = ../yoga/Utils.cpp; sourceTree = "<group>"; };
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGEnums.cpp; path = ../yoga/YGEnums.cpp; sourceTree = "<group>"; };
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Yoga-internal.h"; path = "../yoga/Yoga-internal.h"; sourceTree = "<group>"; };
6D4C7FA02249476800CBB1EC /* YGValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGValue.h; path = ../yoga/YGValue.h; sourceTree = "<group>"; };
6D4C7FA12249476800CBB1EC /* Yoga.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Yoga.h; path = ../yoga/Yoga.h; sourceTree = "<group>"; };
6D4C7FA22249476800CBB1EC /* YGConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YGConfig.h; path = ../yoga/YGConfig.h; sourceTree = "<group>"; };
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YGConfig.cpp; path = ../yoga/YGConfig.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
6D4C7F75224945B200CBB1EC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
6D4C7F6F224945B200CBB1EC = {
isa = PBXGroup;
children = (
6D4C7F982249476800CBB1EC /* CompactValue.h */,
6D4C7F8C2249476700CBB1EC /* instrumentation.h */,
6D4C7F9A2249476800CBB1EC /* log.cpp */,
6D4C7F942249476700CBB1EC /* log.h */,
6D4C7F9D2249476800CBB1EC /* Utils.cpp */,
6D4C7F8A2249476700CBB1EC /* Utils.h */,
6D4C7FA32249476800CBB1EC /* YGConfig.cpp */,
6D4C7FA22249476800CBB1EC /* YGConfig.h */,
6D4C7F9E2249476800CBB1EC /* YGEnums.cpp */,
6D4C7F912249476700CBB1EC /* YGEnums.h */,
6D4C7F952249476800CBB1EC /* YGFloatOptional.h */,
6D4C7F902249476700CBB1EC /* YGLayout.cpp */,
6D4C7F972249476800CBB1EC /* YGLayout.h */,
6D4C7F932249476700CBB1EC /* YGMacros.h */,
6D4C7F892249476700CBB1EC /* YGMarker.cpp */,
6D4C7F8F2249476700CBB1EC /* YGMarker.h */,
6D4C7F9B2249476800CBB1EC /* YGNode.cpp */,
6D4C7F962249476800CBB1EC /* YGNode.h */,
6D4C7F922249476700CBB1EC /* YGNodePrint.cpp */,
6D4C7F8E2249476700CBB1EC /* YGNodePrint.h */,
6D4C7F992249476800CBB1EC /* YGStyle.cpp */,
6D4C7F8D2249476700CBB1EC /* YGStyle.h */,
6D4C7F8B2249476700CBB1EC /* YGValue.cpp */,
6D4C7FA02249476800CBB1EC /* YGValue.h */,
6D4C7F9F2249476800CBB1EC /* Yoga-internal.h */,
6D4C7F9C2249476800CBB1EC /* Yoga.cpp */,
6D4C7FA12249476800CBB1EC /* Yoga.h */,
6D4C7F79224945B200CBB1EC /* Products */,
);
sourceTree = "<group>";
};
6D4C7F79224945B200CBB1EC /* Products */ = {
isa = PBXGroup;
children = (
6D4C7F78224945B200CBB1EC /* libYogaDev.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
6D4C7F77224945B200CBB1EC /* YogaDev */ = {
isa = PBXNativeTarget;
buildConfigurationList = 6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */;
buildPhases = (
6D4C7F74224945B200CBB1EC /* Sources */,
6D4C7F75224945B200CBB1EC /* Frameworks */,
6D4C7F76224945B200CBB1EC /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = YogaDev;
productName = YogaDev;
productReference = 6D4C7F78224945B200CBB1EC /* libYogaDev.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
6D4C7F70224945B200CBB1EC /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Will Wilson";
TargetAttributes = {
6D4C7F77224945B200CBB1EC = {
CreatedOnToolsVersion = 10.1;
};
};
};
buildConfigurationList = 6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 6D4C7F6F224945B200CBB1EC;
productRefGroup = 6D4C7F79224945B200CBB1EC /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
6D4C7F77224945B200CBB1EC /* YogaDev */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
6D4C7F74224945B200CBB1EC /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6D4C7FAD2249476900CBB1EC /* YGEnums.cpp in Sources */,
6D4C7FAE2249476900CBB1EC /* YGConfig.cpp in Sources */,
6D4C7FAA2249476900CBB1EC /* YGNode.cpp in Sources */,
6D4C7FAB2249476900CBB1EC /* Yoga.cpp in Sources */,
6D4C7FA92249476900CBB1EC /* log.cpp in Sources */,
6D4C7FA62249476900CBB1EC /* YGLayout.cpp in Sources */,
6D4C7FAC2249476900CBB1EC /* Utils.cpp in Sources */,
6D4C7FA82249476900CBB1EC /* YGStyle.cpp in Sources */,
6D4C7FA42249476900CBB1EC /* YGMarker.cpp in Sources */,
6D4C7FA52249476900CBB1EC /* YGValue.cpp in Sources */,
6D4C7FA72249476900CBB1EC /* YGNodePrint.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
6D4C7F7F224945B200CBB1EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
6D4C7F80224945B200CBB1EC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
6D4C7F82224945B200CBB1EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
6D4C7F83224945B200CBB1EC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
6D4C7F73224945B200CBB1EC /* Build configuration list for PBXProject "YogaDev" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6D4C7F7F224945B200CBB1EC /* Debug */,
6D4C7F80224945B200CBB1EC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
6D4C7F81224945B200CBB1EC /* Build configuration list for PBXNativeTarget "YogaDev" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6D4C7F82224945B200CBB1EC /* Debug */,
6D4C7F83224945B200CBB1EC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 6D4C7F70224945B200CBB1EC /* Project object */;
}

View File

@@ -6,10 +6,10 @@
# #
podspec = Pod::Spec.new do |spec| podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit' spec.name = 'YogaKit'
spec.version = '1.12.0' spec.version = '1.14.0'
spec.license = { :type => 'MIT', :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/'
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.'
@@ -23,12 +23,11 @@ podspec = Pod::Spec.new do |spec|
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.14'
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' spec.swift_version = '4.0'
end end
# See https://github.com/facebook/yoga/pull/366 # See https://github.com/facebook/yoga/pull/366

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,10 +1,3 @@
<!--
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,10 +1,3 @@
<!--
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,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* 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.
*/
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import android.content.Intent; import android.content.Intent;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* 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.
*/
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import java.io.File; import java.io.File;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* 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.
*/
package com.facebook.samples.yoga; package com.facebook.samples.yoga;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* 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.
*/
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* 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.
*/
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -1,5 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved. /**
* 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.
*/
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import android.os.Bundle; import android.os.Bundle;

View File

@@ -1,11 +1,9 @@
/** /**
* 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
* LICENSE-examples file in the root directory of this source tree. * file in the root directory of this source tree.
*/ */
package com.facebook.samples.yoga; package com.facebook.samples.yoga;
import android.content.Intent; import android.content.Intent;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import java.util.HashMap; import java.util.HashMap;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import android.content.Context; import android.content.Context;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga.android; package com.facebook.yoga.android;
import android.content.Context; import android.content.Context;

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -43,9 +43,6 @@ namespace Facebook.Yoga
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGConfigFree(IntPtr node); public static extern void YGConfigFree(IntPtr node);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGNodeGetInstanceCount();
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int YGConfigGetInstanceCount(); public static extern int YGConfigGetInstanceCount();

View File

@@ -673,10 +673,5 @@ namespace Facebook.Yoga
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() : return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator(); System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
} }
public static int GetInstanceCount()
{
return Native.YGNodeGetInstanceCount();
}
} }
} }

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,3 +1,9 @@
/*
* 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.
*/
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by Yoga.rc // Used by Yoga.rc

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html
using System; using System;
@@ -362,39 +361,6 @@ namespace Facebook.Yoga
Assert.AreEqual(100f, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10f, root_child4.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50f, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
@@ -419,6 +385,39 @@ namespace Facebook.Yoga
Assert.AreEqual(40f, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50f, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10f, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10f, root_child4.LayoutHeight);
} }
[Test] [Test]

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
using System; using System;
@@ -214,8 +213,6 @@ namespace Facebook.Yoga
root_child1_child0.FlexShrink = 1; root_child1_child0.FlexShrink = 1;
root_child1_child0.FlexBasis = 0.Percent(); root_child1_child0.FlexBasis = 0.Percent();
root_child1_child0.Width = 20; root_child1_child0.Width = 20;
root_child1_child0.MinWidth = 0;
root_child1_child0.MinHeight = 0;
root_child1.Insert(0, root_child1_child0); root_child1.Insert(0, root_child1_child0);
YogaNode root_child2 = new YogaNode(config); YogaNode root_child2 = new YogaNode(config);

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexDirectionTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGFlexWrapTest.html
using System; using System;
@@ -530,12 +529,12 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(50f, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL; root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
@@ -548,12 +547,12 @@ namespace Facebook.Yoga
Assert.AreEqual(100f, root_child0.LayoutX); Assert.AreEqual(100f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(50f, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
} }
[Test] [Test]

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html
using System; using System;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
using System; using System;

286
enums.py
View File

@@ -3,107 +3,57 @@
# This source code is licensed under the MIT 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. # LICENSE file in the root directory of this source tree.
from __future__ import absolute_import from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os import os
ENUMS = { ENUMS = {
'Direction': [ "Direction": ["Inherit", "LTR", "RTL"],
'Inherit', "Unit": ["Undefined", "Point", "Percent", "Auto"],
'LTR', "FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"],
'RTL', "Justify": [
"FlexStart",
"Center",
"FlexEnd",
"SpaceBetween",
"SpaceAround",
"SpaceEvenly",
], ],
'Unit': [ "Overflow": ["Visible", "Hidden", "Scroll"],
'Undefined', "Align": [
'Point', "Auto",
'Percent', "FlexStart",
'Auto', "Center",
"FlexEnd",
"Stretch",
"Baseline",
"SpaceBetween",
"SpaceAround",
], ],
'FlexDirection': [ "PositionType": ["Relative", "Absolute"],
'Column', "Display": ["Flex", "None"],
'ColumnReverse', "Wrap": ["NoWrap", "Wrap", "WrapReverse"],
'Row', "MeasureMode": ["Undefined", "Exactly", "AtMost"],
'RowReverse', "Dimension": ["Width", "Height"],
"Edge": [
"Left",
"Top",
"Right",
"Bottom",
"Start",
"End",
"Horizontal",
"Vertical",
"All",
], ],
'Justify': [ "NodeType": ["Default", "Text"],
'FlexStart', "LogLevel": ["Error", "Warn", "Info", "Debug", "Verbose", "Fatal"],
'Center', "ExperimentalFeature": [
'FlexEnd',
'SpaceBetween',
'SpaceAround',
'SpaceEvenly',
],
'Overflow': [
'Visible',
'Hidden',
'Scroll',
],
'Align': [
'Auto',
'FlexStart',
'Center',
'FlexEnd',
'Stretch',
'Baseline',
'SpaceBetween',
'SpaceAround',
],
'PositionType': [
'Relative',
'Absolute',
],
'Display': [
'Flex',
'None',
],
'Wrap': [
'NoWrap',
'Wrap',
'WrapReverse',
],
'MeasureMode': [
'Undefined',
'Exactly',
'AtMost',
],
'Dimension': [
'Width',
'Height',
],
'Edge': [
'Left',
'Top',
'Right',
'Bottom',
'Start',
'End',
'Horizontal',
'Vertical',
'All',
],
'NodeType': [
'Default',
'Text',
],
'LogLevel': [
'Error',
'Warn',
'Info',
'Debug',
'Verbose',
'Fatal',
],
'ExperimentalFeature': [
# Mimic web flex-basis behavior. # Mimic web flex-basis behavior.
'WebFlexBasis', "WebFlexBasis"
],
'PrintOptions': [
('Layout', 1),
('Style', 2),
('Children', 4),
], ],
"PrintOptions": [("Layout", 1), ("Style", 2), ("Children", 4)],
} }
LICENSE = """/** LICENSE = """/**
@@ -115,23 +65,25 @@ LICENSE = """/**
""" """
def to_java_upper(symbol): def to_java_upper(symbol):
symbol = str(symbol) symbol = str(symbol)
out = '' out = ""
for i in range(0, len(symbol)): for i in range(0, len(symbol)):
c = symbol[i] c = symbol[i]
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]): if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
out += '_' out += "_"
out += c.upper() out += c.upper()
return out return out
def to_log_lower(symbol): def to_log_lower(symbol):
symbol = str(symbol) symbol = str(symbol)
out = '' out = ""
for i in range(0, len(symbol)): for i in range(0, len(symbol)):
c = symbol[i] c = symbol[i]
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]): if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
out += '-' out += "-"
out += c.lower() out += c.lower()
return out return out
@@ -139,114 +91,128 @@ def to_log_lower(symbol):
root = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.abspath(__file__))
# write out C & Objective-C headers # write out C & Objective-C headers
with open(root + '/yoga/YGEnums.h', 'w') as f: with open(root + "/yoga/YGEnums.h", "w") as f:
f.write(LICENSE) f.write(LICENSE)
f.write('#pragma once\n\n') f.write("#pragma once\n\n")
f.write('#include "YGMacros.h"\n\n') f.write('#include "YGMacros.h"\n\n')
f.write('YG_EXTERN_C_BEGIN\n\n') f.write("YG_EXTERN_C_BEGIN\n\n")
for name, values in sorted(ENUMS.items()): for name, values in sorted(ENUMS.items()):
f.write('#define YG%sCount %s\n' % (name, len(values))) f.write("#define YG%sCount %s\n" % (name, len(values)))
f.write('typedef YG_ENUM_BEGIN(YG%s) {\n' % name) f.write("typedef YG_ENUM_BEGIN(YG%s) {\n" % name)
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple):
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1])) f.write(" YG%s%s = %d,\n" % (name, value[0], value[1]))
else: else:
f.write(' YG%s%s,\n' % (name, value)) f.write(" YG%s%s,\n" % (name, value))
f.write('} YG_ENUM_END(YG%s);\n' % name) f.write("} YG_ENUM_END(YG%s);\n" % name)
f.write('WIN_EXPORT const char *YG%sToString(const YG%s value);\n' % (name, name)) f.write(
f.write('\n') "WIN_EXPORT const char *YG%sToString(const YG%s value);\n" % (name, name)
f.write('YG_EXTERN_C_END\n') )
f.write("\n")
f.write("YG_EXTERN_C_END\n")
# write out C body for printing # write out C body for printing
with open(root + '/yoga/YGEnums.cpp', 'w') as f: with open(root + "/yoga/YGEnums.cpp", "w") as f:
f.write(LICENSE) f.write(LICENSE)
f.write('#include "YGEnums.h"\n\n') f.write('#include "YGEnums.h"\n\n')
for name, values in sorted(ENUMS.items()): for name, values in sorted(ENUMS.items()):
f.write('const char *YG%sToString(const YG%s value){\n' % (name, name)) f.write("const char *YG%sToString(const YG%s value){\n" % (name, name))
f.write(' switch(value){\n') f.write(" switch(value){\n")
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple):
f.write(' case YG%s%s:\n' % (name, value[0])) f.write(" case YG%s%s:\n" % (name, value[0]))
f.write(' return "%s";\n' % to_log_lower(value[0])) f.write(' return "%s";\n' % to_log_lower(value[0]))
else: else:
f.write(' case YG%s%s:\n' % (name, value)) f.write(" case YG%s%s:\n" % (name, value))
f.write(' return "%s";\n' % to_log_lower(value)) f.write(' return "%s";\n' % to_log_lower(value))
f.write(' }\n') f.write(" }\n")
f.write(' return "unknown";\n') f.write(' return "unknown";\n')
f.write('}\n\n') f.write("}\n\n")
# write out java files # write out java files
for name, values in sorted(ENUMS.items()): for name, values in sorted(ENUMS.items()):
with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f: with open(root + "/java/com/facebook/yoga/Yoga%s.java" % name, "w") as f:
f.write(LICENSE.replace('/**', '/*', 1)) f.write(LICENSE.replace("/**", "/*", 1))
f.write('package com.facebook.yoga;\n\n') f.write("package com.facebook.yoga;\n\n")
f.write('import com.facebook.proguard.annotations.DoNotStrip;\n\n') f.write("import com.facebook.proguard.annotations.DoNotStrip;\n\n")
f.write('@DoNotStrip\n') f.write("@DoNotStrip\n")
f.write('public enum Yoga%s {\n' % name) f.write("public enum Yoga%s {\n" % name)
if len(values) > 0: if len(values) > 0:
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple):
f.write(' %s(%d)' % (to_java_upper(value[0]), value[1])) f.write(" %s(%d)" % (to_java_upper(value[0]), value[1]))
else: else:
f.write(' %s(%d)' % (to_java_upper(value), values.index(value))) f.write(" %s(%d)" % (to_java_upper(value), values.index(value)))
if values.index(value) is len(values) - 1: if values.index(value) is len(values) - 1:
f.write(';\n') f.write(";\n")
else: else:
f.write(',\n') f.write(",\n")
else: else:
f.write('__EMPTY(-1);') f.write("__EMPTY(-1);")
f.write('\n') f.write("\n")
f.write(' private int mIntValue;\n') f.write(" private int mIntValue;\n")
f.write('\n') f.write("\n")
f.write(' Yoga%s(int intValue) {\n' % name) f.write(" Yoga%s(int intValue) {\n" % name)
f.write(' mIntValue = intValue;\n') f.write(" mIntValue = intValue;\n")
f.write(' }\n') f.write(" }\n")
f.write('\n') f.write("\n")
f.write(' public int intValue() {\n') f.write(" public int intValue() {\n")
f.write(' return mIntValue;\n') f.write(" return mIntValue;\n")
f.write(' }\n') f.write(" }\n")
f.write('\n') f.write("\n")
f.write(' public static Yoga%s fromInt(int value) {\n' % name) f.write(" public static Yoga%s fromInt(int value) {\n" % name)
f.write(' switch (value) {\n') f.write(" switch (value) {\n")
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple):
f.write(' case %d: return %s;\n' % (value[1], to_java_upper(value[0]))) f.write(
" case %d: return %s;\n" % (value[1], to_java_upper(value[0]))
)
else: else:
f.write(' case %d: return %s;\n' % (values.index(value), to_java_upper(value))) f.write(
f.write(' default: throw new IllegalArgumentException("Unknown enum value: " + value);\n') " case %d: return %s;\n"
f.write(' }\n') % (values.index(value), to_java_upper(value))
f.write(' }\n') )
f.write('}\n') f.write(
' default: throw new IllegalArgumentException("Unknown enum value: " + value);\n'
)
f.write(" }\n")
f.write(" }\n")
f.write("}\n")
# write out csharp files # write out csharp files
for name, values in sorted(ENUMS.items()): for name, values in sorted(ENUMS.items()):
with open(root + '/csharp/Facebook.Yoga/Yoga%s.cs' % name, 'w') as f: with open(root + "/csharp/Facebook.Yoga/Yoga%s.cs" % name, "w") as f:
f.write(LICENSE) f.write(LICENSE)
f.write('namespace Facebook.Yoga\n{\n') f.write("namespace Facebook.Yoga\n{\n")
if isinstance(next(iter(values or []), None), tuple): if isinstance(next(iter(values or []), None), tuple):
f.write(' [System.Flags]\n') f.write(" [System.Flags]\n")
f.write(' public enum Yoga%s\n {\n' % name) f.write(" public enum Yoga%s\n {\n" % name)
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple):
f.write(' %s = %d,\n' % (value[0], value[1])) f.write(" %s = %d,\n" % (value[0], value[1]))
else: else:
f.write(' %s,\n' % value) f.write(" %s,\n" % value)
f.write(' }\n') f.write(" }\n")
f.write('}\n') f.write("}\n")
# write out javascript file # write out javascript file
with open(root + '/javascript/sources/YGEnums.js', 'w') as f: with open(root + "/javascript/sources/YGEnums.js", "w") as f:
f.write(LICENSE) f.write(LICENSE)
f.write('module.exports = {\n\n') f.write("module.exports = {\n\n")
for name, values in sorted(ENUMS.items()): for name, values in sorted(ENUMS.items()):
f.write(' %s_COUNT: %s,\n' % (to_java_upper(name), len(values))) f.write(" %s_COUNT: %s,\n" % (to_java_upper(name), len(values)))
base = 0 base = 0
for value in values: for value in values:
if isinstance(value, tuple): if isinstance(value, tuple):
f.write(' %s_%s: %d,\n' % (to_java_upper(name), to_java_upper(value[0]), value[1])) f.write(
" %s_%s: %d,\n"
% (to_java_upper(name), to_java_upper(value[0]), value[1])
)
base = value[1] + 1 base = value[1] + 1
else: else:
f.write(' %s_%s: %d,\n' % (to_java_upper(name), to_java_upper(value), base)) f.write(
" %s_%s: %d,\n" % (to_java_upper(name), to_java_upper(value), base)
)
base += 1 base += 1
f.write('\n') f.write("\n")
f.write('};\n') f.write("};\n")

View File

@@ -44,10 +44,9 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) {
'/**', '/**',
' * Copyright (c) Facebook, Inc. and its affiliates.', ' * Copyright (c) Facebook, Inc. and its affiliates.',
' *', ' *',
' * This source code is licensed under the MIT 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.', ' * file in the root directory of this source tree.',
' */', ' */',
'',
'// @Generated by gentest/gentest.rb from gentest/fixtures/' + document.title + '.html', '// @Generated by gentest/gentest.rb from gentest/fixtures/' + document.title + '.html',
'', '',
]); ]);
@@ -138,7 +137,7 @@ function checkDefaultValues() {
{style:'bottom', value:'undefined'}, {style:'bottom', value:'undefined'},
{style:'display', value:'flex'}, {style:'display', value:'flex'},
].forEach(function(item) { ].forEach(function(item) {
assert(item.value === getDefaultStyleValue(item.style), assert(isDefaultStyleValue(item.style, item.value),
item.style + ' should be ' + item.value); item.style + ' should be ' + item.value);
}); });
} }
@@ -159,7 +158,7 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index
continue; continue;
} }
if (node.style[style] !== getDefaultStyleValue(style)) { if (!isDefaultStyleValue(style, node.style[style])) {
switch (style) { switch (style) {
case 'direction': case 'direction':
e.YGNodeStyleSetDirection(nodeName, directionValue(e, node.style[style])); e.YGNodeStyleSetDirection(nodeName, directionValue(e, node.style[style]));
@@ -400,21 +399,38 @@ function displayValue(e, value){
} }
} }
function getDefaultStyleValue(style) { var DEFAULT_STYLES = new Map();
if (style == 'position') {
return 'relative'; function isDefaultStyleValue(style, value) {
} let defaultStyle = DEFAULT_STYLES.get(style);
if (defaultStyle == null) {
switch (style) { switch (style) {
case 'position':
defaultStyle = new Set(['relative']);;
break;
case 'left': case 'left':
case 'top': case 'top':
case 'right': case 'right':
case 'bottom': case 'bottom':
case 'start': case 'start':
case 'end': case 'end':
return 'undefined'; defaultStyle = new Set(['undefined']);
} break;
case 'min-height':
case 'min-width':
defaultStyle = new Set(['0', '0px', 'auto']);
break;
default:
var node = document.getElementById('default'); var node = document.getElementById('default');
return getComputedStyle(node, null).getPropertyValue(style); defaultStyle = new Set([getComputedStyle(node, null)[style]]);
break;
}
DEFAULT_STYLES.set(style, defaultStyle);
}
return DEFAULT_STYLES.get(style).has(value);
} }
function getRoundedSize(node) { function getRoundedSize(node) {

View File

@@ -9,7 +9,7 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
VERSION_NAME=1.12.0-SNAPSHOT VERSION_NAME=1.14.0-SNAPSHOT
POM_URL=https://github.com/facebook/yoga POM_URL=https://github.com/facebook/yoga
POM_SCM_URL=https://github.com/facebook/yoga.git POM_SCM_URL=https://github.com/facebook/yoga.git
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git POM_SCM_CONNECTION=scm:git:https://github.com/facebook/yoga.git

84
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -3,13 +3,18 @@
# This source code is licensed under the MIT 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. # LICENSE file in the root directory of this source tree.
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test") load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "INFER_ANNOTATIONS_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_lib", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test")
CXX_LIBRARY_WHITELIST_FOR_TESTS = CXX_LIBRARY_WHITELIST + [
yoga_cxx_lib("testutil:jni"),
yoga_cxx_lib("testutil:testutil"),
]
yoga_cxx_library( yoga_cxx_library(
name = "jni", name = "jni",
srcs = glob(["jni/*.cpp"]), srcs = glob(["jni/*.cpp"]),
headers = glob(["jni/*.h"]), header_namespace = "yoga/java",
header_namespace = "", exported_headers = glob(["jni/*.h"]),
allow_jni_merging = True, allow_jni_merging = True,
compiler_flags = [ compiler_flags = [
"-fno-omit-frame-pointer", "-fno-omit-frame-pointer",
@@ -55,11 +60,12 @@ yoga_java_library(
yoga_java_test( yoga_java_test(
name = "tests", name = "tests",
srcs = glob(["tests/**/*.java"]), srcs = glob(["tests/**/*.java"]),
cxx_library_whitelist = CXX_LIBRARY_WHITELIST, cxx_library_whitelist = CXX_LIBRARY_WHITELIST_FOR_TESTS,
use_cxx_libraries = True, use_cxx_libraries = True,
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [ deps = [
":java", ":java",
yoga_dep("testutil:java"),
JUNIT_TARGET, JUNIT_TARGET,
], ],
) )

View File

@@ -29,7 +29,7 @@ add_compile_options(
-Wall -Wall
-std=c++11) -std=c++11)
add_library(yoga SHARED jni/YGJNI.cpp) add_library(yoga SHARED jni/YGJNI.cpp jni/YGJTypes.cpp)
target_include_directories(yoga PRIVATE target_include_directories(yoga PRIVATE
${libfb_DIR}/include ${libfb_DIR}/include

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,83 +1,63 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
@DoNotStrip
public class YogaConfig { public class YogaConfig {
public static int SPACING_TYPE = 1; public static int SPACING_TYPE = 1;
public static boolean useBatchingForLayoutOutputs = false;
static {
SoLoader.loadLibrary("yoga");
}
long mNativePointer; long mNativePointer;
private YogaLogger mLogger; private YogaLogger mLogger;
private YogaNodeCloneFunction mYogaNodeCloneFunction; private YogaNodeCloneFunction mYogaNodeCloneFunction;
public boolean avoidGlobalJNIRefs = false;
private native long jni_YGConfigNew();
public YogaConfig() { public YogaConfig() {
mNativePointer = jni_YGConfigNew(); mNativePointer = YogaNative.jni_YGConfigNew();
if (mNativePointer == 0) { if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory"); throw new IllegalStateException("Failed to allocate native memory");
} }
} }
private native void jni_YGConfigFree(long nativePointer);
@Override @Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
try { try {
jni_YGConfigFree(mNativePointer); YogaNative.jni_YGConfigFree(mNativePointer);
} finally { } finally {
super.finalize(); super.finalize();
} }
} }
private native void jni_YGConfigSetExperimentalFeatureEnabled(
long nativePointer,
int feature,
boolean enabled);
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) { public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled); YogaNative.jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
} }
private native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
public void setUseWebDefaults(boolean useWebDefaults) { public void setUseWebDefaults(boolean useWebDefaults) {
jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults); YogaNative.jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
} }
private native void jni_YGConfigSetPrintTreeFlag(long nativePointer, boolean enable);
public void setPrintTreeFlag(boolean enable) { public void setPrintTreeFlag(boolean enable) {
jni_YGConfigSetPrintTreeFlag(mNativePointer, enable); YogaNative.jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
} }
private native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
public void setPointScaleFactor(float pixelsInPoint) { public void setPointScaleFactor(float pixelsInPoint) {
jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint); YogaNative.jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
} }
private native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
/** /**
* Yoga previously had an error where containers would take the maximum space possible instead of the minimum * Yoga previously had an error where containers would take the maximum space possible instead of the minimum
* like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch; * like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch;
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour. * Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
*/ */
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) { public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour); YogaNative.jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
} }
private native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
/** /**
* If this flag is set then yoga would diff the layout without legacy flag and would set a bool in * If this flag is set then yoga would diff the layout without legacy flag and would set a bool in
* YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false * YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false
@@ -85,14 +65,13 @@ public class YogaConfig {
*/ */
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour( public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) { boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour); mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
} }
private native void jni_YGConfigSetLogger(long nativePointer, Object logger);
public void setLogger(YogaLogger logger) { public void setLogger(YogaLogger logger) {
mLogger = logger; mLogger = logger;
jni_YGConfigSetLogger(mNativePointer, logger); YogaNative.jni_YGConfigSetLogger(mNativePointer, logger);
} }
public YogaLogger getLogger() { public YogaLogger getLogger() {

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -0,0 +1,114 @@
/**
* 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.
*/
package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
@DoNotStrip
public class YogaNative {
static {
SoLoader.loadLibrary("yoga");
}
// YGConfig related
static native long jni_YGConfigNew();
static native void jni_YGConfigFree(long nativePointer);
static native void jni_YGConfigSetExperimentalFeatureEnabled(long nativePointer, int feature, boolean enabled);
static native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
static native void jni_YGConfigSetPrintTreeFlag(long nativePointer, boolean enable);
static native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
static native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
static native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
static native void jni_YGConfigSetLogger(long nativePointer, Object logger);
// YGNode related
static native long jni_YGNodeNew(boolean useBatchingForLayoutOutputs);
static native long jni_YGNodeNewWithConfig(long configPointer, boolean useBatchingForLayoutOutputs);
static native void jni_YGNodeFree(long nativePointer);
static native void jni_YGNodeReset(long nativePointer);
static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline);
static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer);
static native void jni_YGNodeClearChildren(long nativePointer);
static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNIBase[] nodes);
static native void jni_YGNodeMarkDirty(long nativePointer);
static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
static native boolean jni_YGNodeIsDirty(long nativePointer);
static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
static native int jni_YGNodeStyleGetDirection(long nativePointer);
static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
static native int jni_YGNodeStyleGetPositionType(long nativePointer);
static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
static native int jni_YGNodeStyleGetFlexWrap(long nativePointer);
static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
static native int jni_YGNodeStyleGetOverflow(long nativePointer);
static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
static native int jni_YGNodeStyleGetDisplay(long nativePointer);
static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
static native float jni_YGNodeStyleGetFlex(long nativePointer);
static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
static native long jni_YGNodeStyleGetFlexBasis(long nativePointer);
static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
static native long jni_YGNodeStyleGetMargin(long nativePointer, int edge);
static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
static native long jni_YGNodeStyleGetPadding(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
static native long jni_YGNodeStyleGetPosition(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
static native long jni_YGNodeStyleGetWidth(long nativePointer);
static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
static native long jni_YGNodeStyleGetHeight(long nativePointer);
static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
static native long jni_YGNodeStyleGetMinWidth(long nativePointer);
static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMinHeight(long nativePointer);
static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMaxWidth(long nativePointer);
static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
static native long jni_YGNodeStyleGetMaxHeight(long nativePointer);
static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodePrint(long nativePointer);
static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
static native long jni_YGNodeClone(long nativePointer);
}

View File

@@ -10,11 +10,11 @@ import javax.annotation.Nullable;
public abstract class YogaNode { public abstract class YogaNode {
public static YogaNode create() { public static YogaNode create() {
return new YogaNodeJNI(); return YogaConfig.useBatchingForLayoutOutputs ? new YogaNodeJNIBatching() : new YogaNodeJNI();
} }
public static YogaNode create(YogaConfig config) { public static YogaNode create(YogaConfig config) {
return new YogaNodeJNI(config); return YogaConfig.useBatchingForLayoutOutputs ? new YogaNodeJNIBatching(config) : new YogaNodeJNI(config);
} }
public abstract void reset(); public abstract void reset();
@@ -211,11 +211,16 @@ public abstract class YogaNode {
public abstract boolean isMeasureDefined(); public abstract boolean isMeasureDefined();
public abstract boolean isBaselineDefined();
public abstract void setData(Object data); public abstract void setData(Object data);
@Nullable
public abstract Object getData(); public abstract Object getData();
public abstract void print(); public abstract void print();
public abstract void setStyleInputs(float[] styleInputs, int size); public abstract void setStyleInputs(float[] styleInputs, int size);
public abstract YogaNode cloneWithoutChildren();
} }

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -7,36 +7,9 @@
package com.facebook.yoga; package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
@DoNotStrip @DoNotStrip
public class YogaNodeJNI extends YogaNode { public class YogaNodeJNI extends YogaNodeJNIBase {
static {
SoLoader.loadLibrary("yoga");
}
/**
* Get native instance count. Useful for testing only.
*/
static native int jni_YGNodeGetInstanceCount();
private YogaNodeJNI mOwner;
@Nullable private List<YogaNodeJNI> mChildren;
private YogaMeasureFunction mMeasureFunction;
private YogaBaselineFunction mBaselineFunction;
private long mNativePointer;
private Object mData;
/* Those flags needs be in sync with YGJNI.cpp */
private static final int MARGIN = 1;
private static final int PADDING = 2;
private static final int BORDER = 4;
private final boolean mAvoidGlobalJNIRefs;
@DoNotStrip @DoNotStrip
private float mWidth = YogaConstants.UNDEFINED; private float mWidth = YogaConstants.UNDEFINED;
@@ -74,48 +47,20 @@ public class YogaNodeJNI extends YogaNode {
private int mLayoutDirection = 0; private int mLayoutDirection = 0;
@DoNotStrip @DoNotStrip
private boolean mHasNewLayout = true; private boolean mHasNewLayout = true;
@DoNotStrip private boolean mDoesLegacyStretchFlagAffectsLayout = false; @DoNotStrip
private boolean mDoesLegacyStretchFlagAffectsLayout = false;
private native long jni_YGNodeNew();
public YogaNodeJNI() { public YogaNodeJNI() {
mAvoidGlobalJNIRefs = false; super();
mNativePointer = jni_YGNodeNew();
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
} }
private native long jni_YGNodeNewWithConfig(long configPointer, boolean avoidGlobalJNIRefs);
public YogaNodeJNI(YogaConfig config) { public YogaNodeJNI(YogaConfig config) {
mAvoidGlobalJNIRefs = config.avoidGlobalJNIRefs; super(config);
mNativePointer = jni_YGNodeNewWithConfig(config.mNativePointer, mAvoidGlobalJNIRefs);
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
} }
@Override @Override
protected void finalize() throws Throwable {
try {
freeNatives();
} finally {
super.finalize();
}
}
private static native void jni_YGNodeFree(long nativePointer);
/* frees the native underlying YGNode. Useful for testing. */
public void freeNatives() {
if (mNativePointer > 0) {
long nativePointer = mNativePointer;
mNativePointer = 0;
jni_YGNodeFree(nativePointer);
}
}
private static native void jni_YGNodeReset(long nativePointer);
public void reset() { public void reset() {
super.reset();
mHasNewLayout = true; mHasNewLayout = true;
mWidth = YogaConstants.UNDEFINED; mWidth = YogaConstants.UNDEFINED;
@@ -136,491 +81,45 @@ public class YogaNodeJNI extends YogaNode {
mBorderBottom = 0; mBorderBottom = 0;
mLayoutDirection = 0; mLayoutDirection = 0;
mMeasureFunction = null;
mBaselineFunction = null;
mData = null;
mDoesLegacyStretchFlagAffectsLayout = false; mDoesLegacyStretchFlagAffectsLayout = false;
jni_YGNodeReset(mNativePointer);
}
public int getChildCount() {
return mChildren == null ? 0 : mChildren.size();
}
public YogaNodeJNI getChildAt(int i) {
if (mChildren == null) {
throw new IllegalStateException("YogaNode does not have children");
}
return mChildren.get(i);
}
private static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
public void addChildAt(YogaNode c, int i) {
YogaNodeJNI child = (YogaNodeJNI) c;
if (child.mOwner != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first.");
}
if (mChildren == null) {
mChildren = new ArrayList<>(4);
}
mChildren.add(i, child);
child.mOwner = this;
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
}
private static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline);
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
}
private static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer);
public boolean isReferenceBaseline() {
return jni_YGNodeIsReferenceBaseline(mNativePointer);
}
private static native void jni_YGNodeClearChildren(long nativePointer);
private void clearChildren() {
mChildren = null;
jni_YGNodeClearChildren(mNativePointer);
}
private static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
public YogaNodeJNI removeChildAt(int i) {
if (mChildren == null) {
throw new IllegalStateException(
"Trying to remove a child of a YogaNode that does not have children");
}
final YogaNodeJNI child = mChildren.remove(i);
child.mOwner = null;
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
}
/**
* @returns the {@link YogaNode} that owns this {@link YogaNode}.
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs
* to.
* This method will return the parent of the {@link YogaNode} when the
* {@link YogaNode} only belongs to one YogaTree or null when the
* {@link YogaNode} is shared between two or more YogaTrees.
*/
@Nullable
public YogaNodeJNI getOwner() {
return mOwner;
}
/** @deprecated Use #getOwner() instead. This will be removed in the next version. */
@Deprecated
@Nullable
public YogaNodeJNI getParent() {
return getOwner();
}
public int indexOf(YogaNode child) {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
private static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNI[] nodes);
public void calculateLayout(float width, float height) {
long[] nativePointers = null;
YogaNodeJNI[] nodes = null;
if (mAvoidGlobalJNIRefs) {
ArrayList<YogaNodeJNI> n = new ArrayList<>();
n.add(this);
for (int i = 0; i < n.size(); ++i) {
List<YogaNodeJNI> children = n.get(i).mChildren;
if (children != null) {
n.addAll(children);
}
}
nodes = n.toArray(new YogaNodeJNI[n.size()]);
nativePointers = new long[nodes.length];
for (int i = 0; i < nodes.length; ++i) {
nativePointers[i] = nodes[i].mNativePointer;
}
}
jni_YGNodeCalculateLayout(mNativePointer, width, height, nativePointers, nodes);
} }
@Override
public boolean hasNewLayout() { public boolean hasNewLayout() {
return mHasNewLayout; return mHasNewLayout;
} }
private static native void jni_YGNodeMarkDirty(long nativePointer);
public void dirty() {
jni_YGNodeMarkDirty(mNativePointer);
}
private static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
public void dirtyAllDescendants() {
jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
}
private static native boolean jni_YGNodeIsDirty(long nativePointer);
public boolean isDirty() {
return jni_YGNodeIsDirty(mNativePointer);
}
private static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
@Override @Override
public void copyStyle(YogaNode srcNode) {
jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNI) srcNode).mNativePointer);
}
public void markLayoutSeen() { public void markLayoutSeen() {
mHasNewLayout = false; mHasNewLayout = false;
} }
private static native int jni_YGNodeStyleGetDirection(long nativePointer); @Override
public YogaDirection getStyleDirection() {
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
}
private static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
public void setDirection(YogaDirection direction) {
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
}
private static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
public YogaFlexDirection getFlexDirection() {
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
}
private static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
public void setFlexDirection(YogaFlexDirection flexDirection) {
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
}
private static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
public YogaJustify getJustifyContent() {
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
}
private static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
public void setJustifyContent(YogaJustify justifyContent) {
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
}
private static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
public YogaAlign getAlignItems() {
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
}
private static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
public void setAlignItems(YogaAlign alignItems) {
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
}
private static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
public YogaAlign getAlignSelf() {
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
}
private static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
public void setAlignSelf(YogaAlign alignSelf) {
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
}
private static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
public YogaAlign getAlignContent() {
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
}
private static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
public void setAlignContent(YogaAlign alignContent) {
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
}
private static native int jni_YGNodeStyleGetPositionType(long nativePointer);
public YogaPositionType getPositionType() {
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
}
private static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
public void setPositionType(YogaPositionType positionType) {
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
}
private static native int jni_YGNodeStyleGetFlexWrap(long nativePointer);
public YogaWrap getWrap() {
return YogaWrap.fromInt(jni_YGNodeStyleGetFlexWrap(mNativePointer));
}
private static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
public void setWrap(YogaWrap flexWrap) {
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
}
private static native int jni_YGNodeStyleGetOverflow(long nativePointer);
public YogaOverflow getOverflow() {
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
}
private static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
public void setOverflow(YogaOverflow overflow) {
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
}
private static native int jni_YGNodeStyleGetDisplay(long nativePointer);
public YogaDisplay getDisplay() {
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
}
private static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
public void setDisplay(YogaDisplay display) {
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
}
private static native float jni_YGNodeStyleGetFlex(long nativePointer);
public float getFlex() {
return jni_YGNodeStyleGetFlex(mNativePointer);
}
private static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
public void setFlex(float flex) {
jni_YGNodeStyleSetFlex(mNativePointer, flex);
}
private static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
public float getFlexGrow() {
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
}
private static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
public void setFlexGrow(float flexGrow) {
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
}
private static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
public float getFlexShrink() {
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
}
private static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
public void setFlexShrink(float flexShrink) {
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
}
private static native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
public YogaValue getFlexBasis() {
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
}
private static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
public void setFlexBasis(float flexBasis) {
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
}
private static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
public void setFlexBasisPercent(float percent) {
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
}
private static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
public void setFlexBasisAuto() {
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
}
private static native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
public YogaValue getMargin(YogaEdge edge) {
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
}
private static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
public void setMargin(YogaEdge edge, float margin) {
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
}
private static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
public void setMarginPercent(YogaEdge edge, float percent) {
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
}
private static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
public void setMarginAuto(YogaEdge edge) {
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
}
private static native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
public YogaValue getPadding(YogaEdge edge) {
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
}
private static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
public void setPadding(YogaEdge edge, float padding) {
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
}
private static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
public void setPaddingPercent(YogaEdge edge, float percent) {
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
}
private static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
public float getBorder(YogaEdge edge) {
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
}
private static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
public void setBorder(YogaEdge edge, float border) {
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
}
private static native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
public YogaValue getPosition(YogaEdge edge) {
return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
}
private static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
public void setPosition(YogaEdge edge, float position) {
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
}
private static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
public void setPositionPercent(YogaEdge edge, float percent) {
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
}
private static native Object jni_YGNodeStyleGetWidth(long nativePointer);
public YogaValue getWidth() {
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
}
private static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
public void setWidth(float width) {
jni_YGNodeStyleSetWidth(mNativePointer, width);
}
private static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
public void setWidthPercent(float percent) {
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
}
private static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
public void setWidthAuto() {
jni_YGNodeStyleSetWidthAuto(mNativePointer);
}
private static native Object jni_YGNodeStyleGetHeight(long nativePointer);
public YogaValue getHeight() {
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
}
private static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
public void setHeight(float height) {
jni_YGNodeStyleSetHeight(mNativePointer, height);
}
private static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
public void setHeightPercent(float percent) {
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
}
private static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
public void setHeightAuto() {
jni_YGNodeStyleSetHeightAuto(mNativePointer);
}
private static native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
public YogaValue getMinWidth() {
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
}
private static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
public void setMinWidth(float minWidth) {
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
}
private static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
public void setMinWidthPercent(float percent) {
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
}
private static native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
public YogaValue getMinHeight() {
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
}
private static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
public void setMinHeight(float minHeight) {
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
}
private static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
public void setMinHeightPercent(float percent) {
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
}
private static native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
public YogaValue getMaxWidth() {
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
}
private static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
public void setMaxWidth(float maxWidth) {
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
}
private static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
public void setMaxWidthPercent(float percent) {
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
}
private static native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
public YogaValue getMaxHeight() {
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
}
private static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
public void setMaxHeight(float maxheight) {
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
}
private static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
public void setMaxHeightPercent(float percent) {
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
}
private static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() {
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
}
private static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
public void setAspectRatio(float aspectRatio) {
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
}
public float getLayoutX() { public float getLayoutX() {
return mLeft; return mLeft;
} }
@Override
public float getLayoutY() { public float getLayoutY() {
return mTop; return mTop;
} }
@Override
public float getLayoutWidth() { public float getLayoutWidth() {
return mWidth; return mWidth;
} }
@Override
public float getLayoutHeight() { public float getLayoutHeight() {
return mHeight; return mHeight;
} }
@Override
public boolean getDoesLegacyStretchFlagAffectsLayout() { public boolean getDoesLegacyStretchFlagAffectsLayout() {
return mDoesLegacyStretchFlagAffectsLayout; return mDoesLegacyStretchFlagAffectsLayout;
} }
@Override
public float getLayoutMargin(YogaEdge edge) { public float getLayoutMargin(YogaEdge edge) {
switch (edge) { switch (edge) {
case LEFT: case LEFT:
@@ -640,6 +139,7 @@ public class YogaNodeJNI extends YogaNode {
} }
} }
@Override
public float getLayoutPadding(YogaEdge edge) { public float getLayoutPadding(YogaEdge edge) {
switch (edge) { switch (edge) {
case LEFT: case LEFT:
@@ -659,6 +159,7 @@ public class YogaNodeJNI extends YogaNode {
} }
} }
@Override
public float getLayoutBorder(YogaEdge edge) { public float getLayoutBorder(YogaEdge edge) {
switch (edge) { switch (edge) {
case LEFT: case LEFT:
@@ -678,89 +179,8 @@ public class YogaNodeJNI extends YogaNode {
} }
} }
@Override
public YogaDirection getLayoutDirection() { public YogaDirection getLayoutDirection() {
return YogaDirection.fromInt(mLayoutDirection); return YogaDirection.fromInt(mLayoutDirection);
} }
private static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final
//
// We cache the jmethodid for this method in Yoga code. This means that even if a subclass
// were to override measure, we'd still call this implementation from layout code since the
// overriding method will have a different jmethodid. This is final to prevent that mistake.
@DoNotStrip
public final long measure(float width, int widthMode, float height, int heightMode) {
if (!isMeasureDefined()) {
throw new RuntimeException("Measure function isn't defined!");
}
return mMeasureFunction.measure(
this,
width,
YogaMeasureMode.fromInt(widthMode),
height,
YogaMeasureMode.fromInt(heightMode));
}
private static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
mBaselineFunction = baselineFunction;
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
}
@DoNotStrip
public final float baseline(float width, float height) {
return mBaselineFunction.baseline(this, width, height);
}
public boolean isMeasureDefined() {
return mMeasureFunction != null;
}
public void setData(Object data) {
mData = data;
}
public Object getData() {
return mData;
}
private static native void jni_YGNodePrint(long nativePointer);
/**
* Use the set logger (defaults to adb log) to print out the styles, children, and computed
* layout of the tree rooted at this node.
*/
public void print() {
jni_YGNodePrint(mNativePointer);
}
private static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
public void setStyleInputs(float[] styleInputsArray, int size) {
jni_YGNodeSetStyleInputs(mNativePointer, styleInputsArray, size);
}
/**
* This method replaces the child at childIndex position with the newNode received by parameter.
* This is different than calling removeChildAt and addChildAt because this method ONLY replaces
* the child in the mChildren datastructure. @DoNotStrip: called from JNI
*
* @return the nativePointer of the newNode {@linl YogaNode}
*/
@DoNotStrip
private final long replaceChild(YogaNodeJNI newNode, int childIndex) {
if (mChildren == null) {
throw new IllegalStateException("Cannot replace child. YogaNode does not have children");
}
mChildren.remove(childIndex);
mChildren.add(childIndex, newNode);
newNode.mOwner = this;
return newNode.mNativePointer;
}
} }

View File

@@ -0,0 +1,533 @@
/**
* 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.
*/
package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
@DoNotStrip
public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
@Nullable private YogaNodeJNIBase mOwner;
@Nullable private List<YogaNodeJNIBase> mChildren;
@Nullable private YogaMeasureFunction mMeasureFunction;
@Nullable private YogaBaselineFunction mBaselineFunction;
private long mNativePointer;
@Nullable private Object mData;
public YogaNodeJNIBase() {
mNativePointer = YogaNative.jni_YGNodeNew(YogaConfig.useBatchingForLayoutOutputs);
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
public YogaNodeJNIBase(YogaConfig config) {
mNativePointer = YogaNative.jni_YGNodeNewWithConfig(config.mNativePointer, YogaConfig.useBatchingForLayoutOutputs);
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
@Override
protected void finalize() throws Throwable {
try {
freeNatives();
} finally {
super.finalize();
}
}
/* frees the native underlying YGNode. Useful for testing. */
public void freeNatives() {
if (mNativePointer > 0) {
long nativePointer = mNativePointer;
mNativePointer = 0;
YogaNative.jni_YGNodeFree(nativePointer);
}
}
public void reset() {
mMeasureFunction = null;
mBaselineFunction = null;
mData = null;
YogaNative.jni_YGNodeReset(mNativePointer);
}
public int getChildCount() {
return mChildren == null ? 0 : mChildren.size();
}
public YogaNodeJNIBase getChildAt(int i) {
if (mChildren == null) {
throw new IllegalStateException("YogaNode does not have children");
}
return mChildren.get(i);
}
public void addChildAt(YogaNode c, int i) {
YogaNodeJNIBase child = (YogaNodeJNIBase) c;
if (child.mOwner != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first.");
}
if (mChildren == null) {
mChildren = new ArrayList<>(4);
}
mChildren.add(i, child);
child.mOwner = this;
YogaNative.jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
}
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
YogaNative.jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
}
public boolean isReferenceBaseline() {
return YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
}
@Override
public YogaNodeJNIBase cloneWithoutChildren() {
try {
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
long clonedNativePointer = YogaNative.jni_YGNodeClone(mNativePointer);
clonedYogaNode.mOwner = null;
clonedYogaNode.mNativePointer = clonedNativePointer;
clonedYogaNode.clearChildren();
return clonedYogaNode;
} catch (CloneNotSupportedException ex) {
// This class implements Cloneable, this should not happen
throw new RuntimeException(ex);
}
}
private void clearChildren() {
mChildren = null;
YogaNative.jni_YGNodeClearChildren(mNativePointer);
}
public YogaNodeJNIBase removeChildAt(int i) {
if (mChildren == null) {
throw new IllegalStateException(
"Trying to remove a child of a YogaNode that does not have children");
}
final YogaNodeJNIBase child = mChildren.remove(i);
child.mOwner = null;
YogaNative.jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
}
/**
* @returns the {@link YogaNode} that owns this {@link YogaNode}.
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs
* to.
* This method will return the parent of the {@link YogaNode} when the
* {@link YogaNode} only belongs to one YogaTree or null when the
* {@link YogaNode} is shared between two or more YogaTrees.
*/
@Nullable
public YogaNodeJNIBase getOwner() {
return mOwner;
}
/** @deprecated Use #getOwner() instead. This will be removed in the next version. */
@Deprecated
@Nullable
public YogaNodeJNIBase getParent() {
return getOwner();
}
public int indexOf(YogaNode child) {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
public void calculateLayout(float width, float height) {
long[] nativePointers = null;
YogaNodeJNIBase[] nodes = null;
ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
n.add(this);
for (int i = 0; i < n.size(); ++i) {
List<YogaNodeJNIBase> children = n.get(i).mChildren;
if (children != null) {
n.addAll(children);
}
}
nodes = n.toArray(new YogaNodeJNIBase[n.size()]);
nativePointers = new long[nodes.length];
for (int i = 0; i < nodes.length; ++i) {
nativePointers[i] = nodes[i].mNativePointer;
}
YogaNative.jni_YGNodeCalculateLayout(mNativePointer, width, height, nativePointers, nodes);
}
public void dirty() {
YogaNative.jni_YGNodeMarkDirty(mNativePointer);
}
public void dirtyAllDescendants() {
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
}
public boolean isDirty() {
return YogaNative.jni_YGNodeIsDirty(mNativePointer);
}
@Override
public void copyStyle(YogaNode srcNode) {
YogaNative.jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
}
public YogaDirection getStyleDirection() {
return YogaDirection.fromInt(YogaNative.jni_YGNodeStyleGetDirection(mNativePointer));
}
public void setDirection(YogaDirection direction) {
YogaNative.jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
}
public YogaFlexDirection getFlexDirection() {
return YogaFlexDirection.fromInt(YogaNative.jni_YGNodeStyleGetFlexDirection(mNativePointer));
}
public void setFlexDirection(YogaFlexDirection flexDirection) {
YogaNative.jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
}
public YogaJustify getJustifyContent() {
return YogaJustify.fromInt(YogaNative.jni_YGNodeStyleGetJustifyContent(mNativePointer));
}
public void setJustifyContent(YogaJustify justifyContent) {
YogaNative.jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
}
public YogaAlign getAlignItems() {
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignItems(mNativePointer));
}
public void setAlignItems(YogaAlign alignItems) {
YogaNative.jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
}
public YogaAlign getAlignSelf() {
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignSelf(mNativePointer));
}
public void setAlignSelf(YogaAlign alignSelf) {
YogaNative.jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
}
public YogaAlign getAlignContent() {
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignContent(mNativePointer));
}
public void setAlignContent(YogaAlign alignContent) {
YogaNative.jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
}
public YogaPositionType getPositionType() {
return YogaPositionType.fromInt(YogaNative.jni_YGNodeStyleGetPositionType(mNativePointer));
}
public void setPositionType(YogaPositionType positionType) {
YogaNative.jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
}
public YogaWrap getWrap() {
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrap(mNativePointer));
}
public void setWrap(YogaWrap flexWrap) {
YogaNative.jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
}
public YogaOverflow getOverflow() {
return YogaOverflow.fromInt(YogaNative.jni_YGNodeStyleGetOverflow(mNativePointer));
}
public void setOverflow(YogaOverflow overflow) {
YogaNative.jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
}
public YogaDisplay getDisplay() {
return YogaDisplay.fromInt(YogaNative.jni_YGNodeStyleGetDisplay(mNativePointer));
}
public void setDisplay(YogaDisplay display) {
YogaNative.jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
}
public float getFlex() {
return YogaNative.jni_YGNodeStyleGetFlex(mNativePointer);
}
public void setFlex(float flex) {
YogaNative.jni_YGNodeStyleSetFlex(mNativePointer, flex);
}
public float getFlexGrow() {
return YogaNative.jni_YGNodeStyleGetFlexGrow(mNativePointer);
}
public void setFlexGrow(float flexGrow) {
YogaNative.jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
}
public float getFlexShrink() {
return YogaNative.jni_YGNodeStyleGetFlexShrink(mNativePointer);
}
public void setFlexShrink(float flexShrink) {
YogaNative.jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
}
public YogaValue getFlexBasis() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetFlexBasis(mNativePointer));
}
public void setFlexBasis(float flexBasis) {
YogaNative.jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
}
public void setFlexBasisPercent(float percent) {
YogaNative.jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
}
public void setFlexBasisAuto() {
YogaNative.jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
}
public YogaValue getMargin(YogaEdge edge) {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()));
}
public void setMargin(YogaEdge edge, float margin) {
YogaNative.jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
}
public void setMarginPercent(YogaEdge edge, float percent) {
YogaNative.jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
}
public void setMarginAuto(YogaEdge edge) {
YogaNative.jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
}
public YogaValue getPadding(YogaEdge edge) {
return valueFromLong(YogaNative.jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()));
}
public void setPadding(YogaEdge edge, float padding) {
YogaNative.jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
}
public void setPaddingPercent(YogaEdge edge, float percent) {
YogaNative.jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
}
public float getBorder(YogaEdge edge) {
return YogaNative.jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
}
public void setBorder(YogaEdge edge, float border) {
YogaNative.jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
}
public YogaValue getPosition(YogaEdge edge) {
return valueFromLong(YogaNative.jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()));
}
public void setPosition(YogaEdge edge, float position) {
YogaNative.jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
}
public void setPositionPercent(YogaEdge edge, float percent) {
YogaNative.jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
}
public YogaValue getWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidth(mNativePointer));
}
public void setWidth(float width) {
YogaNative.jni_YGNodeStyleSetWidth(mNativePointer, width);
}
public void setWidthPercent(float percent) {
YogaNative.jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
}
public void setWidthAuto() {
YogaNative.jni_YGNodeStyleSetWidthAuto(mNativePointer);
}
public YogaValue getHeight() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeight(mNativePointer));
}
public void setHeight(float height) {
YogaNative.jni_YGNodeStyleSetHeight(mNativePointer, height);
}
public void setHeightPercent(float percent) {
YogaNative.jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
}
public void setHeightAuto() {
YogaNative.jni_YGNodeStyleSetHeightAuto(mNativePointer);
}
public YogaValue getMinWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidth(mNativePointer));
}
public void setMinWidth(float minWidth) {
YogaNative.jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
}
public void setMinWidthPercent(float percent) {
YogaNative.jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
}
public YogaValue getMinHeight() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeight(mNativePointer));
}
public void setMinHeight(float minHeight) {
YogaNative.jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
}
public void setMinHeightPercent(float percent) {
YogaNative.jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
}
public YogaValue getMaxWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidth(mNativePointer));
}
public void setMaxWidth(float maxWidth) {
YogaNative.jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
}
public void setMaxWidthPercent(float percent) {
YogaNative.jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
}
public YogaValue getMaxHeight() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeight(mNativePointer));
}
public void setMaxHeight(float maxheight) {
YogaNative.jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
}
public void setMaxHeightPercent(float percent) {
YogaNative.jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
}
public float getAspectRatio() {
return YogaNative.jni_YGNodeStyleGetAspectRatio(mNativePointer);
}
public void setAspectRatio(float aspectRatio) {
YogaNative.jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
}
public abstract boolean getDoesLegacyStretchFlagAffectsLayout();
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
YogaNative.jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final
//
// We cache the jmethodid for this method in Yoga code. This means that even if a subclass
// were to override measure, we'd still call this implementation from layout code since the
// overriding method will have a different jmethodid. This is final to prevent that mistake.
@DoNotStrip
public final long measure(float width, int widthMode, float height, int heightMode) {
if (!isMeasureDefined()) {
throw new RuntimeException("Measure function isn't defined!");
}
return mMeasureFunction.measure(
this,
width,
YogaMeasureMode.fromInt(widthMode),
height,
YogaMeasureMode.fromInt(heightMode));
}
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
mBaselineFunction = baselineFunction;
YogaNative.jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
}
@DoNotStrip
public final float baseline(float width, float height) {
return mBaselineFunction.baseline(this, width, height);
}
public boolean isMeasureDefined() {
return mMeasureFunction != null;
}
@Override
public boolean isBaselineDefined() {
return mBaselineFunction != null;
}
public void setData(Object data) {
mData = data;
}
@Override
public @Nullable Object getData() {
return mData;
}
/**
* Use the set logger (defaults to adb log) to print out the styles, children, and computed
* layout of the tree rooted at this node.
*/
public void print() {
YogaNative.jni_YGNodePrint(mNativePointer);
}
public void setStyleInputs(float[] styleInputsArray, int size) {
YogaNative.jni_YGNodeSetStyleInputs(mNativePointer, styleInputsArray, size);
}
/**
* This method replaces the child at childIndex position with the newNode received by parameter.
* This is different than calling removeChildAt and addChildAt because this method ONLY replaces
* the child in the mChildren datastructure. @DoNotStrip: called from JNI
*
* @return the nativePointer of the newNode {@linl YogaNode}
*/
@DoNotStrip
private final long replaceChild(YogaNodeJNIBase newNode, int childIndex) {
if (mChildren == null) {
throw new IllegalStateException("Cannot replace child. YogaNode does not have children");
}
mChildren.remove(childIndex);
mChildren.add(childIndex, newNode);
newNode.mOwner = this;
return newNode.mNativePointer;
}
private static YogaValue valueFromLong(long raw) {
return new YogaValue(Float.intBitsToFloat((int) raw), (int) (raw >> 32));
}
}

View File

@@ -0,0 +1,177 @@
/**
* 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.
*/
package com.facebook.yoga;
import javax.annotation.Nullable;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public class YogaNodeJNIBatching extends YogaNodeJNIBase {
/* Those flags needs be in sync with YGJNI.cpp */
private static final byte MARGIN = 1;
private static final byte PADDING = 2;
private static final byte BORDER = 4;
private static final byte DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
private static final byte HAS_NEW_LAYOUT = 16;
private static final byte LAYOUT_EDGE_SET_FLAG_INDEX = 0;
private static final byte LAYOUT_WIDTH_INDEX = 1;
private static final byte LAYOUT_HEIGHT_INDEX = 2;
private static final byte LAYOUT_LEFT_INDEX = 3;
private static final byte LAYOUT_TOP_INDEX = 4;
private static final byte LAYOUT_DIRECTION_INDEX = 5;
private static final byte LAYOUT_MARGIN_START_INDEX = 6;
private static final byte LAYOUT_PADDING_START_INDEX = 10;
private static final byte LAYOUT_BORDER_START_INDEX = 14;
@DoNotStrip
private @Nullable float[] arr = null;
@DoNotStrip
private int mLayoutDirection = 0;
private boolean mHasNewLayout = true;
public YogaNodeJNIBatching() {
super();
}
public YogaNodeJNIBatching(YogaConfig config) {
super(config);
}
@Override
public void reset() {
super.reset();
arr = null;
mHasNewLayout = true;
mLayoutDirection = 0;
}
@Override
public float getLayoutX() {
return arr != null ? arr[LAYOUT_LEFT_INDEX] : 0;
}
@Override
public float getLayoutY() {
return arr != null ? arr[LAYOUT_TOP_INDEX] : 0;
}
@Override
public float getLayoutWidth() {
return arr != null ? arr[LAYOUT_WIDTH_INDEX] : 0;
}
@Override
public float getLayoutHeight() {
return arr != null ? arr[LAYOUT_HEIGHT_INDEX] : 0;
}
@Override
public boolean getDoesLegacyStretchFlagAffectsLayout() {
return arr != null && (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & DOES_LEGACY_STRETCH_BEHAVIOUR) == DOES_LEGACY_STRETCH_BEHAVIOUR);
}
@Override
public float getLayoutMargin(YogaEdge edge) {
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) {
switch (edge) {
case LEFT:
return arr[LAYOUT_MARGIN_START_INDEX];
case TOP:
return arr[LAYOUT_MARGIN_START_INDEX + 1];
case RIGHT:
return arr[LAYOUT_MARGIN_START_INDEX + 2];
case BOTTOM:
return arr[LAYOUT_MARGIN_START_INDEX + 3];
case START:
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX + 2] : arr[LAYOUT_MARGIN_START_INDEX];
case END:
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX] : arr[LAYOUT_MARGIN_START_INDEX + 2];
default:
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
}
} else {
return 0;
}
}
@Override
public float getLayoutPadding(YogaEdge edge) {
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) {
int paddingStartIndex = LAYOUT_PADDING_START_INDEX - ((((int)arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4);
switch (edge) {
case LEFT:
return arr[paddingStartIndex];
case TOP:
return arr[paddingStartIndex + 1];
case RIGHT:
return arr[paddingStartIndex + 2];
case BOTTOM:
return arr[paddingStartIndex + 3];
case START:
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex + 2] : arr[paddingStartIndex];
case END:
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex] : arr[paddingStartIndex + 2];
default:
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
}
} else {
return 0;
}
}
@Override
public float getLayoutBorder(YogaEdge edge) {
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & BORDER) == BORDER) {
int borderStartIndex = LAYOUT_BORDER_START_INDEX - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4) - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) ? 0 : 4);
switch (edge) {
case LEFT:
return arr[borderStartIndex];
case TOP:
return arr[borderStartIndex + 1];
case RIGHT:
return arr[borderStartIndex + 2];
case BOTTOM:
return arr[borderStartIndex + 3];
case START:
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex + 2] : arr[borderStartIndex];
case END:
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex] : arr[borderStartIndex + 2];
default:
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
}
} else {
return 0;
}
}
@Override
public YogaDirection getLayoutDirection() {
return YogaDirection.fromInt(arr != null ? (int) arr[LAYOUT_DIRECTION_INDEX] : mLayoutDirection);
}
@Override
public boolean hasNewLayout() {
if (arr != null) {
return (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & HAS_NEW_LAYOUT) == HAS_NEW_LAYOUT;
} else {
return mHasNewLayout;
}
}
@Override
public void markLayoutSeen() {
if (arr != null) {
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & ~(HAS_NEW_LAYOUT);
}
mHasNewLayout = false;
}
}

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,15 +1,11 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public class YogaValue { public class YogaValue {
static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED); static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED);
static final YogaValue ZERO = new YogaValue(0, YogaUnit.POINT); static final YogaValue ZERO = new YogaValue(0, YogaUnit.POINT);
@@ -23,7 +19,6 @@ public class YogaValue {
this.unit = unit; this.unit = unit;
} }
@DoNotStrip
YogaValue(float value, int unit) { YogaValue(float value, int unit) {
this(value, YogaUnit.fromInt(unit)); this(value, YogaUnit.fromInt(unit));
} }

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,4 +1,4 @@
/** /*
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
@@ -7,10 +7,15 @@
#include <fb/fbjni.h> #include <fb/fbjni.h>
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
#include <yoga/Yoga-internal.h>
#include <yoga/log.h> #include <yoga/log.h>
#include <cstdint>
#include <cstring>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include "YGJTypes.h"
using namespace facebook::jni; using namespace facebook::jni;
using namespace std; using namespace std;
using facebook::yoga::detail::Log; using facebook::yoga::detail::Log;
@@ -58,68 +63,79 @@ enum YGStyleInput {
IsReferenceBaseline, IsReferenceBaseline,
}; };
struct JYogaNode : public JavaClass<JYogaNode> { const short int LAYOUT_EDGE_SET_FLAG_INDEX = 0;
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNodeJNI;"; const short int LAYOUT_WIDTH_INDEX = 1;
const short int LAYOUT_HEIGHT_INDEX = 2;
const short int LAYOUT_LEFT_INDEX = 3;
const short int LAYOUT_TOP_INDEX = 4;
const short int LAYOUT_DIRECTION_INDEX = 5;
const short int LAYOUT_MARGIN_START_INDEX = 6;
const short int LAYOUT_PADDING_START_INDEX = 10;
const short int LAYOUT_BORDER_START_INDEX = 14;
bool useBatchingForLayoutOutputs;
namespace {
union YGNodeContext {
uintptr_t edgesSet = 0;
void* asVoidPtr;
}; };
struct JYogaConfig : public JavaClass<JYogaConfig> { const int DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaConfig;"; const int HAS_NEW_LAYOUT = 16;
};
class PtrJNodeMap { class YGNodeEdges {
using JNodeArray = JArrayClass<JYogaNode::javaobject>; uintptr_t edges_;
std::map<YGNodeRef, size_t> ptrsToIdxs_;
alias_ref<JNodeArray> javaNodes_;
public: public:
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {} enum Edge {
PtrJNodeMap( MARGIN = 1,
alias_ref<JArrayLong> nativePointers, PADDING = 2,
alias_ref<JNodeArray> javaNodes) BORDER = 4,
: javaNodes_{javaNodes} { };
auto pin = nativePointers->pinCritical();
auto ptrs = pin.get(); YGNodeEdges(YGNodeRef node) {
for (size_t i = 0, n = pin.size(); i < n; ++i) { auto context = YGNodeContext{};
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i; context.asVoidPtr = node->getContext();
} edges_ = context.edgesSet;
} }
local_ref<JYogaNode> ref(YGNodeRef node) { void setOn(YGNodeRef node) {
auto idx = ptrsToIdxs_.find(node); auto context = YGNodeContext{};
if (idx == ptrsToIdxs_.end()) { context.edgesSet = edges_;
return local_ref<JYogaNode>{}; node->setContext(context.asVoidPtr);
} else {
return javaNodes_->getElement(idx->second);
} }
bool has(Edge edge) { return (edges_ & edge) == edge; }
YGNodeEdges& add(Edge edge) {
edges_ |= edge;
return *this;
}
int get() { return edges_; }
};
struct YogaValue {
static constexpr jint NAN_BYTES = 0x7fc00000;
static jlong asJavaLong(const YGValue& value) {
uint32_t valueBytes = 0;
memcpy(&valueBytes, &value.value, sizeof valueBytes);
return ((jlong) value.unit) << 32 | valueBytes;
}
constexpr static jlong undefinedAsJavaLong() {
return ((jlong) YGUnitUndefined) << 32 | NAN_BYTES;
} }
}; };
struct YGNodeContext { } // namespace
weak_ref<jobject>* ygNodeJObjectRef{nullptr};
int edgeSetFlag = 0;
~YGNodeContext() {
delete ygNodeJObjectRef;
}
};
const int MARGIN = 1;
const int PADDING = 2;
const int BORDER = 3;
static inline YGNodeContext* ygNodeRefToYGNodeContext(YGNodeRef node) {
return reinterpret_cast<YGNodeContext*>(node->getContext());
}
static inline local_ref<JYogaNode> YGNodeJobject( static inline local_ref<JYogaNode> YGNodeJobject(
YGNodeRef node, YGNodeRef node,
void* layoutContext) { void* layoutContext) {
if (layoutContext == nullptr) {
return (reinterpret_cast<weak_ref<JYogaNode>*>(
ygNodeRefToYGNodeContext(node)->ygNodeJObjectRef))
->lockLocal();
} else {
return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node); return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node);
}
} }
static void YGTransferLayoutDirection( static void YGTransferLayoutDirection(
@@ -147,8 +163,62 @@ static void YGTransferLayoutOutputsRecursive(
return; return;
} }
int edgeSetFlag = ygNodeRefToYGNodeContext(root)->edgeSetFlag; auto edgesSet = YGNodeEdges{root};
if (useBatchingForLayoutOutputs) {
bool marginFieldSet = edgesSet.has(YGNodeEdges::MARGIN);
bool paddingFieldSet = edgesSet.has(YGNodeEdges::PADDING);
bool borderFieldSet = edgesSet.has(YGNodeEdges::BORDER);
int fieldFlags = edgesSet.get();
fieldFlags |= HAS_NEW_LAYOUT;
if (YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)) {
fieldFlags |= DOES_LEGACY_STRETCH_BEHAVIOUR;
}
const int arrSize = 6 + (marginFieldSet ? 4 : 0) +
(paddingFieldSet ? 4 : 0) + (borderFieldSet ? 4 : 0);
float arr[18];
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = fieldFlags;
arr[LAYOUT_WIDTH_INDEX] = YGNodeLayoutGetWidth(root);
arr[LAYOUT_HEIGHT_INDEX] = YGNodeLayoutGetHeight(root);
arr[LAYOUT_LEFT_INDEX] = YGNodeLayoutGetLeft(root);
arr[LAYOUT_TOP_INDEX] = YGNodeLayoutGetTop(root);
arr[LAYOUT_DIRECTION_INDEX] =
static_cast<jint>(YGNodeLayoutGetDirection(root));
if (marginFieldSet) {
arr[LAYOUT_MARGIN_START_INDEX] = YGNodeLayoutGetMargin(root, YGEdgeLeft);
arr[LAYOUT_MARGIN_START_INDEX + 1] =
YGNodeLayoutGetMargin(root, YGEdgeTop);
arr[LAYOUT_MARGIN_START_INDEX + 2] =
YGNodeLayoutGetMargin(root, YGEdgeRight);
arr[LAYOUT_MARGIN_START_INDEX + 3] =
YGNodeLayoutGetMargin(root, YGEdgeBottom);
}
if (paddingFieldSet) {
int paddingStartIndex =
LAYOUT_PADDING_START_INDEX - (marginFieldSet ? 0 : 4);
arr[paddingStartIndex] = YGNodeLayoutGetPadding(root, YGEdgeLeft);
arr[paddingStartIndex + 1] = YGNodeLayoutGetPadding(root, YGEdgeTop);
arr[paddingStartIndex + 2] = YGNodeLayoutGetPadding(root, YGEdgeRight);
arr[paddingStartIndex + 3] = YGNodeLayoutGetPadding(root, YGEdgeBottom);
}
if (borderFieldSet) {
int borderStartIndex = LAYOUT_BORDER_START_INDEX -
(marginFieldSet ? 0 : 4) - (paddingFieldSet ? 0 : 4);
arr[borderStartIndex] = YGNodeLayoutGetBorder(root, YGEdgeLeft);
arr[borderStartIndex + 1] = YGNodeLayoutGetBorder(root, YGEdgeTop);
arr[borderStartIndex + 2] = YGNodeLayoutGetBorder(root, YGEdgeRight);
arr[borderStartIndex + 3] = YGNodeLayoutGetBorder(root, YGEdgeBottom);
}
static auto arrField = obj->getClass()->getField<jfloatArray>("arr");
local_ref<jfloatArray> arrFinal = make_float_array(arrSize);
arrFinal->setRegion(0, arrSize, arr);
obj->setFieldValue<jfloatArray>(arrField, arrFinal.get());
} else {
static auto widthField = obj->getClass()->getField<jfloat>("mWidth"); static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
static auto heightField = obj->getClass()->getField<jfloat>("mHeight"); static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
static auto leftField = obj->getClass()->getField<jfloat>("mLeft"); static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
@@ -156,7 +226,8 @@ static void YGTransferLayoutOutputsRecursive(
static auto marginLeftField = static auto marginLeftField =
obj->getClass()->getField<jfloat>("mMarginLeft"); obj->getClass()->getField<jfloat>("mMarginLeft");
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop"); static auto marginTopField =
obj->getClass()->getField<jfloat>("mMarginTop");
static auto marginRightField = static auto marginRightField =
obj->getClass()->getField<jfloat>("mMarginRight"); obj->getClass()->getField<jfloat>("mMarginRight");
static auto marginBottomField = static auto marginBottomField =
@@ -173,7 +244,8 @@ static void YGTransferLayoutOutputsRecursive(
static auto borderLeftField = static auto borderLeftField =
obj->getClass()->getField<jfloat>("mBorderLeft"); obj->getClass()->getField<jfloat>("mBorderLeft");
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop"); static auto borderTopField =
obj->getClass()->getField<jfloat>("mBorderTop");
static auto borderRightField = static auto borderRightField =
obj->getClass()->getField<jfloat>("mBorderRight"); obj->getClass()->getField<jfloat>("mBorderRight");
static auto borderBottomField = static auto borderBottomField =
@@ -181,7 +253,8 @@ static void YGTransferLayoutOutputsRecursive(
static auto hasNewLayoutField = static auto hasNewLayoutField =
obj->getClass()->getField<jboolean>("mHasNewLayout"); obj->getClass()->getField<jboolean>("mHasNewLayout");
static auto doesLegacyStretchBehaviour = obj->getClass()->getField<jboolean>( static auto doesLegacyStretchBehaviour =
obj->getClass()->getField<jboolean>(
"mDoesLegacyStretchFlagAffectsLayout"); "mDoesLegacyStretchFlagAffectsLayout");
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root)); obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
@@ -191,18 +264,21 @@ static void YGTransferLayoutOutputsRecursive(
obj->setFieldValue<jboolean>( obj->setFieldValue<jboolean>(
doesLegacyStretchBehaviour, doesLegacyStretchBehaviour,
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)); YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
YGTransferLayoutDirection(root, obj);
if ((edgeSetFlag & MARGIN) == MARGIN) { if (edgesSet.has(YGNodeEdges::MARGIN)) {
obj->setFieldValue( obj->setFieldValue(
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft)); marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop)); obj->setFieldValue(
marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
obj->setFieldValue( obj->setFieldValue(
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight)); marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
obj->setFieldValue( obj->setFieldValue(
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom)); marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
} }
if ((edgeSetFlag & PADDING) == PADDING) { if (edgesSet.has(YGNodeEdges::PADDING)) {
obj->setFieldValue( obj->setFieldValue(
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft)); paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
obj->setFieldValue( obj->setFieldValue(
@@ -213,18 +289,18 @@ static void YGTransferLayoutOutputsRecursive(
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom)); paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
} }
if ((edgeSetFlag & BORDER) == BORDER) { if (edgesSet.has(YGNodeEdges::BORDER)) {
obj->setFieldValue( obj->setFieldValue(
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft)); borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop)); obj->setFieldValue(
borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
obj->setFieldValue( obj->setFieldValue(
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight)); borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
obj->setFieldValue( obj->setFieldValue(
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom)); borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
} }
}
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
YGTransferLayoutDirection(root, obj);
root->setHasNewLayout(false); root->setHasNewLayout(false);
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) { for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
@@ -250,10 +326,7 @@ static float YGJNIBaselineFunc(
float height, float height,
void* layoutContext) { void* layoutContext) {
if (auto obj = YGNodeJobject(node, layoutContext)) { if (auto obj = YGNodeJobject(node, layoutContext)) {
static auto baselineFunc = return obj->baseline(width, height);
findClassStatic("com/facebook/yoga/YogaNodeJNI")
->getMethod<jfloat(jfloat, jfloat)>("baseline");
return baselineFunc(obj, width, height);
} else { } else {
return height; return height;
} }
@@ -267,6 +340,14 @@ static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr)); return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
} }
jlong jni_YGNodeClone(alias_ref<jobject> thiz, jlong nativePointer) {
auto node = _jlong2YGNodeRef(nativePointer);
const YGNodeRef clonedYogaNode = YGNodeClone(node);
clonedYogaNode->setContext(node->getContext());
return reinterpret_cast<jlong>(clonedYogaNode);
}
static YGSize YGJNIMeasureFunc( static YGSize YGJNIMeasureFunc(
YGNodeRef node, YGNodeRef node,
float width, float width,
@@ -275,13 +356,9 @@ static YGSize YGJNIMeasureFunc(
YGMeasureMode heightMode, YGMeasureMode heightMode,
void* layoutContext) { void* layoutContext) {
if (auto obj = YGNodeJobject(node, layoutContext)) { if (auto obj = YGNodeJobject(node, layoutContext)) {
static auto measureFunc =
findClassStatic("com/facebook/yoga/YogaNodeJNI")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
YGTransferLayoutDirection(node, obj); YGTransferLayoutDirection(node, obj);
const auto measureResult = const auto measureResult =
measureFunc(obj, width, widthMode, height, heightMode); obj->measure(width, widthMode, height, heightMode);
static_assert( static_assert(
sizeof(measureResult) == 8, sizeof(measureResult) == 8,
@@ -307,10 +384,6 @@ static YGSize YGJNIMeasureFunc(
} }
} }
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
};
static int YGJNILogFunc( static int YGJNILogFunc(
const YGConfigRef config, const YGConfigRef config,
const YGNodeRef node, const YGNodeRef node,
@@ -322,24 +395,14 @@ static int YGJNILogFunc(
std::vector<char> buffer(1 + result); std::vector<char> buffer(1 + result);
vsnprintf(buffer.data(), buffer.size(), format, args); vsnprintf(buffer.data(), buffer.size(), format, args);
static auto logFunc =
findClassStatic("com/facebook/yoga/YogaLogger")
->getMethod<void(
local_ref<JYogaNode>, local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt =
JYogaLogLevel::javaClassStatic()
->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
auto jloggerPtr = auto jloggerPtr =
static_cast<global_ref<jobject>*>(YGConfigGetContext(config)); static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
if (jloggerPtr != nullptr) { if (jloggerPtr != nullptr) {
if (auto obj = YGNodeJobject(node, layoutContext)) { if (auto obj = YGNodeJobject(node, layoutContext)) {
logFunc( (*jloggerPtr)
*jloggerPtr, ->log(
obj, obj,
logLevelFromInt( JYogaLogLevel::fromInt(level),
JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
Environment::current()->NewStringUTF(buffer.data())); Environment::current()->NewStringUTF(buffer.data()));
} }
} }
@@ -347,25 +410,21 @@ static int YGJNILogFunc(
return result; return result;
} }
YGNodeContext* createYGNodeContext(alias_ref<jobject> thiz) { jlong jni_YGNodeNew(alias_ref<jobject> thiz, jboolean useBatching) {
YGNodeContext* ygNodeContext = new YGNodeContext();
ygNodeContext->ygNodeJObjectRef = new weak_ref<jobject>(make_weak(thiz));
return ygNodeContext;
}
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
const YGNodeRef node = YGNodeNew(); const YGNodeRef node = YGNodeNew();
node->setContext(createYGNodeContext(thiz)); node->setContext(YGNodeContext{}.asVoidPtr);
node->setPrintFunc(YGPrint); node->setPrintFunc(YGPrint);
useBatchingForLayoutOutputs = useBatching;
return reinterpret_cast<jlong>(node); return reinterpret_cast<jlong>(node);
} }
jlong jni_YGNodeNewWithConfig( jlong jni_YGNodeNewWithConfig(
alias_ref<jobject> thiz, alias_ref<jclass>,
jlong configPointer, jlong configPointer,
jboolean avoidGlobalJNIRefs) { jboolean useBatching) {
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer)); const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
node->setContext(createYGNodeContext(avoidGlobalJNIRefs ? nullptr : thiz)); node->setContext(YGNodeContext{}.asVoidPtr);
useBatchingForLayoutOutputs = useBatching;
return reinterpret_cast<jlong>(node); return reinterpret_cast<jlong>(node);
} }
@@ -374,10 +433,6 @@ void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) {
return; return;
} }
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
auto context = node->getContext();
if (context != nullptr) {
delete reinterpret_cast<YGNodeContext*>(node->getContext());
}
YGNodeFree(node); YGNodeFree(node);
} }
@@ -394,11 +449,13 @@ void jni_YGNodeReset(jlong nativePointer) {
} }
void jni_YGNodePrint(jlong nativePointer) { void jni_YGNodePrint(jlong nativePointer) {
#ifdef DEBUG
const YGNodeRef node = _jlong2YGNodeRef(nativePointer); const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
YGNodePrint( YGNodePrint(
node, node,
(YGPrintOptions)( (YGPrintOptions)(
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren)); YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
#endif
} }
void jni_YGNodeInsertChild( void jni_YGNodeInsertChild(
@@ -479,14 +536,6 @@ void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer)); _jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
} }
struct JYogaValue : public JavaClass<JYogaValue> {
constexpr static auto kJavaDescriptor = "Lcom/facebook/yoga/YogaValue;";
static local_ref<javaobject> create(YGValue value) {
return newInstance(value.value, static_cast<int>(value.unit));
}
};
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \ javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
@@ -498,9 +547,8 @@ struct JYogaValue : public JavaClass<JYogaValue> {
} }
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \ #define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
local_ref<jobject> jni_YGNodeStyleGet##name( \ jlong jni_YGNodeStyleGet##name(jlong nativePointer) { \
alias_ref<jobject>, jlong nativePointer) { \ return YogaValue::asJavaLong( \
return JYogaValue::create( \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \ YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \ } \
\ \
@@ -535,9 +583,8 @@ struct JYogaValue : public JavaClass<JYogaValue> {
} }
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \ #define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
local_ref<jobject> jni_YGNodeStyleGet##name( \ jlong jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
alias_ref<jobject>, jlong nativePointer, jint edge) { \ return YogaValue::asJavaLong(YGNodeStyleGet##name( \
return JYogaValue::create(YGNodeStyleGet##name( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \ _jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
} \ } \
\ \
@@ -598,20 +645,20 @@ YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
jlong jni_YGConfigNew(alias_ref<jobject>) { jlong jni_YGConfigNew(alias_ref<jclass>) {
return reinterpret_cast<jlong>(YGConfigNew()); return reinterpret_cast<jlong>(YGConfigNew());
} }
void jni_YGConfigFree(alias_ref<jobject>, jlong nativePointer) { void jni_YGConfigFree(alias_ref<jclass>, jlong nativePointer) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
// unique_ptr will destruct the underlying global_ref, if present. // unique_ptr will destruct the underlying global_ref, if present.
auto context = std::unique_ptr<global_ref<jobject>>{ auto context = std::unique_ptr<global_ref<JYogaLogger>>{
static_cast<global_ref<jobject>*>(YGConfigGetContext(config))}; static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config))};
YGConfigFree(config); YGConfigFree(config);
} }
void jni_YGConfigSetExperimentalFeatureEnabled( void jni_YGConfigSetExperimentalFeatureEnabled(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jint feature, jint feature,
jboolean enabled) { jboolean enabled) {
@@ -621,7 +668,7 @@ void jni_YGConfigSetExperimentalFeatureEnabled(
} }
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jboolean enabled) { jboolean enabled) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -629,7 +676,7 @@ void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
} }
void jni_YGConfigSetUseWebDefaults( void jni_YGConfigSetUseWebDefaults(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jboolean useWebDefaults) { jboolean useWebDefaults) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -637,7 +684,7 @@ void jni_YGConfigSetUseWebDefaults(
} }
void jni_YGConfigSetPrintTreeFlag( void jni_YGConfigSetPrintTreeFlag(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jboolean enable) { jboolean enable) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -645,7 +692,7 @@ void jni_YGConfigSetPrintTreeFlag(
} }
void jni_YGConfigSetPointScaleFactor( void jni_YGConfigSetPointScaleFactor(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jfloat pixelsInPoint) { jfloat pixelsInPoint) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -653,7 +700,7 @@ void jni_YGConfigSetPointScaleFactor(
} }
void jni_YGConfigSetUseLegacyStretchBehaviour( void jni_YGConfigSetUseLegacyStretchBehaviour(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
jboolean useLegacyStretchBehaviour) { jboolean useLegacyStretchBehaviour) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
@@ -661,19 +708,20 @@ void jni_YGConfigSetUseLegacyStretchBehaviour(
} }
void jni_YGConfigSetLogger( void jni_YGConfigSetLogger(
alias_ref<jobject>, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
alias_ref<jobject> logger) { alias_ref<jobject> logger) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer); const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
auto context = auto context =
reinterpret_cast<global_ref<jobject>*>(YGConfigGetContext(config)); reinterpret_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
if (logger) { if (logger) {
if (context == nullptr) { if (context == nullptr) {
context = new global_ref<jobject>{}; context = new global_ref<JYogaLogger>{};
YGConfigSetContext(config, context); YGConfigSetContext(config, context);
} }
*context = make_global(logger);
*context = make_global(static_ref_cast<JYogaLogger::javaobject>(logger));
config->setLogger(YGJNILogFunc); config->setLogger(YGJNILogFunc);
} else { } else {
if (context != nullptr) { if (context != nullptr) {
@@ -689,6 +737,7 @@ static void YGNodeSetStyleInputs(
float* styleInputs, float* styleInputs,
int size) { int size) {
const auto end = styleInputs + size; const auto end = styleInputs + size;
auto edgesSet = YGNodeEdges{node};
while (styleInputs < end) { while (styleInputs < end) {
auto styleInputKey = static_cast<YGStyleInput>((int) *styleInputs++); auto styleInputKey = static_cast<YGStyleInput>((int) *styleInputs++);
switch (styleInputKey) { switch (styleInputKey) {
@@ -789,58 +838,55 @@ static void YGNodeSetStyleInputs(
YGNodeStyleSetDisplay(node, static_cast<YGDisplay>(*styleInputs++)); YGNodeStyleSetDisplay(node, static_cast<YGDisplay>(*styleInputs++));
break; break;
case Margin: { case Margin: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float marginValue = *styleInputs++; float marginValue = *styleInputs++;
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= MARGIN; edgesSet.add(YGNodeEdges::MARGIN);
YGNodeStyleSetMargin(node, static_cast<YGEdge>(edge), marginValue); YGNodeStyleSetMargin(node, edge, marginValue);
break; break;
} }
case MarginPercent: { case MarginPercent: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float marginPercent = *styleInputs++; float marginPercent = *styleInputs++;
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= MARGIN; edgesSet.add(YGNodeEdges::MARGIN);
YGNodeStyleSetMarginPercent( YGNodeStyleSetMarginPercent(node, edge, marginPercent);
node, static_cast<YGEdge>(edge), marginPercent);
break; break;
} }
case MarginAuto: { case MarginAuto: {
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= MARGIN; edgesSet.add(YGNodeEdges::MARGIN);
YGNodeStyleSetMarginAuto(node, static_cast<YGEdge>(*styleInputs++)); YGNodeStyleSetMarginAuto(node, static_cast<YGEdge>(*styleInputs++));
break; break;
} }
case Padding: { case Padding: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float paddingValue = *styleInputs++; float paddingValue = *styleInputs++;
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= PADDING; edgesSet.add(YGNodeEdges::PADDING);
YGNodeStyleSetPadding(node, static_cast<YGEdge>(edge), paddingValue); YGNodeStyleSetPadding(node, edge, paddingValue);
break; break;
} }
case PaddingPercent: { case PaddingPercent: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float paddingPercent = *styleInputs++; float paddingPercent = *styleInputs++;
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= PADDING; edgesSet.add(YGNodeEdges::PADDING);
YGNodeStyleSetPaddingPercent( YGNodeStyleSetPaddingPercent(node, edge, paddingPercent);
node, static_cast<YGEdge>(edge), paddingPercent);
break; break;
} }
case Border: { case Border: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float borderValue = *styleInputs++; float borderValue = *styleInputs++;
ygNodeRefToYGNodeContext(node)->edgeSetFlag |= BORDER; edgesSet.add(YGNodeEdges::BORDER);
YGNodeStyleSetBorder(node, static_cast<YGEdge>(edge), borderValue); YGNodeStyleSetBorder(node, edge, borderValue);
break; break;
} }
case Position: { case Position: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float positionValue = *styleInputs++; float positionValue = *styleInputs++;
YGNodeStyleSetPosition(node, static_cast<YGEdge>(edge), positionValue); YGNodeStyleSetPosition(node, edge, positionValue);
break; break;
} }
case PositionPercent: { case PositionPercent: {
float edge = *styleInputs++; auto edge = static_cast<YGEdge>(*styleInputs++);
float positionPercent = *styleInputs++; float positionPercent = *styleInputs++;
YGNodeStyleSetPositionPercent( YGNodeStyleSetPositionPercent(node, edge, positionPercent);
node, static_cast<YGEdge>(edge), positionPercent);
break; break;
} }
case IsReferenceBaseline: { case IsReferenceBaseline: {
@@ -851,10 +897,11 @@ static void YGNodeSetStyleInputs(
break; break;
} }
} }
edgesSet.setOn(node);
} }
void jni_YGNodeSetStyleInputs( void jni_YGNodeSetStyleInputs(
alias_ref<jobject> thiz, alias_ref<jclass>,
jlong nativePointer, jlong nativePointer,
alias_ref<JArrayFloat> styleInputs, alias_ref<JArrayFloat> styleInputs,
jint size) { jint size) {
@@ -863,26 +910,18 @@ void jni_YGNodeSetStyleInputs(
YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size); YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size);
} }
jint jni_YGNodeGetInstanceCount() { jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) {
return YGNodeGetInstanceCount();
}
local_ref<jobject> jni_YGNodeStyleGetMargin(
alias_ref<jobject>,
jlong nativePointer,
jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
int edgeSetFlag = ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag; if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
if ((edgeSetFlag & MARGIN) != MARGIN) { return YogaValue::undefinedAsJavaLong();
return JYogaValue::create(YGValueUndefined);
} }
return JYogaValue::create( return YogaValue::asJavaLong(
YGNodeStyleGetMargin(yogaNodeRef, static_cast<YGEdge>(edge))); YGNodeStyleGetMargin(yogaNodeRef, static_cast<YGEdge>(edge)));
} }
void jni_YGNodeStyleSetMargin(jlong nativePointer, jint edge, jfloat margin) { void jni_YGNodeStyleSetMargin(jlong nativePointer, jint edge, jfloat margin) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= MARGIN; YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
YGNodeStyleSetMargin( YGNodeStyleSetMargin(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(margin)); yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(margin));
} }
@@ -892,33 +931,29 @@ void jni_YGNodeStyleSetMarginPercent(
jint edge, jint edge,
jfloat percent) { jfloat percent) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= MARGIN; YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
YGNodeStyleSetMarginPercent( YGNodeStyleSetMarginPercent(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent)); yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
} }
void jni_YGNodeStyleSetMarginAuto(jlong nativePointer, jint edge) { void jni_YGNodeStyleSetMarginAuto(jlong nativePointer, jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= MARGIN; YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
YGNodeStyleSetMarginAuto(yogaNodeRef, static_cast<YGEdge>(edge)); YGNodeStyleSetMarginAuto(yogaNodeRef, static_cast<YGEdge>(edge));
} }
local_ref<jobject> jni_YGNodeStyleGetPadding( jlong jni_YGNodeStyleGetPadding(jlong nativePointer, jint edge) {
alias_ref<jobject>,
jlong nativePointer,
jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
int edgeSetFlag = ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag; if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::PADDING)) {
if ((edgeSetFlag & PADDING) != PADDING) { return YogaValue::undefinedAsJavaLong();
return JYogaValue::create(YGValueUndefined);
} }
return JYogaValue::create( return YogaValue::asJavaLong(
YGNodeStyleGetPadding(yogaNodeRef, static_cast<YGEdge>(edge))); YGNodeStyleGetPadding(yogaNodeRef, static_cast<YGEdge>(edge)));
} }
void jni_YGNodeStyleSetPadding(jlong nativePointer, jint edge, jfloat padding) { void jni_YGNodeStyleSetPadding(jlong nativePointer, jint edge, jfloat padding) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= PADDING; YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
YGNodeStyleSetPadding( YGNodeStyleSetPadding(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(padding)); yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(padding));
} }
@@ -928,15 +963,14 @@ void jni_YGNodeStyleSetPaddingPercent(
jint edge, jint edge,
jfloat percent) { jfloat percent) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= PADDING; YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
YGNodeStyleSetPaddingPercent( YGNodeStyleSetPaddingPercent(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent)); yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
} }
jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) { jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
int edgeSetFlag = ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag; if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::BORDER)) {
if ((edgeSetFlag & BORDER) != BORDER) {
return (jfloat) YGUndefined; return (jfloat) YGUndefined;
} }
return (jfloat) YGNodeStyleGetBorder(yogaNodeRef, static_cast<YGEdge>(edge)); return (jfloat) YGNodeStyleGetBorder(yogaNodeRef, static_cast<YGEdge>(edge));
@@ -944,7 +978,7 @@ jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) { void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
ygNodeRefToYGNodeContext(yogaNodeRef)->edgeSetFlag |= BORDER; YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::BORDER).setOn(yogaNodeRef);
YGNodeStyleSetBorder( YGNodeStyleSetBorder(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border)); yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
} }
@@ -956,7 +990,7 @@ void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
jint JNI_OnLoad(JavaVM* vm, void*) { jint JNI_OnLoad(JavaVM* vm, void*) {
return initialize(vm, [] { return initialize(vm, [] {
registerNatives( registerNatives(
"com/facebook/yoga/YogaNodeJNI", "com/facebook/yoga/YogaNative",
{ {
YGMakeNativeMethod(jni_YGNodeNew), YGMakeNativeMethod(jni_YGNodeNew),
YGMakeNativeMethod(jni_YGNodeNewWithConfig), YGMakeNativeMethod(jni_YGNodeNewWithConfig),
@@ -1001,51 +1035,47 @@ jint JNI_OnLoad(JavaVM* vm, void*) {
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexBasis),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetMargin), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMargin),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetPadding), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPadding),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
YGMakeNativeMethod(jni_YGNodeStyleGetPosition), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPosition),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount),
YGMakeCriticalNativeMethod(jni_YGNodePrint), YGMakeCriticalNativeMethod(jni_YGNodePrint),
YGMakeNativeMethod(jni_YGNodeClone),
YGMakeNativeMethod(jni_YGNodeSetStyleInputs), YGMakeNativeMethod(jni_YGNodeSetStyleInputs),
});
registerNatives(
"com/facebook/yoga/YogaConfig",
{
YGMakeNativeMethod(jni_YGConfigNew), YGMakeNativeMethod(jni_YGConfigNew),
YGMakeNativeMethod(jni_YGConfigFree), YGMakeNativeMethod(jni_YGConfigFree),
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),

44
java/jni/YGJTypes.cpp Normal file
View File

@@ -0,0 +1,44 @@
/*
* 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.
*/
#include "YGJTypes.h"
using facebook::jni::alias_ref;
using facebook::jni::local_ref;
jfloat JYogaNode::baseline(jfloat width, jfloat height) {
static auto javaMethod =
javaClassLocal()->getMethod<jfloat(jfloat, jfloat)>("baseline");
return javaMethod(self(), width, height);
}
jlong JYogaNode::measure(
jfloat width,
jint widthMode,
jfloat height,
jint heightMode) {
static auto javaMethod =
javaClassLocal()->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
return javaMethod(self(), width, widthMode, height, heightMode);
}
facebook::jni::local_ref<JYogaLogLevel> JYogaLogLevel::fromInt(jint logLevel) {
static auto javaMethod =
javaClassStatic()->getStaticMethod<alias_ref<JYogaLogLevel>(jint)>(
"fromInt");
return javaMethod(javaClassStatic(), logLevel);
}
void JYogaLogger::log(
facebook::jni::alias_ref<JYogaNode> node,
facebook::jni::alias_ref<JYogaLogLevel> logLevel,
jstring message) {
static auto javaMethod =
javaClassLocal()
->getMethod<void(
alias_ref<JYogaNode>, alias_ref<JYogaLogLevel>, jstring)>("log");
javaMethod(self(), node, logLevel, message);
}

63
java/jni/YGJTypes.h Normal file
View File

@@ -0,0 +1,63 @@
/*
* 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.
*/
#include <fb/fbjni.h>
#include <yoga/YGValue.h>
#include <yoga/Yoga.h>
#include <map>
using namespace facebook::jni;
using namespace std;
struct JYogaNode : public facebook::jni::JavaClass<JYogaNode> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNodeJNIBase;";
jfloat baseline(jfloat width, jfloat height);
jlong measure(jfloat width, jint widthMode, jfloat height, jint heightMode);
};
struct JYogaLogLevel : public facebook::jni::JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
static facebook::jni::local_ref<JYogaLogLevel> fromInt(jint);
};
struct JYogaLogger : public facebook::jni::JavaClass<JYogaLogger> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogger";
void log(
facebook::jni::alias_ref<JYogaNode>,
facebook::jni::alias_ref<JYogaLogLevel>,
jstring);
};
class PtrJNodeMap {
using JNodeArray = JArrayClass<JYogaNode::javaobject>;
std::map<YGNodeRef, size_t> ptrsToIdxs_;
alias_ref<JNodeArray> javaNodes_;
public:
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {}
PtrJNodeMap(
alias_ref<JArrayLong> nativePointers,
alias_ref<JNodeArray> javaNodes)
: javaNodes_{javaNodes} {
auto pin = nativePointers->pinCritical();
auto ptrs = pin.get();
for (size_t i = 0, n = pin.size(); i < n; ++i) {
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i;
}
}
local_ref<JYogaNode> ref(YGNodeRef node) {
auto idx = ptrsToIdxs_.find(node);
if (idx == ptrsToIdxs_.end()) {
return local_ref<JYogaNode>{};
} else {
return javaNodes_->getElement(idx->second);
}
}
};

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
package com.facebook.proguard.annotations; package com.facebook.proguard.annotations;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View File

@@ -1,9 +1,8 @@
/* /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT license found in the LICENSE * This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree. * file in the root directory of this source tree.
*
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAbsolutePositionTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,8 +1,8 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignContentTest.html
package com.facebook.yoga; package com.facebook.yoga;
@@ -367,39 +366,6 @@ public class YGAlignContentTest {
assertEquals(100f, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
@@ -424,6 +390,39 @@ public class YGAlignContentTest {
assertEquals(40f, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
} }
@Test @Test

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignItemsTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAlignSelfTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGAndroidNewsFeed.html
package com.facebook.yoga; package com.facebook.yoga;
@@ -60,8 +59,7 @@ public class YGAndroidNewsFeed {
root_child0_child0_child0_child0_child0_child0.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child0_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child0_child0_child0_child0.setWidth(120f); root_child0_child0_child0_child0_child0_child0.setWidth(120f);
root_child0_child0_child0_child0_child0_child0.setHeight(120f); root_child0_child0_child0_child0_child0_child0.setHeight(120f);
root_child0_child0_child0_child0_child0.addChildAt( root_child0_child0_child0_child0_child0.addChildAt(root_child0_child0_child0_child0_child0_child0, 0);
root_child0_child0_child0_child0_child0_child0, 0);
final YogaNode root_child0_child0_child0_child0_child1 = createNode(config); final YogaNode root_child0_child0_child0_child0_child1 = createNode(config);
root_child0_child0_child0_child0_child1.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child0_child0_child1.setAlignContent(YogaAlign.STRETCH);
@@ -77,14 +75,12 @@ public class YGAndroidNewsFeed {
root_child0_child0_child0_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0_child0_child0_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0_child0_child0_child0_child1_child0.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child0_child0_child1_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child0_child0_child1_child0.setFlexShrink(1f); root_child0_child0_child0_child0_child1_child0.setFlexShrink(1f);
root_child0_child0_child0_child0_child1.addChildAt( root_child0_child0_child0_child0_child1.addChildAt(root_child0_child0_child0_child0_child1_child0, 0);
root_child0_child0_child0_child0_child1_child0, 0);
final YogaNode root_child0_child0_child0_child0_child1_child1 = createNode(config); final YogaNode root_child0_child0_child0_child0_child1_child1 = createNode(config);
root_child0_child0_child0_child0_child1_child1.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child0_child0_child1_child1.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child0_child0_child1_child1.setFlexShrink(1f); root_child0_child0_child0_child0_child1_child1.setFlexShrink(1f);
root_child0_child0_child0_child0_child1.addChildAt( root_child0_child0_child0_child0_child1.addChildAt(root_child0_child0_child0_child0_child1_child1, 1);
root_child0_child0_child0_child0_child1_child1, 1);
final YogaNode root_child0_child0_child1 = createNode(config); final YogaNode root_child0_child0_child1 = createNode(config);
root_child0_child0_child1.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child1.setAlignContent(YogaAlign.STRETCH);
@@ -107,8 +103,7 @@ public class YGAndroidNewsFeed {
root_child0_child0_child1_child0_child0_child0.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child1_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child1_child0_child0_child0.setWidth(72f); root_child0_child0_child1_child0_child0_child0.setWidth(72f);
root_child0_child0_child1_child0_child0_child0.setHeight(72f); root_child0_child0_child1_child0_child0_child0.setHeight(72f);
root_child0_child0_child1_child0_child0.addChildAt( root_child0_child0_child1_child0_child0.addChildAt(root_child0_child0_child1_child0_child0_child0, 0);
root_child0_child0_child1_child0_child0_child0, 0);
final YogaNode root_child0_child0_child1_child0_child1 = createNode(config); final YogaNode root_child0_child0_child1_child0_child1 = createNode(config);
root_child0_child0_child1_child0_child1.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child1_child0_child1.setAlignContent(YogaAlign.STRETCH);
@@ -124,14 +119,12 @@ public class YGAndroidNewsFeed {
root_child0_child0_child1_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW); root_child0_child0_child1_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0_child0_child1_child0_child1_child0.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child1_child0_child1_child0.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child1_child0_child1_child0.setFlexShrink(1f); root_child0_child0_child1_child0_child1_child0.setFlexShrink(1f);
root_child0_child0_child1_child0_child1.addChildAt( root_child0_child0_child1_child0_child1.addChildAt(root_child0_child0_child1_child0_child1_child0, 0);
root_child0_child0_child1_child0_child1_child0, 0);
final YogaNode root_child0_child0_child1_child0_child1_child1 = createNode(config); final YogaNode root_child0_child0_child1_child0_child1_child1 = createNode(config);
root_child0_child0_child1_child0_child1_child1.setAlignContent(YogaAlign.STRETCH); root_child0_child0_child1_child0_child1_child1.setAlignContent(YogaAlign.STRETCH);
root_child0_child0_child1_child0_child1_child1.setFlexShrink(1f); root_child0_child0_child1_child0_child1_child1.setFlexShrink(1f);
root_child0_child0_child1_child0_child1.addChildAt( root_child0_child0_child1_child0_child1.addChildAt(root_child0_child0_child1_child0_child1_child1, 1);
root_child0_child0_child1_child0_child1_child1, 1);
root.setDirection(YogaDirection.LTR); root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGBorderTest.html
package com.facebook.yoga; package com.facebook.yoga;

View File

@@ -1,10 +1,9 @@
/** /**
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
* *
* This source code is licensed under the MIT 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. * file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html // @Generated by gentest/gentest.rb from gentest/fixtures/YGDimensionTest.html
package com.facebook.yoga; package com.facebook.yoga;

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