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:
When trying to integrate this into an Xcode project that already included CSSLayout.[c|h], we were getting a linker error.
Upon digging in, I found out that Xcode was becoming confused because the imports of the uikit library and the c library are both `#import <CSSLayout/CSSLayout.h>`. So, it needed a new name.
Reviewed By: emilsjolander
Differential Revision: D4162621
fbshipit-source-id: b5f7624eb29f1b9eaebbed5104ec9ea8a12ad2e5
Summary: Currently travis logs indicate it is building with the wrong cxx platform. Explicitly set this to and ios simulator for ios tests
Reviewed By: dshahidehpour
Differential Revision: D4162159
fbshipit-source-id: 50f563132456ee4ba4e5b3b4b1f50b636cb94306
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: Pointed out by the Xcode analyzer
Reviewed By: emilsjolander
Differential Revision: D4159938
fbshipit-source-id: 8b9ff3896c0e222e8e89546881129214bc6ba566
Summary: It was always a mistake to have a measure function here but the recent addition of an assertion made us notice it.
Reviewed By: splhack
Differential Revision: D4156754
fbshipit-source-id: 98fcea6e233cb4f5706ebca37028c8d67edb4c09
Summary: Add tests for checking C side asserts in managed
Reviewed By: emilsjolander
Differential Revision: D4154869
fbshipit-source-id: 5203db27eff963d46f188de448f607a24ed63fab
Summary: Travis builds have been broken for a while. This diff fixes some of the issues surrounding bad buck file configuration as well as missing jni.h file.
Reviewed By: astreet
Differential Revision: D4148724
fbshipit-source-id: 1e284db61280326a4bcbb9337e804a4804348aa6
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:
@public
The goal of this diff is to have assertion failures show up as error logs on Android. To do this, I updated the logging API to take calls with log levels. We now have to pass around va_list unfortunately since you can't re-expand or pass along var-args to a subcall.
Reviewed By: emilsjolander
Differential Revision: D4140898
fbshipit-source-id: e0eb9a1f0b08a7d90a8233f66bb857d5b871b6ad
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: Within `UIView+CSSLayout`, we often nil out the measure function of a node because view hierarchy can often change. Unfortunately, this causes us to hit an assert which crashes the app. Instead, lets the measure func to be set to NULL, regardless of how many children a node might have.
Reviewed By: emilsjolander
Differential Revision: D4148727
fbshipit-source-id: 79a0f3ef1bf7b1dce9a14de96f870e35c042b78b
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.
Reviewed By: gkassabli
Differential Revision: D4147298
fbshipit-source-id: 8416508a31e8d317bf59d956abdbe5760b55bb6d
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.
Reviewed By: gkassabli
Differential Revision: D4147298
fbshipit-source-id: 51152e57eff8e322a833a6d698c30f8c5e2dcc35
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: Not sure why this didn't catch during my testing, but, this causes a build error. #accept2ship
Reviewed By: emilsjolander
Differential Revision: D4143108
fbshipit-source-id: 01c35c5b91767c95485d615eb06e836b023e125a
Summary: For some reason I didn't get a signal of this breakage. Fixing unit tests.
Reviewed By: emilsjolander
Differential Revision: D4140327
fbshipit-source-id: 95049b510a8869b6f68cc841e7f8731364417af9
Summary: css-layout will only call measure which it is unsure of the size of a node so it will never call measure with both modes equal to exact.
Reviewed By: dshahidehpour
Differential Revision: D4142193
fbshipit-source-id: fb8423cf0d45852ecb9df8fed042b25d1a443eea
Summary:
Not all platforms have gtest death tests. There is a define to check for that.
Bracketed the relevant tests with the define.
Reviewed By: youerkang
Differential Revision: D4141823
fbshipit-source-id: 1396657f3ee83853fcda85d5a51708d4e77642cb
Summary: We don't want to expose this in our first usage. Lets kill it.
Reviewed By: emilsjolander
Differential Revision: D4140377
fbshipit-source-id: 0c53845ec65466692b847a5ce40c3b9823dd9557
Summary: You can lose a lot of performance on UIView's if they are not pixel-aligned. This protects it from happening in views which use css-layout.
Reviewed By: emilsjolander
Differential Revision: D4140306
fbshipit-source-id: 53493c08c084a7e3dcd4e05f6a665a99340ea5a6
Summary:
The inline keyword is available only in C++. The __inline and __forceinline keywords are available in both C and C++. For compatibility with previous versions, _inline is a synonym for __inline.
https://msdn.microsoft.com/en-us/library/z8y1yy88(v=vs.120).aspx
Closes https://github.com/facebook/css-layout/pull/239
Reviewed By: astreet
Differential Revision: D4138941
Pulled By: emilsjolander
fbshipit-source-id: cb59dc91ef285e5378036c4912217fd4ec8d9f79
Summary: As I've begun to integrate this into the codebase, I've found that sometimes our layouts are affected by bad implementations of sizeThatFits:. For example, in certain configurations of UILabel it won't take clipping into account and return a size that is much larger than the max size we requested. This adds some checks to make sure we never return a size that is larger than the one specified by `_measure`. This also fixes the bug where `CSSMeasureModeExactly` won't be applied if the measure mode for other parameter is node `CSSMeasureModeExactly`.
Reviewed By: emilsjolander
Differential Revision: D4131195
fbshipit-source-id: 4659fd83892a2c149b3b70733b06b19217507bf9
Summary:
@public
In the JNI portion of CSSLayout, there's a subtle bug where we were caching the jmethodid of the 'measure' of the first object that had measure called on it. However, if that class had overriden measure, then the jmethodid would be specific to that subclass's implementation and would not work for other classes. Conversely, if a regular CSSNode had been called first, then the super method would be called on the subclass instead of the proper overriden method.
Since there's not really a reason to overriden measure anyway (since you can just provide a different measure function), it's safest to just mark it final and explicitly cache the appropriate methodid
Reviewed By: emilsjolander
Differential Revision: D4132428
fbshipit-source-id: 6fb51597d80f1c03681e6611153b52b73b392245
Summary:
@public
We don't need to allocate a list for every node since leaf nodes don't have children.
Reviewed By: emilsjolander
Differential Revision: D4130818
fbshipit-source-id: 80d3e98fce9d2daa0676fd1cbed0e81edcf7adb3
Summary:
@public
Instead of silently ignorning non-leaf nodes with measure functions, we should assert that we don't create those kinds of trees.
Reviewed By: emilsjolander
Differential Revision: D4130770
fbshipit-source-id: a3ef10a2e63bbc12b5aa07977e4b84c8d59e3ffe
Summary: flex is just shorthand for flexBasis, flexGrow and flexShrink, and I don't want to expose overflow yet, so, removing them from the API.
Reviewed By: ryanolsonk
Differential Revision: D4126773
fbshipit-source-id: e3b9ef714832cb5665bd20d7fa92f97a266c9210
Summary: Currently, when we try to remove a child from a node, that node is mark dirty //regardless of whether or not anything was actually removed//. This fixes it.
Reviewed By: gkassabli
Differential Revision: D4125453
fbshipit-source-id: 745cfc55269415fea106a80c72401eb3074f2d31
Summary: This exposes an API so people can find out the resulting size of a layout calculation without changing the frame of the view.
Reviewed By: emilsjolander
Differential Revision: D4124630
fbshipit-source-id: f2b28d8a5474857cb1c92e021a1f161806826cda
Summary: We need to expose CSSLayout caching check to CKFlexboxComponent to enable performant bridging to CKComponentKit
Reviewed By: emilsjolander
Differential Revision: D4124705
fbshipit-source-id: 23284967900585fa20dcb51c9cc1bee829b32975
Summary: With the current implementation, as long as you had set a value on usesFlexbox (YES or NO), it would return YES. This fixes it.
Reviewed By: amonshiz
Differential Revision: D4124485
fbshipit-source-id: 32fe4ec0109b5c8678a112f9d4295bd17a6f6dc2
Summary: We don't want people to somehow change the underlying cnode on our CSSNodeBridge. Making it readonly.
Reviewed By: rnystrom
Differential Revision: D4124496
fbshipit-source-id: f88ed82c1df17d401aeca6f6341e429c95e55624
Summary:
Even so the problem of #236 has been fixed via ced779b there is still a case where you have a out of bound array access of undefined behaviour. This PR prevents the out of bound access of the underlying c array. The out of bound access happens if you already have 4 subViews and add another one. Then you will access CSSNodeGetChild with 4 which points into uninitialized memory.
Closes https://github.com/facebook/css-layout/pull/237
Reviewed By: dshahidehpour
Differential Revision: D4107743
Pulled By: emilsjolander
fbshipit-source-id: 0f21397f3a77308369acfea7327733f74eb72e00
Summary: Previously, we would preallocate Node's with a child list of 4. We recently removed that logic (see diff below), and as a result, if you tried to access a Node's list of children before it had been allocated, you would crash. I added a simple check to protect from crashes, the operation of the check is O(1) so we shouldn't see a perf hit.
Reviewed By: emilsjolander
Differential Revision: D4104093
fbshipit-source-id: cd7b09818759aa76415b97e241f1a6746a2bc50c
Summary: Simplify logic for what value to return in smaller functions with a preference for ternary operator where possible.
Reviewed By: gkassabli
Differential Revision: D4101772
fbshipit-source-id: 626df10c0fc76278c330c86be4dc82fdda5f5156
Summary: This list can only contain CSSNodeRefs so don't use void*
Reviewed By: gkassabli
Differential Revision: D4101773
fbshipit-source-id: 8a5c9066da796967bd02ce6b1fc74ff40e15dfe1
Summary: Add a more complex benchmark which actually take a couple milliseconds to perform. This makes it easier to see if optimizations have any effect. More styles should be added later to make sure the benchmarks covers most of the csslayout code.
Reviewed By: gkassabli
Differential Revision: D4101780
fbshipit-source-id: 6bdf703edfbe64c47c77e04ef1ca946f4b75d093
Summary: Since these functions are private and only used in the implementation file, we don't need to declare them beforehand.
Reviewed By: emilsjolander
Differential Revision: D4088488
fbshipit-source-id: 738175a4aae27d88d32f8c2cf6b47a4f6ae32aab
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: Set layout outputs on CSSNode from C after layout calculation finishes instead of relying on calling jni gettings from java code. This should be much more efficient as it avoids a lot of jni overhead and also allows for calling getLayoutWidth() etc multiple times without incurring a penalty.
Reviewed By: lexs
Differential Revision: D4077968
fbshipit-source-id: bce86ba610cd5ae36cfb45d78b2609c63a14cfa3
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