Commit Graph

504 Commits

Author SHA1 Message Date
Emil Sjolander
ac44d2ea6e use #pragma once
Summary: #pragma once is widely supported and is a lot harder to get wrong than #ifdef include guards.

Reviewed By: lucasr

Differential Revision: D3648895

fbshipit-source-id: faf42cda82764adaf41cf3f3f9109d48aea203fe
2016-08-02 08:08:09 -07:00
Emil Sjolander
9ab97af05d Re-enable travis
Summary: Add travis config file.

Reviewed By: lucasr

Differential Revision: D3649004

fbshipit-source-id: 27f257246965db473dc85ec6fed6b9a32bc8a621
2016-08-02 08:08:09 -07:00
Emil Sjolander
cdf18b9c2b Update readme with java instructions
Summary: Java instructions were missing from the readme. Add a quick note about how to run tests in java.

Reviewed By: lucasr

Differential Revision: D3648981

fbshipit-source-id: d9009a60bb1bb0837722f914981ef4e31f0adb68
2016-08-02 08:08:09 -07:00
Emil Sjolander
c7d02257e3 Make use of modern standard types
Summary: stdint.h defines the modern standard c types which have a fixed memory size. This makes the program run more predictably as well as removing the need to ugly double work types such as `unsigned int` or `long long`.

Reviewed By: lucasr

Differential Revision: D3649096

fbshipit-source-id: dc9fc8861c3106494c5d00d6ac337da50a4c945b
2016-08-02 08:08:09 -07:00
Emil Sjolander
c72321f8a9 Add first benchmark
Summary: Implement some very basic benchmarking infra. We need benchmarks in css-layout and I want to add something now so that others have the option to follow an example when implementing a benchmark.

Reviewed By: lucasr

Differential Revision: D3648889

fbshipit-source-id: 60b93c6e5ed027a37195a9a5d86e681e3e79a5b9
2016-08-01 07:40:11 -07:00
Emil Sjolander
a0805d0b90 shouldUpdate -> hasNewLayout
Summary: This moves the api in line with the java api. hasNewLayout makes for sense than shouldUpdate because the API is not telling css layout to update but is instead just a marker for the user of the API to know if there has been a new layout since last time it checked.

Reviewed By: majak

Differential Revision: D3613695

fbshipit-source-id: 4e16e8d4de90660a09d6e1d3a43c6c5e89349993
2016-08-01 05:37:31 -07:00
Mengjue Wang
5207b90420 Provide RTL support for RCTShadowView according to new csslayout
Summary:
@public The make current RCTShadowView support RTL layout.
1 Change all left/right to start/end for margin, padding, boarder and position
2 Calculate position in the same way as margin, padding and boarder

Reviewed By: fkgozali

Differential Revision: D3619292

fbshipit-source-id: eaaa6faeee93c964d59bb6f498d89effc09ed567
2016-07-29 10:37:40 -07:00
Mengjue Wang
5e7d95b403 bottom styling isn't applied when a View is not absolute-positioned
Summary: @public The new CSSLayout have a wrong calculate for the getRelativePosition. So use the getLeadingPosition will get 0 instead of return undefined. Fix it with using isLeadingPosDefined.

Reviewed By: fkgozali

Differential Revision: D3640799

fbshipit-source-id: 50d3bd2ea4c0d8bf96ba34297425ba269b0535cd
2016-07-28 23:37:41 -07:00
Mengjue Wang
041960fcbc Reverted commit D3629662
Summary: The test case CSSLayoutTest/test_layout_node_with_bottom has some problem. I can't find a way to fix it without get the screen size. I decided to remove it first. If we could find a better way to right this test case. We can add it again.

Reviewed By: fkgozali

Differential Revision: D3629662

