Update css-layout sync scripts

Reviewed By: emilsjolander

Differential Revision: D3424265

fbshipit-source-id: b1a765bbe11f776e418ae8b01c5c2a292f590a6b
This commit is contained in:
Pieter De Baets 2016-06-15 09:44:30 -07:00 committed by Facebook Github Bot 1
parent b7352b4667
commit 0a9cc99a4f
5 changed files with 2004 additions and 2026 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,212 +1,203 @@
/** /**
* * Copyright (c) 2014-present, Facebook, Inc.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !! This file is a check-in from github! !!
* !! !!
* !! You should not modify this file directly. Instead: !!
* !! 1) Go to https://github.com/facebook/css-layout !!
* !! 2) Make a pull request and get it merged !!
* !! 3) Copy the file from github to here !!
* !! (don't forget to keep this header) !!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* @generated
*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved. * All rights reserved.
*
* This source code is licensed under the BSD-style license found in the * 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 * 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. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#ifndef __LAYOUT_H // NOTE: this file is auto-copied from https://github.com/facebook/css-layout
#define __LAYOUT_H // @generated SignedSource<<c504fae9470271c5617f345667bef8ad>>
#include <math.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++ #ifndef __LAYOUT_H
#ifndef NAN #define __LAYOUT_H
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *)__nan)
#endif
#define CSS_UNDEFINED NAN #include <math.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
typedef enum { // Not defined in MSVC++
CSS_DIRECTION_INHERIT = 0, #ifndef NAN
CSS_DIRECTION_LTR, static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
CSS_DIRECTION_RTL #define NAN (*(const float *)__nan)
} css_direction_t; #endif
typedef enum { #define CSS_UNDEFINED NAN
CSS_FLEX_DIRECTION_COLUMN = 0,
CSS_FLEX_DIRECTION_COLUMN_REVERSE,
CSS_FLEX_DIRECTION_ROW,
CSS_FLEX_DIRECTION_ROW_REVERSE
} css_flex_direction_t;
typedef enum { typedef enum {
CSS_JUSTIFY_FLEX_START = 0, CSS_DIRECTION_INHERIT = 0,
CSS_JUSTIFY_CENTER, CSS_DIRECTION_LTR,
CSS_JUSTIFY_FLEX_END, CSS_DIRECTION_RTL
CSS_JUSTIFY_SPACE_BETWEEN, } css_direction_t;
CSS_JUSTIFY_SPACE_AROUND
} css_justify_t;
typedef enum { typedef enum {
CSS_OVERFLOW_VISIBLE = 0, CSS_FLEX_DIRECTION_COLUMN = 0,
CSS_OVERFLOW_HIDDEN CSS_FLEX_DIRECTION_COLUMN_REVERSE,
} css_overflow_t; CSS_FLEX_DIRECTION_ROW,
CSS_FLEX_DIRECTION_ROW_REVERSE
} css_flex_direction_t;
// Note: auto is only a valid value for alignSelf. It is NOT a valid value for typedef enum {
// alignItems. CSS_JUSTIFY_FLEX_START = 0,
typedef enum { CSS_JUSTIFY_CENTER,
CSS_ALIGN_AUTO = 0, CSS_JUSTIFY_FLEX_END,
CSS_ALIGN_FLEX_START, CSS_JUSTIFY_SPACE_BETWEEN,
CSS_ALIGN_CENTER, CSS_JUSTIFY_SPACE_AROUND
CSS_ALIGN_FLEX_END, } css_justify_t;
CSS_ALIGN_STRETCH
} css_align_t;
typedef enum { typedef enum {
CSS_POSITION_RELATIVE = 0, CSS_OVERFLOW_VISIBLE = 0,
CSS_POSITION_ABSOLUTE CSS_OVERFLOW_HIDDEN
} css_position_type_t; } css_overflow_t;
typedef enum { // Note: auto is only a valid value for alignSelf. It is NOT a valid value for
CSS_NOWRAP = 0, // alignItems.
CSS_WRAP typedef enum {
} css_wrap_type_t; CSS_ALIGN_AUTO = 0,
CSS_ALIGN_FLEX_START,
CSS_ALIGN_CENTER,
CSS_ALIGN_FLEX_END,
CSS_ALIGN_STRETCH
} css_align_t;
// Note: left and top are shared between position[2] and position[4], so typedef enum {
// they have to be before right and bottom. CSS_POSITION_RELATIVE = 0,
typedef enum { CSS_POSITION_ABSOLUTE
CSS_LEFT = 0, } css_position_type_t;
CSS_TOP,
CSS_RIGHT,
CSS_BOTTOM,
CSS_START,
CSS_END,
CSS_POSITION_COUNT
} css_position_t;
typedef enum { typedef enum {
CSS_MEASURE_MODE_UNDEFINED = 0, CSS_NOWRAP = 0,
CSS_MEASURE_MODE_EXACTLY, CSS_WRAP
CSS_MEASURE_MODE_AT_MOST, } css_wrap_type_t;
CSS_MEASURE_MODE_COUNT
} css_measure_mode_t;
typedef enum { // Note: left and top are shared between position[2] and position[4], so
CSS_WIDTH = 0, // they have to be before right and bottom.
CSS_HEIGHT typedef enum {
} css_dimension_t; CSS_LEFT = 0,
CSS_TOP,
CSS_RIGHT,
CSS_BOTTOM,
CSS_START,
CSS_END,
CSS_POSITION_COUNT
} css_position_t;
typedef struct { typedef enum {
float available_width; CSS_MEASURE_MODE_UNDEFINED = 0,
float available_height; CSS_MEASURE_MODE_EXACTLY,
css_measure_mode_t width_measure_mode; CSS_MEASURE_MODE_AT_MOST,
css_measure_mode_t height_measure_mode; CSS_MEASURE_MODE_COUNT
} css_measure_mode_t;
float computed_width; typedef enum {
float computed_height; CSS_WIDTH = 0,
} css_cached_measurement_t; CSS_HEIGHT
} css_dimension_t;
enum { typedef struct {
// This value was chosen based on empiracle data. Even the most complicated float available_width;
// layouts should not require more than 16 entries to fit within the cache. float available_height;
CSS_MAX_CACHED_RESULT_COUNT = 16 css_measure_mode_t width_measure_mode;
}; css_measure_mode_t height_measure_mode;
typedef struct { float computed_width;
float position[4]; float computed_height;
float dimensions[2]; } css_cached_measurement_t;
css_direction_t direction;
float flex_basis; enum {
// 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.
CSS_MAX_CACHED_RESULT_COUNT = 16
};
// Instead of recomputing the entire layout every single time, we typedef struct {
// cache some information to break early when nothing changed float position[4];
bool should_update; float dimensions[2];
int generation_count; css_direction_t direction;
css_direction_t last_parent_direction;
int next_cached_measurements_index; float flex_basis;
css_cached_measurement_t cached_measurements[CSS_MAX_CACHED_RESULT_COUNT];
float measured_dimensions[2];
css_cached_measurement_t cached_layout; // Instead of recomputing the entire layout every single time, we
} css_layout_t; // cache some information to break early when nothing changed
bool should_update;
int generation_count;
css_direction_t last_parent_direction;
typedef struct { int next_cached_measurements_index;
float dimensions[2]; css_cached_measurement_t cached_measurements[CSS_MAX_CACHED_RESULT_COUNT];
} css_dim_t; float measured_dimensions[2];
typedef struct { css_cached_measurement_t cached_layout;
css_direction_t direction; } css_layout_t;
css_flex_direction_t flex_direction;
css_justify_t justify_content;
css_align_t align_content;
css_align_t align_items;
css_align_t align_self;
css_position_type_t position_type;
css_wrap_type_t flex_wrap;
css_overflow_t 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];
} css_style_t;
typedef struct css_node css_node_t; typedef struct {
struct css_node { float dimensions[2];
css_style_t style; } css_dim_t;
css_layout_t layout;
int children_count;
int line_index;
css_node_t* next_child; typedef struct {
css_direction_t direction;
css_flex_direction_t flex_direction;
css_justify_t justify_content;
css_align_t align_content;
css_align_t align_items;
css_align_t align_self;
css_position_type_t position_type;
css_wrap_type_t flex_wrap;
css_overflow_t 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];
} css_style_t;
css_dim_t (*measure)(void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode); typedef struct css_node css_node_t;
void (*print)(void *context); struct css_node {
struct css_node* (*get_child)(void *context, int i); css_style_t style;
bool (*is_dirty)(void *context); css_layout_t layout;
bool (*is_text_node)(void *context); int children_count;
void *context; int line_index;
};
// Lifecycle of nodes and children css_node_t* next_child;
css_node_t *new_css_node(void);
void init_css_node(css_node_t *node);
void free_css_node(css_node_t *node);
// Print utilities css_dim_t (*measure)(void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode);
typedef enum { void (*print)(void *context);
CSS_PRINT_LAYOUT = 1, struct css_node* (*get_child)(void *context, int i);
CSS_PRINT_STYLE = 2, bool (*is_dirty)(void *context);
CSS_PRINT_CHILDREN = 4, bool (*is_text_node)(void *context);
} css_print_options_t; void *context;
void print_css_node(css_node_t *node, css_print_options_t options); };
// Function that computes the layout! // Lifecycle of nodes and children
void layoutNode(css_node_t *node, float availableWidth, float availableHeight, css_direction_t parentDirection); css_node_t *new_css_node(void);
bool isUndefined(float value); void init_css_node(css_node_t *node);
void free_css_node(css_node_t *node);
#endif // Print utilities
typedef enum {
CSS_PRINT_LAYOUT = 1,
CSS_PRINT_STYLE = 2,
CSS_PRINT_CHILDREN = 4,
} css_print_options_t;
void print_css_node(css_node_t *node, css_print_options_t options);
// Function that computes the layout!
void layoutNode(css_node_t *node, float availableWidth, float availableHeight, css_direction_t parentDirection);
bool isUndefined(float value);
#endif

View File

@ -4,11 +4,12 @@ The code here should be kept in sync with GitHub.
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/383d8a6b3dcbdb978e012e29040e1a43157765c6 HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/383d8a6b3dcbdb978e012e29040e1a43157765c6
There is generated code in: There is generated code in:
- README.facebook (this file) - README (this file)
- java/com/facebook/csslayout (this folder) - fbandroid/java/com/facebook/csslayout
- javatests/com/facebook/csslayout - fbandroid/javatests/com/facebook/csslayout
- fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout
The code was generated by running 'make' in the css-layout folder and running: The code was generated by running 'make' in the css-layout folder and running:
./syncFromGithub.sh <pathToGithubRepo> <pathToFbAndroid> scripts/sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>

View File

@ -5,8 +5,11 @@ HEAD at the time this code was synced: https://github.com/facebook/css-layout/co
There is generated code in: There is generated code in:
- README (this file) - README (this file)
- java/com/facebook/csslayout (this folder) - fbandroid/java/com/facebook/csslayout
- javatests/com/facebook/csslayout - fbandroid/javatests/com/facebook/csslayout
- fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout
The code was generated by running 'make' in the css-layout folder and copied to React Native. The code was generated by running 'make' in the css-layout folder and running:
scripts/sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>

View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function usage { function usage {
echo "usage: syncFromGithub.sh <pathToGithubRepo> <pathToFbAndroidRepo>"; echo "usage: sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>";
} }
function patchfile { function patchfile {
# Add React Native copyright # Add React Native copyright
printf "/**\n" >> /tmp/csslayoutsync.tmp printf "/**\n" > /tmp/csslayoutsync.tmp
printf " * Copyright (c) 2014-present, Facebook, Inc.\n" >> /tmp/csslayoutsync.tmp printf " * Copyright (c) 2014-present, Facebook, Inc.\n" >> /tmp/csslayoutsync.tmp
printf " * All rights reserved.\n" >> /tmp/csslayoutsync.tmp printf " * All rights reserved.\n" >> /tmp/csslayoutsync.tmp
printf " * This source code is licensed under the BSD-style license found in the\n" >> /tmp/csslayoutsync.tmp printf " * This source code is licensed under the BSD-style license found in the\n" >> /tmp/csslayoutsync.tmp
@ -21,7 +21,7 @@ function patchfile {
printf "!plEphiEmie@IsG>>\n\n" >> /tmp/csslayoutsync.tmp printf "!plEphiEmie@IsG>>\n\n" >> /tmp/csslayoutsync.tmp
tail -n +9 $1 >> /tmp/csslayoutsync.tmp tail -n +9 $1 >> /tmp/csslayoutsync.tmp
mv /tmp/csslayoutsync.tmp $1 mv /tmp/csslayoutsync.tmp $1
$ROOT/scripts/signedsource.py sign $1 $ROOT/fbandroid/scripts/signedsource.py sign $1
} }
if [ -z $1 ]; then if [ -z $1 ]; then
@ -44,15 +44,19 @@ pushd $GITHUB
COMMIT_ID=$(git rev-parse HEAD) COMMIT_ID=$(git rev-parse HEAD)
popd popd
SRC=$GITHUB/src/java/src/com/facebook/csslayout C_SRC=$GITHUB/src/
JAVA_SRC=$GITHUB/src/java/src/com/facebook/csslayout
TESTS=$GITHUB/src/java/tests/com/facebook/csslayout TESTS=$GITHUB/src/java/tests/com/facebook/csslayout
FBA_SRC=$ROOT/java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/csslayout/ FBA_SRC=$ROOT/fbandroid/java/com/facebook/catalyst/js/react-native-github/ReactAndroid/src/main/java/com/facebook/csslayout/
FBA_TESTS=$ROOT/javatests/com/facebook/csslayout FBA_TESTS=$ROOT/fbandroid/javatests/com/facebook/csslayout/
FBO_SRC=$ROOT/fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout/
echo "Copying src files over..." echo "Copying fbandroid src files over..."
cp $SRC/*.java $FBA_SRC cp $JAVA_SRC/*.java $FBA_SRC
echo "Copying test files over..." echo "Copying fbandroid test files over..."
cp $TESTS/*.java $FBA_TESTS cp $TESTS/*.java $FBA_TESTS
echo "Copying fbobjc src files over..."
cp $C_SRC/Layout.{c,h} $FBO_SRC
echo "Patching files..." echo "Patching files..."
for sourcefile in $FBA_SRC/*.java; do for sourcefile in $FBA_SRC/*.java; do
@ -61,23 +65,9 @@ done
for testfile in $FBA_TESTS/*.java; do for testfile in $FBA_TESTS/*.java; do
patchfile $testfile patchfile $testfile
done done
for sourcefile in $FBO_SRC/Layout.{c,h}; do
echo "Writing README.facebook" patchfile $sourcefile
done
echo "The source of truth for css-layout is: https://github.com/facebook/css-layout
The code here should be kept in sync with GitHub.
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/$COMMIT_ID
There is generated code in:
- README.facebook (this file)
- java/com/facebook/csslayout (this folder)
- javatests/com/facebook/csslayout
The code was generated by running 'make' in the css-layout folder and running:
./syncFromGithub.sh <pathToGithubRepo> <pathToFbAndroid>
" > $FBA_SRC/README.facebook
echo "Writing README" echo "Writing README"
@ -88,12 +78,14 @@ HEAD at the time this code was synced: https://github.com/facebook/css-layout/co
There is generated code in: There is generated code in:
- README (this file) - README (this file)
- java/com/facebook/csslayout (this folder) - fbandroid/java/com/facebook/csslayout
- javatests/com/facebook/csslayout - fbandroid/javatests/com/facebook/csslayout
- fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout
The code was generated by running 'make' in the css-layout folder and copied to React Native. The code was generated by running 'make' in the css-layout folder and running:
" > $FBA_SRC/README
echo "fbandroid was updated. Please also update the fbobjc version under" \ scripts/sync-css-layout.sh <pathToGithubRepo> <pathToFbSourceRepo>
"fbobjc/Libraries/FBReactKit/js/react-native-github/React/Layout/Layout.c." " > /tmp/csslayoutsync.tmp
echo "Please run buck test //javatests/com/facebook/csslayout"
cp /tmp/csslayoutsync.tmp "$FBA_SRC/README"
cp /tmp/csslayoutsync.tmp "$FBO_SRC/README"