Commit Graph

167 Commits

Author SHA1 Message Date
Devon Govett
221510cfcf Fix nits 2015-10-04 14:11:07 -07:00
Devon Govett
2636a4fbed Merge branch 'master' of github.com:facebook/css-layout into js-caching 2015-10-04 12:33:17 -07:00
Devon Govett
7b2140d7f9 Implement caching in the JS version 2015-10-04 11:45:54 -07:00
Devon Govett
5af85c5ef6 Inline some isUndefined calls 2015-10-03 23:14:04 -07:00
Devon Govett
0f5d3ae8f0 Don't use the in operator 2015-10-03 23:13:33 -07:00
Devon Govett
39b45c65c1 Speed up margin/padding/border lookups 2015-10-03 23:11:09 -07:00
Christopher Chedeau
e280a577ae Fix width being ignored when has a value of 0
8f6a96adbc added a test in isDimDefined that checks if `value > 0.0`, but unfortunately, it did not faithfully port the JavaScript version which is `value >= 0.0`. Sadly, no test covered this so it went unnoticed.
2015-09-25 13:10:21 -07:00
Lucas Rocha
765ff8463e Add fast path for simple stack layouts
Change the initial line loop to opportunistically position children in
the in container with simple stacking params i.e. vertical/horizontal
stacking on non-flexible STRETCH/FLEX_START aligned. This allows us to
skip the main and cross axis loops (Loop C and D, respectively)
partially and even completely in many common scenarios.

In my benchamrks, this gives us about ~15% performance win in many
setups.
2015-09-10 11:19:28 +01:00
Lucas Rocha
909c14117f Fix dimension check for STRETCH children
The correct check is on the layout state, no the style.
2015-09-10 11:19:28 +01:00
Lucas Rocha
9a149c83ff Avoid extra work when justifyContent is FLEX_START
Remaining space and between space only need to be updated when
justifyContent is not FLEX_START.
2015-09-10 11:19:28 +01:00
Lucas Rocha
2321165d53 Move condition to the non-redundant block
No need to check for RELATIVE position when position type is ABSOLUTE
and dimension is set.
2015-09-08 15:34:51 +01:00
Lucas Rocha
d1a49a4f0b Reduce search range of flexible children
We were traversing all children to only perform calculations/changes to
flexible children in order to avoid new allocations during layout. This
diff ensures we only visit flexible children during layout calculations
if any are present. We accomplish this by keeping a private linked list
of flexible children.
2015-09-08 15:34:51 +01:00
Lucas Rocha
793220faf8 Skip final loop on absolute children, if possible
There's no need to go through all absolute children at the end of the
layout calculation if the node at hand doesn't have any. This also
ensures only absolutely positioned children are traversed in the final
loop.
2015-09-08 15:34:51 +01:00
Lucas Rocha
996f2a03d5 Merge pre-fill loop into main line loop
There's no need to go through all children before starting the main line loop
as we'll visit all children in the former loop anyway. This diff merges the
pre-fill loop into the main line one to avoid an extraneous traversal on the
node's children.
2015-09-08 15:34:27 +01:00
Lucas Rocha
877a2838a6 Skip trailing position loop, if possible
There's no need to set the trailing position on left-to-right layouts
as the nodes will already have what we need (x, y, width, and height).
This means we still have an extra cost for reversed layout directions
but they are not as common as LTR ones.
2015-09-08 15:33:26 +01:00
Lucas Rocha
1ab785b7a3 Inline immutable values in layout algorithm
Store immutable values from the node being laid out to avoid unnecessary
method invocations during layout calculation. This gives us a 3%-5%
performance boost in my benchmarks on Android.
2015-09-08 15:15:52 +01:00
Lucas Rocha
06c708053f Change Java to use array indexes instead of methods
Method invocations are not entirely free on Android. Change the
generated Java code to use the same array-based approach used in
JS and C to compute dimensions, positions, etc instead of relying
too heavily on method invovations. As a bonus, the Java transpiler
becomes a lot simpler because the code is more analogous to the C
counterpart.

