Summary:
Fix#326. I'll open another PR once this one gets accepted to add support for `YGLayoutGetBorder` 👌
Closes https://github.com/facebook/yoga/pull/335
Reviewed By: gkassabli
Differential Revision: D4409399
Pulled By: emilsjolander
fbshipit-source-id: 8153f6701cab60b55a485f6d2e0b9f7767481090
Summary: Allow aspect ratio to expand beyond bounds of parent as is generally accepted in css
Reviewed By: passy
Differential Revision: D4397547
fbshipit-source-id: d2b1ca7b096f2f17b3efbd8f47a50678bfe7bb5f
Summary:
Added baseline support (see #132)
You have the ability for a custom baseline function (```float(*YGBaselineFunc)(YGNodeRef node);```) to return whatever baseline you want.
Closes https://github.com/facebook/yoga/pull/317
Reviewed By: splhack
Differential Revision: D4385061
Pulled By: emilsjolander
fbshipit-source-id: cb8a59a09237c840fa3e21753ab68239997dab0c
Summary: Add API for retrieving the computed final padding of a node. Many frameworks such as React Native retrieve padding via `YGNodeStyleGetPadding` but given that we now support percentage values this is not correct anymore.
Differential Revision: D4376572
fbshipit-source-id: 3ffb66e77090fc1257511bec5c933f9b0c304b9f
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
Summary: Improve performance of allocations and reseting by writing fewer bits. Also just looks nicer imho.
Reviewed By: passy
Differential Revision: D4356994
fbshipit-source-id: ebbe52163e0c86230bfa4131b657941afe16fbf1
Summary:
@public
AspectRatio is a new addition and soon after introduction we noticed use cases which is did not support. Specifically we wanted to support a node being as large as possible within a container while maintaining an arbitrary aspect ratio. This was not possible due to the low priority of AspectRatio, by increasing the priority of AspectRatio this is now possible as FlexGrow will grow an item to fit its parent unless the AspectRatio makes it too big in the cross axis, the AspectRatio will now override the FlexGrow in the main axis in that case.
Differential Revision: D4346720
fbshipit-source-id: 1f15613604190e3ad5ff4a467ba57db4bcfd2741
Summary:
@public
Aspect ratio being defined as width/height or height/width depending on the situation it was used in turned out to be very confusing. This diff makes aspect ratio always be defined as width/height irregardless of the usage.
Differential Revision: D4339132
fbshipit-source-id: e5da32750b55ddaf6acaf1cbd7662d86f2b480c3
Summary: This test creates a repro case for Yoga to emulate UFI layout failure
Reviewed By: emilsjolander
Differential Revision: D4313632
fbshipit-source-id: 35be7d86b50a9ae08c81891a889a74e4b61f2d27
Summary: I kept wrongly typing this function which is a good sign that the name is inconsistent.
Reviewed By: gkassabli
Differential Revision: D4333480
fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad
Summary: Rename test files to use new name
Reviewed By: gkassabli
Differential Revision: D4265235
fbshipit-source-id: 0090d3949828058baf7435f33d4068de92756bad
Summary: This renames the core C api to use the new Yoga branding.
Differential Revision: D4259190
fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.
Reviewed By: gkassabli
Differential Revision: D4226734
fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag.
Reviewed By: gkassabli
Differential Revision: D4222910
fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
Summary:
Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely can be further improved. I'm looking forward to your ideas.
Closes https://github.com/facebook/css-layout/pull/256
Reviewed By: splhack
Differential Revision: D4214168
Pulled By: emilsjolander
fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236
Summary:
Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values.
Closes https://github.com/facebook/css-layout/pull/257
Reviewed By: splhack
Differential Revision: D4213809
Pulled By: emilsjolander
fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2
Summary: Implement aspect ratio as part of Yoga. Aspect ratio allows users of the library to specify the size of the undefined dimension in terms of an aspect ratio. See test cases for examples.
Reviewed By: gkassabli
Differential Revision: D4211458
fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d
Summary:
computed flex basis was incorrectly being reused in some circumstances between calls to caluclateLayout
also run format script.
Reviewed By: dshahidehpour
Differential Revision: D4207106
fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d
Summary:
- Add a convenience function to copy all style from one node to another.
- CSSNodeIsDirty will return true after this function if any style was changed in the destination node.
Reviewed By: emilsjolander
Differential Revision: D4188514
fbshipit-source-id: af8d7fb5e8688c64aea05ce7ad23fff9233fb441
Summary:
- Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib.
- Fixed memory leaks in tests.
- Close#247
For example, to use dlmalloc with USE_DL_PREFIX
CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree);
Reviewed By: emilsjolander
Differential Revision: D4178386
fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b
Summary: Java and csharp already use CSSWrap and not CSSWrapType. Let's consolidate and stick with the shorter of the two.
Reviewed By: gkassabli
Differential Revision: D4174257
fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592
Summary:
Fixes issue brought up in https://github.com/facebook/react-native/issues/10603
The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this.
Reviewed By: gkassabli
Differential Revision: D4157971
fbshipit-source-id: 3cfae15ac8b65b70f01789444099ee684e1b099a
Summary: Previous fix for flex in max size constraint was not entirely correct and was missing a test case for the time when the max constraint is not applied. This diff addresses that.
Reviewed By: gkassabli
Differential Revision: D4162104
fbshipit-source-id: 08feba6cb4e789c9aa12179e2cdeadc66b011841
Summary:
If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.
This is a re-land of D4147298. I have updated the diff to check explicitly for exact measure mode to also handle at_most case correctly.
Reviewed By: gkassabli
Differential Revision: D4153133
fbshipit-source-id: 2333150a83857cc30078cc8d52761cbd00652830
Summary: Default value for positions should be undefined not 0px. Fixing this leads to more correct tests.
Reviewed By: gkassabli
Differential Revision: D4153329
fbshipit-source-id: d0f194f9c47eac93d3815ec7e55568a1016bc7fe
Summary: Within `UIView+CSSLayout`, we often nil out the measure function of a node because view hierarchy can often change. Unfortunately, this causes us to hit an assert which crashes the app. Instead, lets the measure func to be set to NULL, regardless of how many children a node might have.
Reviewed By: emilsjolander
Differential Revision: D4148727
fbshipit-source-id: 79a0f3ef1bf7b1dce9a14de96f870e35c042b78b
Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.
Reviewed By: gkassabli
Differential Revision: D4147298
fbshipit-source-id: 8416508a31e8d317bf59d956abdbe5760b55bb6d
Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.
Reviewed By: gkassabli
Differential Revision: D4147298
fbshipit-source-id: 51152e57eff8e322a833a6d698c30f8c5e2dcc35
Summary:
Max dimension constraints were not correctly passed down to children.
see https://github.com/facebook/css-layout/issues/230 for more info
fixes#230
Reviewed By: gkassabli
Differential Revision: D4147199
fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9
Summary: Scrolling through feed and logging when this optimization is hit leads to... 0 logs. If anything this just adds to confusion. It was initially added due to instinct and not data, which was a mistake. I am happy to add some similar optimization in the future if we have data that it is useful in real world situations, currently it just leads to bugs and confusion though.
Reviewed By: astreet
Differential Revision: D4146785
fbshipit-source-id: e20d780fbd5759b8f38b809e8cadf29cedee82a8
Summary:
Not all platforms have gtest death tests. There is a define to check for that.
Bracketed the relevant tests with the define.
Reviewed By: youerkang
Differential Revision: D4141823
fbshipit-source-id: 1396657f3ee83853fcda85d5a51708d4e77642cb
Summary:
@public
Instead of silently ignorning non-leaf nodes with measure functions, we should assert that we don't create those kinds of trees.
Reviewed By: emilsjolander
Differential Revision: D4130770
fbshipit-source-id: a3ef10a2e63bbc12b5aa07977e4b84c8d59e3ffe
Summary: Currently, when we try to remove a child from a node, that node is mark dirty //regardless of whether or not anything was actually removed//. This fixes it.
Reviewed By: gkassabli
Differential Revision: D4125453
fbshipit-source-id: 745cfc55269415fea106a80c72401eb3074f2d31
Summary: Previously, we would preallocate Node's with a child list of 4. We recently removed that logic (see diff below), and as a result, if you tried to access a Node's list of children before it had been allocated, you would crash. I added a simple check to protect from crashes, the operation of the check is O(1) so we shouldn't see a perf hit.
Reviewed By: emilsjolander
Differential Revision: D4104093
fbshipit-source-id: cd7b09818759aa76415b97e241f1a6746a2bc50c
Summary: To perform some JNI optimizations for java we need a reference to the node in the measure function. This updates the API to provide the whole node as input instead of just the context.
Reviewed By: javache
Differential Revision: D4081544
fbshipit-source-id: d49679025cea027cf7b8482898de0a01fe0f9d40
Summary: canUseCachedMeasurement function was not handling CSSMeasureModeAtMost correctly so a bunch of measurements that could have been reused were not. When a previous measurement used AtMost and the new one as an AtMost with a smaller constraint but still bigger than the previous computed size it should be OK to re-use the previously computed size.
Reviewed By: gkassabli
Differential Revision: D4071621
fbshipit-source-id: 19d87d939051ddf8ee2e1c6e60efee22d173bbb9
Summary:
- Revise scripts to generate Java and C# unittests using the same HTML fixtures as well as C for code coverage.
- Add wrap_column test workaround in gentest.js.
- Add checkDefaultValues for sanity check of the CSSLayout default values by test-template.html
- Add `align-content: flex-start;` in default div to align with CSSLayout default
$ cd csharp/gentest
$ ruby gentest.rb
- macOS example for C#
$ cd csharp/tests/Facebook.CSSLayout
$ clang -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -g -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp
$ mcs -debug -t:library -r:nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs
$ mono64 --debug nunit-console.exe CSSLayoutTest.dll
Reviewed By: emilsjolander
Differential Revision: D4053777
fbshipit-source-id: 84450208015e65baf604987bd56c6a268598b545
Summary: Flex basis should override height/width. Not the other way around.
Reviewed By: gkassabli
Differential Revision: D4029374
fbshipit-source-id: bc3c72879f3937a50bf8a636b547adc7b9a4f5a7
Summary: Min dimension was not respected when calculating justify content. This diff ensures that the min dimension is taken into account when at most measure spec is used.
Reviewed By: gkassabli, lucasr
Differential Revision: D4021443
fbshipit-source-id: 00f58c6078ac3076221e1148aacc34712786deb5