Commit Graph

522 Commits

Author SHA1 Message Date
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
Emil Sjolander
328db9ca1c Include soloader as aar
Summary: This means we don't need to use buck fetch. soloader ships as an aar and does not get updated often.

Differential Revision: D3696638

fbshipit-source-id: 57fc7c24067ee833f47ed7c34b927a0d84e20200
2016-08-10 08:37:46 -07:00
Emil Sjolander
f15b563166 Use spacing for position
Summary: Use spacing for position in public api. This was already the case internally

Differential Revision: D3690235

fbshipit-source-id: 4c04952e6ded32fd5fbfdccf63736cf025ae470e
2016-08-10 05:22:32 -07:00
Emil Sjolander
7f27046cc5 Expose methods to set position Start|End
Summary:
As they're were not available yet.

Emil, I'm going to wait for your diffs to land before pushing this to
avoid disruptions on your side.

Differential Revision: D3669177

fbshipit-source-id: b06f382cb89546e817a2475298cf2cad17d95a2c
2016-08-09 04:37:45 -07:00
ymmuse
faad5cdf4d fix CSSNodeList memory leak
Summary:
CSSNodeListFree does not free the list->items memory
Closes https://github.com/facebook/css-layout/pull/214

Differential Revision: D3683643

Pulled By: emilsjolander

fbshipit-source-id: 7f9ef19f4603d5558cc2f8302756b3bcec2f6c12
2016-08-08 04:52:35 -07:00
James Ide
256d080fd2 Prefix isUndefined with "CSS"
Summary:
Consistently namespace all of css-layout's public C API with "CSS". The only function that needed to be renamed was isUndefined, which I renamed to CSSValueIsUndefined.

Fixes #210.
Closes https://github.com/facebook/css-layout/pull/211

Reviewed By: lucasr

Differential Revision: D3674922

Pulled By: emilsjolander

fbshipit-source-id: 1752f477bde45586db112fe2654d0404cc52e1d1
2016-08-05 06:37:38 -07:00
Emil Sjolander
efe1595f0e Add and run clang format script
Summary: This code used to be auto generated. Let's let clang-format clean up some stuff for us.

Reviewed By: lucasr

Differential Revision: D3662225

fbshipit-source-id: ddd4064cbf9be21ca6a97001ace1b56b4314c86f
2016-08-04 08:23:02 -07:00
Emil Sjolander
9278ff462e Add the ability to attach data to a java CSSNode
Summary: The C version already has this ability via the same name 'context'. This can be used to attach arbitrary data about your view hierarchy to a CSSNode. Previously this could only be done in java via subclassing CSSNode.

Reviewed By: lucasr

Differential Revision: D3662065

fbshipit-source-id: 560a768092f17381e99b349d08bd4a8b365541be
2016-08-04 08:23:02 -07:00
Emil Sjolander
b32d384337 Fallback to System.loadLibrary if SoLoader has not been initialized
Summary: To make the library easier to get started with we don't want to force people to use SoLoader. If SoLoader is not initialized we will fall back to the standard System.loadLibrary() method.

Reviewed By: lucasr

Differential Revision: D3661990

fbshipit-source-id: f2003577aa3d2f89ec579b6f889fdfb684110b60
2016-08-04 08:23:02 -07:00
Emil Sjolander
f5caf93c6e Only perform class and method lookup once
Summary: This caches the class and method id references between calls. The class lookup is done once per method still but I think that is ok for now as the code becomes somewhat cleaner and more self contained.

Reviewed By: lucasr

Differential Revision: D3661989

fbshipit-source-id: 68d4557364bb8957400aefb2603c2e46424ccec3
2016-08-04 08:23:01 -07:00
Emil Sjolander
c74eae50ac Add jni bindings
Summary: Add jni bindings for csslayout. First step in many of removing LayoutEngine.java and performing all layout in native.

Reviewed By: lucasr

Differential Revision: D3648793

fbshipit-source-id: d0e696e196fa7c63109c9117a65645ca3d6c9c00
2016-08-04 08:23:01 -07:00
Emil Sjolander
7af5e3d68d Dont redefine abort() as it may leak into other files
Summary: Anyone importing this header would have abort() redefined to nothing. That's not good. Fix mistake by defining a CSS_ABORT() macro instead.

Differential Revision: D3661871

fbshipit-source-id: 14a9d076299b4f21d17a2bed68aa30b796c438a5
2016-08-03 02:07:39 -07:00
Emil Sjolander
9689062f6c Implement custom assert macro
Summary: assert.h assertion gets stripped from builds. I don't want these assertions to be stripped so implement a custom assert macro. This also allows the assertion to be documented with a message.

Reviewed By: javache

Differential Revision: D3648805

fbshipit-source-id: a6bf1bb55e1e0ee37284647ab76d66f3956a66c0
2016-08-02 08:08:09 -07:00
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