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
Summary: If views are hidden on screen, we don't want to bother including them in layout calculations.
Reviewed By: rnystrom
Differential Revision: D4022992
fbshipit-source-id: 2e93eb911f26223f305ef7ce788f86d050b83e4a
Summary: I'm going to make some changes, but first, I want to get testing setup.
Reviewed By: rnystrom
Differential Revision: D4022585
fbshipit-source-id: a48516faad0bcb1a9cf5610ab21da5ee099c6f16
Summary: Don't assume a node with a measure function is a leaf node
Reviewed By: gkassabli
Differential Revision: D4021096
fbshipit-source-id: 7e039239b1697a0ac42dce9f4b7e252a931bad7e
Summary: Rename C test target to match pattern of other test targets
Reviewed By: gkassabli
Differential Revision: D4014931
fbshipit-source-id: 2b4b831d6073214e8162a1d27b7478f3665a795f
Summary: This diff adds compatibility with Apple TVOS Buck build for CSSLayout library. Warning fixes are needed to ensure correct build
Reviewed By: emilsjolander
Differential Revision: D4001901
fbshipit-source-id: f095b4ac0ba91addb28d877b411ec27ecff4aad6
Summary: Update readme adding UIKit and fixing things that have changed
Differential Revision: D4015068
fbshipit-source-id: 213a60bea6f16ca01a4e613c8e3563f7c354ca8e
Summary:
The changed functions tripped -Wmissing-prototypes. (e.g.,
`void Foo();` doesn't count as a prototype in C. you need `void
Foo(void);`)
Reviewed By: mzlee
Differential Revision: D4012611
fbshipit-source-id: f56949d464e0ce602138b60f4abfd45b211be3b2
Summary: Add flexbox support to UIViews via a category
Reviewed By: dshahidehpour
Differential Revision: D4002873
fbshipit-source-id: f89de3acdf8fd89c7801918dcad34ba9011dd025
Summary: Move java buck rules out of the root buck file and into the java subfolder. This matches how buck should be used. Having one huge buck file is not best practice.
Reviewed By: lucasr
Differential Revision: D4008408
fbshipit-source-id: 5895c62cc8806d6a849e1b2cc6ea95c36b9d99b6
Summary: Remove tests for CSSNodeDEPRECATED. Java tests will be replaced by jni binding tests in upcoming diff.
Reviewed By: lucasr
Differential Revision: D3992821
fbshipit-source-id: d4877674c96f667f5acf92aab58af02aa27da4c2
Summary: Rename init() -> reinit() to be more in line with what it now does as the initiall init is done when constructing the object.
Reviewed By: lucasr
Differential Revision: D3992811
fbshipit-source-id: 61a10acc873ec028b2789007a400d89e62cf31d6
Summary: Rename reset() -> free() to be more in line with what it now does as the default implementation is JNI
Reviewed By: lucasr
Differential Revision: D3992808
fbshipit-source-id: 8428ae33268d1417ce8642b741e47150a17bf077
Summary: Don't require calling init() to used an allocated object. This makes more sense and is more in line with how jni in java is generally managed.
Reviewed By: lucasr
Differential Revision: D3992802
fbshipit-source-id: 06d65821f1802ed8f2b2db651cef69f6851803f2