fbshipit-source-id: 303f81a74919e5d3bf037e2809e1345a554a7009
2016-07-28 21:52:33 -07:00
Mengjue Wang
46c842c71a Fix CSSLayout to Support RTL
Summary:
@public The current CSSLayout can't support RTL because wrong calculation for absolute position.
This change is mainly to fix the issue: https://github.com/facebook/css-layout/issues/197
Three main problems I fixed:
1. Calculate the position in the same way as margin, boarder, and padding. So that to fix the absolute problem.
2. Fix one wrong calculation for leading value when we only know the trailing value. It was hard code for the LTR situation. Now I changed it to depends on the main Axis.
3. Expose getter and setter function for RN to read layout direction and start/end position value.

Reviewed By: fkgozali

Differential Revision: D3616949

fbshipit-source-id: ae7a47cc0a5d02b42b95f87232be51ab144056d9
2016-07-28 14:52:40 -07:00
Mengjue Wang
b26794a375 Fix the test files according to new CSSLayout change
Summary: The test case CSSLayoutTest/test_layout_node_with_bottom has some problem. I can't find a way to fix it without get the screen size. I decided to remove it first. If we could find a better way to right this test case. We can add it again.

Reviewed By: fkgozali

Differential Revision: D3629662

fbshipit-source-id: 62d6cd3827d20ae670af55d1c072bd9645a701b9
2016-07-28 11:07:38 -07:00
Emil Sjolander
8ffff2bfaf update readme
Summary: Update readme with info about building and github markdown syntax

Differential Revision: D3613284

fbshipit-source-id: 1f57009ccf02a48fe100f675ce08503e15cb6c22
2016-07-25 09:52:59 -07:00
FBShipIt
fdd8552c4e Import new C source of truth css-layout
fbshipit-source-id: e866918d6c62fc1cf3a04c269f782b94db9b875a
2016-07-25 15:53:07 +01:00
Emil Sjolander
93809b69c8 Restructure things to fit upcoming diff 2016-07-25 15:48:39 +01:00
Emil Sjölander
667106e423 Merge pull request #206 from facebook/revert-199-measure-fix
Revert "Correctly size cross axis when measuring flex basis"
2016-07-13 11:02:05 +01:00
Emil Sjölander
57874a1a9e Revert "Correctly size cross axis when measuring flex basis" 2016-07-13 10:42:03 +01:00
Emil Sjölander
8b7f353746 Merge pull request #199 from emilsjolander/measure-fix
Correctly size cross axis when measuring flex basis
2016-07-08 16:47:19 +01:00
Emil Sjolander
ca34ff4446 Correctly size cross axis when measuring flex basis 2016-07-08 16:05:21 +01:00
Emil Sjölander
d878091c4b Merge pull request #203 from emilsjolander/at-most-root-js
Add missing js implementation for PR #200
2016-07-08 15:52:19 +01:00
Emil Sjolander
c4fa32cfd3 Add missing js implementation for PR #200 2016-07-08 14:43:30 +01:00
Emil Sjölander
6e05325f08 Merge pull request #200 from emilsjolander/at-most-root
Use AT_MOST measurespec when onyl max dimension is defined
2016-07-04 23:25:04 +01:00
Emil Sjolander
a1f36b53f5 Use AT_MOST measurespec when onyl max dimension is defined 2016-07-02 11:22:57 +01:00
Emil Sjölander
383d8a6b3d Merge pull request #195 from emilsjolander/imrpove-cache-hit
Improve heuristic for cache re-use
2016-06-09 10:55:48 -04:00
Emil Sjolander
7b0c008300 Improve heuristic for cache re-use 2016-06-09 10:33:00 -04:00
Emil Sjölander
45e595e6ae Merge pull request #193 from emilsjolander/stretch-perf
Measure with exact measurement when stretch is defined
2016-06-09 10:21:04 -04:00
Emil Sjolander
2a816bf5a7 Measure with exact measurement when stretch is defined 2016-06-08 14:00:31 -04:00
Emil Sjölander
71eb25d1cc Merge pull request #196 from emilsjolander/styling
Remove whitespace on empty lines etc.
2016-06-03 22:19:53 +01:00
Emil Sjolander
c06752e052 Remove whitespace on empty lines etc. 2016-06-03 22:19:03 +01:00
Emil Sjölander
bd92550d57 Merge pull request #192 from rigdern/rigdern/expose-props
Expose getters and setters for some new properties
2016-06-02 17:20:30 +01:00
Adam Comella
9260363fef Expose getters and setters for some new properties
The properties include overflow and min/max height/width.
2016-06-01 12:56:35 -07:00
Emil Sjölander
9d62cee68b Merge pull request #185 from rigdern/rigdern/spec-conformance
Alter layout engine to conform closer to W3C spec
2016-05-31 11:04:41 +01:00
Adam Comella
16f43dac87 Skip measurement when there's no available vertical space
We already did this optimization when there wasn't any
available horizontal space. Now we're covering the
vertical space case as well.

