mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
CamelCase
Reviewed By: majak Differential Revision: D3576069 fbshipit-source-id: cecda2cdb67f2f66ac92e336068d58731ccdb101
This commit is contained in:
committed by
Facebook Github Bot 2
parent
b7bf24bc7f
commit
1aa7ad0ab8
File diff suppressed because it is too large
Load Diff
@@ -21,132 +21,132 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
||||
#define NAN (*(const float *)__nan)
|
||||
#endif
|
||||
|
||||
#define CSS_UNDEFINED NAN
|
||||
#define CSSUndefined NAN
|
||||
|
||||
#include "CSSMacros.h"
|
||||
|
||||
CSS_EXTERN_C_BEGIN
|
||||
|
||||
typedef enum {
|
||||
CSS_DIRECTION_INHERIT = 0,
|
||||
CSS_DIRECTION_LTR,
|
||||
CSS_DIRECTION_RTL
|
||||
} css_direction_t;
|
||||
typedef enum CSSDirection {
|
||||
CSSDirectionInherit,
|
||||
CSSDirectionLTR,
|
||||
CSSDirectionRTL,
|
||||
} CSSDirection;
|
||||
|
||||
typedef enum {
|
||||
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 CSSFlexDirection {
|
||||
CSSFlexDirectionColumn,
|
||||
CSSFlexDirectionColumnReverse,
|
||||
CSSFlexDirectionRow,
|
||||
CSSFlexDirectionRowReverse,
|
||||
} CSSFlexDirection;
|
||||
|
||||
typedef enum {
|
||||
CSS_JUSTIFY_FLEX_START = 0,
|
||||
CSS_JUSTIFY_CENTER,
|
||||
CSS_JUSTIFY_FLEX_END,
|
||||
CSS_JUSTIFY_SPACE_BETWEEN,
|
||||
CSS_JUSTIFY_SPACE_AROUND
|
||||
} css_justify_t;
|
||||
typedef enum CSSJustify {
|
||||
CSSJustifyFlexStart,
|
||||
CSSJustifyCenter,
|
||||
CSSJustifyFlexEnd,
|
||||
CSSJustifySpaceBetween,
|
||||
CSSJustifySpaceAround,
|
||||
} CSSJustify;
|
||||
|
||||
typedef enum {
|
||||
CSS_OVERFLOW_VISIBLE = 0,
|
||||
CSS_OVERFLOW_HIDDEN
|
||||
} css_overflow_t;
|
||||
typedef enum CSSOverflow {
|
||||
CSSOverflowVisible,
|
||||
CSSOverflowHidden,
|
||||
} CSSOverflow;
|
||||
|
||||
// Note: auto is only a valid value for alignSelf. It is NOT a valid value for
|
||||
// alignItems.
|
||||
typedef enum {
|
||||
CSS_ALIGN_AUTO = 0,
|
||||
CSS_ALIGN_FLEX_START,
|
||||
CSS_ALIGN_CENTER,
|
||||
CSS_ALIGN_FLEX_END,
|
||||
CSS_ALIGN_STRETCH
|
||||
} css_align_t;
|
||||
typedef enum CSSAlign {
|
||||
CSSAlignAuto,
|
||||
CSSAlignFlexStart,
|
||||
CSSAlignCenter,
|
||||
CSSAlignFlexEnd,
|
||||
CSSAlignStretch,
|
||||
} CSSAlign;
|
||||
|
||||
typedef enum {
|
||||
CSS_POSITION_RELATIVE = 0,
|
||||
CSS_POSITION_ABSOLUTE
|
||||
} css_position_type_t;
|
||||
typedef enum CSSPositionType {
|
||||
CSSPositionTypeRelative,
|
||||
CSSPositionTypeAbsolute,
|
||||
} CSSPositionType;
|
||||
|
||||
typedef enum {
|
||||
CSS_NOWRAP = 0,
|
||||
CSS_WRAP
|
||||
} css_wrap_type_t;
|
||||
typedef enum CSSWrapType {
|
||||
CSSWrapTypeNoWrap,
|
||||
CSSWrapTypeWrap,
|
||||
} CSSWrapType;
|
||||
|
||||
// Note: left and top are shared between position[2] and position[4], so
|
||||
// they have to be before right and bottom.
|
||||
typedef enum {
|
||||
CSS_LEFT = 0,
|
||||
CSS_TOP,
|
||||
CSS_RIGHT,
|
||||
CSS_BOTTOM,
|
||||
CSS_START,
|
||||
CSS_END,
|
||||
CSS_POSITION_COUNT
|
||||
} css_position_t;
|
||||
typedef enum CSSPosition {
|
||||
CSSPositionLeft,
|
||||
CSSPositionTop,
|
||||
CSSPositionRight,
|
||||
CSSPositionBottom,
|
||||
CSSPositionStart,
|
||||
CSSPositionEnd,
|
||||
CSSPositionCount,
|
||||
} CSSPosition;
|
||||
|
||||
typedef enum {
|
||||
CSS_MEASURE_MODE_UNDEFINED = 0,
|
||||
CSS_MEASURE_MODE_EXACTLY,
|
||||
CSS_MEASURE_MODE_AT_MOST,
|
||||
CSS_MEASURE_MODE_COUNT
|
||||
} css_measure_mode_t;
|
||||
typedef enum CSSMeasureMode {
|
||||
CSSMeasureModeUndefined,
|
||||
CSSMeasureModeExactly,
|
||||
CSSMeasureModeAtMost,
|
||||
CSSMeasureModeCount,
|
||||
} CSSMeasureMode;
|
||||
|
||||
typedef enum {
|
||||
CSS_WIDTH = 0,
|
||||
CSS_HEIGHT
|
||||
} css_dimension_t;
|
||||
typedef enum CSSDimension {
|
||||
CSSDimensionWidth,
|
||||
CSSDimensionHeight,
|
||||
} CSSDimension;
|
||||
|
||||
typedef struct {
|
||||
float available_width;
|
||||
float available_height;
|
||||
css_measure_mode_t width_measure_mode;
|
||||
css_measure_mode_t height_measure_mode;
|
||||
typedef struct CSSCachedMeasurement {
|
||||
float availableWidth;
|
||||
float availableHeight;
|
||||
CSSMeasureMode widthMeasureMode;
|
||||
CSSMeasureMode heightMeasureMode;
|
||||
|
||||
float computed_width;
|
||||
float computed_height;
|
||||
} css_cached_measurement_t;
|
||||
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 {
|
||||
// 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
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct CSSLayout {
|
||||
float position[4];
|
||||
float dimensions[2];
|
||||
css_direction_t direction;
|
||||
CSSDirection direction;
|
||||
|
||||
float flex_basis;
|
||||
float flexBasis;
|
||||
|
||||
// Instead of recomputing the entire layout every single time, we
|
||||
// cache some information to break early when nothing changed
|
||||
bool should_update;
|
||||
int generation_count;
|
||||
css_direction_t last_parent_direction;
|
||||
bool shouldUpdate;
|
||||
int generationCount;
|
||||
CSSDirection lastParentDirection;
|
||||
|
||||
int next_cached_measurements_index;
|
||||
css_cached_measurement_t cached_measurements[CSS_MAX_CACHED_RESULT_COUNT];
|
||||
float measured_dimensions[2];
|
||||
int nextCachedMeasurementsIndex;
|
||||
CSSCachedMeasurement cachedMeasurements[CSS_MAX_CACHED_RESULT_COUNT];
|
||||
float measuredDimensions[2];
|
||||
|
||||
css_cached_measurement_t cached_layout;
|
||||
} css_layout_t;
|
||||
CSSCachedMeasurement cached_layout;
|
||||
} CSSLayout;
|
||||
|
||||
typedef struct {
|
||||
typedef struct CSSMeasureResult {
|
||||
float dimensions[2];
|
||||
} css_dim_t;
|
||||
} CSSMeasureResult;
|
||||
|
||||
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;
|
||||
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];
|
||||
@@ -165,40 +165,40 @@ typedef struct {
|
||||
float dimensions[2];
|
||||
float minDimensions[2];
|
||||
float maxDimensions[2];
|
||||
} css_style_t;
|
||||
} CSSStyle;
|
||||
|
||||
typedef struct css_node css_node_t;
|
||||
struct css_node {
|
||||
css_style_t style;
|
||||
css_layout_t layout;
|
||||
int children_count;
|
||||
int line_index;
|
||||
typedef struct CSSNode {
|
||||
CSSStyle style;
|
||||
CSSLayout layout;
|
||||
int childCount;
|
||||
int lineIndex;
|
||||
|
||||
css_node_t* next_child;
|
||||
struct CSSNode* nextChild;
|
||||
|
||||
css_dim_t (*measure)(void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode);
|
||||
CSSMeasureResult (*measure)(void *context, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode);
|
||||
void (*print)(void *context);
|
||||
struct css_node* (*get_child)(void *context, int i);
|
||||
bool (*is_dirty)(void *context);
|
||||
bool (*is_text_node)(void *context);
|
||||
struct CSSNode* (*getChild)(void *context, int i);
|
||||
bool (*isDirty)(void *context);
|
||||
bool (*isTextNode)(void *context);
|
||||
void *context;
|
||||
};
|
||||
} CSSNode;
|
||||
|
||||
// Lifecycle of nodes and children
|
||||
css_node_t *new_css_node(void);
|
||||
void init_css_node(css_node_t *node);
|
||||
void free_css_node(css_node_t *node);
|
||||
CSSNode *CSSNodeNew();
|
||||
void CSSNodeInit(CSSNode *node);
|
||||
void CSSNodeFree(CSSNode *node);
|
||||
|
||||
// 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);
|
||||
typedef enum CSSPrintOptions {
|
||||
CSSPrintOptionsLayout = 1,
|
||||
CSSPrintOptionsStyle = 2,
|
||||
CSSPrintOptionsChildren = 4,
|
||||
} CSSPrintOptions;
|
||||
|
||||
void CSSNodePrint(CSSNode *node, CSSPrintOptions options);
|
||||
|
||||
// Function that computes the layout!
|
||||
void layoutNode(css_node_t *node, float availableWidth, float availableHeight, css_direction_t parentDirection);
|
||||
void layoutNode(CSSNode *node, float availableWidth, float availableHeight, CSSDirection parentDirection);
|
||||
bool isUndefined(float value);
|
||||
|
||||
CSS_EXTERN_C_END
|
||||
|
||||
Reference in New Issue
Block a user