Summary: Add compile flag from CSSLayout to jni target as well
Reviewed By: passy
Differential Revision: D4248473
fbshipit-source-id: 18a163a3daedc56e98c7bdc38e10fc8626999f94
Summary: Remove deprecated java code and make use of CSSEdge instead of the now removed Spacing class.
Reviewed By: AaaChiuuu
Differential Revision: D4233198
fbshipit-source-id: 736d79be266e1b9f2d62e5fe6d901de47123cdc1
Summary: The Style prefix does not make sense in the java and c# api and only a few methods had it. This diff removes the last of those.
Reviewed By: splhack
Differential Revision: D4232920
fbshipit-source-id: 6e2ff21bbb7e0e441892023c14df579d1bc7aa49
Summary: Soloader is safer than System load library, retrying with System load library just hides errors
Reviewed By: lexs
Differential Revision: D4243906
fbshipit-source-id: e4d691c9c49f3b9316f67e39b9f277657d78fb3c
Summary: Add notice in readme to prepare open source for large renaming diffs.
Reviewed By: splhack
Differential Revision: D4240761
fbshipit-source-id: 4c8070a06c3ac009b67eb7bef5de11ce3ab3e4d8
Summary:
At least or x86_64 linux, it appears that you need position-independent
code is required in order to link against it. Otherwise you see errors
like this:
```
/usr/bin/ld: lib_sys.rlib(CSSLayout.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: lib_sys.rlib(CSSNodeList.c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
```
If I understand it correctly, you don't strictly need PIC for static libraries, but as soon as you want to link *other* dynamically linked library into it, it is required - which makes logical sense to me. Let me know if you want to enable this by default or leave it up to the developers to enable this if needed.
Closes https://github.com/facebook/css-layout/pull/263
Reviewed By: passy
Differential Revision: D4237009
Pulled By: emilsjolander
fbshipit-source-id: e73ea0ea22520758ec958a031d6e2ca62fdcda15
Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.
Reviewed By: gkassabli
Differential Revision: D4226734
fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag.
Reviewed By: gkassabli
Differential Revision: D4222910
fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
Summary: I found that if you move a subview to a different index, it would cause a crash in subsequent layout passes because the `CSSNodeRef` representing it was being re-inserted into the list. I spent a lot of time figuring out the best way to "diff" the view hierarchy from before and after, and I found the easiest implementation is also the most reliable. We can continue to optimize, but this is a great start.
Reviewed By: emilsjolander
Differential Revision: D4218623
fbshipit-source-id: 06253089492ac37ae4b94b7c30140ce6ed680ed2
Summary:
Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely can be further improved. I'm looking forward to your ideas.
Closes https://github.com/facebook/css-layout/pull/256
Reviewed By: splhack
Differential Revision: D4214168
Pulled By: emilsjolander
fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236
Summary:
Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values.
Closes https://github.com/facebook/css-layout/pull/257
Reviewed By: splhack
Differential Revision: D4213809
Pulled By: emilsjolander
fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2
Summary:
We currently have a bug in `UIView+CSSLayout.m` that you can repro in a scenario like this:
```
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setIncludeInLayout:NO];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setIncludeInLayout:NO];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setIncludeInLayout:YES];
[container addSubview:subview3];
[container css_applyLayout];
```
`subview3` (which is the only view whose is going to be included in layout calculation) is inserted at child index 2, instead of 0. This eventually can cause crash in CSSLayout.c because it will attempt access a child in the list which is null.
Reviewed By: emilsjolander
Differential Revision: D4215659
fbshipit-source-id: a615f50e51f85b15d3bdb437e55958865898b183
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213339
fbshipit-source-id: 5ca35ca307594f3419fd0dee81321d3c2e06710f
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213313
fbshipit-source-id: 2061a809202f7f948bff1b3ee8dc4c230692a223
Summary: Try to move more code out of the main measure function
Reviewed By: gkassabli
Differential Revision: D4213302
fbshipit-source-id: df4bc43848325e99ad338a2fa6d5c9404315b0e6
Summary: Implement aspect ratio as part of Yoga. Aspect ratio allows users of the library to specify the size of the undefined dimension in terms of an aspect ratio. See test cases for examples.
Reviewed By: gkassabli
Differential Revision: D4211458
fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d
Summary:
computed flex basis was incorrectly being reused in some circumstances between calls to caluclateLayout
also run format script.
Reviewed By: dshahidehpour
Differential Revision: D4207106
fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d
Summary:
```isnan``` is already defined in ```math.h``` (at least when using VS13) so there is no need to redefine it. it also is a nan for float and not for double opposed to ```_isnan```
Closes https://github.com/facebook/css-layout/pull/253
Reviewed By: emilsjolander
Differential Revision: D4199331
Pulled By: splhack
fbshipit-source-id: 139fb0efd68dd5df79bbaef863a8e8b9246c795d
Summary:
Use ```size_t```instead of ```unsinged long``` as this is the "offical" return type of ```strlen```. Is VS13 ```size_t``` is defined as ```unsigned long long``` which leads to a compiler warning.
Closes https://github.com/facebook/css-layout/pull/254
Reviewed By: emilsjolander
Differential Revision: D4199327
Pulled By: splhack
fbshipit-source-id: 5e1a91f282bf776e4d9f5806e6467dfe36c7a633
Summary:
- Add a convenience function to copy all style from one node to another.
- CSSNodeIsDirty will return true after this function if any style was changed in the destination node.
Reviewed By: emilsjolander
Differential Revision: D4188514
fbshipit-source-id: af8d7fb5e8688c64aea05ce7ad23fff9233fb441
Summary:
- Problem: Build error in Visual Studio since an array cannot have zero size.
- e6702e1168 (commitcomment-19839659)
- Solution: Add 1 until we'll have actual CSSExperimentalFeature value.
Reviewed By: emilsjolander
Differential Revision: D4191268
fbshipit-source-id: 53fdcc388292e76c2b97ad071f0d7c27d0613ecf
Summary:
When dealing with manual sizing in UIView's (or UIKit in general) we see a common pattern like so:
Below we have an example implementation of a view with two Labels that want to be stacked horizontally. If we don't pass a second string, we hide the second label and give up the available space to the first label. See below:
```
interface TitleSubtitleView : UIView
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;
end
implementation {
UILabel *_titleLabel;
UILabel *_subtitleLabel;
}
....
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
_titleLabel.text = title;
if (subtitle.length > 0) {
_subtitleLabel.hidden = NO;
_subtitleLabel.text = subtitle;
} else {
_subtitleLabel.hidden = YES;
}
}
- (CGSize)sizeThatFits:(CGSize)size {
const CGSize titleSize = [_titleLabel sizeThatFits:size];
CGSize subtitleSize = CGSizeZero;
if (!_subtitleLabel.isHidden) {
subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
const CGSize titleSize = [_titleLabel sizeThatFits:size];
_titleLabel.frame = CGRectMake(0, 0, titleSize.width, titleSize.height);
if (!_subtitleLabel.isHidden) {
subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
_subtitleLabel.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, subtitleSize.width, subtitleSize.height);
}
}
```
The problem is with the CSSLayout framework, as long as your view is in hierarchy, it's going to be allocated space during layout calculation. The only way to fix the view above would be to completely remove it from view hierarchy if it isn't being used. The problem is that adding/removing views from hierarchy is much less performant than hiding.
As a result, we need a way to tell the CSSLayoutKit library that even though a view is in hierarchy, we don't want to include it in layout. With this diff, we could change the class to look like this:
```
interface TitleSubtitleView : UIView
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;
end
implementation {
UILabel *_titleLabel;
UILabel *_subtitleLabel;
}
....
- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
_titleLabel.text = title;
_subtitleLabel.text = subtitle;
const BOOL subtitleHasText = subtitle.length > 0;
_subtitleLabel.hidden = !subtitleHasText;
[_subtitleLabel css_includeInLayout:!subtitleHasText];
}
- (CGSize)sizeThatFits:(CGSize)size {
const intrinsicSize = [self css_intrinsicSize];
return CGSizeMake(MIN(size.width, intrinsicSize.width), MIN(size.height, intrinsicSize.height)));
}
- (void)layoutSubviews {
[super layoutSubviews];
[self css_applyLayout];
}
```
Reviewed By: emilsjolander
Differential Revision: D4189897
fbshipit-source-id: 403d11d84d47691e3ce0b5ac18a180b0e4c104c4
Summary: When I try to use this in practice, I have come to realize that css_sizeThatFits will 99% return to you the constrainedSize that you pass it, thus making it useless. Instead, we replace it with a new API that will tell you the optimal size of the resolved layout. From this we can choose to use that size, or scale it down.
Reviewed By: emilsjolander
Differential Revision: D4191873
fbshipit-source-id: d36a2850448d9d82f97e5ef4c7397778c2a14094
Summary: Remove infra for dynamically downloading gtest as this fails like 50% of the time on travis. I'll manually push gtest as a submodule instead.
Reviewed By: gkassabli
Differential Revision: D4183033
fbshipit-source-id: 09a121b8ede7a5974a29b6692edc63bff79aece7
Summary: For some reason these tests don't pass when running in travis. They are still running internally so we should catch any regressions. We can remove this if we figure out what is causing travis to fail here but until now I would rather get travis to pass.
Reviewed By: dshahidehpour
Differential Revision: D4189251
fbshipit-source-id: a27d3390f6b6fdcac6a3312d02581bb64969fd4b
Summary:
- Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib.
- Fixed memory leaks in tests.
- Close#247
For example, to use dlmalloc with USE_DL_PREFIX
CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree);
Reviewed By: emilsjolander
Differential Revision: D4178386
fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b
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: If some test previous to this test fails to de-allocate a node we don't want this test to fail.
Reviewed By: dshahidehpour
Differential Revision: D4182179
fbshipit-source-id: 229dd5736d6d7b9c1b22b181e022c788584b9c17
Summary: Talked with emilsjolander offline, and we want to keep the prefixes standardized in this lib. Changing CLK prefixes to CSS.
Reviewed By: emilsjolander
Differential Revision: D4175634
fbshipit-source-id: 7152268b9312df3fdb8eaee7ce3f6baabc5de937
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: Java and csharp already use CSSWrap and not CSSWrapType. Let's consolidate and stick with the shorter of the two.
Reviewed By: gkassabli
Differential Revision: D4174257
fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592
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: There is a little bit of tidying that was needed for this class. The documentation was inconsistent in the header, the static functions were prefixed with underscores (discouraged by apple). Cleaned it all up.
Reviewed By: rnystrom
Differential Revision: D4167936
fbshipit-source-id: 6e9a6e7fb78e3cff290b867a1ac0d5dd5cc9de5b
Summary: Just firming up some stuff with more compiler flags.
Reviewed By: rnystrom
Differential Revision: D4168081
fbshipit-source-id: fced407f03944081bdd70cc28c57e3dc842ff7f0
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