Commit Graph

766 Commits

Author SHA1 Message Date
Emil Sjolander
033658196f JNI version is the default, its name should reflect that
Summary: JNI version is the default, its name should reflect that

Reviewed By: lucasr

Differential Revision: D3992777

fbshipit-source-id: cdd4cc58f3c15b5db1158f6f794394eb5c44a44d
2016-10-12 03:53:04 -07:00
Emil Sjolander
136ec25e8c Remove xcode_public_headers_symlinks from open source
Summary: Remove internal xcode_public_headers_symlinks flag from open source in hope to fix travis builds.

Reviewed By: lucasr

Differential Revision: D3992698

fbshipit-source-id: 1bd19bdd18d1bdfff595c19475bb2adc23d95335
2016-10-12 03:22:42 -07:00
Emil Sjolander
62dba4c741 Clearly mark java CSSNode as deprecated. It will go away very soon
Summary: Clearly mark java CSSNode as deprecated. It will go away very soon.

Reviewed By: lucasr

Differential Revision: D3992775

fbshipit-source-id: b3ceca277e5c7426eb51f8cbeacf5e2fe451c6ec
2016-10-12 02:52:56 -07:00
Emil Sjolander
871a7cf310 Move csharp tests into csharp folder
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
2016-10-11 07:08:10 -07:00
Emil Sjolander
cdf4ee1e59 Move benchmark buck file into benchmark directory
Summary: buck rules are not meant to be in the root buck file but instead next to source files. This diff moves benchmark rule into benchmark folder.

Reviewed By: lucasr

Differential Revision: D3992992

fbshipit-source-id: 34782ff73bbd5b799d83d0f01b553bfab928f1df
2016-10-11 05:52:50 -07:00
Emil Sjolander
588d2c91ba Remove unused buck rule
Summary: CSSLayoutTestUtils doesn't exist anymore

Reviewed By: lucasr

Differential Revision: D3992982

fbshipit-source-id: 427270e5a164974a8e964a4b23461b18d9b91066
2016-10-11 05:07:40 -07:00
Emil Sjolander
f61fbd269e Add finalizer to release any unreleased native memory
Summary: Ensure all native memory is released once gc deallocates the java object reference.

Reviewed By: lucasr

Differential Revision: D3992759

fbshipit-source-id: f648b72ead5bdb7257a5197496b19795f71f3788
2016-10-11 04:52:49 -07:00
Emil Sjolander
d506e6ab94 Enable running within robolectric
Summary: Add some dependencies to enable running the native version of csslayout within robolectric internally.

Reviewed By: lucasr

Differential Revision: D3960840

fbshipit-source-id: 08a45f7299b04f70f643b0c9b95da13f90690dd8
2016-10-08 06:22:50 -07:00
Kazuki Sakamoto
56f6efdecf Introduce CSSAssertSetFailFunc and CSSAsserFail to throw managed exception
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
2016-10-07 12:38:08 -07:00
Kazuki Sakamoto
90844d62c5 WeakReference for parent
Summary: - Use WeakReference for parent to avoid circular reference although GC will treat it

Reviewed By: emilsjolander

Differential Revision: D3982520

fbshipit-source-id: b0f6764aa4df3da53be51f6cb4fe2994d989afdf
2016-10-07 11:23:00 -07:00
Kazuki Sakamoto
c233bafeb2 Introduce CSSNodeGetInstanceCount API
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
2016-10-07 11:23:00 -07:00
Kazuki Sakamoto
b57abb2f60 Remove unused GCHandle
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
2016-10-07 11:22:59 -07:00
Emil Sjolander
56279110c0 Resolve some differences between CSSNode and CSSNodeJNI
Summary: This diff resolves some differences in behaviour between jni and java css nodes. This ensures certain test cases pass with both implementations.

Reviewed By: lucasr

Differential Revision: D3960755

fbshipit-source-id: 3e13a9435208851a96a619c07625ef2a5402f5ec
2016-10-07 05:22:45 -07:00
Kazuki Sakamoto
01115b8bbd Add unittest
Summary: - Unittest for P/Invoke integration

Reviewed By: emilsjolander

Differential Revision: D3977114

fbshipit-source-id: 11f6bf747898433226c920997839e938734cbd77
2016-10-06 06:08:06 -07:00
Kazuki Sakamoto
47bd1bb943 Align C# implementation with Java and Dispose pattern
Summary:
- Align C# implementation with Java JNI implementation
  - AssertNativeInstance
    - is this instance disposed?
    - does this instance have native instance pointer?
- Align Dispose and destructor with Dispose pattern
  - https://msdn.microsoft.com/en-us/library/fs2xkftw(v=vs.110).aspx

    if (disposing)
    {
      Free maanged objects here
    }
    Free unmanaged objects here
    disposed = true;

