Summary: This list can only contain CSSNodeRefs so don't use void*
Reviewed By: gkassabli
Differential Revision: D4101773
fbshipit-source-id: 8a5c9066da796967bd02ce6b1fc74ff40e15dfe1
Summary: Add a more complex benchmark which actually take a couple milliseconds to perform. This makes it easier to see if optimizations have any effect. More styles should be added later to make sure the benchmarks covers most of the csslayout code.
Reviewed By: gkassabli
Differential Revision: D4101780
fbshipit-source-id: 6bdf703edfbe64c47c77e04ef1ca946f4b75d093
Summary: Since these functions are private and only used in the implementation file, we don't need to declare them beforehand.
Reviewed By: emilsjolander
Differential Revision: D4088488
fbshipit-source-id: 738175a4aae27d88d32f8c2cf6b47a4f6ae32aab
Summary:
- bit operation with long
- Clean up _measureOutput which is no longer needed
- Fix unittests (SetMeasureFunction, unused error)
Reviewed By: emilsjolander
Differential Revision: D4082401
fbshipit-source-id: b3b2dd002d108c5b43f36a4a73ce8e5233281b45
Summary: Set layout outputs on CSSNode from C after layout calculation finishes instead of relying on calling jni gettings from java code. This should be much more efficient as it avoids a lot of jni overhead and also allows for calling getLayoutWidth() etc multiple times without incurring a penalty.
Reviewed By: lexs
Differential Revision: D4077968
fbshipit-source-id: bce86ba610cd5ae36cfb45d78b2609c63a14cfa3
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: This is an API breaking change done to allow us to avoid an allocation during measurement. Instead we do the same trick as is done when passing measure results to C, we path them into a long.
Reviewed By: splhack
Differential Revision: D4081037
fbshipit-source-id: 28adbcdd160cbd3f59a0fdd4b9f1200ae18678f1
Summary: This state was never reset when we switched to doing reset in C instead of re-allocating.
Differential Revision: D4081049
fbshipit-source-id: 0b9ad70339ad906ad5219ad2679329cfe2fd7abc
Summary:
- Prevent the GC from collecting MeasureInternal in order to call managed MeasureFunction properly from unmanaged
- TestMeasureFuncWithDestructor will fail without the fix
- Avoid new as C implementation
Reviewed By: emilsjolander
Differential Revision: D4080765
fbshipit-source-id: d58fa18f6f74012aeda5dd15dfa7ceb0b64584d0
Summary: Many layout systems query the padding after calculation to as it is needs to be propagated to the underlying view system on the platform. However most nodes have no padding set on them so going 4-6 times through JNI layer to figure this out is a waste of time.
Differential Revision: D4080909
fbshipit-source-id: 7eb1885c615191055aa21e3435c6fbc652b883ae
Summary: There is no reason to malloc a list of 4 child pointers for every CSS node eagerly. Instead, we malloc the list (preserving the default size of 4) when we try to put stuff in it.
Reviewed By: emilsjolander
Differential Revision: D4078012
fbshipit-source-id: 7cdcab03ec4067550a5fee5e1baea14344f3a8f9
Summary: sleeping in the measure function was done to ensure we were not regressing in double measure calls. This was before we have CSSLayoutMeasureCacheTest though. Let's switch over benchmark to purely benchmark the algorithm and not simulate measure time.
Reviewed By: swolchok
Differential Revision: D4078186
fbshipit-source-id: e1c16806b3c8714e223e1cfcb6c43846f8f6bbb2
Summary:
This PR leads to removing the children from the end. [So we don't have the overhead of copying them to the front](dcaef7ecb0/CSSLayout/CSSNodeList.c (L62)).
Closes https://github.com/facebook/css-layout/pull/233
Reviewed By: emilsjolander
Differential Revision: D4075905
Pulled By: splhack
fbshipit-source-id: d8b460badb01bfc6ea647004c799395b9cab9e7c
Summary:
- Update CSSNodeFree to unlink parent and children for C#, Java and Objective-C bindings finalizer.
- [C#] Fix build (Fix#232)
- [C#] Add Clear API for convenience as CSSNodeFreeRecursive.
- [C#] Revise and add unit tests
Reviewed By: emilsjolander
Differential Revision: D4069655
fbshipit-source-id: 1fd764059784d7968af38b6aaf7fb6f70fdee8ee
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: Remove duplicate functions calls. Using instruments I could see a 5% perf increase from this change.
Reviewed By: gkassabli
Differential Revision: D4068140
fbshipit-source-id: 91261afb73e1c5e23c2cfc84df6ecc5c844a4e78
Summary: The current implementation was made out of simplicity and to keep the same API as before. Now that the java version of csslayout is deprecated it is time to change the API to make the calls more efficient for the JNI version. This diff with reduce allocations as well as reduce the number of JNI calls done.
Differential Revision: D4050773
fbshipit-source-id: 3fd04c27f887a36875e455b5404a17154ac18f91
Summary: Instead of having different lifetimes for java and c memory we can can tie them together and make them much easier to manage. This also leads to automatically pooling native memory if pooling java memory.
Differential Revision: D4051454
fbshipit-source-id: 8f5d010be520b3d1c981a7f85e5e6d95773ea6c1
Summary: It doesn't make sense to have a getter for the shorthand as it is the computed flexGrow and flexShrink values that you should care about.
Reviewed By: gkassabli
Differential Revision: D4064674
fbshipit-source-id: 69935b85042020b4e8c61a393c1be8f4d42a6674
Summary: when setting both flex and flexGrow then flexGrow should override flex even though flex was setter after.
Reviewed By: gkassabli
Differential Revision: D4064696
fbshipit-source-id: db2d4b8e60209f0a9eed6794a167b85e453be41c
Summary:
- Update README for gentest
- Fix gentest.rb for the right working dir
Reviewed By: emilsjolander
Differential Revision: D4065863
fbshipit-source-id: 5c6bd9d18779c05c1de24c06a83b148889facb6b
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:
When using CSS-Layout in a C# UWP project in x86, by default the MSVC compiler defaults the delegate calling convention to cdecl, while .NET assumes that all delegates are declared using stdcall. This causes a problem when invoking such as this error:
```
Run-Time Check Failure #0 - The value of ESP was not properly saved across
a function call. This is usually a result of calling a function declared with one
calling convention with a function pointer declared with a different calling
convention.
```
This PR changes the calling convention in the C# code to reflect cdecl by using the `UnmanagedFunctionPointer` attribute and setting the calling convention to `CallingConvention.Cdecl`.
```csharp
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate CSSSize CSSMeasureFunc(
IntPtr context,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode);
```
I have updated all calls as well to other functions. I
Closes https://github.com/facebook/css-layout/pull/231
Reviewed By: emilsjolander
Differential Revision: D4063437
Pulled By: splhack
fbshipit-source-id: b1069a1b9f675d2623a64a1c5f3189292a18a646
Summary: ryandm pointed out that `use_cxx_library` is necessary for fbcode overrides. And that's also true for fbandroid now.
Reviewed By: ryandm
Differential Revision: D4053192
fbshipit-source-id: 453e77df6f31b9bf6b2d221d7def8361e2966ff2
Summary:
Originally, we thought that skipping the measurement of views that were hidden would be a nice optimiatzion. Upon further review, we saw that according to Apple's `UIView` documentation:
> A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual.
So, to keep parity with common iOS layout APIs, we are going to size and layout views, even if they are hidden.
Reviewed By: emilsjolander
Differential Revision: D4051225
fbshipit-source-id: 0794cbad293a7de83d109dad2b3983d83845d145
Summary: Fixup format file for hopefully the last time in a while and re-format code
Reviewed By: gkassabli
Differential Revision: D4044545
fbshipit-source-id: 60ebb73cfdd9dbc9b5fae62ddebf37e9b1e6eecf
Summary:
- CSSLayoutSetLogger
- Problem: Unity or other logging system can't use printf output
- Solution: Add CSSLogger to pass CSSNodePrint result to UnityEngine.Debug.Log or other logging system via CSSLogger function for debugging purpose
Reviewed By: emilsjolander
Differential Revision: D4027044
fbshipit-source-id: 90e2e449260888770f71fa7ea790ca9764d91c44
Summary: Flex basis should override height/width. Not the other way around.
Reviewed By: gkassabli
Differential Revision: D4029374
fbshipit-source-id: bc3c72879f3937a50bf8a636b547adc7b9a4f5a7
Summary: Use typedefs from header for print and measure functions
Reviewed By: gkassabli
Differential Revision: D4036421
fbshipit-source-id: 01f15cb840363850970e6a60e661af06fd6ec9e0
Summary:
The flag to use in fbandroid is `-Duses_native_libraries` passed in via `vm_args`
In `fbandroid/third-party/build-tools/java/java.sh` looks for this flag to override the default java with the fbcode runtime java.
Reviewed By: ryandm
Differential Revision: D4024857
fbshipit-source-id: 0ace0ee94fea32376a24004582556fa1d7d2e222
Summary: If we ever add more cases to an enum the compiler would not complain if we used default.
Reviewed By: gkassabli
Differential Revision: D4036440
fbshipit-source-id: f5ef4c8afff0f353de50681ad304878f90255fef
Summary: Prefer inline style to computed style as inline style should be the source of truth and computed style may differ
Reviewed By: gkassabli
Differential Revision: D4029373
fbshipit-source-id: 39ce9d577f295c2361dc384212d7467418c63c33
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
Summary: using `IS_THIS_FBOBJC` will break the tests in the open-source repo. This fixes Facebook builds and open source builds.
Reviewed By: WaseemTheDream, mzlee
Differential Revision: D4025580
fbshipit-source-id: 8280520a63134744fd24518aa6f45423aa0ecd03
Summary: Now that we have some tests, lets run them.
Reviewed By: emilsjolander
Differential Revision: D4023765
fbshipit-source-id: 9f2fa723dc9a33f12c0470b782d6329b432546fa
Summary: Gate it with `THIS_IS_FBOBJC` for now - the better solution is gating with fb_xplat_cxx_library and fb_xplat_cxx_test
Reviewed By: dshahidehpour
Differential Revision: D4024973
fbshipit-source-id: 2ce744fd67630b39b0498d0479a034d0b05c68ed
Summary: Wrote some tests to make sure the associated objects we use for layout live and die with the objects. This was worthwhile because it made me realize UIView+CSSLayout wasn't enabled to ARC. As a result, my tests were failing because they weren't explicitly deallocing nodes.
Reviewed By: rnystrom
Differential Revision: D4023324
fbshipit-source-id: 5356cf4f0522582d75f83b5eb2193d9bc8d63aee
Summary: `sizeThatFits:` can be expensive, this optimizes our measuring function so that we do not call it if we know that we are going to use the exact height and width that were passed-in.
Reviewed By: rnystrom
Differential Revision: D4023715
fbshipit-source-id: dc02703b50bafd168ffab62ed98a7f6342100cc9