Commit Graph

834 Commits

Author SHA1 Message Date
Dustin Shahidehpour
05ba3a2565 Do not measure the view if it is hidden.
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
2016-10-14 14:37:43 -07:00
Dustin Shahidehpour
89440f630f Add Testing to uikit.
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
2016-10-14 13:37:50 -07:00
Kazuki Sakamoto
832d07902e Modify unittest
Summary:
- Disable destructor tests in Unity Editor, seems GC is flaky.
- Use current native instance counts

Reviewed By: emilsjolander

Differential Revision: D4018951

fbshipit-source-id: a57f0e1fa5a46e7de0b88235124d437d20e4082b
2016-10-14 07:08:29 -07:00
Emil Sjolander
b45a7e3737 Don't assume a node with a measure function is a leaf node
Summary: Don't assume a node with a measure function is a leaf node

Reviewed By: gkassabli

Differential Revision: D4021096

fbshipit-source-id: 7e039239b1697a0ac42dce9f4b7e252a931bad7e
2016-10-14 04:37:53 -07:00
Emil Sjolander
14009ec470 Rename C test target to match pattern of other test targets
Summary: Rename C test target to match pattern of other test targets

Reviewed By: gkassabli

Differential Revision: D4014931

fbshipit-source-id: 2b4b831d6073214e8162a1d27b7478f3665a795f
2016-10-13 11:39:35 -07:00
Georgiy Kassabli
203e3dc9b8 Compatibility with Apple TVOS
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
2016-10-13 10:52:44 -07:00
Kazuki Sakamoto
7548164edb Clean up MeasureFunc and PrintFunc
Summary:
- Remove unneeded instance variables
- Simplify MeasureFunc call
- Add unittest

Reviewed By: emilsjolander

Differential Revision: D4013176

fbshipit-source-id: 4cdfa3ac3ad60a6bac5cda10644376ee9c46300b
2016-10-13 08:07:58 -07:00
Kazuki Sakamoto
722bfb9032 Align C# implementation with Java
Summary:
- Align C# implementation with Java JNI implementation
  - No need to call init(reinit)
  - Rename Initialize and Reset
- Add unittests

Reviewed By: emilsjolander

Differential Revision: D4009351

fbshipit-source-id: 191ddec30b0c8518eb0d76c0579afe909b673fac
2016-10-13 08:07:58 -07:00
Emil Sjolander
2a8a4e10c6 Update readme adding UIKit and fixing things that have changed
Summary: Update readme adding UIKit and fixing things that have changed

Differential Revision: D4015068

fbshipit-source-id: 213a60bea6f16ca01a4e613c8e3563f7c354ca8e
2016-10-13 06:22:53 -07:00
Scott Wolchok
8df9320f4c Fix build with -Wmissing-prototypes
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
2016-10-12 21:22:55 -07:00
Emil Sjolander
df6b4d3682 Add tests for java jni bindings
Summary: Add tests for java jni integration

Reviewed By: lucasr

Differential Revision: D4008411

fbshipit-source-id: c896a3925ff3f7fa368176a3d03c84eb7188ef60
2016-10-12 10:08:54 -07:00
Emil Sjolander
8939bcb96d UIView category
Summary: Add flexbox support to UIViews via a category

Reviewed By: dshahidehpour

Differential Revision: D4002873

fbshipit-source-id: f89de3acdf8fd89c7801918dcad34ba9011dd025
2016-10-12 09:37:42 -07:00
Kazuki Sakamoto
d3fc24e842 Implement SetPosition
Summary: Implement missing SetPosition method in CSSNode

Reviewed By: emilsjolander

Differential Revision: D4006153

fbshipit-source-id: 488263965c2b3b2bd46f3ac58575776a748e3eb9
2016-10-12 09:22:54 -07:00
Emil Sjolander
7f6b942146 Move java rules into java directory
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
2016-10-12 09:07:51 -07:00
Emil Sjolander
29fa232129 Remove tests for CSSNodeDEPRECATED
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
2016-10-12 06:07:42 -07:00
Emil Sjolander
41b64478c4 Rename init() -> reinit() to be more in line with what it now does
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
2016-10-12 03:53:04 -07:00
Emil Sjolander
23acf2156f Rename reset() -> free() to be more in line with what it now does
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
2016-10-12 03:53:04 -07:00
Emil Sjolander
1de914737a Automatically init native memory when allocating java wrapper
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
2016-10-12 03:53:04 -07:00
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