summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bytecode/opcodes.h78
-rw-r--r--src/parse/important.c20
-rw-r--r--src/parse/properties/Makefile2
-rw-r--r--src/parse/properties/flex.c213
-rw-r--r--src/parse/properties/flex_flow.c137
-rw-r--r--src/parse/properties/properties.c13
-rw-r--r--src/parse/properties/properties.gen26
-rw-r--r--src/parse/properties/properties.h37
-rw-r--r--src/parse/propstrings.c26
-rw-r--r--src/parse/propstrings.h48
-rw-r--r--src/select/computed.c91
-rw-r--r--src/select/computed.h43
-rw-r--r--src/select/dispatch.c50
-rw-r--r--src/select/properties/Makefile10
-rw-r--r--src/select/properties/align_content.c81
-rw-r--r--src/select/properties/align_items.c75
-rw-r--r--src/select/properties/align_self.c78
-rw-r--r--src/select/properties/display.c6
-rw-r--r--src/select/properties/flex_basis.c79
-rw-r--r--src/select/properties/flex_direction.c72
-rw-r--r--src/select/properties/flex_grow.c62
-rw-r--r--src/select/properties/flex_shrink.c62
-rw-r--r--src/select/properties/flex_wrap.c69
-rw-r--r--src/select/properties/justify_content.c79
-rw-r--r--src/select/properties/min_height.c4
-rw-r--r--src/select/properties/min_width.c5
-rw-r--r--src/select/properties/order.c62
-rw-r--r--src/select/properties/properties.h10
-rw-r--r--src/select/propget.h254
-rw-r--r--src/select/propset.h250
30 files changed, 1956 insertions, 86 deletions
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 64ea482..82bf75f 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -10,6 +10,33 @@
#include <inttypes.h>
+enum op_align_content {
+ ALIGN_CONTENT_STRETCH = 0x0000,
+ ALIGN_CONTENT_FLEX_START = 0x0001,
+ ALIGN_CONTENT_FLEX_END = 0x0002,
+ ALIGN_CONTENT_CENTER = 0x0003,
+ ALIGN_CONTENT_SPACE_BETWEEN = 0x0004,
+ ALIGN_CONTENT_SPACE_AROUND = 0x0005,
+ ALIGN_CONTENT_SPACE_EVENLY = 0x0006
+};
+
+enum op_align_items {
+ ALIGN_ITEMS_STRETCH = 0x0000,
+ ALIGN_ITEMS_FLEX_START = 0x0001,
+ ALIGN_ITEMS_FLEX_END = 0x0002,
+ ALIGN_ITEMS_CENTER = 0x0003,
+ ALIGN_ITEMS_BASELINE = 0x0004
+};
+
+enum op_align_self {
+ ALIGN_SELF_STRETCH = 0x0000,
+ ALIGN_SELF_FLEX_START = 0x0001,
+ ALIGN_SELF_FLEX_END = 0x0002,
+ ALIGN_SELF_CENTER = 0x0003,
+ ALIGN_SELF_BASELINE = 0x0004,
+ ALIGN_SELF_AUTO = 0x0005
+};
+
enum op_azimuth {
AZIMUTH_ANGLE = 0x0080,
@@ -303,7 +330,9 @@ enum op_display {
DISPLAY_TABLE_COLUMN = 0x000c,
DISPLAY_TABLE_CELL = 0x000d,
DISPLAY_TABLE_CAPTION = 0x000e,
- DISPLAY_NONE = 0x000f
+ DISPLAY_NONE = 0x000f,
+ DISPLAY_FLEX = 0x0010,
+ DISPLAY_INLINE_FLEX = 0x0011
};
enum op_elevation {
@@ -320,6 +349,33 @@ enum op_empty_cells {
EMPTY_CELLS_HIDE = 0x0001
};
+enum op_flex_basis {
+ FLEX_BASIS_AUTO = 0x0000,
+ FLEX_BASIS_CONTENT = 0x0001,
+ FLEX_BASIS_SET = 0x0080
+};
+
+enum op_flex_direction {
+ FLEX_DIRECTION_ROW = 0x0000,
+ FLEX_DIRECTION_ROW_REVERSE = 0x0001,
+ FLEX_DIRECTION_COLUMN = 0x0002,
+ FLEX_DIRECTION_COLUMN_REVERSE = 0x0003
+};
+
+enum op_flex_grow {
+ FLEX_GROW_SET = 0x0080
+};
+
+enum op_flex_shrink {
+ FLEX_SHRINK_SET = 0x0080
+};
+
+enum op_flex_wrap {
+ FLEX_WRAP_NOWRAP = 0x0000,
+ FLEX_WRAP_WRAP = 0x0001,
+ FLEX_WRAP_WRAP_REVERSE = 0x0002
+};
+
enum op_float {
FLOAT_LEFT = 0x0000,
FLOAT_RIGHT = 0x0001,
@@ -385,6 +441,15 @@ enum op_height {
HEIGHT_AUTO = 0x0000
};
+enum op_justify_content {
+ JUSTIFY_CONTENT_FLEX_START = 0x0000,
+ JUSTIFY_CONTENT_FLEX_END = 0x0001,
+ JUSTIFY_CONTENT_CENTER = 0x0002,
+ JUSTIFY_CONTENT_SPACE_BETWEEN = 0x0003,
+ JUSTIFY_CONTENT_SPACE_AROUND = 0x0004,
+ JUSTIFY_CONTENT_SPACE_EVENLY = 0x0005
+};
+
enum op_left {
LEFT_SET = BOTTOM_SET,
LEFT_AUTO = BOTTOM_AUTO
@@ -445,17 +510,23 @@ enum op_max_width {
};
enum op_min_height {
- MIN_HEIGHT_SET = 0x0080
+ MIN_HEIGHT_SET = 0x0080,
+ MIN_HEIGHT_AUTO = 0x0000
};
enum op_min_width {
- MIN_WIDTH_SET = 0x0080
+ MIN_WIDTH_SET = 0x0080,
+ MIN_WIDTH_AUTO = 0x0000
};
enum op_opacity {
OPACITY_SET = 0x0080
};
+enum op_order {
+ ORDER_SET = 0x0080
+};
+
enum op_orphans {
ORPHANS_SET = 0x0080
};
@@ -735,4 +806,3 @@ enum op_z_index {
};
#endif
-
diff --git a/src/parse/important.c b/src/parse/important.c
index ca4d60c..e0e8620 100644
--- a/src/parse/important.c
+++ b/src/parse/important.c
@@ -258,6 +258,21 @@ void css__make_style_important(css_style *style)
offset += 2; /* length + units */
break;
+ case CSS_PROP_FLEX_BASIS:
+ if (value == FLEX_BASIS_SET)
+ offset += 2; /* length + units */
+ break;
+
+ case CSS_PROP_FLEX_GROW:
+ if (value == FLEX_GROW_SET)
+ offset++; /* value */
+ break;
+
+ case CSS_PROP_FLEX_SHRINK:
+ if (value == FLEX_SHRINK_SET)
+ offset++; /* value */
+ break;
+
case CSS_PROP_FONT_FAMILY:
while (value != FONT_FAMILY_END) {
switch (value) {
@@ -331,6 +346,11 @@ void css__make_style_important(css_style *style)
offset++; /* value */
break;
+ case CSS_PROP_ORDER:
+ if (value == ORDER_SET)
+ offset++; /* value */
+ break;
+
case CSS_PROP_ORPHANS:
case CSS_PROP_PITCH_RANGE:
case CSS_PROP_RICHNESS:
diff --git a/src/parse/properties/Makefile b/src/parse/properties/Makefile
index 6d6cff0..6461dda 100644
--- a/src/parse/properties/Makefile
+++ b/src/parse/properties/Makefile
@@ -45,6 +45,8 @@ DIR_SOURCES := \
cue.c \
cursor.c \
elevation.c \
+ flex.c \
+ flex_flow.c \
font.c \
font_family.c \
font_weight.c \
diff --git a/src/parse/properties/flex.c b/src/parse/properties/flex.c
new file mode 100644
index 0000000..9e284d9
--- /dev/null
+++ b/src/parse/properties/flex.c
@@ -0,0 +1,213 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "parse/properties/properties.h"
+#include "parse/properties/utils.h"
+
+/**
+ * Parse list-style
+ *
+ * \param c Parsing context
+ * \param vector Vector of tokens to process
+ * \param ctx Pointer to vector iteration context
+ * \param result Pointer to location to receive resulting style
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_INVALID if the input is not valid
+ *
+ * Post condition: \a *ctx is updated with the next token to process
+ * If the input is invalid, then \a *ctx remains unchanged.
+ */
+
+css_error css__parse_flex(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result)
+{
+ int orig_ctx = *ctx;
+ int prev_ctx;
+ const css_token *token;
+ css_error error;
+ bool grow = true;
+ bool shrink = true;
+ bool basis = true;
+ css_style *grow_style;
+ css_style *shrink_style;
+ css_style *basis_style;
+ bool short_auto = false;
+ bool short_none = false;
+ bool match;
+
+ /* Firstly, handle inherit */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL)
+ return CSS_INVALID;
+
+ if (is_css_inherit(c, token)) {
+ error = css_stylesheet_style_inherit(result,
+ CSS_PROP_FLEX_GROW);
+ if (error != CSS_OK)
+ return error;
+
+ error = css_stylesheet_style_inherit(result,
+ CSS_PROP_FLEX_SHRINK);
+
+ if (error != CSS_OK)
+ return error;
+
+ error = css_stylesheet_style_inherit(result,
+ CSS_PROP_FLEX_BASIS);
+
+ if (error == CSS_OK)
+ parserutils_vector_iterate(vector, ctx);
+
+ return error;
+ }
+
+ /* allocate styles */
+ error = css__stylesheet_style_create(c->sheet, &grow_style);
+ if (error != CSS_OK)
+ return error;
+
+ error = css__stylesheet_style_create(c->sheet, &shrink_style);
+ if (error != CSS_OK) {
+ css__stylesheet_style_destroy(grow_style);
+ return error;
+ }
+
+ error = css__stylesheet_style_create(c->sheet, &basis_style);
+ if (error != CSS_OK) {
+ css__stylesheet_style_destroy(grow_style);
+ css__stylesheet_style_destroy(shrink_style);
+ return error;
+ }
+
+ /* Handle shorthand none, equivalent of flex: 0 0 auto; */
+ if ((token->type == CSS_TOKEN_IDENT) &&
+ (lwc_string_caseless_isequal(
+ token->idata, c->strings[NONE],
+ &match) == lwc_error_ok && match)) {
+ short_none = true;
+ parserutils_vector_iterate(vector, ctx);
+
+ } else if ((token->type == CSS_TOKEN_IDENT) &&
+ (lwc_string_caseless_isequal(
+ token->idata, c->strings[AUTO],
+ &match) == lwc_error_ok && match)) {
+ /* Handle shorthand auto, equivalent of flex: 1 1 auto; */
+ short_auto = true;
+ parserutils_vector_iterate(vector, ctx);
+
+ } else do {
+ /* Attempt to parse the various longhand properties */
+ prev_ctx = *ctx;
+ error = CSS_OK;
+
+ /* Ensure that we're not about to parse another inherit */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token != NULL && is_css_inherit(c, token)) {
+ error = CSS_INVALID;
+ goto css__parse_flex_cleanup;
+ }
+
+ if ((grow) &&
+ (error = css__parse_flex_grow(c, vector,
+ ctx, grow_style)) == CSS_OK) {
+ grow = false;
+ } else if ((basis) &&
+ (error = css__parse_flex_basis(c, vector,
+ ctx, basis_style)) == CSS_OK) {
+ basis = false;
+ } else if ((shrink) &&
+ (error = css__parse_flex_shrink(c, vector,
+ ctx, shrink_style)) == CSS_OK) {
+ shrink = false;
+ }
+
+ if (error == CSS_OK) {
+ consumeWhitespace(vector, ctx);
+ token = parserutils_vector_peek(vector, *ctx);
+ } else {
+ /* Forcibly cause loop to exit */
+ token = NULL;
+ }
+ } while (*ctx != prev_ctx && token != NULL);
+
+ /* defaults */
+ if (grow) {
+ error = css__stylesheet_style_appendOPV(grow_style,
+ CSS_PROP_FLEX_GROW, 0, FLEX_GROW_SET);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ css_fixed grow_num = short_auto ? INTTOFIX(1) : 0;
+ error = css__stylesheet_style_append(grow_style, grow_num);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+ }
+
+ if (shrink) {
+ error = css__stylesheet_style_appendOPV(shrink_style,
+ CSS_PROP_FLEX_SHRINK, 0, FLEX_SHRINK_SET);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ css_fixed shrink_num = short_none ? 0 : INTTOFIX(1);
+ error = css__stylesheet_style_append(shrink_style, shrink_num);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+ }
+
+ if (basis) {
+ /* Default is auto, but zero if grow or shrink are set */
+ if (!grow || !shrink) {
+ error = css__stylesheet_style_appendOPV(basis_style,
+ CSS_PROP_FLEX_BASIS, 0,
+ FLEX_BASIS_SET);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ error = css__stylesheet_style_vappend(
+ basis_style, 2, 0, UNIT_PX);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ } else {
+ error = css__stylesheet_style_appendOPV(basis_style,
+ CSS_PROP_FLEX_BASIS, 0,
+ FLEX_BASIS_AUTO);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+ }
+ }
+
+ error = css__stylesheet_merge_style(result, grow_style);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ error = css__stylesheet_merge_style(result, shrink_style);
+ if (error != CSS_OK)
+ goto css__parse_flex_cleanup;
+
+ error = css__stylesheet_merge_style(result, basis_style);
+
+css__parse_flex_cleanup:
+
+ css__stylesheet_style_destroy(basis_style);
+ css__stylesheet_style_destroy(shrink_style);
+ css__stylesheet_style_destroy(grow_style);
+
+ if (error != CSS_OK)
+ *ctx = orig_ctx;
+
+ return error;
+}
+
diff --git a/src/parse/properties/flex_flow.c b/src/parse/properties/flex_flow.c
new file mode 100644
index 0000000..6a83e15
--- /dev/null
+++ b/src/parse/properties/flex_flow.c
@@ -0,0 +1,137 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "parse/properties/properties.h"
+#include "parse/properties/utils.h"
+
+/**
+ * Parse flex-flow
+ *
+ * \param c Parsing context
+ * \param vector Vector of tokens to process
+ * \param ctx Pointer to vector iteration context
+ * \param result Pointer to location to receive resulting style
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_INVALID if the input is not valid
+ *
+ * Post condition: \a *ctx is updated with the next token to process
+ * If the input is invalid, then \a *ctx remains unchanged.
+ */
+
+css_error css__parse_flex_flow(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result)
+{
+ int orig_ctx = *ctx;
+ int prev_ctx;
+ const css_token *token;
+ css_error error;
+ bool direction = true;
+ bool wrap = true;
+ css_style *direction_style;
+ css_style *wrap_style;
+
+ /* Firstly, handle inherit */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token == NULL)
+ return CSS_INVALID;
+
+ if (is_css_inherit(c, token)) {
+ error = css_stylesheet_style_inherit(result,
+ CSS_PROP_FLEX_DIRECTION);
+ if (error != CSS_OK)
+ return error;
+
+ error = css_stylesheet_style_inherit(result,
+ CSS_PROP_FLEX_WRAP);
+
+ if (error == CSS_OK)
+ parserutils_vector_iterate(vector, ctx);
+
+ return error;
+ }
+
+ /* allocate styles */
+ error = css__stylesheet_style_create(c->sheet, &direction_style);
+ if (error != CSS_OK)
+ return error;
+
+ error = css__stylesheet_style_create(c->sheet, &wrap_style);
+ if (error != CSS_OK) {
+ css__stylesheet_style_destroy(direction_style);
+ return error;
+ }
+
+ /* Attempt to parse the various longhand properties */
+ do {
+ prev_ctx = *ctx;
+ error = CSS_OK;
+
+ /* Ensure that we're not about to parse another inherit */
+ token = parserutils_vector_peek(vector, *ctx);
+ if (token != NULL && is_css_inherit(c, token)) {
+ error = CSS_INVALID;
+ goto css__parse_flex_flow_cleanup;
+ }
+
+ if ((wrap) &&
+ (error = css__parse_flex_wrap(c, vector,
+ ctx, wrap_style)) == CSS_OK) {
+ wrap = false;
+ } else if ((direction) &&
+ (error = css__parse_flex_direction(c, vector,
+ ctx, direction_style)) == CSS_OK) {
+ direction = false;
+ }
+
+ if (error == CSS_OK) {
+ consumeWhitespace(vector, ctx);
+
+ token = parserutils_vector_peek(vector, *ctx);
+ } else {
+ /* Forcibly cause loop to exit */
+ token = NULL;
+ }
+ } while (*ctx != prev_ctx && token != NULL);
+
+
+ /* defaults */
+ if (direction) {
+ error = css__stylesheet_style_appendOPV(direction_style,
+ CSS_PROP_FLEX_DIRECTION,
+ 0, FLEX_DIRECTION_ROW);
+ }
+
+ if (wrap) {
+ error = css__stylesheet_style_appendOPV(wrap_style,
+ CSS_PROP_FLEX_WRAP,
+ 0, FLEX_WRAP_NOWRAP);
+ }
+
+ error = css__stylesheet_merge_style(result, direction_style);
+ if (error != CSS_OK)
+ goto css__parse_flex_flow_cleanup;
+
+ error = css__stylesheet_merge_style(result, wrap_style);
+
+css__parse_flex_flow_cleanup:
+
+ css__stylesheet_style_destroy(wrap_style);
+ css__stylesheet_style_destroy(direction_style);
+
+ if (error != CSS_OK)
+ *ctx = orig_ctx;
+
+ return error;
+}
+
diff --git a/src/parse/properties/properties.c b/src/parse/properties/properties.c
index f32e374..3f374fa 100644
--- a/src/parse/properties/properties.c
+++ b/src/parse/properties/properties.c
@@ -12,6 +12,9 @@
*/
const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
{
+ css__parse_align_content,
+ css__parse_align_items,
+ css__parse_align_self,
css__parse_azimuth,
css__parse_background,
css__parse_background_attachment,
@@ -71,6 +74,13 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_display,
css__parse_elevation,
css__parse_empty_cells,
+ css__parse_flex,
+ css__parse_flex_basis,
+ css__parse_flex_direction,
+ css__parse_flex_flow,
+ css__parse_flex_grow,
+ css__parse_flex_shrink,
+ css__parse_flex_wrap,
css__parse_float,
css__parse_font,
css__parse_font_family,
@@ -79,6 +89,7 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_font_variant,
css__parse_font_weight,
css__parse_height,
+ css__parse_justify_content,
css__parse_left,
css__parse_letter_spacing,
css__parse_line_height,
@@ -96,6 +107,7 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_min_height,
css__parse_min_width,
css__parse_opacity,
+ css__parse_order,
css__parse_orphans,
css__parse_outline,
css__parse_outline_color,
@@ -146,4 +158,3 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_writing_mode,
css__parse_z_index
};
-
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index 60d5536..61dcd5e 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -16,7 +16,7 @@ cue_before:CSS_PROP_CUE_BEFORE IDENT:( INHERIT: NONE:0,CUE_BEFORE_NONE IDENT:) U
direction:CSS_PROP_DIRECTION IDENT:( INHERIT: LTR:0,DIRECTION_LTR RTL:0,DIRECTION_RTL IDENT:)
-display:CSS_PROP_DISPLAY IDENT:( INHERIT: INLINE:0,DISPLAY_INLINE BLOCK:0,DISPLAY_BLOCK LIST_ITEM:0,DISPLAY_LIST_ITEM RUN_IN:0,DISPLAY_RUN_IN INLINE_BLOCK:0,DISPLAY_INLINE_BLOCK TABLE:0,DISPLAY_TABLE INLINE_TABLE:0,DISPLAY_INLINE_TABLE TABLE_ROW_GROUP:0,DISPLAY_TABLE_ROW_GROUP TABLE_HEADER_GROUP:0,DISPLAY_TABLE_HEADER_GROUP TABLE_FOOTER_GROUP:0,DISPLAY_TABLE_FOOTER_GROUP TABLE_ROW:0,DISPLAY_TABLE_ROW TABLE_COLUMN_GROUP:0,DISPLAY_TABLE_COLUMN_GROUP TABLE_COLUMN:0,DISPLAY_TABLE_COLUMN TABLE_CELL:0,DISPLAY_TABLE_CELL TABLE_CAPTION:0,DISPLAY_TABLE_CAPTION NONE:0,DISPLAY_NONE IDENT:)
+display:CSS_PROP_DISPLAY IDENT:( INHERIT: INLINE:0,DISPLAY_INLINE BLOCK:0,DISPLAY_BLOCK LIST_ITEM:0,DISPLAY_LIST_ITEM RUN_IN:0,DISPLAY_RUN_IN INLINE_BLOCK:0,DISPLAY_INLINE_BLOCK TABLE:0,DISPLAY_TABLE INLINE_TABLE:0,DISPLAY_INLINE_TABLE TABLE_ROW_GROUP:0,DISPLAY_TABLE_ROW_GROUP TABLE_HEADER_GROUP:0,DISPLAY_TABLE_HEADER_GROUP TABLE_FOOTER_GROUP:0,DISPLAY_TABLE_FOOTER_GROUP TABLE_ROW:0,DISPLAY_TABLE_ROW TABLE_COLUMN_GROUP:0,DISPLAY_TABLE_COLUMN_GROUP TABLE_COLUMN:0,DISPLAY_TABLE_COLUMN TABLE_CELL:0,DISPLAY_TABLE_CELL TABLE_CAPTION:0,DISPLAY_TABLE_CAPTION NONE:0,DISPLAY_NONE FLEX:0,DISPLAY_FLEX INLINE_FLEX:0,DISPLAY_INLINE_FLEX IDENT:)
empty_cells:CSS_PROP_EMPTY_CELLS IDENT:( INHERIT: SHOW:0,EMPTY_CELLS_SHOW HIDE:0,EMPTY_CELLS_HIDE IDENT:)
@@ -43,9 +43,9 @@ max_height:CSS_PROP_MAX_HEIGHT IDENT:( INHERIT: NONE:0,MAX_HEIGHT_NONE IDENT:) L
max_width:CSS_PROP_MAX_WIDTH IDENT:( INHERIT: NONE:0,MAX_WIDTH_NONE IDENT:) LENGTH_UNIT:( UNIT_PX:MAX_WIDTH_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
-min_height:CSS_PROP_MIN_HEIGHT IDENT:INHERIT LENGTH_UNIT:( UNIT_PX:MIN_HEIGHT_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
+min_height:CSS_PROP_MIN_HEIGHT IDENT:( INHERIT: AUTO:0,MIN_HEIGHT_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_HEIGHT_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
-min_width:CSS_PROP_MIN_WIDTH IDENT:INHERIT LENGTH_UNIT:( UNIT_PX:MIN_WIDTH_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
+min_width:CSS_PROP_MIN_WIDTH IDENT:( INHERIT: AUTO:0,MIN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:MIN_WIDTH_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
color:CSS_PROP_COLOR IDENT:INHERIT COLOR:COLOR_SET
@@ -217,3 +217,23 @@ column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: AUTO:0,COLUMN_WIDTH_AUTO IDE
writing_mode:CSS_PROP_WRITING_MODE IDENT:( INHERIT: HORIZONTAL_TB:0,WRITING_MODE_HORIZONTAL_TB VERTICAL_RL:0,WRITING_MODE_VERTICAL_RL VERTICAL_LR:0,WRITING_MODE_VERTICAL_LR IDENT:)
box_sizing:CSS_PROP_BOX_SIZING IDENT:( INHERIT: CONTENT_BOX:0,BOX_SIZING_CONTENT_BOX BORDER_BOX:0,BOX_SIZING_BORDER_BOX IDENT:)
+
+align_content:CSS_PROP_ALIGN_CONTENT IDENT:( INHERIT: STRETCH:0,ALIGN_CONTENT_STRETCH FLEX_START:0,ALIGN_CONTENT_FLEX_START FLEX_END:0,ALIGN_CONTENT_FLEX_END CENTER:0,ALIGN_CONTENT_CENTER SPACE_BETWEEN:0,ALIGN_CONTENT_SPACE_BETWEEN SPACE_AROUND:0,ALIGN_CONTENT_SPACE_AROUND SPACE_EVENLY:0,ALIGN_CONTENT_SPACE_EVENLY IDENT:)
+
+align_items:CSS_PROP_ALIGN_ITEMS IDENT:( INHERIT: STRETCH:0,ALIGN_ITEMS_STRETCH FLEX_START:0,ALIGN_ITEMS_FLEX_START FLEX_END:0,ALIGN_ITEMS_FLEX_END CENTER:0,ALIGN_ITEMS_CENTER BASELINE:0,ALIGN_ITEMS_BASELINE IDENT:)
+
+align_self:CSS_PROP_ALIGN_SELF IDENT:( INHERIT: STRETCH:0,ALIGN_SELF_STRETCH FLEX_START:0,ALIGN_SELF_FLEX_START FLEX_END:0,ALIGN_SELF_FLEX_END CENTER:0,ALIGN_SELF_CENTER BASELINE:0,ALIGN_SELF_BASELINE AUTO:0,ALIGN_SELF_AUTO IDENT:)
+
+flex_basis:CSS_PROP_FLEX_BASIS IDENT:( INHERIT: AUTO:0,FLEX_BASIS_AUTO CONTENT:0,FLEX_BASIS_CONTENT IDENT:) LENGTH_UNIT:( UNIT_PX:FLEX_BASIS_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
+
+flex_direction:CSS_PROP_FLEX_DIRECTION IDENT:( INHERIT: ROW:0,FLEX_DIRECTION_ROW ROW_REVERSE:0,FLEX_DIRECTION_ROW_REVERSE COLUMN:0,FLEX_DIRECTION_COLUMN COLUMN_REVERSE:0,FLEX_DIRECTION_COLUMN_REVERSE IDENT:)
+
+flex_grow:CSS_PROP_FLEX_GROW IDENT:INHERIT NUMBER:( false:FLEX_GROW_SET RANGE:num<0 NUMBER:)
+
+flex_shrink:CSS_PROP_FLEX_SHRINK IDENT:INHERIT NUMBER:( false:FLEX_SHRINK_SET RANGE:num<0 NUMBER:)
+
+flex_wrap:CSS_PROP_FLEX_WRAP IDENT:( INHERIT: NOWRAP:0,FLEX_WRAP_NOWRAP WRAP_STRING:0,FLEX_WRAP_WRAP WRAP_REVERSE:0,FLEX_WRAP_WRAP_REVERSE IDENT:)
+
+justify_content:CSS_PROP_JUSTIFY_CONTENT IDENT:( INHERIT: FLEX_START:0,JUSTIFY_CONTENT_FLEX_START FLEX_END:0,JUSTIFY_CONTENT_FLEX_END CENTER:0,JUSTIFY_CONTENT_CENTER SPACE_BETWEEN:0,JUSTIFY_CONTENT_SPACE_BETWEEN SPACE_AROUND:0,JUSTIFY_CONTENT_SPACE_AROUND SPACE_EVENLY:0,JUSTIFY_CONTENT_SPACE_EVENLY IDENT:)
+
+order:CSS_PROP_ORDER IDENT:INHERIT NUMBER:( true:ORDER_SET NUMBER:)
diff --git a/src/parse/properties/properties.h b/src/parse/properties/properties.h
index 4517515..1e085c5 100644
--- a/src/parse/properties/properties.h
+++ b/src/parse/properties/properties.h
@@ -22,6 +22,15 @@ typedef css_error (*css_prop_handler)(css_language *c,
extern const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP];
+css_error css__parse_align_content(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_align_items(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_align_self(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
css_error css__parse_azimuth(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
@@ -199,6 +208,27 @@ css_error css__parse_elevation(css_language *c,
css_error css__parse_empty_cells(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
+css_error css__parse_flex(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_flex_basis(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_flex_direction(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_flex_flow(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_flex_grow(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_flex_shrink(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
+css_error css__parse_flex_wrap(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
css_error css__parse_float(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
@@ -223,6 +253,9 @@ css_error css__parse_font_weight(css_language *c,
css_error css__parse_height(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
+css_error css__parse_justify_content(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
css_error css__parse_left(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
@@ -274,6 +307,9 @@ css_error css__parse_min_width(css_language *c,
css_error css__parse_opacity(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
+css_error css__parse_order(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
css_error css__parse_orphans(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
@@ -423,4 +459,3 @@ css_error css__parse_z_index(css_language *c,
css_style *result);
#endif
-
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index dd6bee4..bfd2965 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -82,6 +82,9 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "before", SLEN("before") },
{ "after", SLEN("after") },
+ { "align-content", SLEN("align-content") },
+ { "align-items", SLEN("align-items") },
+ { "align-self", SLEN("align-self") },
{ "azimuth", SLEN("azimuth") },
{ "background", SLEN("background") },
{ "background-attachment", SLEN("background-attachment") },
@@ -141,6 +144,13 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "display", SLEN("display") },
{ "elevation", SLEN("elevation") },
{ "empty-cells", SLEN("empty-cells") },
+ { "flex", SLEN("flex") },
+ { "flex-basis", SLEN("flex-basis") },
+ { "flex-direction", SLEN("flex-direction") },
+ { "flex-flow", SLEN("flex-flow") },
+ { "flex-grow", SLEN("flex-grow") },
+ { "flex-shrink", SLEN("flex-shrink") },
+ { "flex-wrap", SLEN("flex-wrap") },
{ "float", SLEN("float") },
{ "font", SLEN("font") },
{ "font-family", SLEN("font-family") },
@@ -149,6 +159,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "font-variant", SLEN("font-variant") },
{ "font-weight", SLEN("font-weight") },
{ "height", SLEN("height") },
+ { "justify-content", SLEN("justify-content") },
{ "left", SLEN("left") },
{ "letter-spacing", SLEN("letter-spacing") },
{ "line-height", SLEN("line-height") },
@@ -166,6 +177,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "min-height", SLEN("min-height") },
{ "min-width", SLEN("min-width") },
{ "opacity", SLEN("opacity") },
+ { "order", SLEN("order") },
{ "orphans", SLEN("orphans") },
{ "outline", SLEN("outline") },
{ "outline-color", SLEN("outline-color") },
@@ -415,6 +427,18 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "vertical-lr", SLEN("vertical-lr") },
{ "content-box", SLEN("content-box") },
{ "border-box", SLEN("border-box") },
+ { "stretch", SLEN("stretch") },
+ { "inline-flex", SLEN("inline-flex") },
+ { "flex-start", SLEN("flex-start") },
+ { "flex-end", SLEN("flex-end") },
+ { "space-between", SLEN("space-between") },
+ { "space-around", SLEN("space-around") },
+ { "space-evenly", SLEN("space-evenly") },
+ { "row", SLEN("row") },
+ { "row-reverse", SLEN("row-reverse") },
+ { "column-reverse", SLEN("column-reverse") },
+ { "wrap", SLEN("wrap") },
+ { "wrap-reverse", SLEN("wrap-reverse") },
{ "aliceblue", SLEN("aliceblue") },
{ "antiquewhite", SLEN("antiquewhite") },
@@ -621,5 +645,3 @@ void css__propstrings_unref(void)
lwc_string_unref(css__propstrings.strings[i]);
}
}
-
-
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index e0d16e2..67eaa5f 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -38,12 +38,12 @@ enum {
/* Properties */
FIRST_PROP,
- AZIMUTH = FIRST_PROP, BACKGROUND, BACKGROUND_ATTACHMENT,
- BACKGROUND_COLOR, BACKGROUND_IMAGE, BACKGROUND_POSITION,
- BACKGROUND_REPEAT, BORDER, BORDER_BOTTOM, BORDER_BOTTOM_COLOR,
- BORDER_BOTTOM_STYLE, BORDER_BOTTOM_WIDTH, BORDER_COLLAPSE,
- BORDER_COLOR, BORDER_LEFT, BORDER_LEFT_COLOR, BORDER_LEFT_STYLE,
- BORDER_LEFT_WIDTH, BORDER_RIGHT, BORDER_RIGHT_COLOR,
+ ALIGN_CONTENT = FIRST_PROP, ALIGN_ITEMS, ALIGN_SELF, AZIMUTH,
+ BACKGROUND, BACKGROUND_ATTACHMENT, BACKGROUND_COLOR, BACKGROUND_IMAGE,
+ BACKGROUND_POSITION, BACKGROUND_REPEAT, BORDER, BORDER_BOTTOM,
+ BORDER_BOTTOM_COLOR, BORDER_BOTTOM_STYLE, BORDER_BOTTOM_WIDTH,
+ BORDER_COLLAPSE, BORDER_COLOR, BORDER_LEFT, BORDER_LEFT_COLOR,
+ BORDER_LEFT_STYLE, BORDER_LEFT_WIDTH, BORDER_RIGHT, BORDER_RIGHT_COLOR,
BORDER_RIGHT_STYLE, BORDER_RIGHT_WIDTH, BORDER_SPACING,
BORDER_STYLE, BORDER_TOP, BORDER_TOP_COLOR, BORDER_TOP_STYLE,
BORDER_TOP_WIDTH, BORDER_WIDTH, BOTTOM, BOX_SIZING, BREAK_AFTER,
@@ -51,21 +51,22 @@ enum {
COLUMN_COUNT, COLUMN_FILL, COLUMN_GAP, COLUMN_RULE, COLUMN_RULE_COLOR,
COLUMN_RULE_STYLE, COLUMN_RULE_WIDTH, COLUMN_SPAN, COLUMN_WIDTH,
CONTENT, COUNTER_INCREMENT, COUNTER_RESET, CUE, CUE_AFTER, CUE_BEFORE,
- CURSOR, DIRECTION, DISPLAY, ELEVATION, EMPTY_CELLS, LIBCSS_FLOAT, FONT,
- FONT_FAMILY, FONT_SIZE, FONT_STYLE, FONT_VARIANT, FONT_WEIGHT, HEIGHT,
- LEFT, LETTER_SPACING, LINE_HEIGHT, LIST_STYLE, LIST_STYLE_IMAGE,
- LIST_STYLE_POSITION, LIST_STYLE_TYPE, MARGIN, MARGIN_BOTTOM,
- MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, MAX_HEIGHT, MAX_WIDTH,
- MIN_HEIGHT, MIN_WIDTH, OPACITY, ORPHANS, OUTLINE, OUTLINE_COLOR,
- OUTLINE_STYLE, OUTLINE_WIDTH, OVERFLOW, OVERFLOW_X, OVERFLOW_Y, PADDING,
- PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP,
- PAGE_BREAK_AFTER, PAGE_BREAK_BEFORE, PAGE_BREAK_INSIDE, PAUSE,
- PAUSE_AFTER, PAUSE_BEFORE, PITCH_RANGE, PITCH, PLAY_DURING, POSITION,
- QUOTES, RICHNESS, RIGHT, SPEAK_HEADER, SPEAK_NUMERAL, SPEAK_PUNCTUATION,
- SPEAK, SPEECH_RATE, STRESS, TABLE_LAYOUT, TEXT_ALIGN, TEXT_DECORATION,
- TEXT_INDENT, TEXT_TRANSFORM, TOP, UNICODE_BIDI, VERTICAL_ALIGN,
- VISIBILITY, VOICE_FAMILY, VOLUME, WHITE_SPACE, WIDOWS, WIDTH,
- WORD_SPACING, WRITING_MODE, Z_INDEX,
+ CURSOR, DIRECTION, DISPLAY, ELEVATION, EMPTY_CELLS, FLEX, FLEX_BASIS,
+ FLEX_DIRECTION, FLEX_FLOW, FLEX_GROW, FLEX_SHRINK, FLEX_WRAP,
+ LIBCSS_FLOAT, FONT, FONT_FAMILY, FONT_SIZE, FONT_STYLE, FONT_VARIANT,
+ FONT_WEIGHT, HEIGHT, JUSTIFY_CONTENT, LEFT, LETTER_SPACING, LINE_HEIGHT,
+ LIST_STYLE, LIST_STYLE_IMAGE, LIST_STYLE_POSITION, LIST_STYLE_TYPE,
+ MARGIN, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP,
+ MAX_HEIGHT, MAX_WIDTH, MIN_HEIGHT, MIN_WIDTH, OPACITY, ORDER, ORPHANS,
+ OUTLINE, OUTLINE_COLOR, OUTLINE_STYLE, OUTLINE_WIDTH, OVERFLOW,
+ OVERFLOW_X, OVERFLOW_Y, PADDING, PADDING_BOTTOM, PADDING_LEFT,
+ PADDING_RIGHT, PADDING_TOP, PAGE_BREAK_AFTER, PAGE_BREAK_BEFORE,
+ PAGE_BREAK_INSIDE, PAUSE, PAUSE_AFTER, PAUSE_BEFORE, PITCH_RANGE, PITCH,
+ PLAY_DURING, POSITION, QUOTES, RICHNESS, RIGHT, SPEAK_HEADER,
+ SPEAK_NUMERAL, SPEAK_PUNCTUATION, SPEAK, SPEECH_RATE, STRESS,
+ TABLE_LAYOUT, TEXT_ALIGN, TEXT_DECORATION, TEXT_INDENT, TEXT_TRANSFORM,
+ TOP, UNICODE_BIDI, VERTICAL_ALIGN, VISIBILITY, VOICE_FAMILY, VOLUME,
+ WHITE_SPACE, WIDOWS, WIDTH, WORD_SPACING, WRITING_MODE, Z_INDEX,
LAST_PROP = Z_INDEX,
@@ -98,7 +99,9 @@ enum {
LIBCSS_RIGHT, CURRENTCOLOR, ODD, EVEN, SRC, LOCAL, INITIAL,
FORMAT, WOFF, TRUETYPE, OPENTYPE, EMBEDDED_OPENTYPE, SVG, COLUMN,
AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL,
- VERTICAL_LR, CONTENT_BOX, BORDER_BOX,
+ VERTICAL_LR, CONTENT_BOX, BORDER_BOX, STRETCH, INLINE_FLEX, FLEX_START,
+ FLEX_END, SPACE_BETWEEN, SPACE_AROUND, SPACE_EVENLY, ROW, ROW_REVERSE,
+ COLUMN_REVERSE, WRAP_STRING, WRAP_REVERSE,
/* Named colours */
FIRST_COLOUR,
@@ -138,4 +141,3 @@ css_error css__propstrings_get(lwc_string ***strings);
void css__propstrings_unref(void);
#endif
-
diff --git a/src/select/computed.c b/src/select/computed.c
index 03e7c15..ebb2b29 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -749,13 +749,39 @@ uint8_t css_computed_font_style(const css_computed_style *style)
uint8_t css_computed_min_height(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- return get_min_height(style, length, unit);
+ uint8_t min_height = get_min_height(style, length, unit);
+
+ if (min_height == CSS_MIN_HEIGHT_AUTO) {
+ uint8_t display = get_display(style);
+
+ if (display != CSS_DISPLAY_FLEX &&
+ display != CSS_DISPLAY_INLINE_FLEX) {
+ min_height = CSS_MIN_HEIGHT_SET;
+ *length = 0;
+ *unit = CSS_UNIT_PX;
+ }
+ }
+
+ return min_height;
}
uint8_t css_computed_min_width(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
- return get_min_width(style, length, unit);
+ uint8_t min_width = get_min_width(style, length, unit);
+
+ if (min_width == CSS_MIN_WIDTH_AUTO) {
+ uint8_t display = get_display(style);
+
+ if (display != CSS_DISPLAY_FLEX &&
+ display != CSS_DISPLAY_INLINE_FLEX) {
+ min_width = CSS_MIN_WIDTH_SET;
+ *length = 0;
+ *unit = CSS_UNIT_PX;
+ }
+ }
+
+ return min_width;
}
uint8_t css_computed_background_repeat(const css_computed_style *style)
@@ -927,6 +953,8 @@ uint8_t css_computed_display(const css_computed_style *style,
root /* 4. */) {
if (display == CSS_DISPLAY_INLINE_TABLE) {
return CSS_DISPLAY_TABLE;
+ } else if (display == CSS_DISPLAY_INLINE_FLEX) {
+ return CSS_DISPLAY_FLEX;
} else if (display == CSS_DISPLAY_INLINE ||
display == CSS_DISPLAY_RUN_IN ||
display == CSS_DISPLAY_TABLE_ROW_GROUP ||
@@ -1054,6 +1082,59 @@ uint8_t css_computed_widows(const css_computed_style *style,
return get_widows(style, widows);
}
+uint8_t css_computed_align_content(const css_computed_style *style)
+{
+ return get_align_content(style);
+}
+
+uint8_t css_computed_align_items(const css_computed_style *style)
+{
+ return get_align_items(style);
+}
+
+uint8_t css_computed_align_self(const css_computed_style *style)
+{
+ return get_align_self(style);
+}
+
+uint8_t css_computed_flex_basis(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ return get_flex_basis(style, length, unit);
+}
+
+uint8_t css_computed_flex_direction(const css_computed_style *style)
+{
+ return get_flex_direction(style);
+}
+
+uint8_t css_computed_flex_grow(const css_computed_style *style,
+ css_fixed *number)
+{
+ return get_flex_grow(style, number);
+}
+
+uint8_t css_computed_flex_shrink(const css_computed_style *style,
+ css_fixed *number)
+{
+ return get_flex_shrink(style, number);
+}
+
+uint8_t css_computed_flex_wrap(const css_computed_style *style)
+{
+ return get_flex_wrap(style);
+}
+
+uint8_t css_computed_justify_content(const css_computed_style *style)
+{
+ return get_justify_content(style);
+}
+
+uint8_t css_computed_order(const css_computed_style *style,
+ int32_t *order)
+{
+ return get_order(style, order);
+}
/******************************************************************************
* Library internals *
@@ -1205,6 +1286,12 @@ css_error css__compute_absolute_values(const css_computed_style *parent,
if (error != CSS_OK)
return error;
+ /* Fix up flex-basis */
+ error = compute_absolute_length(style, &ex_size.data.length,
+ get_flex_basis, set_flex_basis);
+ if (error != CSS_OK)
+ return error;
+
/* Uncommon properties */
if (style->i.uncommon != NULL) {
/* Fix up border-spacing */
diff --git a/src/select/computed.h b/src/select/computed.h
index 9f2abdd..a8934b1 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -160,8 +160,14 @@ struct css_computed_style_i {
* visibility 2
* white_space 3
* box_sizing 2
+ * align_content 3
+ * align_items 3
+ * align_self 3
+ * flex_direction 3
+ * flex_wrap 2
+ * justify_content 3
* ---
- * 86 bits
+ * 103 bits
*
* Colours are 32bits of AARRGGBB
* Dimensions are encoded as a fixed point value + 4 bits of unit data
@@ -192,8 +198,8 @@ struct css_computed_style_i {
* margin_left 2 + 4 4
* max_height 2 + 4 4
* max_width 2 + 4 4
- * min_height 1 + 4 4
- * min_width 1 + 4 4
+ * min_height 2 + 4 4
+ * min_width 2 + 4 4
* padding_top 1 + 4 4
* padding_right 1 + 4 4
* padding_bottom 1 + 4 4
@@ -202,8 +208,12 @@ struct css_computed_style_i {
* vertical_align 4 + 4 4
* width 2 + 4 4
* z_index 2 4
+ * flex_basis 2 + 4 4
+ * flex_grow 1 4
+ * flex_shrink 1 4
+ * order 1 4
* --- ---
- * 181 bits 140 + 2sizeof(ptr) bytes
+ * 196 bits 156 + 2sizeof(ptr) bytes
*
* Encode font family as an array of string objects, terminated with a
* blank entry.
@@ -219,11 +229,11 @@ struct css_computed_style_i {
* 1 bit sizeof(ptr) bytes
*
* ___ ___
- * 269 bits 140 + 4sizeof(ptr) bytes
+ * 303 bits 156 + 4sizeof(ptr) bytes
*
- * 34 bytes 140 + 4sizeof(ptr) bytes
+ * 38 bytes 156 + 4sizeof(ptr) bytes
* ===================
- * 174 + 4sizeof(ptr) bytes
+ * 194 + 4sizeof(ptr) bytes
*
* Bit allocations:
*
@@ -247,8 +257,8 @@ struct css_computed_style_i {
* 17 mmmmmmee max-height | empty-cells
* 18 mmmmmmff max-width | float
* 19 wwwwwwff width | font-style
- * 20 mmmmmbbb min-height | background-repeat
- * 21 mmmmmccc min-width | clear
+ * 20 mmmmmmff min-height | flex-wrap
+ * 21 mmmmmmsg min-width | flex-shrink | flex_grow
* 22 tttttxxx padding-top | overflow-x
* 23 rrrrrppp padding-right | position
* 24 bbbbboss padding-bottom | opacity | box-sizing
@@ -262,9 +272,12 @@ struct css_computed_style_i {
* 32 ffffllll font-weight | list-style-type
* 33 oooottuu outline-style | table-layout | unicode-bidi
* 34 vvlltttt visibility | list-style-position | text-align
- * 35 yyy..... overflow-y | <unused>
+ * 35 yyybbbaa overflow-y | background-repeat | align-content1
+ * 36 bbbbbbaj flex-basis | align-content2 | justify_content1
+ * 37 fffcccjj flex-direction | clear | justify_content2
+ * 38 iiissso. align-items | align-self | order
*/
- uint8_t bits[35];
+ uint8_t bits[38];
uint8_t unused[1];
@@ -310,6 +323,14 @@ struct css_computed_style_i {
int32_t z_index;
+ css_fixed flex_basis;
+
+ css_fixed flex_grow;
+
+ css_fixed flex_shrink;
+
+ int32_t order;
+
css_computed_uncommon *uncommon;/**< Uncommon properties */
void *aural; /**< Aural properties */
};
diff --git a/src/select/dispatch.c b/src/select/dispatch.c
index 7af9000..3ab4c96 100644
--- a/src/select/dispatch.c
+++ b/src/select/dispatch.c
@@ -587,5 +587,55 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
PROPERTY_FUNCS(box_sizing),
0,
GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(align_content),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(align_items),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(align_self),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_basis),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_direction),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_grow),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_shrink),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(flex_wrap),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(justify_content),
+ 0,
+ GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(order),
+ 0,
+ GROUP_NORMAL
}
};
diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile
index 288eda9..6c6cf84 100644
--- a/src/select/properties/Makefile
+++ b/src/select/properties/Makefile
@@ -1,5 +1,8 @@
# Sources
DIR_SOURCES := helpers.c \
+align_content.c \
+align_items.c \
+align_self.c \
azimuth.c \
background_attachment.c \
background_color.c \
@@ -47,6 +50,11 @@ direction.c \
display.c \
elevation.c \
empty_cells.c \
+flex_basis.c \
+flex_direction.c \
+flex_grow.c \
+flex_shrink.c \
+flex_wrap.c \
float.c \
font_family.c \
font_size.c \
@@ -54,6 +62,7 @@ font_style.c \
font_variant.c \
font_weight.c \
height.c \
+justify_content.c \
left.c \
letter_spacing.c \
line_height.c \
@@ -69,6 +78,7 @@ max_width.c \
min_height.c \
min_width.c \
opacity.c \
+order.c \
orphans.c \
outline_color.c \
outline_style.c \
diff --git a/src/select/properties/align_content.c b/src/select/properties/align_content.c
new file mode 100644
index 0000000..f43cd8e
--- /dev/null
+++ b/src/select/properties/align_content.c
@@ -0,0 +1,81 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_align_content(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ALIGN_CONTENT_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case ALIGN_CONTENT_STRETCH:
+ value = CSS_ALIGN_CONTENT_STRETCH;
+ break;
+ case ALIGN_CONTENT_FLEX_START:
+ value = CSS_ALIGN_CONTENT_FLEX_START;
+ break;
+ case ALIGN_CONTENT_FLEX_END:
+ value = CSS_ALIGN_CONTENT_FLEX_END;
+ break;
+ case ALIGN_CONTENT_CENTER:
+ value = CSS_ALIGN_CONTENT_CENTER;
+ break;
+ case ALIGN_CONTENT_SPACE_BETWEEN:
+ value = CSS_ALIGN_CONTENT_SPACE_BETWEEN;
+ break;
+ case ALIGN_CONTENT_SPACE_AROUND:
+ value = CSS_ALIGN_CONTENT_SPACE_AROUND;
+ break;
+ case ALIGN_CONTENT_SPACE_EVENLY:
+ value = CSS_ALIGN_CONTENT_SPACE_EVENLY;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_align_content(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_align_content_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_align_content(style, hint->status);
+}
+
+css_error css__initial_align_content(css_select_state *state)
+{
+ return set_align_content(state->computed, CSS_ALIGN_CONTENT_STRETCH);
+}
+
+css_error css__compose_align_content(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_align_content(child);
+
+ if (type == CSS_ALIGN_CONTENT_INHERIT) {
+ type = get_align_content(parent);
+ }
+
+ return set_align_content(result, type);
+}
+
diff --git a/src/select/properties/align_items.c b/src/select/properties/align_items.c
new file mode 100644
index 0000000..ad69c81
--- /dev/null
+++ b/src/select/properties/align_items.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_align_items(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ALIGN_ITEMS_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case ALIGN_ITEMS_STRETCH:
+ value = CSS_ALIGN_ITEMS_STRETCH;
+ break;
+ case ALIGN_ITEMS_FLEX_START:
+ value = CSS_ALIGN_ITEMS_FLEX_START;
+ break;
+ case ALIGN_ITEMS_FLEX_END:
+ value = CSS_ALIGN_ITEMS_FLEX_END;
+ break;
+ case ALIGN_ITEMS_CENTER:
+ value = CSS_ALIGN_ITEMS_CENTER;
+ break;
+ case ALIGN_ITEMS_BASELINE:
+ value = CSS_ALIGN_ITEMS_BASELINE;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_align_items(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_align_items_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_align_items(style, hint->status);
+}
+
+css_error css__initial_align_items(css_select_state *state)
+{
+ return set_align_items(state->computed, CSS_ALIGN_ITEMS_STRETCH);
+}
+
+css_error css__compose_align_items(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_align_items(child);
+
+ if (type == CSS_ALIGN_ITEMS_INHERIT) {
+ type = get_align_items(parent);
+ }
+
+ return set_align_items(result, type);
+}
+
diff --git a/src/select/properties/align_self.c b/src/select/properties/align_self.c
new file mode 100644
index 0000000..e8e469e
--- /dev/null
+++ b/src/select/properties/align_self.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_align_self(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ALIGN_SELF_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case ALIGN_SELF_STRETCH:
+ value = CSS_ALIGN_SELF_STRETCH;
+ break;
+ case ALIGN_SELF_FLEX_START:
+ value = CSS_ALIGN_SELF_FLEX_START;
+ break;
+ case ALIGN_SELF_FLEX_END:
+ value = CSS_ALIGN_SELF_FLEX_END;
+ break;
+ case ALIGN_SELF_CENTER:
+ value = CSS_ALIGN_SELF_CENTER;
+ break;
+ case ALIGN_SELF_BASELINE:
+ value = CSS_ALIGN_SELF_BASELINE;
+ break;
+ case ALIGN_SELF_AUTO:
+ value = CSS_ALIGN_SELF_AUTO;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_align_self(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_align_self_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_align_self(style, hint->status);
+}
+
+css_error css__initial_align_self(css_select_state *state)
+{
+ return set_align_self(state->computed, CSS_ALIGN_SELF_AUTO);
+}
+
+css_error css__compose_align_self(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_align_self(child);
+
+ if (type == CSS_ALIGN_SELF_INHERIT) {
+ type = get_align_self(parent);
+ }
+
+ return set_align_self(result, type);
+}
+
diff --git a/src/select/properties/display.c b/src/select/properties/display.c
index 40c2e3e..510d24a 100644
--- a/src/select/properties/display.c
+++ b/src/select/properties/display.c
@@ -71,6 +71,12 @@ css_error css__cascade_display(uint32_t opv, css_style *style,
case DISPLAY_NONE:
value = CSS_DISPLAY_NONE;
break;
+ case DISPLAY_FLEX:
+ value = CSS_DISPLAY_FLEX;
+ break;
+ case DISPLAY_INLINE_FLEX:
+ value = CSS_DISPLAY_INLINE_FLEX;
+ break;
}
}
diff --git a/src/select/properties/flex_basis.c b/src/select/properties/flex_basis.c
new file mode 100644
index 0000000..1a92a6b
--- /dev/null
+++ b/src/select/properties/flex_basis.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_flex_basis(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_BASIS_INHERIT;
+ css_fixed length = 0;
+ uint32_t unit = UNIT_PX;
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case FLEX_BASIS_AUTO:
+ value = CSS_FLEX_BASIS_AUTO;
+ break;
+ case FLEX_BASIS_CONTENT:
+ value = CSS_FLEX_BASIS_CONTENT;
+ break;
+ case FLEX_BASIS_SET:
+ value = CSS_FLEX_BASIS_SET;
+ length = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(length));
+ unit = *((uint32_t *) style->bytecode);
+ advance_bytecode(style, sizeof(unit));
+ break;
+ }
+ }
+
+ unit = css__to_css_unit(unit);
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_basis(state->computed, value, length, unit);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_basis_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_basis(style, hint->status,
+ hint->data.length.value, hint->data.length.unit);
+}
+
+css_error css__initial_flex_basis(css_select_state *state)
+{
+ return set_flex_basis(state->computed, CSS_FLEX_BASIS_AUTO, 0,
+ CSS_UNIT_PX);
+}
+
+css_error css__compose_flex_basis(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ uint8_t type = get_flex_basis(child, &length, &unit);
+
+ if (type == CSS_FLEX_BASIS_INHERIT) {
+ type = get_flex_basis(parent, &length, &unit);
+ }
+
+ return set_flex_basis(result, type, length, unit);
+}
+
diff --git a/src/select/properties/flex_direction.c b/src/select/properties/flex_direction.c
new file mode 100644
index 0000000..79703be
--- /dev/null
+++ b/src/select/properties/flex_direction.c
@@ -0,0 +1,72 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_flex_direction(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_DIRECTION_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case FLEX_DIRECTION_ROW:
+ value = CSS_FLEX_DIRECTION_ROW;
+ break;
+ case FLEX_DIRECTION_ROW_REVERSE:
+ value = CSS_FLEX_DIRECTION_ROW_REVERSE;
+ break;
+ case FLEX_DIRECTION_COLUMN:
+ value = CSS_FLEX_DIRECTION_COLUMN;
+ break;
+ case FLEX_DIRECTION_COLUMN_REVERSE:
+ value = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_direction(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_direction_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_direction(style, hint->status);
+}
+
+css_error css__initial_flex_direction(css_select_state *state)
+{
+ return set_flex_direction(state->computed, CSS_FLEX_DIRECTION_ROW);
+}
+
+css_error css__compose_flex_direction(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_flex_direction(child);
+
+ if (type == CSS_FLEX_DIRECTION_INHERIT) {
+ type = get_flex_direction(parent);
+ }
+
+ return set_flex_direction(result, type);
+}
+
diff --git a/src/select/properties/flex_grow.c b/src/select/properties/flex_grow.c
new file mode 100644
index 0000000..7f37cfe
--- /dev/null
+++ b/src/select/properties/flex_grow.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_flex_grow(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_GROW_INHERIT;
+ css_fixed flex_grow = 0;
+
+ if (isInherit(opv) == false) {
+ value = CSS_FLEX_GROW_SET;
+
+ flex_grow = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(flex_grow));
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_grow(state->computed, value, flex_grow);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_grow_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_grow(style, hint->status, hint->data.fixed);
+}
+
+css_error css__initial_flex_grow(css_select_state *state)
+{
+ return set_flex_grow(state->computed, CSS_FLEX_GROW_SET, INTTOFIX(0));
+}
+
+css_error css__compose_flex_grow(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_fixed flex_grow = 0;
+ uint8_t type = get_flex_grow(child, &flex_grow);
+
+ if (type == CSS_FLEX_GROW_INHERIT) {
+ type = get_flex_grow(parent, &flex_grow);
+ }
+
+ return set_flex_grow(result, type, flex_grow);
+}
+
diff --git a/src/select/properties/flex_shrink.c b/src/select/properties/flex_shrink.c
new file mode 100644
index 0000000..d1acd2a
--- /dev/null
+++ b/src/select/properties/flex_shrink.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_flex_shrink(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_SHRINK_INHERIT;
+ css_fixed flex_shrink = 0;
+
+ if (isInherit(opv) == false) {
+ value = CSS_FLEX_SHRINK_SET;
+
+ flex_shrink = *((css_fixed *) style->bytecode);
+ advance_bytecode(style, sizeof(flex_shrink));
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_shrink(state->computed, value, flex_shrink);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_shrink_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_shrink(style, hint->status, hint->data.fixed);
+}
+
+css_error css__initial_flex_shrink(css_select_state *state)
+{
+ return set_flex_shrink(state->computed, CSS_FLEX_SHRINK_SET, INTTOFIX(1));
+}
+
+css_error css__compose_flex_shrink(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_fixed flex_shrink = 0;
+ uint8_t type = get_flex_shrink(child, &flex_shrink);
+
+ if (type == CSS_FLEX_SHRINK_INHERIT) {
+ type = get_flex_shrink(parent, &flex_shrink);
+ }
+
+ return set_flex_shrink(result, type, flex_shrink);
+}
+
diff --git a/src/select/properties/flex_wrap.c b/src/select/properties/flex_wrap.c
new file mode 100644
index 0000000..688a9b6
--- /dev/null
+++ b/src/select/properties/flex_wrap.c
@@ -0,0 +1,69 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_flex_wrap(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_FLEX_WRAP_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case FLEX_WRAP_NOWRAP:
+ value = CSS_FLEX_WRAP_NOWRAP;
+ break;
+ case FLEX_WRAP_WRAP:
+ value = CSS_FLEX_WRAP_WRAP;
+ break;
+ case FLEX_WRAP_WRAP_REVERSE:
+ value = CSS_FLEX_WRAP_WRAP_REVERSE;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_flex_wrap(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_flex_wrap_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_flex_wrap(style, hint->status);
+}
+
+css_error css__initial_flex_wrap(css_select_state *state)
+{
+ return set_flex_wrap(state->computed, CSS_FLEX_WRAP_NOWRAP);
+}
+
+css_error css__compose_flex_wrap(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_flex_wrap(child);
+
+ if (type == CSS_FLEX_WRAP_INHERIT) {
+ type = get_flex_wrap(parent);
+ }
+
+ return set_flex_wrap(result, type);
+}
+
diff --git a/src/select/properties/justify_content.c b/src/select/properties/justify_content.c
new file mode 100644
index 0000000..2e17ca5
--- /dev/null
+++ b/src/select/properties/justify_content.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_justify_content(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_JUSTIFY_CONTENT_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case JUSTIFY_CONTENT_FLEX_START:
+ value = CSS_JUSTIFY_CONTENT_FLEX_START;
+ break;
+ case JUSTIFY_CONTENT_FLEX_END:
+ value = CSS_JUSTIFY_CONTENT_FLEX_END;
+ break;
+ case JUSTIFY_CONTENT_CENTER:
+ value = CSS_JUSTIFY_CONTENT_CENTER;
+ break;
+ case JUSTIFY_CONTENT_SPACE_BETWEEN:
+ value = CSS_JUSTIFY_CONTENT_SPACE_BETWEEN;
+ break;
+ case JUSTIFY_CONTENT_SPACE_AROUND:
+ value = CSS_JUSTIFY_CONTENT_SPACE_AROUND;
+ break;
+ case JUSTIFY_CONTENT_SPACE_EVENLY:
+ value = CSS_JUSTIFY_CONTENT_SPACE_EVENLY;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_justify_content(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_justify_content_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_justify_content(style, hint->status);
+}
+
+css_error css__initial_justify_content(css_select_state *state)
+{
+ return set_justify_content(state->computed,
+ CSS_JUSTIFY_CONTENT_FLEX_START);
+}
+
+css_error css__compose_justify_content(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_justify_content(child);
+
+ if (type == CSS_JUSTIFY_CONTENT_INHERIT) {
+ type = get_justify_content(parent);
+ }
+
+ return set_justify_content(result, type);
+}
+
diff --git a/src/select/properties/min_height.c b/src/select/properties/min_height.c
index 687d8a1..a5389ce 100644
--- a/src/select/properties/min_height.c
+++ b/src/select/properties/min_height.c
@@ -17,7 +17,7 @@
css_error css__cascade_min_height(uint32_t opv, css_style *style,
css_select_state *state)
{
- return css__cascade_length(opv, style, state, set_min_height);
+ return css__cascade_length_auto(opv, style, state, set_min_height);
}
css_error css__set_min_height_from_hint(const css_hint *hint,
@@ -29,7 +29,7 @@ css_error css__set_min_height_from_hint(const css_hint *hint,
css_error css__initial_min_height(css_select_state *state)
{
- return set_min_height(state->computed, CSS_MIN_HEIGHT_SET,
+ return set_min_height(state->computed, CSS_MIN_HEIGHT_AUTO,
0, CSS_UNIT_PX);
}
diff --git a/src/select/properties/min_width.c b/src/select/properties/min_width.c
index 5365588..8460e01 100644
--- a/src/select/properties/min_width.c
+++ b/src/select/properties/min_width.c
@@ -17,7 +17,7 @@
css_error css__cascade_min_width(uint32_t opv, css_style *style,
css_select_state *state)
{
- return css__cascade_length(opv, style, state, set_min_width);
+ return css__cascade_length_auto(opv, style, state, set_min_width);
}
css_error css__set_min_width_from_hint(const css_hint *hint,
@@ -29,7 +29,8 @@ css_error css__set_min_width_from_hint(const css_hint *hint,
css_error css__initial_min_width(css_select_state *state)
{
- return set_min_width(state->computed, CSS_MIN_WIDTH_SET, 0, CSS_UNIT_PX);
+ return set_min_width(state->computed, CSS_MIN_WIDTH_AUTO,
+ 0, CSS_UNIT_PX);
}
css_error css__compose_min_width(const css_computed_style *parent,
diff --git a/src/select/properties/order.c b/src/select/properties/order.c
new file mode 100644
index 0000000..0366537
--- /dev/null
+++ b/src/select/properties/order.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Lucas Neves <lcneves@gmail.com>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_order(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_ORDER_INHERIT;
+ css_fixed order = 0;
+
+ if (isInherit(opv) == false) {
+ value = CSS_ORDER_SET;
+
+ order = FIXTOINT(*((css_fixed *) style->bytecode));
+ advance_bytecode(style, sizeof(order));
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_order(state->computed, value, order);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_order_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_order(style, hint->status, hint->data.integer);
+}
+
+css_error css__initial_order(css_select_state *state)
+{
+ return set_order(state->computed, CSS_ORDER_SET, 0);
+}
+
+css_error css__compose_order(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ int32_t order = 0;
+ uint8_t type = get_order(child, &order);
+
+ if (type == CSS_ORDER_INHERIT) {
+ type = get_order(parent, &order);
+ }
+
+ return set_order(result, type, order);
+}
+
diff --git a/src/select/properties/properties.h b/src/select/properties/properties.h
index a1ab49f..6eac397 100644
--- a/src/select/properties/properties.h
+++ b/src/select/properties/properties.h
@@ -21,6 +21,9 @@
css_error css__compose_##pname (const css_computed_style *parent, const css_computed_style *child, css_computed_style *result); \
uint32_t destroy_##pname (void *bytecode)
+PROPERTY_FUNCS(align_content);
+PROPERTY_FUNCS(align_items);
+PROPERTY_FUNCS(align_self);
PROPERTY_FUNCS(azimuth);
PROPERTY_FUNCS(background_attachment);
PROPERTY_FUNCS(background_color);
@@ -68,6 +71,11 @@ PROPERTY_FUNCS(direction);
PROPERTY_FUNCS(display);
PROPERTY_FUNCS(elevation);
PROPERTY_FUNCS(empty_cells);
+PROPERTY_FUNCS(flex_basis);
+PROPERTY_FUNCS(flex_direction);
+PROPERTY_FUNCS(flex_grow);
+PROPERTY_FUNCS(flex_shrink);
+PROPERTY_FUNCS(flex_wrap);
PROPERTY_FUNCS(float);
PROPERTY_FUNCS(font_family);
PROPERTY_FUNCS(font_size);
@@ -75,6 +83,7 @@ PROPERTY_FUNCS(font_style);
PROPERTY_FUNCS(font_variant);
PROPERTY_FUNCS(font_weight);
PROPERTY_FUNCS(height);
+PROPERTY_FUNCS(justify_content);
PROPERTY_FUNCS(left);
PROPERTY_FUNCS(letter_spacing);
PROPERTY_FUNCS(line_height);
@@ -90,6 +99,7 @@ PROPERTY_FUNCS(max_width);
PROPERTY_FUNCS(min_height);
PROPERTY_FUNCS(min_width);
PROPERTY_FUNCS(opacity);
+PROPERTY_FUNCS(order);
PROPERTY_FUNCS(orphans);
PROPERTY_FUNCS(outline_color);
PROPERTY_FUNCS(outline_style);
diff --git a/src/select/propget.h b/src/select/propget.h
index 6719443..737dcd4 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -1268,7 +1268,7 @@ static inline uint8_t get_background_attachment(
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_INDEX
-#define BOX_SIZING_INDEX 34
+#define BOX_SIZING_INDEX 23
#define BOX_SIZING_SHIFT 0
#define BOX_SIZING_MASK 0x3
static inline uint8_t get_box_sizing(
@@ -1457,8 +1457,8 @@ static inline uint8_t get_font_style(
#undef FONT_STYLE_INDEX
#define MIN_HEIGHT_INDEX 19
-#define MIN_HEIGHT_SHIFT 3
-#define MIN_HEIGHT_MASK 0xf8
+#define MIN_HEIGHT_SHIFT 2
+#define MIN_HEIGHT_MASK 0xfc
static inline uint8_t get_min_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -1467,21 +1467,21 @@ static inline uint8_t get_min_height(
bits &= MIN_HEIGHT_MASK;
bits >>= MIN_HEIGHT_SHIFT;
- /* 5bits: uuuut : units | type */
- if ((bits & 0x1) == CSS_MIN_HEIGHT_SET) {
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MIN_HEIGHT_SET) {
*length = style->i.min_height;
- *unit = bits >> 1;
+ *unit = bits >> 2;
}
- return (bits & 0x1);
+ return (bits & 0x3);
}
#undef MIN_HEIGHT_MASK
#undef MIN_HEIGHT_SHIFT
#undef MIN_HEIGHT_INDEX
#define MIN_WIDTH_INDEX 20
-#define MIN_WIDTH_SHIFT 3
-#define MIN_WIDTH_MASK 0xf8
+#define MIN_WIDTH_SHIFT 2
+#define MIN_WIDTH_MASK 0xfc
static inline uint8_t get_min_width(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -1490,21 +1490,21 @@ static inline uint8_t get_min_width(
bits &= MIN_WIDTH_MASK;
bits >>= MIN_WIDTH_SHIFT;
- /* 5bits: uuuut : units | type */
- if ((bits & 0x1) == CSS_MIN_WIDTH_SET) {
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MIN_WIDTH_SET) {
*length = style->i.min_width;
- *unit = bits >> 1;
+ *unit = bits >> 2;
}
- return (bits & 0x1);
+ return (bits & 0x3);
}
#undef MIN_WIDTH_MASK
#undef MIN_WIDTH_SHIFT
#undef MIN_WIDTH_INDEX
-#define BACKGROUND_REPEAT_INDEX 19
-#define BACKGROUND_REPEAT_SHIFT 0
-#define BACKGROUND_REPEAT_MASK 0x7
+#define BACKGROUND_REPEAT_INDEX 34
+#define BACKGROUND_REPEAT_SHIFT 2
+#define BACKGROUND_REPEAT_MASK 0x1c
static inline uint8_t get_background_repeat(
const css_computed_style *style)
{
@@ -1519,9 +1519,9 @@ static inline uint8_t get_background_repeat(
#undef BACKGROUND_REPEAT_SHIFT
#undef BACKGROUND_REPEAT_INDEX
-#define CLEAR_INDEX 20
-#define CLEAR_SHIFT 0
-#define CLEAR_MASK 0x7
+#define CLEAR_INDEX 36
+#define CLEAR_SHIFT 2
+#define CLEAR_MASK 0x1c
static inline uint8_t get_clear(
const css_computed_style *style)
{
@@ -2189,4 +2189,220 @@ static inline uint8_t get_widows(
#undef WIDOWS_SHIFT
#undef WIDOWS_INDEX
+#define ALIGN_CONTENT_INDEX_A 34
+#define ALIGN_CONTENT_SHIFT_A 0
+#define ALIGN_CONTENT_MASK_A 0x3
+#define ALIGN_CONTENT_INDEX_B 35
+#define ALIGN_CONTENT_SHIFT_B 1
+#define ALIGN_CONTENT_MASK_B 0x2
+static inline uint8_t get_align_content(
+ const css_computed_style *style)
+{
+ uint8_t bits_a = style->i.bits[ALIGN_CONTENT_INDEX_A];
+ bits_a &= ALIGN_CONTENT_MASK_A;
+ bits_a >>= ALIGN_CONTENT_SHIFT_A;
+
+ uint8_t bits_b = style->i.bits[ALIGN_CONTENT_INDEX_B];
+ bits_b &= ALIGN_CONTENT_MASK_B;
+ bits_b >>= ALIGN_CONTENT_SHIFT_B;
+ /* Most significant bit out of three */
+ bits_b <<= 2;
+
+ uint8_t bits = bits_a | bits_b;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef ALIGN_CONTENT_MASK_A
+#undef ALIGN_CONTENT_SHIFT_A
+#undef ALIGN_CONTENT_INDEX_A
+#undef ALIGN_CONTENT_MASK_B
+#undef ALIGN_CONTENT_SHIFT_B
+#undef ALIGN_CONTENT_INDEX_B
+
+#define FLEX_WRAP_INDEX 19
+#define FLEX_WRAP_SHIFT 0
+#define FLEX_WRAP_MASK 0x3
+static inline uint8_t get_flex_wrap(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->i.bits[FLEX_WRAP_INDEX];
+ bits &= FLEX_WRAP_MASK;
+ bits >>= FLEX_WRAP_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef FLEX_WRAP_MASK
+#undef FLEX_WRAP_SHIFT
+#undef FLEX_WRAP_INDEX
+
+#define FLEX_BASIS_INDEX 35
+#define FLEX_BASIS_SHIFT 2
+#define FLEX_BASIS_MASK 0xfc
+static inline uint8_t get_flex_basis(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->i.bits[FLEX_BASIS_INDEX];
+ bits &= FLEX_BASIS_MASK;
+ bits >>= FLEX_BASIS_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_FLEX_BASIS_SET) {
+ *length = style->i.flex_basis;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef FLEX_BASIS_MASK
+#undef FLEX_BASIS_SHIFT
+#undef FLEX_BASIS_INDEX
+
+#define FLEX_SHRINK_INDEX 20
+#define FLEX_SHRINK_SHIFT 1
+#define FLEX_SHRINK_MASK 0x2
+static inline uint8_t get_flex_shrink(
+ const css_computed_style *style, css_fixed *number)
+{
+ uint8_t bits = style->i.bits[FLEX_SHRINK_INDEX];
+ bits &= FLEX_SHRINK_MASK;
+ bits >>= FLEX_SHRINK_SHIFT;
+
+ /* 1bit: type */
+ if ((bits & 0x1) == CSS_FLEX_SHRINK_SET) {
+ *number = style->i.flex_shrink;
+ }
+
+ return (bits & 0x1);
+}
+#undef FLEX_SHRINK_MASK
+#undef FLEX_SHRINK_SHIFT
+#undef FLEX_SHRINK_INDEX
+
+#define FLEX_GROW_INDEX 20
+#define FLEX_GROW_SHIFT 0
+#define FLEX_GROW_MASK 0x1
+static inline uint8_t get_flex_grow(
+ const css_computed_style *style, css_fixed *number)
+{
+ uint8_t bits = style->i.bits[FLEX_GROW_INDEX];
+ bits &= FLEX_GROW_MASK;
+ bits >>= FLEX_GROW_SHIFT;
+
+ /* 1bit: type */
+ if ((bits & 0x1) == CSS_FLEX_GROW_SET) {
+ *number = style->i.flex_grow;
+ }
+
+ return (bits & 0x1);
+}
+#undef FLEX_GROW_MASK
+#undef FLEX_GROW_SHIFT
+#undef FLEX_GROW_INDEX
+
+#define FLEX_DIRECTION_INDEX 36
+#define FLEX_DIRECTION_SHIFT 5
+#define FLEX_DIRECTION_MASK 0xe0
+static inline uint8_t get_flex_direction(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
+ bits &= FLEX_DIRECTION_MASK;
+ bits >>= FLEX_DIRECTION_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef FLEX_DIRECTION_MASK
+#undef FLEX_DIRECTION_SHIFT
+#undef FLEX_DIRECTION_INDEX
+
+#define JUSTIFY_CONTENT_INDEX_A 35
+#define JUSTIFY_CONTENT_SHIFT_A 0
+#define JUSTIFY_CONTENT_MASK_A 0x1
+#define JUSTIFY_CONTENT_INDEX_B 36
+#define JUSTIFY_CONTENT_SHIFT_B 0
+#define JUSTIFY_CONTENT_MASK_B 0x3
+static inline uint8_t get_justify_content(
+ const css_computed_style *style)
+{
+ uint8_t bits_a = style->i.bits[JUSTIFY_CONTENT_INDEX_A];
+ bits_a &= JUSTIFY_CONTENT_MASK_A;
+ bits_a >>= JUSTIFY_CONTENT_SHIFT_A;
+
+ uint8_t bits_b = style->i.bits[JUSTIFY_CONTENT_INDEX_B];
+ bits_b &= JUSTIFY_CONTENT_MASK_B;
+ bits_b >>= JUSTIFY_CONTENT_SHIFT_B;
+ /* Most significant two bits out of three */
+ bits_b <<= 1;
+
+ uint8_t bits = bits_a | bits_b;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef JUSTIFY_CONTENT_MASK_A
+#undef JUSTIFY_CONTENT_SHIFT_A
+#undef JUSTIFY_CONTENT_INDEX_A
+#undef JUSTIFY_CONTENT_MASK_B
+#undef JUSTIFY_CONTENT_SHIFT_B
+#undef JUSTIFY_CONTENT_INDEX_B
+
+#define ORDER_INDEX 37
+#define ORDER_SHIFT 1
+#define ORDER_MASK 0x2
+static inline uint8_t get_order(
+ const css_computed_style *style, int32_t *number)
+{
+ uint8_t bits = style->i.bits[ORDER_INDEX];
+ bits &= ORDER_MASK;
+ bits >>= ORDER_SHIFT;
+
+ /* 1bit: type */
+ if ((bits & 0x1) == CSS_ORDER_SET) {
+ *number = style->i.order;
+ }
+
+ return (bits & 0x1);
+}
+#undef ORDER_MASK
+#undef ORDER_SHIFT
+#undef ORDER_INDEX
+
+#define ALIGN_ITEMS_INDEX 37
+#define ALIGN_ITEMS_SHIFT 5
+#define ALIGN_ITEMS_MASK 0xe0
+static inline uint8_t get_align_items(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->i.bits[ALIGN_ITEMS_INDEX];
+ bits &= ALIGN_ITEMS_MASK;
+ bits >>= ALIGN_ITEMS_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef ALIGN_ITEMS_MASK
+#undef ALIGN_ITEMS_SHIFT
+#undef ALIGN_ITEMS_INDEX
+
+#define ALIGN_SELF_INDEX 37
+#define ALIGN_SELF_SHIFT 2
+#define ALIGN_SELF_MASK 0x1c
+static inline uint8_t get_align_self(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->i.bits[ALIGN_SELF_INDEX];
+ bits &= ALIGN_SELF_MASK;
+ bits >>= ALIGN_SELF_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef ALIGN_SELF_MASK
+#undef ALIGN_SELF_SHIFT
+#undef ALIGN_SELF_INDEX
+
#endif
diff --git a/src/select/propset.h b/src/select/propset.h
index 3f4038c..ea7ca48 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -908,7 +908,7 @@ static inline css_error set_background_image(
((type & 0x1) << BACKGROUND_IMAGE_SHIFT);
if (url != NULL) {
- style->i.background_image = lwc_string_ref(url);
+ style->i.background_image = lwc_string_ref(url);
} else {
style->i.background_image = NULL;
}
@@ -1361,7 +1361,7 @@ static inline css_error set_background_attachment(
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_INDEX
-#define BOX_SIZING_INDEX 34
+#define BOX_SIZING_INDEX 23
#define BOX_SIZING_SHIFT 0
#define BOX_SIZING_MASK 0x3
static inline css_error set_box_sizing(
@@ -1551,17 +1551,17 @@ static inline css_error set_font_style(
#undef FONT_STYLE_INDEX
#define MIN_HEIGHT_INDEX 19
-#define MIN_HEIGHT_SHIFT 3
-#define MIN_HEIGHT_MASK 0xf8
+#define MIN_HEIGHT_SHIFT 2
+#define MIN_HEIGHT_MASK 0xfc
static inline css_error set_min_height(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
uint8_t *bits = &style->i.bits[MIN_HEIGHT_INDEX];
- /* 5bits: uuuut : units | type */
+ /* 6bits: uuuutt : units | type */
*bits = (*bits & ~MIN_HEIGHT_MASK) |
- (((type & 0x1) | (unit << 1)) << MIN_HEIGHT_SHIFT);
+ (((type & 0x3) | (unit << 2)) << MIN_HEIGHT_SHIFT);
style->i.min_height = length;
@@ -1572,17 +1572,17 @@ static inline css_error set_min_height(
#undef MIN_HEIGHT_INDEX
#define MIN_WIDTH_INDEX 20
-#define MIN_WIDTH_SHIFT 3
-#define MIN_WIDTH_MASK 0xf8
+#define MIN_WIDTH_SHIFT 2
+#define MIN_WIDTH_MASK 0xfc
static inline css_error set_min_width(
css_computed_style *style, uint8_t type,
css_fixed length, css_unit unit)
{
uint8_t *bits = &style->i.bits[MIN_WIDTH_INDEX];
- /* 5bits: uuuut : units | type */
+ /* 6bits: uuuutt : units | type */
*bits = (*bits & ~MIN_WIDTH_MASK) |
- (((type & 0x1) | (unit << 1)) << MIN_WIDTH_SHIFT);
+ (((type & 0x3) | (unit << 2)) << MIN_WIDTH_SHIFT);
style->i.min_width = length;
@@ -1592,9 +1592,9 @@ static inline css_error set_min_width(
#undef MIN_WIDTH_SHIFT
#undef MIN_WIDTH_INDEX
-#define BACKGROUND_REPEAT_INDEX 19
-#define BACKGROUND_REPEAT_SHIFT 0
-#define BACKGROUND_REPEAT_MASK 0x7
+#define BACKGROUND_REPEAT_INDEX 34
+#define BACKGROUND_REPEAT_SHIFT 2
+#define BACKGROUND_REPEAT_MASK 0x1c
static inline css_error set_background_repeat(
css_computed_style *style, uint8_t type)
{
@@ -1610,9 +1610,9 @@ static inline css_error set_background_repeat(
#undef BACKGROUND_REPEAT_SHIFT
#undef BACKGROUND_REPEAT_INDEX
-#define CLEAR_INDEX 20
-#define CLEAR_SHIFT 0
-#define CLEAR_MASK 0x7
+#define CLEAR_INDEX 36
+#define CLEAR_SHIFT 2
+#define CLEAR_MASK 0x1c
static inline css_error set_clear(
css_computed_style *style, uint8_t type)
{
@@ -2325,4 +2325,222 @@ static inline css_error set_widows(
#undef WIDOWS_SHIFT
#undef WIDOWS_MASK
+#define ALIGN_CONTENT_INDEX_A 34
+#define ALIGN_CONTENT_SHIFT_A 0
+#define ALIGN_CONTENT_MASK_A 0x3
+#define ALIGN_CONTENT_INDEX_B 35
+#define ALIGN_CONTENT_SHIFT_B 1
+#define ALIGN_CONTENT_MASK_B 0x2
+static inline css_error set_align_content(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits_a = &style->i.bits[ALIGN_CONTENT_INDEX_A];
+ uint8_t *bits_b = &style->i.bits[ALIGN_CONTENT_INDEX_B];
+
+ /* type is 3bits: assigning the least significant two */
+ *bits_a = (*bits_a & ~ALIGN_CONTENT_MASK_A) |
+ ((type & 0x3) << ALIGN_CONTENT_SHIFT_A);
+
+ /* type is 3bits: assigning the most significant one */
+ *bits_b = (*bits_b & ~ALIGN_CONTENT_MASK_B) |
+ (((type & 0x4) >> 2) << ALIGN_CONTENT_SHIFT_B);
+
+ return CSS_OK;
+}
+#undef ALIGN_CONTENT_MASK_A
+#undef ALIGN_CONTENT_SHIFT_A
+#undef ALIGN_CONTENT_INDEX_A
+#undef ALIGN_CONTENT_MASK_B
+#undef ALIGN_CONTENT_SHIFT_B
+#undef ALIGN_CONTENT_INDEX_B
+
+#define FLEX_WRAP_INDEX 19
+#define FLEX_WRAP_SHIFT 0
+#define FLEX_WRAP_MASK 0x3
+static inline css_error set_flex_wrap(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->i.bits[FLEX_WRAP_INDEX];
+
+ /* 2bits: type */
+ *bits = (*bits & ~FLEX_WRAP_MASK) |
+ ((type & 0x3) << FLEX_WRAP_SHIFT);
+
+ return CSS_OK;
+}
+#undef FLEX_WRAP_MASK
+#undef FLEX_WRAP_SHIFT
+#undef FLEX_WRAP_INDEX
+
+#define FLEX_BASIS_INDEX 35
+#define FLEX_BASIS_SHIFT 2
+#define FLEX_BASIS_MASK 0xfc
+static inline css_error set_flex_basis(
+ css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint8_t *bits = &style->i.bits[FLEX_BASIS_INDEX];
+
+ /* 6bits: uuuutt : units | type */
+ *bits = (*bits & ~FLEX_BASIS_MASK) |
+ (((type & 0x3) | (unit << 2)) << FLEX_BASIS_SHIFT);
+
+ style->i.flex_basis = length;
+
+ return CSS_OK;
+}
+
+#undef FLEX_BASIS_MASK
+#undef FLEX_BASIS_SHIFT
+#undef FLEX_BASIS_INDEX
+
+#define FLEX_SHRINK_INDEX 20
+#define FLEX_SHRINK_SHIFT 1
+#define FLEX_SHRINK_MASK 0x2
+static inline css_error set_flex_shrink(
+ css_computed_style *style, uint8_t type,
+ css_fixed number)
+{
+ uint8_t *bits = &style->i.bits[FLEX_SHRINK_INDEX];
+
+ /* 1bit: type */
+ *bits = (*bits & ~FLEX_SHRINK_MASK) |
+ ((type & 0x1) << FLEX_SHRINK_SHIFT);
+
+ style->i.flex_shrink = number;
+
+ return CSS_OK;
+}
+
+#undef FLEX_SHRINK_MASK
+#undef FLEX_SHRINK_SHIFT
+#undef FLEX_SHRINK_INDEX
+
+#define FLEX_GROW_INDEX 20
+#define FLEX_GROW_SHIFT 0
+#define FLEX_GROW_MASK 0x1
+static inline css_error set_flex_grow(
+ css_computed_style *style, uint8_t type,
+ css_fixed number)
+{
+ uint8_t *bits = &style->i.bits[FLEX_GROW_INDEX];
+
+ /* 1bit: type */
+ *bits = (*bits & ~FLEX_GROW_MASK) |
+ ((type & 0x1) << FLEX_GROW_SHIFT);
+
+ style->i.flex_grow = number;
+
+ return CSS_OK;
+}
+
+#undef FLEX_GROW_MASK
+#undef FLEX_GROW_SHIFT
+#undef FLEX_GROW_INDEX
+
+#define FLEX_DIRECTION_INDEX 36
+#define FLEX_DIRECTION_SHIFT 5
+#define FLEX_DIRECTION_MASK 0xe0
+static inline css_error set_flex_direction(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->i.bits[FLEX_DIRECTION_INDEX];
+
+ /* 3bits: type */
+ *bits = (*bits & ~FLEX_DIRECTION_MASK) |
+ ((type & 0x7) << FLEX_DIRECTION_SHIFT);
+
+ return CSS_OK;
+}
+#undef FLEX_DIRECTION_MASK
+#undef FLEX_DIRECTION_SHIFT
+#undef FLEX_DIRECTION_INDEX
+
+#define JUSTIFY_CONTENT_INDEX_A 35
+#define JUSTIFY_CONTENT_SHIFT_A 0
+#define JUSTIFY_CONTENT_MASK_A 0x1
+#define JUSTIFY_CONTENT_INDEX_B 36
+#define JUSTIFY_CONTENT_SHIFT_B 0
+#define JUSTIFY_CONTENT_MASK_B 0x3
+static inline css_error set_justify_content(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits_a = &style->i.bits[JUSTIFY_CONTENT_INDEX_A];
+ uint8_t *bits_b = &style->i.bits[JUSTIFY_CONTENT_INDEX_B];
+
+ /* type is 3bits: assigning the least significant one */
+ *bits_a = (*bits_a & ~JUSTIFY_CONTENT_MASK_A) |
+ ((type & 0x1) << JUSTIFY_CONTENT_SHIFT_A);
+
+ /* type is 3bits: assigning the most significant two */
+ *bits_b = (*bits_b & ~JUSTIFY_CONTENT_MASK_B) |
+ (((type & 0x6) >> 1) << JUSTIFY_CONTENT_SHIFT_B);
+
+ return CSS_OK;
+}
+#undef JUSTIFY_CONTENT_MASK_A
+#undef JUSTIFY_CONTENT_SHIFT_A
+#undef JUSTIFY_CONTENT_INDEX_A
+#undef JUSTIFY_CONTENT_MASK_B
+#undef JUSTIFY_CONTENT_SHIFT_B
+#undef JUSTIFY_CONTENT_INDEX_B
+
+#define ORDER_INDEX 37
+#define ORDER_SHIFT 1
+#define ORDER_MASK 0x2
+static inline css_error set_order(
+ css_computed_style *style, uint8_t type,
+ int32_t number)
+{
+ uint8_t *bits = &style->i.bits[ORDER_INDEX];
+
+ /* 1bit: type */
+ *bits = (*bits & ~ORDER_MASK) |
+ ((type & 0x1) << ORDER_SHIFT);
+
+ style->i.order = number;
+
+ return CSS_OK;
+}
+
+#undef ORDER_MASK
+#undef ORDER_SHIFT
+#undef ORDER_INDEX
+
+#define ALIGN_ITEMS_INDEX 37
+#define ALIGN_ITEMS_SHIFT 5
+#define ALIGN_ITEMS_MASK 0xe0
+static inline css_error set_align_items(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->i.bits[ALIGN_ITEMS_INDEX];
+
+ /* 3bits: type */
+ *bits = (*bits & ~ALIGN_ITEMS_MASK) |
+ ((type & 0x7) << ALIGN_ITEMS_SHIFT);
+
+ return CSS_OK;
+}
+#undef ALIGN_ITEMS_MASK
+#undef ALIGN_ITEMS_SHIFT
+#undef ALIGN_ITEMS_INDEX
+
+#define ALIGN_SELF_INDEX 37
+#define ALIGN_SELF_SHIFT 2
+#define ALIGN_SELF_MASK 0x1c
+static inline css_error set_align_self(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->i.bits[ALIGN_SELF_INDEX];
+
+ /* 3bits: type */
+ *bits = (*bits & ~ALIGN_SELF_MASK) |
+ ((type & 0x7) << ALIGN_SELF_SHIFT);
+
+ return CSS_OK;
+}
+#undef ALIGN_SELF_MASK
+#undef ALIGN_SELF_SHIFT
+#undef ALIGN_SELF_INDEX
+
#endif