-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fbshipit-source-id: e866918d6c62fc1cf3a04c269f782b94db9b875a
- Loading branch information
FBShipIt
committed
Jul 25, 2016
0 parents
commit c633493
Showing
49 changed files
with
25,064 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[cxx] | ||
gtest_dep = //lib/gtest:gtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
158950c02e1553d3a17979e74d9df020594e4d30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_STORE | ||
|
||
/buck-cache/ | ||
/buck-out/ | ||
/.buckconfig.local | ||
/.buckd | ||
/lib/gtest/googletest-*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_STORE | ||
|
||
/buck-cache/ | ||
/buck-out/ | ||
/.buckconfig.local | ||
/.buckd | ||
/lib/gtest/googletest-*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright (c) 2014-present, Facebook, Inc. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. An additional grant | ||
# of patent rights can be found in the PATENTS file in the same directory. | ||
|
||
include_defs('//CSSLAYOUT_DEFS') | ||
|
||
BASE_COMPILER_FLAGS = [ | ||
'-fno-omit-frame-pointer', | ||
'-fexceptions', | ||
'-Wall', | ||
'-Werror', | ||
] | ||
|
||
GMOCK_OVERRIDE_FLAGS = [ | ||
# gmock does not mark mocked methods as override, ignore the warnings in tests | ||
'-Wno-inconsistent-missing-override', | ||
] | ||
|
||
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c11'] | ||
TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + ['-std=c++11'] | ||
|
||
cxx_library( | ||
name = 'CSSLayout', | ||
srcs = glob(['CSSLayout/*.c']), | ||
tests=[':CSSLayout_tests'], | ||
exported_headers = subdir_glob([('', 'CSSLayout/*.h')]), | ||
header_namespace = '', | ||
compiler_flags = COMPILER_FLAGS, | ||
deps = [], | ||
visibility = ['PUBLIC'], | ||
) | ||
|
||
cxx_library( | ||
name = 'CSSLayoutTestUtils', | ||
srcs = glob(['tests/CSSLayoutTestUtils/*.c']), | ||
exported_headers = subdir_glob([('tests', 'CSSLayoutTestUtils/*.h')]), | ||
header_namespace = '', | ||
compiler_flags = COMPILER_FLAGS, | ||
deps = [ | ||
':CSSLayout', | ||
], | ||
visibility = ['PUBLIC'], | ||
) | ||
|
||
cxx_test( | ||
name = 'CSSLayout_tests', | ||
contacts = ['emilsj@fb.com'], | ||
srcs = glob(['tests/*.cpp']), | ||
compiler_flags = TEST_COMPILER_FLAGS, | ||
deps = [ | ||
':CSSLayout', | ||
':CSSLayoutTestUtils', | ||
GTEST_TARGET, | ||
], | ||
visibility = ['PUBLIC'], | ||
) | ||
|
||
java_library( | ||
name = 'CSSLayout_java', | ||
srcs = glob(['java/**/*.java']), | ||
tests=[':CSSLayout_java_tests'], | ||
source = '1.7', | ||
target = '1.7', | ||
deps = [ | ||
INFER_ANNOTATIONS_TARGET, | ||
JSR_305_TARGET, | ||
], | ||
visibility = ['PUBLIC'], | ||
) | ||
|
||
java_test( | ||
name = 'CSSLayout_java_tests', | ||
srcs = glob(['tests/java/**/*.java']), | ||
deps = [ | ||
':CSSLayout_java', | ||
JUNIT_TARGET, | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Contributing to css-layout | ||
We want to make contributing to this project as easy and transparent as | ||
possible. | ||
|
||
## Our Development Process | ||
All the development is happening on GitHub first and we have internal tools to sync down to Facebook codebase. | ||
|
||
## Pull Requests | ||
We actively welcome your pull requests. | ||
1. Fork the repo and create your branch from `master`. | ||
2. If you've added code that should be tested, add tests | ||
3. If you've changed APIs, update the documentation. | ||
4. Ensure the test suite passes. | ||
5. Make sure your code lints. | ||
6. If you haven't already, complete the Contributor License Agreement ("CLA"). | ||
|
||
## Contributor License Agreement ("CLA") | ||
In order to accept your pull request, we need you to submit a CLA. You only need | ||
to do this once to work on any of Facebook's open source projects. | ||
|
||
Complete your CLA here: <https://code.facebook.com/cla> | ||
|
||
## Issues | ||
We use GitHub issues to track public bugs. Please ensure your description is | ||
clear and has sufficient instructions to be able to reproduce the issue. | ||
|
||
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe | ||
disclosure of security bugs. In those cases, please go through the process | ||
outlined on that page and do not file a public issue. | ||
|
||
## Coding Style | ||
* 2 spaces for indentation rather than tabs | ||
* 80 character line length | ||
* ... | ||
|
||
## License | ||
By contributing to css-layout, you agree that your contributions will be licensed | ||
under its BSD license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
CSSLAYOUT_ROOT = '//...' | ||
INFER_ANNOTATIONS_TARGET = '//lib/infer-annotations:infer-annotations' | ||
JSR_305_TARGET = '//lib/jsr-305:jsr-305' | ||
JUNIT_TARGET = '//lib/junit:junit' | ||
GTEST_TARGET = '//lib/gtest:gtest' | ||
GTEST_DL_URL = 'https://github.com/google/googletest/archive/release-1.7.0.zip' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#ifndef __CSS_LAYOUT_INTERNAL_H | ||
#define __CSS_LAYOUT_INTERNAL_H | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "CSSLayout.h" | ||
#include "CSSNodeList.h" | ||
|
||
CSS_EXTERN_C_BEGIN | ||
|
||
typedef struct CSSCachedMeasurement { | ||
float availableWidth; | ||
float availableHeight; | ||
CSSMeasureMode widthMeasureMode; | ||
CSSMeasureMode heightMeasureMode; | ||
|
||
float computedWidth; | ||
float computedHeight; | ||
} CSSCachedMeasurement; | ||
|
||
// This value was chosen based on empiracle data. Even the most complicated | ||
// layouts should not require more than 16 entries to fit within the cache. | ||
enum { | ||
CSS_MAX_CACHED_RESULT_COUNT = 16 | ||
}; | ||
|
||
typedef struct CSSLayout { | ||
float position[4]; | ||
float dimensions[2]; | ||
CSSDirection direction; | ||
|
||
float flexBasis; | ||
|
||
// Instead of recomputing the entire layout every single time, we | ||
// cache some information to break early when nothing changed | ||
int generationCount; | ||
CSSDirection lastParentDirection; | ||
|
||
int nextCachedMeasurementsIndex; | ||
CSSCachedMeasurement cachedMeasurements[CSS_MAX_CACHED_RESULT_COUNT]; | ||
float measuredDimensions[2]; | ||
|
||
CSSCachedMeasurement cached_layout; | ||
} CSSLayout; | ||
|
||
typedef struct CSSStyle { | ||
CSSDirection direction; | ||
CSSFlexDirection flexDirection; | ||
CSSJustify justifyContent; | ||
CSSAlign alignContent; | ||
CSSAlign alignItems; | ||
CSSAlign alignSelf; | ||
CSSPositionType positionType; | ||
CSSWrapType flexWrap; | ||
CSSOverflow overflow; | ||
float flex; | ||
float margin[6]; | ||
float position[4]; | ||
/** | ||
* You should skip all the rules that contain negative values for the | ||
* following attributes. For example: | ||
* {padding: 10, paddingLeft: -5} | ||
* should output: | ||
* {left: 10 ...} | ||
* the following two are incorrect: | ||
* {left: -5 ...} | ||
* {left: 0 ...} | ||
*/ | ||
float padding[6]; | ||
float border[6]; | ||
float dimensions[2]; | ||
float minDimensions[2]; | ||
float maxDimensions[2]; | ||
} CSSStyle; | ||
|
||
typedef struct CSSNode { | ||
CSSStyle style; | ||
CSSLayout layout; | ||
int lineIndex; | ||
bool shouldUpdate; | ||
bool isTextNode; | ||
CSSNodeRef parent; | ||
CSSNodeListRef children; | ||
bool isDirty; | ||
|
||
struct CSSNode* nextChild; | ||
|
||
CSSSize (*measure)(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode); | ||
void (*print)(void *context); | ||
void *context; | ||
} CSSNode; | ||
|
||
CSS_EXTERN_C_END | ||
|
||
#endif |
Oops, something went wrong.