Commit Graph

59 Commits

Author SHA1 Message Date
Adam Comella
8177bfe702 Heuristics for skipping calls to the measure function
Introduced heuristics that enable css-layout to avoid
calling measure functions under a number of conditions.
This enables us to save time by skipping unnecessary
measurements.
2016-05-18 13:40:34 -07:00
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
Emil Sjolander
7bd6b2b7dd Add support for measure mode 2016-04-01 11:01:16 +01: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
e4c93e8c59 Updated to use eslint from fbjs-scripts 2015-10-07 21:52:22 +01: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
e1d99952f7 update const 2015-08-05 21:57:06 -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
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
c7fbf44474 'alignContent' defaults to 'flex-start' instead of 'stretch' ; 2015-05-10 00:19:30 +08:00
Pierre Renaux
8493789989 [src/Layout-test-utils.js]: Fix so that RunLayoutTests.html works on Chrome for Windows ; 2015-05-10 00:19:29 +08:00
Pierre Renaux
cc5f772bff Style fixes ; 2015-05-10 00:19:29 +08:00
Pierre Renaux
9ca681ff28 [src/__tests__/Layout-random-test.js]: Added alignContent in the list of random permutations ; 2015-05-10 00:19:28 +08:00
Pierre Renaux
15a8430be9 [src/Layout-test-utils.js]: Added inplaceRoundNumbersInObject to testRandomLayout so that much less random tests fail ; Moved inplaceRoundNumbersInObject in the main functions instead of having it in nameLayout ; 2015-05-10 00:19:28 +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
f4226d3ff5 [src/Layout-test-utils.js]: Added testMeasurePrecision and inplaceRoundNumbersInObject which snap the numbers to pixels so that we don't have to re-adjust for each browser version (Chrome 42 changed their computation, it can output floating point values for dom elements) ; 2015-05-10 00:19:27 +08:00
Tadeu Zagallo
1cbb5eef26 Fix lint errors and consts tests 2015-04-24 14:00:40 +01:00
Jan Kassens
dda464cdb9 Fix getIframe test helper
Chrome seems to always be ready on the first iteration, so this doesn't affect
Chrome, but on Firefox, the `iframe` is undefined in the recursive call.

This makes most of the test in `RunLayoutTests.html` pass in Firefox. The only
failing test is the one checking font sizes.
2015-03-31 20:27:58 -07: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
Ryan Seddon
1ad94fa4e1 Fix firefox iframe timing issue, fixes #25 2015-02-05 21:14:19 +11:00
Christopher Chedeau
0e56641b28 Update font constants 2015-02-04 07:57:13 -08:00
Christopher Chedeau
28243156e4 make C and Java tests pass and update their code 2014-12-11 20:23:53 +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
e0bcbdcfc1 more tweaks to the pretty print function 2014-12-11 13:56:29 +00:00
Christopher Chedeau
0f9b777623 better way to ignore iframe width 2014-12-11 13:44:03 +00:00
Christopher Chedeau
fde2328ba6 better pretty-print function 2014-12-11 13:30:46 +00:00
Christopher Chedeau
8031cbe134 do not infinite loop on random layouts anymore 2014-12-11 12:17:40 +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
Alex Kotliarskyi
308d0edc0b Add test that makes sure text consts are in sync 2014-09-26 20:38:34 -07:00
Alex Kotliarskyi
a047e4d5fe Automated script to transpile code and tests to C 2014-09-26 17:19:59 -07:00
Andrew Rasmussen
e506416fa3 aggregate test failures and print a summary after running tests 2014-09-25 17:56:02 -07:00
Christopher Chedeau
d8c1889ba4 use constants for text examples 2014-09-19 18:36:18 -07:00
Christopher Chedeau
9119ebcea6 Make vendor prefix work on safari 2014-09-19 18:26:53 -07:00
Christopher Chedeau
8974b7fdb7 Make variables for text sizes so it is easier to fix when the browser changes 2014-09-19 18:22:09 -07:00
Christopher Chedeau
d7f3ea868d Import latest changes 2014-09-11 09:23:30 -07:00
Christopher Chedeau
842d654b0f overlapping left and right + workaround chrome bug 2014-06-12 11:27:49 -07:00
Christopher Chedeau
d2ce2420f4 Lots of changes that I forgot to properly commit 2014-06-04 10:51:23 -07:00
Christopher Chedeau
0708b5eb75 autogen c version of text from js 2014-04-28 13:06:00 -07:00
Christopher Chedeau
6123dbb33b initial support for string in c 2014-04-28 12:34:04 -07:00
Christopher Chedeau
490a7c74d5 move extractLayoutNode out of layout.js 2014-04-27 12:37:26 -07:00
Christopher Chedeau
a0ffafe37d support <Text> 2014-04-26 19:02:16 -07:00
Christopher Chedeau
61919a1b2f text with padding and margin 2014-04-26 17:11:22 -07:00