Commit Graph

102 Commits

Author SHA1 Message Date
Adam Comella
f3dd51ab97 Alter layout engine to conform closer to W3C spec
The primary goals of this change are:
  - Better conformance to the W3C flexbox standard (https://www.w3.org/TR/css-flexbox-1/)
    and a clear articulation of the areas where it deviates from the spec.
  - Support for flex-shrink.
  - Conformance with layout effects of "overflow: hidden".

Specifically, here are the limitations of this implementation as compared to the W3C
flexbox standard (this is also documented in Layout.js):
  - Display property is always assumed to be 'flex' except for Text nodes, which
    are assumed to be 'inline-flex'.
  - The 'zIndex' property (or any form of z ordering) is not supported. Nodes are
    stacked in document order.
  - The 'order' property is not supported. The order of flex items is always defined
    by document order.
  - The 'visibility' property is always assumed to be 'visible'. Values of 'collapse'
    and 'hidden' are not supported.
  - The 'wrap' property supports only 'nowrap' (which is the default) or 'wrap'. The
    rarely-used 'wrap-reverse' is not supported.
  - Rather than allowing arbitrary combinations of flexGrow, flexShrink and
    flexBasis, this algorithm supports only the three most common combinations:
      - flex: 0 is equiavlent to flex: 0 0 auto
      - flex: n (where n is a positive value) is equivalent to flex: n 0 0
      - flex: -1 (or any negative value) is equivalent to flex: 0 1 auto
  - Margins cannot be specified as 'auto'. They must be specified in terms of pixel
    values, and the default value is 0.
  - The 'baseline' value is not supported for alignItems and alignSelf properties.
  - Values of width, maxWidth, minWidth, height, maxHeight and minHeight must be
    specified as pixel values, not as percentages.
  - There is no support for calculation of dimensions based on intrinsic aspect ratios
    (e.g. images).
  - There is no support for forced breaks.
  - It does not support vertical inline directions (top-to-bottom or bottom-to-top text).

And here is how the implementation deviates from the standard (this is also documented in
Layout.js):
  - Section 4.5 of the spec indicates that all flex items have a default minimum
    main size. For text blocks, for example, this is the width of the widest word.
    Calculating the minimum width is expensive, so we forego it and assume a default
    minimum main size of 0.
  - Min/Max sizes in the main axis are not honored when resolving flexible lengths.
  - The spec indicates that the default value for 'flexDirection' is 'row', but
    the algorithm below assumes a default of 'column'.
2016-04-26 19:45:58 -07:00
Pieter De Baets
b157ab4a00 Reset child position/sizes before calculating layout 2016-03-29 11:05:53 +01:00
Alex Bogomazov
425345aa8d Redo layout of 'stretch' aligned items for correct positioning of nested
items

Fixes facebook/css-layout#83, facebook/css-layout#100,
facebook/css-layout#127.
2016-02-26 00:43:58 +03:00
Emil Sjolander
c9094f94d0 Check layout instead of style before setting height and width to whatever is set in layout 2016-01-06 15:07:41 +00:00
Martin Kralik
f2aa5ba604 passing height to the measure function
This diff:
* adds height as another parameter passed to the measure function, computed the same way width is
* adds tests for this extension, which has involved adding a new measure function to all of js, c, java and c# tests
2015-12-14 15:00:13 +00:00
Colin Eberhardt
45f62c424c Widened scope of CI eslint to all JavaScript files 2015-10-05 13:21:19 +01: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
Colin Eberhardt
f9bb74aedf Updated the public API to no-longer extract nodes 2015-08-13 09:56:16 +01:00
Colin Eberhardt
401f473449 Added eslint to the build
Fixes #102
2015-08-11 16:52:57 +01:00
Jared Forsyth
f7bab441e0 change to an xit 2015-08-06 12:35:12 -07:00
Jared Forsyth
3e9ac12d22 add failing test 2015-08-06 09:36:28 -07: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
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
Pierre Renaux
14e264f5be Made relevant JS tests transpile to C ; [src/Layout.c]: print_css_node_rec(): print alignContent ; [src/Layout-test-utils.c]: add_failed_test(): Sets failed_test->next to NULL, otherwise the test crashes if there's one and only one failure ; Added type casts so that it can be compiled as C++ by MSVC on Windows ; [Makefile]: Added c_test_msvc target when running in Windows so that the test executable can be built and debugged with Visual Studio on Windows ; 2015-05-10 00:20:28 +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
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
1cbb5eef26 Fix lint errors and consts tests 2015-04-24 14:00:40 +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
Christopher Chedeau
b912acf8e3 Add more failing tests if someone wants to pick them up and have fun :p 2015-04-06 16:08:12 -07:00
Russell Keith-Magee
9cf2e71e01 Added extra test to check for potential division by zero. 2015-04-01 14:46:28 +08:00
Russell Keith-Magee
c523b7c404 Added support for min/max width and height constraints. 2015-03-31 17:32:54 +08: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
daviskoh
cf9b841e33 Fix jshint issues
* add .jshintrc
* address semicolon errors
* ignore 'already defined' errors
2015-02-05 19:49:55 -05:00
Christopher Chedeau
0e56641b28 Update font constants 2015-02-04 07:57:13 -08:00
Christopher Chedeau
d82ec0ddfd add bug reports urls for weird behaviors 2014-12-12 15:16:25 +00:00
Christopher Chedeau
1605bdfb1e add weird result from chrome 2014-12-12 13:14:18 +00: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
e838124625 remove support for flex: 0 since chrome behavior is really weird 2014-12-11 16:52:38 +00:00
Christopher Chedeau
544f377f20 implement 1/64 rounding like chrome. Didn't add a test for it because this is Chrome specific and shouldn't be on ios and android 2014-12-11 16:31:57 +00:00
Christopher Chedeau
ab64a5b624 fix children with left 2014-12-11 15:58:45 +00:00
Christopher Chedeau
ba873aa3d7 fix layout border bottom and flex end with an empty child 2014-12-11 14:42:31 +00:00
Christopher Chedeau
79286e6263 fix positive margin top inside of justify content center container 2014-12-11 14:31:17 +00:00
Christopher Chedeau
570f7bf98a fix test case not passing because of div by 0 2014-12-11 14:22:04 +00:00
Christopher Chedeau
5a3303ac5e fix bug with negative margin inside of a justifyContent: center container 2014-12-11 14:12:12 +00:00
Christopher Chedeau
ef73ebd935 add tests for flexWrap 2014-12-11 13:57:03 +00:00
Christopher Chedeau
c2aa92cd0b Add licenses and remove third party libraries 2014-10-29 08:01:22 -07:00
Christopher Chedeau
c0f895c6f2 Make align-items: stretch the default 2014-10-08 09:35:44 -07:00
Andrew Rasmussen
7eef01f299 make setting bottom/right calculate top/left 2014-09-30 15:24:42 -07:00
Andrew Rasmussen
0ae8bcf8f6 Add second position: absolute pass 2014-09-30 13:11:32 -07:00
Andrew Rasmussen
c149d3110d rename position: absolute test case 2014-09-29 14:07:47 -07:00
Alex Kotliarskyi
a047e4d5fe Automated script to transpile code and tests to C 2014-09-26 17:19:59 -07:00
Christopher Chedeau
6653d955c0 Merge pull request #5 from frantic/refactor-tests-step-1
Split JS tests into manual and random
2014-09-26 16:02:38 -07:00
Alex Kotliarskyi
2e954232d9 Split JS tests into manual and random 2014-09-26 16:00:56 -07:00