Reviewed By: emilsjolander

Differential Revision: D3977015

fbshipit-source-id: 023cf5b15aacfada14a85c321576aa81d7f95125
2016-10-06 06:08:05 -07:00
Kazuki Sakamoto
2870d3ce4d Remove .dll from DllName for other platforms
Summary:
- Different platforms have different naming conventions
  - http://www.mono-project.com/docs/advanced/pinvoke/#library-names
- Unity iOS requires special name `__Internal`
  - https://docs.unity3d.com/Manual/PluginsForIOS.html

Reviewed By: emilsjolander

Differential Revision: D3976369

fbshipit-source-id: 4c1d7fe226c5c2a89531ee1c2ee8b47df847b3e4
2016-10-06 06:08:05 -07:00
mattpodwysocki
23f2878808 rocket: fix P/Invoke sig for bool
Summary:
Fixes the `bool` marshaling issue as describe on [MSDN](https://blogs.msdn.microsoft.com/jaredpar/2008/10/14/pinvoke-and-bool-or-should-i-say-bool/) so C# will now act properly.
Closes https://github.com/facebook/css-layout/pull/226

Reviewed By: IanChilds

Differential Revision: D3967349

Pulled By: emilsjolander

fbshipit-source-id: f61d3bb39eb1b0b6e749629825234615b425e930
2016-10-05 02:37:55 -07:00
Hoa Dinh
11f85ce91e create symlinks in xplat
Summary: In the libraries where headers symlinks are required, we enable them.

Reviewed By: skotchvail

Differential Revision: D3943274

fbshipit-source-id: c7ec741af020a60bb7c39b10773cea58a33adc3e
2016-09-29 10:23:33 -07:00
Emil Sjolander
1f300a58fb Free memory used in tests to enable use of valgrind
Summary: Its very usefull to be able to run valgrind on the tests and benchmarks. We were previously not freeing test memory so valgrind output was very messy.

Reviewed By: javache

Differential Revision: D3937493

fbshipit-source-id: 23c6970d7769b081575d39de583ba954fc65a397
2016-09-29 04:22:47 -07:00
mattpodwysocki
dbf3b11946 Add C# example for css-layout CSSNode
Summary:
This PR adds the C# version of the `CSSNode` API calls where it currently has only Java and C versions.
Closes https://github.com/facebook/css-layout/pull/225

Reviewed By: lucasr

Differential Revision: D3936431

Pulled By: emilsjolander

fbshipit-source-id: 689cb359c204c6c52e04e031c66615fb04c001af
2016-09-28 03:23:26 -07:00
Emil Sjolander
3b1515f2b7 Fix bug introduced by D3886866
Summary: I accidentally turned the logic around when cleaning up some code. This was subtle and only caught a week later by a RN product engineer. This fixes the bug without reverting the rest of the code cleanup.

Reviewed By: lucasr

Differential Revision: D3923635

fbshipit-source-id: bfeb175bb40393be63cafb6a995b22701b87ffec
2016-09-27 10:22:59 -07:00
Emil Sjolander
6b16dc4060 Fix flex-end/flex-start RTL transpilation
Summary: Oops, when regexing start->left/right end->left/right I did not take into account flex-start and flex-end. Easiest solution is to regex back flex-left and flex-right into their correct values.

Reviewed By: lucasr

Differential Revision: D3930244

fbshipit-source-id: 20742cbc8e5f23af694e14584c7c3df89526876e
2016-09-27 08:52:44 -07:00
mattpodwysocki
9c93c7fc42 Removes unnecessary CSSLayoutContext param from CalculateLayout
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
2016-09-27 04:37:37 -07:00
Emil Sjolander
15d5cb0169 BREAKING - Fix unconstraint sizing in main axis
Summary:
@public
This fixes measuring of items in the main axis of a container. Previously items were in a lot of cases measured with UNSPECIFIED instead of AT_MOST. This was to support scrolling containers. The correct way to handle scrolling containers is to instead provide them with their own overflow value to activate this behavior. This is also similar to how the web works.

This is a breaking change. Most of your layouts will continue to function as before however some of them might not. Typically this is due to having a `flex: 1` style where it is currently a no-op due to being measured with an undefined size but after this change it may collapse your component to take zero size due to the implicit `flexBasis: 0` now being correctly treated. Removing the bad `flex: 1` style or changing it to `flexGrow: 1` should solve most if not all layout issues your see after this diff.

Reviewed By: majak

Differential Revision: D3876927

fbshipit-source-id: 81ea1c9d6574dd4564a3333f1b3617cf84b4022f
2016-09-26 06:22:39 -07:00
Christopher Chedeau
dba5faabb2 Syntax highlight C code in README
Summary: Closes https://github.com/facebook/css-layout/pull/221

Reviewed By: vjeux

Differential Revision: D3914024

Pulled By: emilsjolander

fbshipit-source-id: 4cb0741e526dfefbbb41e8afed1c2f52823df08a
2016-09-23 09:22:38 -07:00
mattpodwysocki
ff8f17ac99 Introducing .NET version of css-layout using P/Invoke
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
2016-09-22 16:37:46 -07:00
Emil Sjolander
017fb2c734 Cleanup some multiline code
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886866

fbshipit-source-id: e19c1be4af58605933f90b5bf381008338be2236
2016-09-20 10:23:09 -07:00
Emil Sjolander
8fd14c710c Move justifyContent check into switch statement
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886861

fbshipit-source-id: 17ba2962016af34b5add3ce6d8355c9c305a35c0
2016-09-20 10:23:09 -07:00
Emil Sjolander
1415a5d7fd Remove empty line in function call
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886856

fbshipit-source-id: cf76ad9b6c85a62b9f2683618a6abe986d98acc2
2016-09-20 10:23:09 -07:00
Emil Sjolander
2592894d2d Remove use of snake_case
Summary: some general cleanup

Reviewed By: lucasr

Differential Revision: D3886849

fbshipit-source-id: eaf3f219fe1ccb717ba363dba0d2f475ffb204e3
2016-09-20 10:23:09 -07:00
Ben Hiller
dcaef7ecb0 Reverted commit D3856585
Summary: Add tests to check that measure modes are set correctly.

Reviewed By: lucasr

Differential Revision: D3856585

fbshipit-source-id: 421b368d2d2cbca1d2ba4d58d850836cb22128ac
2016-09-14 12:07:40 -07:00
Emil Sjolander
2dcd8b4074 Reverted commit D3855801
Summary:
@public
Introduce `overflow:scroll` so that scrolling can be implemented without the current overflow:visible hackiness. Currently we use AT_MOST to measure in the cross axis but not in the main axis. This was done to enable scrolling containers where children are not constraint in the main axis by their parent. This caused problems for non-scrolling containers though as it meant that their children cannot be measured correctly in the main axis. Introducing `overflow:scroll` fixes this.

Reviewed By: astreet

Differential Revision: D3855801

fbshipit-source-id: 3c365f9e6ef612fd9d9caaaa8c650e9702176e77
2016-09-14 11:37:51 -07:00
Emil Sjolander
1951242a52 Add tests for measure modes
Summary: Add tests to check that measure modes are set correctly.

Reviewed By: lucasr

Differential Revision: D3856585

fbshipit-source-id: 5fa407f149b1c081503b4ad7aa5f0203ec5b1cc0
2016-09-14 09:07:44 -07:00
Emil Sjolander
d4121401d7 BREAKING - Fix unconstraint sizing in main axis
Summary:
@public
Introduce `overflow:scroll` so that scrolling can be implemented without the current overflow:visible hackiness. Currently we use AT_MOST to measure in the cross axis but not in the main axis. This was done to enable scrolling containers where children are not constraint in the main axis by their parent. This caused problems for non-scrolling containers though as it meant that their children cannot be measured correctly in the main axis. Introducing `overflow:scroll` fixes this.

Reviewed By: astreet

Differential Revision: D3855801

fbshipit-source-id: 6077b0bcb68fe5ddd4aa22926acab40ff4d83949
2016-09-14 09:07:44 -07:00
Emil Sjolander
0be3b1013f Remove legacy test suite
Summary: Now that gentest has been used to cover all flexbox properties as well as some internal behavior I thought it was time to remove the old CSSLayoutTest.cpp. This removes a huge amount of previously regex transpiled code in favor of the new test suite which does more fine grained assertions and uses the public api. Given that RTL support was added to gentest now I feel confident that the new test suite covers all and more cases than the old one.

Reviewed By: lucasr

Differential Revision: D3863095

fbshipit-source-id: a2c4f87cd2263b4cc1fcdec4f2a0964f0696472f
2016-09-14 08:52:44 -07:00
Emil Sjolander
21a05417cd Generate RTL version of tests
Summary: Generate RTL versions of css-layout tests

Reviewed By: lucasr

Differential Revision: D3863081

fbshipit-source-id: df4debb3c1e371425d7c297f8d013b8042ad1e0e
2016-09-14 08:52:44 -07:00
Emil Sjolander
8fcb265830 Make generated test input more copy pastable
Summary: previously when copying in a test inout into an editor the user of gentest needed to remove the ` * ` prefix. This was annoying so this diff fixes that by removing that from gentest.

Reviewed By: lucasr

Differential Revision: D3862943

fbshipit-source-id: 06bd3ee3fa3f85cc44b6ea1d67cf3e91ed368791
2016-09-14 08:52:44 -07:00
Emil Sjolander
64fffcb8f3 Remove flex section from readme as it now supports all web properties
Summary: Update readme to reflect new support.

Reviewed By: lucasr

Differential Revision: D3856292

fbshipit-source-id: 012f3d1171330cc93c34de300153ff4bb1326819
2016-09-14 08:22:37 -07:00
Emil Sjolander
059384f277 Improve formatting of generated test code input
Summary: Make input html easier to read by indenting it and adding a space between children. The code to do this could very well be improved but it works for the current set of inputs.

Reviewed By: lucasr

Differential Revision: D3798087

fbshipit-source-id: 0d50ff276000f14ed078cf5ce2e7560ace285a6a
2016-08-31 11:22:42 -07:00
Emil Sjolander
57725e849a Copy fbjni library from react-native 2016-08-31 16:15:15 +01:00
Adam Comella
b51e832e4e Fix sizing of absolutely positioned nodes inside overflow:hidden parent
Summary:
When an absolutely positioned node appeared inside an overflow:hidden
parent, we were limiting its height. This is inconsistent with how
layout behaves on the web.
Closes https://github.com/facebook/css-layout/pull/218

Reviewed By: lucasr

Differential Revision: D3797285

Pulled By: emilsjolander

fbshipit-source-id: 98f98e77aa26edce86b9882c1cac284799b69a27
2016-08-31 08:07:59 -07:00
Emil Sjolander
d9191431ff Generate test for border (and fix gentest to include border offset)
Summary: Generate tests for border. This required modifying gentest to add the parent clientLeft and clientTop so that border width are accounted for in output.

Reviewed By: lucasr

Differential Revision: D3791286

fbshipit-source-id: 698cc2332a3f4118e1afdfbfd745ba824e8ec3f4
2016-08-31 08:07:59 -07:00
Emil Sjolander
251a499ba6 Generate tests for padding
Summary: Add generated tests for padding

Reviewed By: lucasr

Differential Revision: D3791211

fbshipit-source-id: 7fb4580c2ab8fba05532df746297c7a0ec6a734e
2016-08-31 08:07:59 -07:00
Emil Sjolander
3c33184dbb Add tests for margin
Summary: Generate tests for margins

Reviewed By: lucasr

Differential Revision: D3791131

fbshipit-source-id: e038ccd8b9314a8cc472e4f57d77c5f097228344
2016-08-31 08:07:59 -07:00
Emil Sjolander
583830b3df Fix and add tests for cssedge priority
Summary: While adding tests for CSSEdge I found that when setting both horizontal/vertical/all + left/right then left/right were not correctly overriding the others. This is now fixed and validated through added tests

Reviewed By: lucasr

Differential Revision: D3791106

fbshipit-source-id: 3e0c943f94218848a1fbf36e5ae48dbc720ea923
2016-08-31 08:07:59 -07:00
Emil Sjolander
36eaae88e0 Add tests for dirty propagation
Summary: Previous test for dirty propagation (last test in CSSLayoutTest.cpp) only tested one specific case. This tests much more of the bahavior to ensure that a vital optimization in css-layout is applied correctly.

Reviewed By: lucasr

Differential Revision: D3790968

fbshipit-source-id: af11a5924640cd1d497920cd97549603a9f147cc
2016-08-31 08:07:59 -07:00
Emil Sjolander
284634c880 Remove unnecesarry imports for tests
Summary: Minimal imports

Reviewed By: lucasr

Differential Revision: D3790919

fbshipit-source-id: 496078d8132252307ef2b3cb45472917a19d7750
2016-08-31 06:22:46 -07:00
Emil Sjolander
94bbbde930 Make use of fbjni
Summary: Use fbjni for safer and easier jni bridging. This diff includes all of fbjni as it currently does not live as its own open source project. The code was copied from the react-native open source distribution.

Reviewed By: ritzau

Differential Revision: D3764065

fbshipit-source-id: 7ff566af314dcb5279460c322c476ef6f6ed8131
2016-08-31 05:08:29 -07:00
Emil Sjolander
1051c39a59 Add tests for measure caching
Summary: Measure caching is a crucial optimization to css-layout which re-uses the output of the measure function if possible. This logic was never covered by tests.

Reviewed By: lucasr

Differential Revision: D3790915

fbshipit-source-id: 7fe6d5ebb1303d3186d24d15e401901bc7c8ecdb
2016-08-31 05:08:29 -07:00
Emil Sjolander
1abb2d1714 Change dynamic library extension depending on platform
Summary: don't hardcode .so extension. Different platforms use different extensions such as .dll, .so, .dylib

Reviewed By: lucasr

Differential Revision: D3785675

fbshipit-source-id: c326e330741e65a7f5d3cb4e4105894c582a2a12
2016-08-30 10:22:36 -07:00