pull in github css-layout into fbobjc react native
Reviewed By: @vjeux Differential Revision: D2448929
This commit is contained in:
parent
d94ed42e1c
commit
e665acca4b
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,4 @@
|
|||
/**
|
||||
* @generated SignedSource<<58298c7a8815a8675e970b0347dedfed>>
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* !! This file is a check-in from github! !!
|
||||
|
@ -7,7 +6,8 @@
|
|||
* !! 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) Execute ./import.sh to pull in the latest version !!
|
||||
* !! 3) Copy the file from github to here !!
|
||||
* !! (don't forget to keep this header) !!
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* Copyright (c) 2014, Facebook, Inc.
|
||||
|
@ -22,12 +22,29 @@
|
|||
#define __LAYOUT_H
|
||||
|
||||
#include <math.h>
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
// Not defined in MSVC++
|
||||
#ifndef NAN
|
||||
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
||||
#define NAN (*(const float *)__nan)
|
||||
#endif
|
||||
|
||||
#define CSS_UNDEFINED NAN
|
||||
|
||||
typedef enum {
|
||||
CSS_DIRECTION_INHERIT = 0,
|
||||
CSS_DIRECTION_LTR,
|
||||
CSS_DIRECTION_RTL
|
||||
} css_direction_t;
|
||||
|
||||
typedef enum {
|
||||
CSS_FLEX_DIRECTION_COLUMN = 0,
|
||||
CSS_FLEX_DIRECTION_ROW
|
||||
CSS_FLEX_DIRECTION_COLUMN_REVERSE,
|
||||
CSS_FLEX_DIRECTION_ROW,
|
||||
CSS_FLEX_DIRECTION_ROW_REVERSE
|
||||
} css_flex_direction_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -65,6 +82,8 @@ typedef enum {
|
|||
CSS_TOP,
|
||||
CSS_RIGHT,
|
||||
CSS_BOTTOM,
|
||||
CSS_START,
|
||||
CSS_END,
|
||||
CSS_POSITION_COUNT
|
||||
} css_position_t;
|
||||
|
||||
|
@ -74,8 +93,9 @@ typedef enum {
|
|||
} css_dimension_t;
|
||||
|
||||
typedef struct {
|
||||
float position[2];
|
||||
float position[4];
|
||||
float dimensions[2];
|
||||
css_direction_t direction;
|
||||
|
||||
// Instead of recomputing the entire layout every single time, we
|
||||
// cache some information to break early when nothing changed
|
||||
|
@ -84,6 +104,7 @@ typedef struct {
|
|||
float last_parent_max_width;
|
||||
float last_dimensions[2];
|
||||
float last_position[2];
|
||||
css_direction_t last_direction;
|
||||
} css_layout_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -91,14 +112,16 @@ typedef struct {
|
|||
} css_dim_t;
|
||||
|
||||
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;
|
||||
float flex;
|
||||
float margin[4];
|
||||
float margin[6];
|
||||
float position[4];
|
||||
/**
|
||||
* You should skip all the rules that contain negative values for the
|
||||
|
@ -110,22 +133,29 @@ typedef struct {
|
|||
* {left: -5 ...}
|
||||
* {left: 0 ...}
|
||||
*/
|
||||
float padding[4];
|
||||
float border[4];
|
||||
float padding[6];
|
||||
float border[6];
|
||||
float dimensions[2];
|
||||
float minDimensions[2];
|
||||
float maxDimensions[2];
|
||||
} css_style_t;
|
||||
|
||||
typedef struct css_node {
|
||||
typedef struct css_node css_node_t;
|
||||
struct css_node {
|
||||
css_style_t style;
|
||||
css_layout_t layout;
|
||||
int children_count;
|
||||
int line_index;
|
||||
|
||||
css_node_t* next_absolute_child;
|
||||
css_node_t* next_flex_child;
|
||||
|
||||
css_dim_t (*measure)(void *context, float width);
|
||||
void (*print)(void *context);
|
||||
struct css_node* (*get_child)(void *context, int i);
|
||||
bool (*is_dirty)(void *context);
|
||||
void *context;
|
||||
} css_node_t;
|
||||
};
|
||||
|
||||
|
||||
// Lifecycle of nodes and children
|
||||
|
@ -142,7 +172,7 @@ typedef enum {
|
|||
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 maxWidth);
|
||||
void layoutNode(css_node_t *node, float maxWidth, css_direction_t parentDirection);
|
||||
bool isUndefined(float value);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -219,7 +219,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
|||
parentConstraint:(__unused CGSize)parentConstraint
|
||||
{
|
||||
[self fillCSSNode:_cssNode];
|
||||
layoutNode(_cssNode, CSS_UNDEFINED);
|
||||
layoutNode(_cssNode, CSS_UNDEFINED, CSS_DIRECTION_INHERIT);
|
||||
[self applyLayoutNode:_cssNode viewsWithNewFrame:viewsWithNewFrame absolutePosition:CGPointZero];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue