Commit Graph

766 Commits

Author SHA1 Message Date
Emil Sjolander
c28148caff Exclude tests from formatting as they are auto-generated and include html
Summary: Don't want to autoformat tests as they are autogenerated. Also they contain html which we don't want to get limited by line length.

Reviewed By: lucasr

Differential Revision: D3785246

fbshipit-source-id: 3e07b300ad16a1f0de53840e399eea25f4672b58
2016-08-30 10:07:53 -07:00
Emil Sjolander
e3fa40e694 Allow specifying the test name in the input to gentest
Summary: Allow adding test name within html through the id of the root element. This makes it much easier to re-generate test files.

Differential Revision: D3771966

fbshipit-source-id: 313e1648dcf4521e7c649f54c4ced2aa3297bf06
2016-08-26 10:38:01 -07:00
Lucas Rocha
89c00a7a3b Make Spacing.release() public
Summary: So that it can be reset when Spacing is used outside CSSNode.

Differential Revision: D3763593

fbshipit-source-id: 27436c0dbd292b38cfc98f4cfb8e2d12787b85d6
2016-08-26 04:22:54 -07:00
Emil Sjolander
2808e547c6 Revert changes causing layout failures
Summary: Revert changes to flex-basis as it broke some specific layouts. Will update later with a more comprehensive set of tests

Differential Revision: D3776987

fbshipit-source-id: 06bd154a36f895782f45511cd8cf49cc6d7cbe7d
2016-08-26 03:22:35 -07:00
Emil Sjolander
8b4a61df1a Generate tests for min/max height/width
Summary: Generate tests for min/max height/width

Differential Revision: D3771576

fbshipit-source-id: a114f79bdb3d36237d7ecc22f8cef69b6899fc3d
2016-08-25 15:38:14 -07:00
Emil Sjolander
43faff434a Generate tests for flex properties
Summary: Generate tests for flex-properties and fix bug where flex basis was not taken into account when parent main dimension was undefined.

Differential Revision: D3771513

fbshipit-source-id: 1b5edc7a28bb26217e8a6d10d1829d9031c3ae2e
2016-08-25 15:38:14 -07:00
Emil Sjolander
ea9a6ce06f Generate test for justify content
Summary: Generate tests for justify content

Differential Revision: D3771389

fbshipit-source-id: 2f6c5a38e6899b9ef05b7ad2da9b881c3b71e15c
2016-08-25 15:38:14 -07:00
Emil Sjolander
beb51fac1b Generate test for align content
Summary: Generate tests for align content

Differential Revision: D3771383

fbshipit-source-id: 4a0798486522bdfd7f10ca4db7086096494f03d8
2016-08-25 15:38:14 -07:00
Emil Sjolander
d33befeb98 Generate test for align self
Summary: Generate tests for align self

Differential Revision: D3771377

fbshipit-source-id: eaeec8a7ac5609bd8dd95d31500054510ab749d9
2016-08-25 15:38:14 -07:00
Emil Sjolander
2fc622adbd Generate test for flex wrap
Summary: Generate tests for flex wrap. The behavior for how the parents cross dimension is sized based on the children differs between browsers but looking at the spec this is the correct implementation.

Differential Revision: D3771140

fbshipit-source-id: bf144d506834e1d4217222bc2422150884a0be1c
2016-08-25 15:38:14 -07:00
Emil Sjolander
1fd3a16116 Fix naming of some style props in gentest
Summary: These props were never tested so I didn't notice the typo until now.

Differential Revision: D3771132