This optimization assumes that, for a node with a
measure function, if there isn't any available
horizontal or vertical space, then we don't need to
measure the node and can assume that the node is 0x0.
2016-05-25 10:53:15 -07:00
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
8779d942ea Fix positioning of items with min/max width/height
We found a case where a flexible item with a max width that was supposed
to be centered was positioned in the wrong location.

The problem was with our 2 pass approach for sizing flexible items with
a min/max width/height. Items sized in the first pass were being double
counted when calculating the remainingFreeSpace. Specifically, their
sizes were being subtracted from remainingFreeSpace in both the first
and second passes.

I also noticed a second unrelated bug. We weren't correctly calculating
deltaFreeSpace in the first pass. When calculating deltaFreeSpace, we
need to take into account the flex basis like we do in the second pass.
Consequently, in the first pass I changed this:
  deltaFreeSpace -= boundMainSize;

To this:
  deltaFreeSpace -= boundMainSize - childFlexBasis;

The problem there was that we'd end up double counting childFlexBasis
in the remainingFreeSpace.
2016-05-11 00:29:40 -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 Sjölander
b0d00ad338 Merge pull request #163 from emilsjolander/measuremode
Add support for measure mode
2016-04-06 18:07:37 +01:00
Emil Sjolander
7bd6b2b7dd Add support for measure mode 2016-04-01 11:01:16 +01:00
Pieter De Baets
68e0b0cc58 Merge pull request #182 from javache/skip-layout-correctly
Correct skipLayout condition in Layout.c
2016-03-30 15:22:43 +01:00
Pieter De Baets
5b56be412c Correct skipLayout condition in Layout.c
Fixes #155
2016-03-30 12:11:49 +01:00
Lucas Rocha
3454511947 Merge pull request #178 from javache/node-layout-reset 2016-03-29 11:15:53 +01:00
Pieter De Baets
b157ab4a00 Reset child position/sizes before calculating layout 2016-03-29 11:05:53 +01:00
Lucas Rocha
8d5cdd4e6c Merge pull request #145 from alebo/issue-127 2016-03-01 23:07:14 +00: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
Christopher Chedeau
dd8e5cd65d Merge pull request #170 from casandrasilva/patch-1
fixes UMD url
2016-02-05 03:57:39 -08:00
Casandra Silva Zenteno
64704dd708 fixes UMD url 2016-02-04 23:31:16 -08:00
Christopher Chedeau
dc7059d340 Merge pull request #166 from RReverser/patch-1
Add C# to the supported language list
2016-01-13 06:26:40 -08:00
Ingvar Stepanyan
acd295e470 Add C# to the supported language list 2016-01-13 14:15:48 +00:00
Lucas Rocha
5d5630d3c8 Merge pull request #161 from emilsjolander/master 2016-01-07 12:17:49 +00: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
Christopher Chedeau
f3b6fb3be0 Merge pull request #159 from CatalystCode/dirty
Need dirty() to be virtual to override in special cases.
2016-01-05 07:19:23 -08:00