In my local benchmarks this change gives us a major performance
boost on Android (between 15% and 30%) depending on the device
and the runtime (Dalvik|Art).
2015-09-08 15:15:46 +01:00
Colin Eberhardt
f9bb74aedf Updated the public API to no-longer extract nodes 2015-08-13 09:56:16 +01:00
Colin Eberhardt
5653e4ef82 Fixed build and added distribution files to the repo 2015-08-11 21:22:27 +01:00
Colin Eberhardt
7f9b3afe33 Updated documentation
(And added missing change from previous commit!)
2015-08-11 17:56:21 +01:00
Lucas Rocha
524b44200a Expose the resolved direction in the node's layout 2015-05-20 11:35:01 +01:00
Pierre Renaux
019fc9b88c Merge remote-tracking branch 'upstream/master' 2015-05-17 21:54:30 +08:00
Lucas Rocha
03dfe7bb17 Implement (padding|border|margin)-(start|end) support 2015-05-14 17:43:33 +01:00
Christopher Chedeau
c3a2ddcce7 Merge pull request #84 from lukasreichart/master
If the measure function is defined: only return from execution of lay…
2015-05-14 08:48:04 -07:00
Nick Lockwood
9175721f07 Removed space before -- for consistency with code style. 2015-05-12 10:10:39 +01:00
Nick Lockwood
bf1d7eacfd Fixed spacing for wrapped elements 2015-05-12 09:54:02 +01:00
Lucas Rocha
36a46673f9 Support ROW_REVERSE, COLUMN_REVERSE and RTL direction 2015-05-11 11:24:21 +01:00
Lukas Reichart
fca176109d If the measure function is defined: only return from execution of layoutNode, when the node has no children. 2015-05-10 17:46:48 +02:00
Pierre Renaux
09f0c12a8f [src/Layout.js]: Cleaner line loop in <Loop E> (alignContent layout) ; 2015-05-10 00:20:29 +08:00
Pierre Renaux
c7fbf44474 'alignContent' defaults to 'flex-start' instead of 'stretch' ; 2015-05-10 00:19:30 +08:00
Pierre Renaux
cc5f772bff Style fixes ; 2015-05-10 00:19:29 +08:00
Pierre Renaux
68d029e460 [src/__tests__/Layout-test.js]: Added 16 test cases for each alignContent / alignItems combination - also includes alignSelf testing within the test data ; 2015-05-10 00:19:27 +08:00
Pierre Renaux
998fa1d6ba [Issue facebook/css-layout#78]: Implemented alignContent ; 2015-05-10 00:19:27 +08:00
Christopher Chedeau
3203e86155 Merge pull request #70 from tadeuzagallo/remove-dead-code
Remove unused code pointed by Xcode
2015-05-05 08:10:04 -07:00
Andrew Rasmussen
86c39b5e4f Revert "Ensure that flex children adopt their parent's cross-axis min dimension."
This reverts commit b8316413b3.

This was causing issues for existing components built with React
Native.. we need to investigate more in the future.
2015-05-01 12:16:47 -07:00
Andrew Rasmussen
5f52e947cb Fix layout for absolutely positioned nodes with absolutely positioned parents that have border and/or padding 2015-04-30 14:40:39 -07:00
Tadeu Zagallo
aad5efe938 Remove unused code pointed by Xcode 2015-04-24 16:45:49 +01:00
Russell Keith-Magee
b8316413b3 Ensure that flex children adopt their parent's cross-axis min dimension. 2015-04-07 10:52:15 +08:00
Russell Keith-Magee
6ca5fc5cb4 Cleanup of accessor logic in boundAxis. 2015-04-01 14:46:55 +08:00
Russell Keith-Magee
2b6844f00a Simplified logic distributing flex space. 2015-03-31 18:58:56 +08:00
Russell Keith-Magee
c523b7c404 Added support for min/max width and height constraints. 2015-03-31 17:32:54 +08:00
Tom Mulcahy
ddd7a899ac Make Java measure thread-safe. 2015-03-26 22:49:48 +00:00
daviskoh
9c71cc6d1f resolve merge conflicts 2015-02-17 21:30:41 -05:00
daviskoh
3a6e50db99 Address eslint errors:
* modify .eslintrc w/ globals & rules
* use judgement in deciding bet proj style & eslint recommendation
* make
2015-02-17 21:12:29 -05:00
Jimmy Miller
8fe8c15e6d Rework javascript api to match README 2015-02-15 20:56:37 -05:00
Alexander Gugel
b942b5ff60 Add UMD 2015-02-12 20:46:29 +01:00
daviskoh
cf9b841e33 Fix jshint issues
* add .jshintrc
* address semicolon errors
* ignore 'already defined' errors
2015-02-05 19:49:55 -05:00
Christopher Chedeau
9001a3d2ac do not infinite loop when there's an element bigger than the container with flex-wrap 2014-12-12 12:24:26 +00:00
Christopher Chedeau
10fb645777 Initial implementation of flexWrap 2014-12-12 12:03:31 +00:00
Christopher Chedeau
ab64a5b624 fix children with left 2014-12-11 15:58:45 +00:00