fbshipit-source-id: 9d7c2037195f29b3cac5d21599035edf3b7830ff
2016-08-25 15:38:14 -07:00
Emil Sjolander
aa70125f6c Generate tests for absolute layout
Summary: generate absolute layout tests. Also make sure default value for position is relative (#default div is absolutely positioned)

Reviewed By: IanChilds

Differential Revision: D3770947

fbshipit-source-id: 0327b071c0dc1aa4574ded759dcc667768b28f55
2016-08-25 15:38:14 -07:00
Emil Sjolander
9985e398b3 Generate test for align items
Summary: generate align-items tests

Reviewed By: IanChilds

Differential Revision: D3770946

fbshipit-source-id: 30ec043a8819d31a611f689bf89635f6a51c1628
2016-08-25 15:38:14 -07:00
Emil Sjolander
b629bcacab Generate test for flex direction
Summary: Generate flex-direction tests

Reviewed By: IanChilds

Differential Revision: D3770939

fbshipit-source-id: 7c02fe91bd50345c18653f70d1b572b643c44d26
2016-08-25 15:38:14 -07:00
Emil Sjolander
f65febb1af Remove certain computed values from output style
Summary: Remove output properties from computed styles as they will be computed to their output values before we can read them. Only include them if they are explicitly set by the user.

Reviewed By: IanChilds

Differential Revision: D3770917

fbshipit-source-id: e55996cf8744073496debea19c36a188d2e5086c
2016-08-25 15:38:14 -07:00
Emil Sjolander
ccbfee3841 Ensure multiple test cases all have the same origin
Summary: Make the test cases absolute to ensure left/top are both zero for each layout in the test case.

Reviewed By: IanChilds

Differential Revision: D3770913

fbshipit-source-id: c3085c2f8709b52fde0af7f47e1417252997b610
2016-08-25 15:38:14 -07:00
Emil Sjolander
9eb75e27cc Update gentest to new api
Summary: Update gentest to handle new CSSEdge api

Reviewed By: IanChilds

Differential Revision: D3770906

fbshipit-source-id: 1fa978354209fb8f4d0c5a2f892e1c79b062d4de
2016-08-25 15:38:14 -07:00
rh389
15afb4207c Use quote style for local includes
Summary:
This PR changes `#include <CSSLayout/*.h>` to  `#include "*.h"` within the `CSSLayout` directory.

Rationale: Quote includes are preferred for user (aka local/project) includes, whereas angle includes are preferred for standard libraries and external frameworks. In particular, XCode 7.1+ will not search user paths (even the current directory) when angle brackets are used unless "Always search user paths" is enabled - it is off by default and [Apple recommend](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW110) that it is only enabled for backwards compatibility.

I think this is the best fix for https://github.com/facebook/react-native/issues/9014, and seems like good practice in any case.
Closes https://github.com/facebook/css-layout/pull/217

Reviewed By: majak

Differential Revision: D3764132

Pulled By: emilsjolander

fbshipit-source-id: c8a6e8d19db71455922e3ba8f6c72bd66018fa84
2016-08-24 10:52:35 -07:00
Emil Sjolander
f1ae87cd73 Implement flex properties in java version as well
Summary: Implement flexShrink flexGrow and flexBasis in java as well because it will take a bit until the java code is removed

Reviewed By: lucasr

Differential Revision: D3753231

fbshipit-source-id: ea41d887cd99d1f03d2bc876a2fd7141dbe48320
2016-08-23 04:37:46 -07:00
Emil Sjolander
e8465aee45 Fix benchmark build
Summary: Benchmarks were broken by const diff leaving in some code which should not have changed. This was not caught earlier due to benchmarks only being run on travis.

Reviewed By: IanChilds

Differential Revision: D3751151

fbshipit-source-id: 08207ce7ad584d4681a27ec0727bbfdbc1198d05
2016-08-22 08:22:38 -07:00
Emil Sjolander
ca72b2b796 Use const where possible
Summary: Use const where possible. This does not use const for all variables as that would require too much refactoring for one diff. It does however use const where currently possible as well as does some small refactoring to enable const usage in more locations. Striving for 100% const usage leads to code with is easier to reason about as a reference will always reference the same value. The compiler will also assist if you accidentally override a reference.

Reviewed By: IanChilds

Differential Revision: D3741999

fbshipit-source-id: 1ba7da5784c3047f2d4c03746890192f724aa65e
2016-08-22 07:07:41 -07:00
Emil Sjolander
4bcefd8845 Remove unnecessary indirection
Summary: Remove unnecessary function calls which just caused indirection and thus confusion. These were an artifact of the regex transpilation.

Reviewed By: IanChilds

Differential Revision: D3741988

fbshipit-source-id: fdb31dc45a478508b41c522f0e1b3ef842971b50
2016-08-22 07:07:41 -07:00
Emil Sjolander
0672f5572f Move default spacing out of csslayout
Summary: The concept of default padding was confusing and only used by react-native android. Makes more sense to let them manage this themselve.

Reviewed By: foghina

Differential Revision: D3709574

fbshipit-source-id: 6e0277bd97407a5c642d742f93ca2ac70d7307da
2016-08-18 03:37:37 -07:00
Emil Sjolander
9d34b4e110 Compute edge values similar to how Spacing.java does it
Summary: When moving over java code to JNI we must make sure things like spacing behave the same. This introduces the same concepts to the C code.

Reviewed By: lexs

Differential Revision: D3728742

fbshipit-source-id: aa19400880afa49664f7bde72b1df45314e699bb
2016-08-17 10:38:40 -07:00
Emil Sjolander
dab03cb800 Remove CSSPosition in favor of CSSEdge
Summary: When adding CSSEdge I kinda forgot we had CSSPosition. I should have just refactor renamed CSSPosition and added some fields. Well this cleans that up.

Reviewed By: IanChilds

Differential Revision: D3728740

fbshipit-source-id: 19dc817a637b80d1f6df8d76982feb2e1fb2705a
2016-08-17 10:38:38 -07:00
Emil Sjolander
dd2346f8ac Document format.sh
Summary: Mention format.sh script in README and CONTRIBUTING docs

Reviewed By: IanChilds

Differential Revision: D3728789

fbshipit-source-id: 1d5d99dc627b6cb87898d282aae8adfcaeec7c14
2016-08-17 06:37:43 -07:00
Emil Sjolander
dde2b349f2 Support 64 bit platforms
Summary: Pointers are 64 bit on 64 bit platforms so using an int might truncate the pointer. Using longs supports 32 bit platforms as well.

Reviewed By: davidaurelio

Differential Revision: D3722479

fbshipit-source-id: c132f24c92c8476b328713861ad30670a43040c4
2016-08-16 08:52:38 -07:00
Emil Sjolander
7cd6305371 Fix parameter order
Summary: JNI code isn't covered by tests yet so I accidentally passed the spacing constant as a pointer value. oops.

Differential Revision: D3722391

fbshipit-source-id: 9adaf7b80d7bad93887a122c10eb06159a5189c2
2016-08-16 06:07:42 -07:00
Emil Sjolander
f28dacf280 import function before using it
Summary: We don't run this file internally so this was not caught earlier. Must of course include the function before using it.

Reviewed By: lucasr

Differential Revision: D3717080

fbshipit-source-id: 15c070b6b18bfa4fdd495e8c3b1b5ae62cb09824
2016-08-16 03:52:43 -07:00
Emil Sjolander
a960203567 Use single function for margin, position, padding, and border
Summary:
marginLeft(node, margin) -> margin(node, CSSEdgeLeft, margin)

This reduces the api surface of CSSLayout as well as puts the api more in line with the java version. This also adds support for CSSEdgeAll which java has had support for for a while. This also open up the possibility of doing margin(node, CSSEdgeLeft | CSSEdgeTop, margin) in the future.

Reviewed By: lucasr

Differential Revision: D3715201

fbshipit-source-id: ea81ed426f0f7853bb542355c01fc16ae4360238
2016-08-15 09:23:28 -07:00
Emil Sjolander
48e5304276 Specify format folders more granularly
Summary: We don't want to format files in lib/ for example. For some reason java/jni and tests/CSSLayoutTestUtils folders were previously ignored. This change formats those folders as well.

Reviewed By: lucasr

Differential Revision: D3715203

fbshipit-source-id: 37bcbd36bcf8535cfca73d6a806ab0f1d097dde7
2016-08-15 09:23:28 -07:00
Emil Sjolander
53ff4f59ca Allow format script to be run from anywhere
Summary: Previously format script had to be run from the root directory. With this change it can be run from anywhere

Reviewed By: lucasr

Differential Revision: D3715186

fbshipit-source-id: a46bc0b49aa32f0860bb3e3097ae7b08bdccbf2e
2016-08-15 09:23:28 -07:00
Emil Sjolander
28bc42a988 Add generation script header to generated tests
Summary: Add header to generated code so that code can easily be re-generated in case test generation is improved in the future.

Reviewed By: lucasr

Differential Revision: D3715181

fbshipit-source-id: 593baa691c2d7c7f171c6673898fb8a2ecf0e008
2016-08-15 09:23:28 -07:00
Emil Sjolander
c373056d80 Add the ability to generate multiple test cases
Summary: Modify test generation script to be able to generate multiple test cases

Reviewed By: lucasr

Differential Revision: D3714577

fbshipit-source-id: d2bc2155712f946c5a24231a9532d2acc097524c
2016-08-15 09:23:28 -07:00
Emil Sjolander
f68521aa69 Add support for flex-grow, flex-shrink, and flex-basis
Summary: Add support for flex-grow, flex-shrink, and flex-basis properties. The flex property behavior is preserved for backwards compatibility.

Reviewed By: lucasr

Differential Revision: D3714520

fbshipit-source-id: 80d3a9a1e2b6f74b863bbe22357f2c9865fa290e
2016-08-15 09:23:28 -07:00
Emil Sjolander
fdd5c8ce82 Use library style imports
Summary: Use library style imports to avoid lint warning

Reviewed By: IanChilds

Differential Revision: D3714512

fbshipit-source-id: 4c42d52b3ab92903e9e9451df0ca1564e2d33f0f
2016-08-15 09:23:28 -07:00
Emil Sjolander
7a1e353404 Update clang-format rules
Summary: Spent a couple hours customizing the clang-format rules to better match the desired code style.

Reviewed By: IanChilds

Differential Revision: D3714510

fbshipit-source-id: f6d0436346416aab023aacbedd70ea189e583e8d
2016-08-15 09:23:27 -07:00
Emil Sjolander
6a44dbc43b Add no-op allow_unsafe_import for open source
Summary: allow_unsafe_import was added to internal builds. add no-op version for open source

Reviewed By: IanChilds

Differential Revision: D3714497

fbshipit-source-id: fac9710726fd981d442c84c5b5879a94b955d102
2016-08-15 09:23:27 -07:00
Michal Lowicki
597354a43b Enable build file sandboxing in fbandroid
Summary:
Enable build file sandboxing in fbandroid.
Importing modules in build files that are not whitelisted will be blocked, this can be overriden by using

  with allow_unsafe_import():
      import foo

`import os` and `import os.path` will not be blocked and will import a safe version of `os` module instead (functions not accessing the file system like `os.path.join()` will be accessible), full `os` module can be imported using `allow_unsafe_import()`

Reviewed By: plamenko

Differential Revision: D3649817

fbshipit-source-id: 3e6a3ab9c4c6a56a99ca7adf599323143a5844f4
2016-08-12 09:38:05 -07:00
Emil Sjolander
1ce14cd097 Update readme
Summary: Docs!

Reviewed By: IanChilds

Differential Revision: D3709305

fbshipit-source-id: 1c8b7c1395bd78f073195eade1839ead4d9dacad
2016-08-12 08:52:41 -07:00
Emil Sjolander
d125911894 Print more detailed benchmark results including median and stddev
Summary: Mean was previously printed just because it was the quickest. Median is a better measurement and we need to include stddev for the sake of comparison against previous diff.

Differential Revision: D3709165

fbshipit-source-id: 67aff0877192143df82a9c24cbedb1f49616eec7
2016-08-12 06:22:38 -07:00
Emil Sjolander
e307dc22d1 Expose alignContent to java
Summary: Expose already existing alignContent property to java

Reviewed By: IanChilds

Differential Revision: D3709071

fbshipit-source-id: 421d75924ecc12d6d0975e342f3862cf5592f65f
2016-08-12 04:22:41 -07:00
Emil Sjolander
916170f6ac Dont generate so for main library
Summary: A .so file is only needed for the JNI target. The main library can be static.

Differential Revision: D3703897

fbshipit-source-id: b2efb98a6ae4488e6107c736c263cad35ef7c4fe
2016-08-12 03:53:52 -07:00
Emil Sjolander
57021eba9d Run benchmarks on previous revision as well
Summary: Checkout previous revision and re-run benchmark on travis

Differential Revision: D3697439

fbshipit-source-id: 260c5e379ae5caa667cf315e210ff4a7349b5868
2016-08-11 11:52:44 -07:00
Emil Sjolander
a43b813517 Add test generation scripts
Summary:
Add first version of test generation script. Currently works for most layouts and styles. Probably has a bunch of broken edge-case.

Usage:
$ gentest/gentest.sh
<Enter HTML with inline styles> e.g. <div style="width: 100px; height: 100px;"></div>
Open chrome dev tools console tab.
Copy code from console into file and save.
Run buck test //:CSSLayout

Differential Revision: D3697812

fbshipit-source-id: e6809f95bf6782e7e2cc47b9cdd3a25a13163c5c
2016-08-11 11:52:44 -07:00
Emil Sjolander
e5a3f7bf5b Turn on higher optimization level
Summary: quicker the better

Reviewed By: adamjernst

Differential Revision: D3697615

fbshipit-source-id: 822fb0927601849b364d3a649af934a0e82108e3
2016-08-11 03:07:51 -07:00
Emil Sjolander
af5b14335e Use modern initializer syntax instead of comments
Summary: Modern C allows us to document this kind of thing using C and not comments.

Reviewed By: adamjernst

Differential Revision: D3698569

fbshipit-source-id: c92b18540140662979cf001aeedaa76504c6a3ac
2016-08-11 03:07:51 -07:00
Emil Sjolander
118f64f206 Add benchmarks and change repetition count
Summary: The previous repetition count did not scale to many benchmarks. Also add more benchmarks

Reviewed By: adamjernst

Differential Revision: D3697280

fbshipit-source-id: 56fe424f36936445f31d6e9fa080abbdd816d32d
2016-08-11 02:37:38 -07:00
Emil Sjolander
450472766d Fix travis build
Summary: Building on osx machines makes things a lot easier.

Differential Revision: D3693987

fbshipit-source-id: f6e2599f99a3fd4ac6fb2a6efd5563074da707d0
2016-08-10 08:37:46 -07:00
Emil Sjolander
759cb707a4 Remove .buckversion
Summary: .buckversion is not needed in open source and we have no good way to keep it updated.

Differential Revision: D3696643

fbshipit-source-id: 3ce47a605730935e40f3cd3256a8ec3bd1f7b396
2016-08-10 08:37:46 -07:00