Summary: Keeping enums in sync between all the different bindings is tedious and error prone. Getting one of the values in the incorrect order could lead to many hours of debugging as they are passed as ints to C. This diff adds a simple python script to generate these enums for all languages. This also makes it much easier to add support for more languages in the future
Reviewed By: gkassabli
Differential Revision: D4174263
fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10
Summary: We want to start experimenting with changes to the library in a more controlled and easier to measure manner. This diff adds the basics of an experiment layer to csslayout.
Reviewed By: gkassabli
Differential Revision: D4174260
fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd
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: Same as Java, it allows to use float and double values in Make arguments.
Reviewed By: emilsjolander
Differential Revision: D4163347
fbshipit-source-id: f373247b3f37e7940a66044000cca2935068decf
Summary: Add tests for checking C side asserts in managed
Reviewed By: emilsjolander
Differential Revision: D4154869
fbshipit-source-id: 5203db27eff963d46f188de448f607a24ed63fab
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:
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:
- 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: 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:
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: 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 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:
- 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: Move csharp tests into csharp/tests instead of tests. I feel like it makes more sense to have tests next to source. This is similar to how the C version has it as well.
Reviewed By: splhack
Differential Revision: D3993002
fbshipit-source-id: d9241f8ce7707c17a49c17fea2cce9959d52697d
Summary:
- Define CSS_ASSERT_FAIL_ENABLED for P/Invoke (Visual Studio project already has it)
- Pass managed delegate pointer to unmanaged side via P/Invoke.
- CSSAssertFail will call the managed delegate when assert failed.
- The delegate will throw managed exception.
Reviewed By: emilsjolander
Differential Revision: D3982084
fbshipit-source-id: 058a87c10ca89238362be4d8759cc00dd0c9b376
Summary: - Use WeakReference for parent to avoid circular reference although GC will treat it
Reviewed By: emilsjolander
Differential Revision: D3982520
fbshipit-source-id: b0f6764aa4df3da53be51f6cb4fe2994d989afdf
Summary:
- Add CSSNodeGetInstanceCount API to get the number of native instances.
- It makes testing easy.
Reviewed By: emilsjolander
Differential Revision: D3981990
fbshipit-source-id: 98005ae1fc21d4c8802f24030fff9ffb00bd292d
Summary:
- Unused _context GCHandle prevent calling CSSNode destructor.
- CSSNode C# impl will retain children node when calling CSSNodeInsertChild, so the lifetime of C# object is the same as the lifetime of native instance.
Reviewed By: emilsjolander
Differential Revision: D3981697
fbshipit-source-id: 71f0f7be97fd694d27934d7d07deb64ee08b2840
Summary:
Closes#222 for the `csharp` implementation which does not use the `CSSLayoutContext` parameter in the `CalculateLayout` method call.
Closes https://github.com/facebook/css-layout/pull/223
Reviewed By: lucasr
Differential Revision: D3918948
Pulled By: emilsjolander
fbshipit-source-id: 8708e08b226500727e33d131ed880bb7e077c08e
Summary:
This version of the css-layout project includes support for .NET projects. Up in the air is how many configurations of .NET projects we allow for, such as Portable Class Libraries, Universal Windows Platform, .NET Core, etc. Still needs integration with Buck.
Closes https://github.com/facebook/css-layout/pull/220
Reviewed By: lucasr
Differential Revision: D3909367
Pulled By: emilsjolander
fbshipit-source-id: aaaa9c4ff2d3452649f256c3268cf873cf33a0b9