diff options
Diffstat (limited to 'src')
70 files changed, 2562 insertions, 1465 deletions
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h index 01ea25a..7a1377b 100644 --- a/src/bytecode/opcodes.h +++ b/src/bytecode/opcodes.h @@ -29,11 +29,11 @@ enum op_align_items { }; 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_STRETCH = ALIGN_ITEMS_STRETCH, + ALIGN_SELF_FLEX_START = ALIGN_ITEMS_FLEX_START, + ALIGN_SELF_FLEX_END = ALIGN_ITEMS_FLEX_END, + ALIGN_SELF_CENTER = ALIGN_ITEMS_CENTER, + ALIGN_SELF_BASELINE = ALIGN_ITEMS_BASELINE, ALIGN_SELF_AUTO = 0x0005 }; @@ -332,7 +332,9 @@ enum op_display { DISPLAY_TABLE_CAPTION = 0x000e, DISPLAY_NONE = 0x000f, DISPLAY_FLEX = 0x0010, - DISPLAY_INLINE_FLEX = 0x0011 + DISPLAY_INLINE_FLEX = 0x0011, + DISPLAY_GRID = 0x0012, + DISPLAY_INLINE_GRID = 0x0013 }; enum op_elevation { @@ -349,6 +351,11 @@ enum op_empty_cells { EMPTY_CELLS_HIDE = 0x0001 }; +enum op_fill_opacity { + FILL_OPACITY_SET = 0x0080 +}; + + enum op_flex_basis { FLEX_BASIS_AUTO = 0x0000, FLEX_BASIS_CONTENT = 0x0001, @@ -663,7 +670,8 @@ enum op_position { POSITION_STATIC = 0x0000, POSITION_RELATIVE = 0x0001, POSITION_ABSOLUTE = 0x0002, - POSITION_FIXED = 0x0003 + POSITION_FIXED = 0x0003, + POSITION_STICKY = 0x0004 }; enum op_quotes { @@ -718,6 +726,10 @@ enum op_stress { STRESS_SET = 0x0080 }; +enum op_stroke_opacity { + STROKE_OPACITY_SET = 0x0080 +}; + enum op_table_layout { TABLE_LAYOUT_AUTO = 0x0000, TABLE_LAYOUT_FIXED = 0x0001 diff --git a/src/parse/font_face.c b/src/parse/font_face.c index f17d50e..055a118 100644 --- a/src/parse/font_face.c +++ b/src/parse/font_face.c @@ -41,7 +41,7 @@ static bool font_rule_font_family_reserved(css_language *c, } static css_error font_face_parse_font_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_font_face *font_face) { css_error error; @@ -60,7 +60,7 @@ static css_error font_face_parse_font_family(css_language *c, } static css_error font_face_src_parse_format(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_font_face_format *format) { bool match; @@ -120,7 +120,7 @@ static css_error font_face_src_parse_format(css_language *c, } static css_error font_face_src_parse_spec_or_name(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, lwc_string **location, css_font_face_location_type *location_type, css_font_face_format *format) @@ -194,10 +194,10 @@ static css_error font_face_src_parse_spec_or_name(css_language *c, } static css_error font_face_parse_src(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_font_face *font_face) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error = CSS_OK; const css_token *token; css_font_face_src *srcs = NULL, *new_srcs = NULL; @@ -258,10 +258,10 @@ cleanup: } static css_error font_face_parse_font_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_font_face *font_face) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error = CSS_OK; const css_token *token; enum css_font_style_e style = 0; @@ -299,10 +299,10 @@ static css_error font_face_parse_font_style(css_language *c, } static css_error font_face_parse_font_weight(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_font_face *font_face) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error = CSS_OK; const css_token *token; enum css_font_weight_e weight = 0; @@ -374,7 +374,7 @@ static css_error font_face_parse_font_weight(css_language *c, */ css_error css__parse_font_descriptor(css_language *c, const css_token *descriptor, const parserutils_vector *vector, - int *ctx, css_rule_font_face *rule) + int32_t *ctx, css_rule_font_face *rule) { css_font_face *font_face = rule->font_face; css_error error; diff --git a/src/parse/font_face.h b/src/parse/font_face.h index 435380e..dc00ef1 100644 --- a/src/parse/font_face.h +++ b/src/parse/font_face.h @@ -17,6 +17,6 @@ css_error css__parse_font_descriptor(css_language *c, const css_token *descriptor, const parserutils_vector *vector, - int *ctx, struct css_rule_font_face *rule); + int32_t *ctx, struct css_rule_font_face *rule); #endif diff --git a/src/parse/important.c b/src/parse/important.c index 1066d90..02aafc4 100644 --- a/src/parse/important.c +++ b/src/parse/important.c @@ -25,10 +25,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_important(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, uint8_t *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; bool match = false; const css_token *token; @@ -346,6 +346,16 @@ void css__make_style_important(css_style *style) offset++; /* value */ break; + case CSS_PROP_FILL_OPACITY: + if (value == FILL_OPACITY_SET) + offset++; /* value */ + break; + + case CSS_PROP_STROKE_OPACITY: + if (value == STROKE_OPACITY_SET) + offset++; /* value */ + break; + case CSS_PROP_ORDER: if (value == ORDER_SET) offset++; /* value */ diff --git a/src/parse/important.h b/src/parse/important.h index ba5e118..e939c4b 100644 --- a/src/parse/important.h +++ b/src/parse/important.h @@ -12,7 +12,7 @@ #include "parse/language.h" css_error css__parse_important(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, uint8_t *result); void css__make_style_important(css_style *style); diff --git a/src/parse/language.c b/src/parse/language.c index c2d02d7..936ab3d 100644 --- a/src/parse/language.c +++ b/src/parse/language.c @@ -63,37 +63,37 @@ static css_error lookupNamespace(css_language *c, /* Selector list parsing */ static css_error parseClass(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector_detail *specific); static css_error parseAttrib(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector_detail *specific); static css_error parseNth(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector_detail_value *value); static css_error parsePseudo(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool in_not, css_selector_detail *specific); static css_error parseSpecific(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool in_not, css_selector_detail *specific); static css_error parseAppendSpecific(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **parent); static css_error parseSelectorSpecifics(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **parent); static css_error parseTypeSelector(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_qname *qname); static css_error parseSimpleSelector(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **result); static css_error parseCombinator(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_combinator *result); static css_error parseSelector(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **result); static css_error parseSelectorList(css_language *c, const parserutils_vector *vector, css_rule *rule); @@ -101,7 +101,7 @@ static css_error parseSelectorList(css_language *c, /* Declaration parsing */ static css_error parseProperty(css_language *c, const css_token *property, const parserutils_vector *vector, - int *ctx, css_rule *rule); + int32_t *ctx, css_rule *rule); /** * Create a CSS language parser @@ -790,7 +790,7 @@ css_error handleDeclaration(css_language *c, const parserutils_vector *vector) { css_error error; const css_token *token, *ident; - int ctx = 0; + int32_t ctx = 0; context_entry *entry; css_rule *rule; @@ -945,7 +945,7 @@ css_error lookupNamespace(css_language *c, lwc_string *prefix, lwc_string **uri) ******************************************************************************/ css_error parseClass(css_language *c, const parserutils_vector *vector, - int *ctx, css_selector_detail *specific) + int32_t *ctx, css_selector_detail *specific) { css_qname qname; css_selector_detail_value detail_value; @@ -976,7 +976,7 @@ css_error parseClass(css_language *c, const parserutils_vector *vector, } css_error parseAttrib(css_language *c, const parserutils_vector *vector, - int *ctx, css_selector_detail *specific) + int32_t *ctx, css_selector_detail *specific) { css_qname qname; css_selector_detail_value detail_value; @@ -1078,7 +1078,7 @@ css_error parseAttrib(css_language *c, const parserutils_vector *vector, } css_error parseNth(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector_detail_value *value) { const css_token *token; @@ -1279,7 +1279,7 @@ css_error parseNth(css_language *c, } css_error parsePseudo(css_language *c, const parserutils_vector *vector, - int *ctx, bool in_not, css_selector_detail *specific) + int32_t *ctx, bool in_not, css_selector_detail *specific) { static const struct { @@ -1459,7 +1459,7 @@ css_error parsePseudo(css_language *c, const parserutils_vector *vector, } css_error parseSpecific(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool in_not, css_selector_detail *specific) { css_error error; @@ -1514,7 +1514,7 @@ css_error parseSpecific(css_language *c, } css_error parseAppendSpecific(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **parent) { css_error error; @@ -1529,7 +1529,7 @@ css_error parseAppendSpecific(css_language *c, } css_error parseSelectorSpecifics(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **parent) { css_error error; @@ -1551,7 +1551,7 @@ css_error parseSelectorSpecifics(css_language *c, } css_error parseTypeSelector(css_language *c, const parserutils_vector *vector, - int *ctx, css_qname *qname) + int32_t *ctx, css_qname *qname) { const css_token *token; css_error error; @@ -1612,10 +1612,10 @@ css_error parseTypeSelector(css_language *c, const parserutils_vector *vector, } css_error parseSimpleSelector(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_selector **result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; css_selector *selector; @@ -1678,7 +1678,7 @@ css_error parseSimpleSelector(css_language *c, } css_error parseCombinator(css_language *c, const parserutils_vector *vector, - int *ctx, css_combinator *result) + int32_t *ctx, css_combinator *result) { const css_token *token; css_combinator comb = CSS_COMBINATOR_NONE; @@ -1719,7 +1719,7 @@ css_error parseCombinator(css_language *c, const parserutils_vector *vector, } css_error parseSelector(css_language *c, const parserutils_vector *vector, - int *ctx, css_selector **result) + int32_t *ctx, css_selector **result) { css_error error; const css_token *token = NULL; @@ -1785,7 +1785,7 @@ css_error parseSelectorList(css_language *c, const parserutils_vector *vector, css_error error; const css_token *token = NULL; css_selector *selector = NULL; - int ctx = 0; + int32_t ctx = 0; /* Strip any leading whitespace (can happen if in nested block) */ consumeWhitespace(vector, &ctx); @@ -1843,7 +1843,7 @@ css_error parseSelectorList(css_language *c, const parserutils_vector *vector, ******************************************************************************/ css_error parseProperty(css_language *c, const css_token *property, - const parserutils_vector *vector, int *ctx, css_rule *rule) + const parserutils_vector *vector, int32_t *ctx, css_rule *rule) { css_error error; css_prop_handler handler = NULL; diff --git a/src/parse/language.h b/src/parse/language.h index 2ab4987..81a096a 100644 --- a/src/parse/language.h +++ b/src/parse/language.h @@ -64,7 +64,7 @@ css_error css__language_destroy(css_language *language); * \param vector The vector to consume from * \param ctx The vector's context */ -static inline void consumeWhitespace(const parserutils_vector *vector, int *ctx) +static inline void consumeWhitespace(const parserutils_vector *vector, int32_t *ctx) { const css_token *token = NULL; diff --git a/src/parse/mq.c b/src/parse/mq.c index b5478a1..5031e34 100644 --- a/src/parse/mq.c +++ b/src/parse/mq.c @@ -79,11 +79,11 @@ void css__mq_query_destroy(css_mq_query *media) } static css_error mq_parse_condition(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool permit_or, css_mq_cond **cond); static css_error mq_parse_ratio( - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, const css_token *numerator, css_fixed *ratio) { const css_token *token; @@ -260,7 +260,7 @@ static css_error mq_parse_range__convert_to_level_4( } static css_error mq_parse_range(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, const css_token *name_or_value, css_mq_feature **feature) { @@ -443,7 +443,7 @@ static css_error mq_parse_range(lwc_string **strings, } static css_error mq_parse_media_feature(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_mq_feature **feature) { const css_token *name_or_value, *token; @@ -565,7 +565,7 @@ static css_error mq_parse_media_feature(lwc_string **strings, * CSS Syntax Module Level 3: 8.2 */ static css_error mq_parse_consume_any_value(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool until, const char until_char) { const css_token *token; @@ -627,7 +627,7 @@ static css_error mq_parse_consume_any_value(lwc_string **strings, } static css_error mq_parse_general_enclosed(lwc_string **strings, - const parserutils_vector *vector, int *ctx) + const parserutils_vector *vector, int32_t *ctx) { const css_token *token; css_error error; @@ -671,7 +671,7 @@ static css_error mq_parse_general_enclosed(lwc_string **strings, } static css_error mq_parse_media_in_parens(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_mq_cond_or_feature **cond_or_feature) { const css_token *token; @@ -754,7 +754,7 @@ static css_error mq_parse_media_in_parens(lwc_string **strings, } static css_error mq_parse_condition(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool permit_or, css_mq_cond **cond) { const css_token *token; @@ -959,7 +959,7 @@ static css_error mq_parse_type(lwc_string **strings, lwc_string *type, } static css_error mq_parse_media_query(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_mq_query **query) { const css_token *token; @@ -984,7 +984,7 @@ static css_error mq_parse_media_query(lwc_string **strings, lwc_string_caseless_isequal(token->idata, strings[NOT], &match) == lwc_error_ok && match) { - int old_ctx = *ctx; + int32_t old_ctx = *ctx; parserutils_vector_iterate(vector, ctx); consumeWhitespace(vector, ctx); @@ -1100,7 +1100,7 @@ static css_error css__mq_parse__create_not_all( } css_error css__mq_parse_media_list(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_mq_query **media) { css_mq_query *result = NULL, *last = NULL; @@ -1162,7 +1162,7 @@ static css_error css_parse_media_query_handle_event( const parserutils_vector *tokens, void *pw) { - int idx = 0; + int32_t idx = 0; css_error err; css_mq_query *media; const css_token *tok; diff --git a/src/parse/mq.h b/src/parse/mq.h index 7a51578..ec19419 100644 --- a/src/parse/mq.h +++ b/src/parse/mq.h @@ -88,7 +88,7 @@ css_error css_parse_media_query(lwc_string **strings, css_mq_query **media_out); css_error css__mq_parse_media_list(lwc_string **strings, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_mq_query **media); void css__mq_query_destroy(css_mq_query *media); diff --git a/src/parse/properties/Makefile b/src/parse/properties/Makefile index 6461dda..df84d49 100644 --- a/src/parse/properties/Makefile +++ b/src/parse/properties/Makefile @@ -45,6 +45,7 @@ DIR_SOURCES := \ cue.c \ cursor.c \ elevation.c \ + fill_opacity.c \ flex.c \ flex_flow.c \ font.c \ @@ -61,6 +62,7 @@ DIR_SOURCES := \ play_during.c \ properties.c \ quotes.c \ + stroke_opacity.c \ text_decoration.c \ utils.c \ voice_family.c diff --git a/src/parse/properties/azimuth.c b/src/parse/properties/azimuth.c index c1ff9ae..a9265d1 100644 --- a/src/parse/properties/azimuth.c +++ b/src/parse/properties/azimuth.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_azimuth(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; uint8_t flags = 0; diff --git a/src/parse/properties/background.c b/src/parse/properties/background.c index e11fcc9..20aeb30 100644 --- a/src/parse/properties/background.c +++ b/src/parse/properties/background.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_background(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error = CSS_OK; diff --git a/src/parse/properties/background_position.c b/src/parse/properties/background_position.c index 534950c..1d87e6a 100644 --- a/src/parse/properties/background_position.c +++ b/src/parse/properties/background_position.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_background_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; uint8_t flags = 0; diff --git a/src/parse/properties/border.c b/src/parse/properties/border.c index 26cdbcd..be269ab 100644 --- a/src/parse/properties/border.c +++ b/src/parse/properties/border.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; error = css__parse_border_side(c, vector, ctx, result, BORDER_SIDE_TOP); diff --git a/src/parse/properties/border_color.c b/src/parse/properties/border_color.c index 41dbc2a..60b401e 100644 --- a/src/parse/properties/border_color.c +++ b/src/parse/properties/border_color.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; uint16_t side_val[4]; diff --git a/src/parse/properties/border_spacing.c b/src/parse/properties/border_spacing.c index b931eda..e00fb27 100644 --- a/src/parse/properties/border_spacing.c +++ b/src/parse/properties/border_spacing.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; css_fixed length[2] = { 0 }; diff --git a/src/parse/properties/border_style.c b/src/parse/properties/border_style.c index 7be1f8d..4d54900 100644 --- a/src/parse/properties/border_style.c +++ b/src/parse/properties/border_style.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; uint16_t side_val[4]; diff --git a/src/parse/properties/border_width.c b/src/parse/properties/border_width.c index 90bd4cc..b11ca05 100644 --- a/src/parse/properties/border_width.c +++ b/src/parse/properties/border_width.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; uint16_t side_val[4]; diff --git a/src/parse/properties/clip.c b/src/parse/properties/clip.c index 76fa364..4bf653d 100644 --- a/src/parse/properties/clip.c +++ b/src/parse/properties/clip.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_clip(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; int num_lengths = 0; diff --git a/src/parse/properties/column_rule.c b/src/parse/properties/column_rule.c index 146783c..7bfcad5 100644 --- a/src/parse/properties/column_rule.c +++ b/src/parse/properties/column_rule.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_column_rule(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error; diff --git a/src/parse/properties/columns.c b/src/parse/properties/columns.c index edc7ee6..277a305 100644 --- a/src/parse/properties/columns.c +++ b/src/parse/properties/columns.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_columns(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error = CSS_OK; diff --git a/src/parse/properties/content.c b/src/parse/properties/content.c index 186abcc..b32de22 100644 --- a/src/parse/properties/content.c +++ b/src/parse/properties/content.c @@ -29,10 +29,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_content(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/properties/css_property_parser_gen.c b/src/parse/properties/css_property_parser_gen.c index 1e8b007..3e1d997 100644 --- a/src/parse/properties/css_property_parser_gen.c +++ b/src/parse/properties/css_property_parser_gen.c @@ -106,7 +106,7 @@ void output_header(FILE *outputf, const char *descriptor, struct keyval *parser_ " * If the input is invalid, then \\a *ctx remains unchanged.\n" " */\n" "css_error css__parse_%s(css_language *c,\n" - " const parserutils_vector *vector, int *ctx,\n" + " const parserutils_vector *vector, int32_t *ctx,\n" " css_style *result%s)\n" "{\n", descriptor, @@ -120,7 +120,7 @@ void output_header(FILE *outputf, const char *descriptor, struct keyval *parser_ void output_token_type_check(FILE *outputf, bool do_token_check, struct keyval_list *IDENT, struct keyval_list *URI, struct keyval_list *NUMBER) { fprintf(outputf, - " int orig_ctx = *ctx;\n" + " int32_t orig_ctx = *ctx;\n" " css_error error;\n" " const css_token *token;\n" " bool match;\n\n" diff --git a/src/parse/properties/cue.c b/src/parse/properties/cue.c index 98844bd..db64412 100644 --- a/src/parse/properties/cue.c +++ b/src/parse/properties/cue.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_cue(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *first_token; const css_token *token; diff --git a/src/parse/properties/cursor.c b/src/parse/properties/cursor.c index ad2200c..b61d9a9 100644 --- a/src/parse/properties/cursor.c +++ b/src/parse/properties/cursor.c @@ -27,10 +27,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_cursor(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error = CSS_OK; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/properties/elevation.c b/src/parse/properties/elevation.c index 7fe5bf2..b456799 100644 --- a/src/parse/properties/elevation.c +++ b/src/parse/properties/elevation.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_elevation(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; uint8_t flags = 0; diff --git a/src/parse/properties/fill_opacity.c b/src/parse/properties/fill_opacity.c new file mode 100644 index 0000000..caed86f --- /dev/null +++ b/src/parse/properties/fill_opacity.c @@ -0,0 +1,82 @@ +/* + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#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 fill-opacity + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result 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_fill_opacity(css_language *c, + const parserutils_vector *vector, int32_t *ctx, + css_style *result) +{ + int32_t orig_ctx = *ctx; + css_error error; + const css_token *token; + enum flag_value flag_value; + + token = parserutils_vector_iterate(vector, ctx); + if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT) && (token->type != CSS_TOKEN_NUMBER))) { + *ctx = orig_ctx; + return CSS_INVALID; + } + + flag_value = get_css_flag_value(c, token); + + if (flag_value != FLAG_VALUE__NONE) { + error = css_stylesheet_style_flag_value(result, flag_value, + CSS_PROP_FILL_OPACITY); + + } else if (token->type == CSS_TOKEN_NUMBER) { + css_fixed num = 0; + size_t consumed = 0; + + num = css__number_from_lwc_string(token->idata, false, &consumed); + /* Invalid if there are trailing characters */ + if (consumed != lwc_string_length(token->idata)) { + *ctx = orig_ctx; + return CSS_INVALID; + } + + /* Clamp to range [0,1] */ + if (num < 0) + num = 0; + if (num > INTTOFIX(1)) + num = INTTOFIX(1); + + error = css__stylesheet_style_appendOPV(result, CSS_PROP_FILL_OPACITY, 0, FILL_OPACITY_SET); + if (error != CSS_OK) { + *ctx = orig_ctx; + return error; + } + + error = css__stylesheet_style_append(result, num); + } else { + error = CSS_INVALID; + } + + if (error != CSS_OK) + *ctx = orig_ctx; + + return error; +} + diff --git a/src/parse/properties/flex.c b/src/parse/properties/flex.c index d8f3848..a29309b 100644 --- a/src/parse/properties/flex.c +++ b/src/parse/properties/flex.c @@ -29,10 +29,10 @@ */ css_error css__parse_flex(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error; diff --git a/src/parse/properties/flex_flow.c b/src/parse/properties/flex_flow.c index 2d9c60a..a5e2926 100644 --- a/src/parse/properties/flex_flow.c +++ b/src/parse/properties/flex_flow.c @@ -29,10 +29,10 @@ */ css_error css__parse_flex_flow(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error; diff --git a/src/parse/properties/font.c b/src/parse/properties/font.c index 7ce9701..16a6cc4 100644 --- a/src/parse/properties/font.c +++ b/src/parse/properties/font.c @@ -224,12 +224,12 @@ static css_error parse_system_font(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_font(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { const css_token *token; css_error error; - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; css_system_font system_font; diff --git a/src/parse/properties/font_family.c b/src/parse/properties/font_family.c index b309f45..2f8782e 100644 --- a/src/parse/properties/font_family.c +++ b/src/parse/properties/font_family.c @@ -99,10 +99,10 @@ static css_code_t font_family_value(css_language *c, const css_token *token, boo * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_font_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; bool match; diff --git a/src/parse/properties/font_weight.c b/src/parse/properties/font_weight.c index abe0b78..77ec9a1 100644 --- a/src/parse/properties/font_weight.c +++ b/src/parse/properties/font_weight.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_font_weight(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; uint8_t flags = 0; diff --git a/src/parse/properties/list_style.c b/src/parse/properties/list_style.c index e6e8eae..1cb373a 100644 --- a/src/parse/properties/list_style.c +++ b/src/parse/properties/list_style.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_list_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error; diff --git a/src/parse/properties/list_style_type.c b/src/parse/properties/list_style_type.c index fe66bcb..eb7f363 100644 --- a/src/parse/properties/list_style_type.c +++ b/src/parse/properties/list_style_type.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_list_style_type(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *ident; uint8_t flags = 0; diff --git a/src/parse/properties/margin.c b/src/parse/properties/margin.c index 63adddc..1ee56f7 100644 --- a/src/parse/properties/margin.c +++ b/src/parse/properties/margin.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_margin(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; uint16_t side_val[4]; diff --git a/src/parse/properties/opacity.c b/src/parse/properties/opacity.c index 5d7b176..22acd76 100644 --- a/src/parse/properties/opacity.c +++ b/src/parse/properties/opacity.c @@ -27,10 +27,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_opacity(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/properties/outline.c b/src/parse/properties/outline.c index 8ceac8a..ac91ffd 100644 --- a/src/parse/properties/outline.c +++ b/src/parse/properties/outline.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_outline(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error; diff --git a/src/parse/properties/overflow.c b/src/parse/properties/overflow.c index 7bc1938..dbb373a 100644 --- a/src/parse/properties/overflow.c +++ b/src/parse/properties/overflow.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_overflow(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error1, error2 = CSS_OK; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/properties/padding.c b/src/parse/properties/padding.c index bef3607..a87ffa5 100644 --- a/src/parse/properties/padding.c +++ b/src/parse/properties/padding.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_padding(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_fixed side_length[4]; diff --git a/src/parse/properties/pause.c b/src/parse/properties/pause.c index b238d20..e558337 100644 --- a/src/parse/properties/pause.c +++ b/src/parse/properties/pause.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_pause(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *first_token; const css_token *token; diff --git a/src/parse/properties/play_during.c b/src/parse/properties/play_during.c index 54e048f..da7f236 100644 --- a/src/parse/properties/play_during.c +++ b/src/parse/properties/play_during.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_play_during(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; uint8_t flags = 0; diff --git a/src/parse/properties/properties.c b/src/parse/properties/properties.c index 06524da..2cc849c 100644 --- a/src/parse/properties/properties.c +++ b/src/parse/properties/properties.c @@ -74,6 +74,7 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] = css__parse_display, css__parse_elevation, css__parse_empty_cells, + css__parse_fill_opacity, css__parse_flex, css__parse_flex_basis, css__parse_flex_direction, @@ -140,6 +141,7 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] = css__parse_speak, css__parse_speech_rate, css__parse_stress, + css__parse_stroke_opacity, css__parse_table_layout, css__parse_text_align, css__parse_text_decoration, @@ -261,6 +263,8 @@ const uint32_t property_unit_mask[CSS_N_PROPERTIES] = { [CSS_PROP_WORD_SPACING] = UNIT_MASK_WORD_SPACING, [CSS_PROP_Z_INDEX] = UNIT_MASK_Z_INDEX, [CSS_PROP_OPACITY] = UNIT_MASK_OPACITY, + [CSS_PROP_FILL_OPACITY] = UNIT_MASK_FILL_OPACITY, + [CSS_PROP_STROKE_OPACITY] = UNIT_MASK_STROKE_OPACITY, [CSS_PROP_BREAK_AFTER] = UNIT_MASK_BREAK_AFTER, [CSS_PROP_BREAK_BEFORE] = UNIT_MASK_BREAK_BEFORE, [CSS_PROP_BREAK_INSIDE] = UNIT_MASK_BREAK_INSIDE, diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen index 4fd8ba0..b0e797c 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: INITIAL: REVERT: UNSET: NONE:0,C direction:CSS_PROP_DIRECTION IDENT:( INHERIT: INITIAL: REVERT: UNSET: LTR:0,DIRECTION_LTR RTL:0,DIRECTION_RTL IDENT:) -display:CSS_PROP_DISPLAY IDENT:( INHERIT: INITIAL: REVERT: UNSET: 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:) +display:CSS_PROP_DISPLAY IDENT:( INHERIT: INITIAL: REVERT: UNSET: 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 GRID:0,DISPLAY_GRID INLINE_GRID:0,DISPLAY_INLINE_GRID IDENT:) empty_cells:CSS_PROP_EMPTY_CELLS IDENT:( INHERIT: INITIAL: REVERT: UNSET: SHOW:0,EMPTY_CELLS_SHOW HIDE:0,EMPTY_CELLS_HIDE IDENT:) @@ -148,7 +148,7 @@ pitch:CSS_PROP_PITCH IDENT:( INHERIT: INITIAL: REVERT: UNSET: X_LOW:0,PITCH_X_LO pitch_range:CSS_PROP_PITCH_RANGE IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:PITCH_RANGE_SET RANGE:num<0||num>F_100 NUMBER:) -position:CSS_PROP_POSITION IDENT:( INHERIT: INITIAL: REVERT: UNSET: LIBCSS_STATIC:0,POSITION_STATIC RELATIVE:0,POSITION_RELATIVE ABSOLUTE:0,POSITION_ABSOLUTE FIXED:0,POSITION_FIXED IDENT:) +position:CSS_PROP_POSITION IDENT:( INHERIT: INITIAL: REVERT: UNSET: LIBCSS_STATIC:0,POSITION_STATIC RELATIVE:0,POSITION_RELATIVE ABSOLUTE:0,POSITION_ABSOLUTE FIXED:0,POSITION_FIXED STICKY:0,POSITION_STICKY IDENT:) richness:CSS_PROP_RICHNESS IDENT:( INHERIT: INITIAL: REVERT: UNSET: IDENT:) NUMBER:( false:RICHNESS_SET RANGE:num<0||num>F_100 NUMBER:) diff --git a/src/parse/properties/properties.h b/src/parse/properties/properties.h index 1e7f821..17b7f41 100644 --- a/src/parse/properties/properties.h +++ b/src/parse/properties/properties.h @@ -17,445 +17,451 @@ * Type of property handler function */ typedef css_error (*css_prop_handler)(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); 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, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_align_items(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_align_self(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_azimuth(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_background(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_background_attachment(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_background_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_background_image(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_background_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_background_repeat(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_bottom_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_bottom_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_bottom_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_collapse(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_left_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_left_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_left_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_right_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_right_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_right_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_top_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_top_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_top_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_border_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_box_sizing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_break_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_break_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_break_inside(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_caption_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_clear(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_clip(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_columns(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_count(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_fill(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_gap(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_rule(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_rule_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_rule_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_rule_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_span(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_column_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_content(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_counter_increment(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_counter_reset(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_cue(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_cue_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_cue_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_cursor(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_direction(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_display(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_elevation(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_empty_cells(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, + css_style *result); +css_error css__parse_fill_opacity(css_language *c, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex_basis(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex_direction(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex_flow(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex_grow(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex_shrink(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_flex_wrap(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_float(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_font(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_font_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_font_size(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_font_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_font_variant(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_font_weight(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_justify_content(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_letter_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_line_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_list_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_list_style_image(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_list_style_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_list_style_type(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_margin(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_margin_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_margin_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_margin_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_margin_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_max_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_max_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_min_height(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_min_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_opacity(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_order(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_orphans(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_outline(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_outline_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_outline_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_outline_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_overflow(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_overflow_x(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_overflow_y(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_padding(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_padding_bottom(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_padding_left(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_padding_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_padding_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_page_break_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_page_break_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_page_break_inside(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_pause(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_pause_after(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_pause_before(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_pitch_range(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_pitch(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_play_during(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_position(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_quotes(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_richness(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_right(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_speak_header(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_speak_numeral(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_speak_punctuation(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_speak(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_speech_rate(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_stress(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, + css_style *result); +css_error css__parse_stroke_opacity(css_language *c, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_table_layout(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_text_align(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_text_decoration(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_text_indent(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_text_transform(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_top(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_unicode_bidi(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_vertical_align(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_visibility(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_voice_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_volume(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_white_space(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_widows(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_word_spacing(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_writing_mode(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); css_error css__parse_z_index(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result); /** Mapping from property bytecode index to bytecode unit class mask. */ @@ -546,6 +552,8 @@ extern const uint32_t property_unit_mask[CSS_N_PROPERTIES]; #define UNIT_MASK_WORD_SPACING (UNIT_LENGTH) #define UNIT_MASK_Z_INDEX (0) #define UNIT_MASK_OPACITY (0) +#define UNIT_MASK_FILL_OPACITY (0) +#define UNIT_MASK_STROKE_OPACITY (0) #define UNIT_MASK_BREAK_AFTER (0) #define UNIT_MASK_BREAK_BEFORE (0) #define UNIT_MASK_BREAK_INSIDE (0) diff --git a/src/parse/properties/quotes.c b/src/parse/properties/quotes.c index b71158f..f5360a4 100644 --- a/src/parse/properties/quotes.c +++ b/src/parse/properties/quotes.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_quotes(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error = CSS_INVALID; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/properties/stroke_opacity.c b/src/parse/properties/stroke_opacity.c new file mode 100644 index 0000000..7c10998 --- /dev/null +++ b/src/parse/properties/stroke_opacity.c @@ -0,0 +1,82 @@ +/* + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#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 stroke-opacity + * + * \param c Parsing context + * \param vector Vector of tokens to process + * \param ctx Pointer to vector iteration context + * \param result 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_stroke_opacity(css_language *c, + const parserutils_vector *vector, int32_t *ctx, + css_style *result) +{ + int32_t orig_ctx = *ctx; + css_error error; + const css_token *token; + enum flag_value flag_value; + + token = parserutils_vector_iterate(vector, ctx); + if ((token == NULL) || ((token->type != CSS_TOKEN_IDENT) && (token->type != CSS_TOKEN_NUMBER))) { + *ctx = orig_ctx; + return CSS_INVALID; + } + + flag_value = get_css_flag_value(c, token); + + if (flag_value != FLAG_VALUE__NONE) { + error = css_stylesheet_style_flag_value(result, flag_value, + CSS_PROP_STROKE_OPACITY); + + } else if (token->type == CSS_TOKEN_NUMBER) { + css_fixed num = 0; + size_t consumed = 0; + + num = css__number_from_lwc_string(token->idata, false, &consumed); + /* Invalid if there are trailing characters */ + if (consumed != lwc_string_length(token->idata)) { + *ctx = orig_ctx; + return CSS_INVALID; + } + + /* Clamp to range [0,1] */ + if (num < 0) + num = 0; + if (num > INTTOFIX(1)) + num = INTTOFIX(1); + + error = css__stylesheet_style_appendOPV(result, CSS_PROP_STROKE_OPACITY, 0, STROKE_OPACITY_SET); + if (error != CSS_OK) { + *ctx = orig_ctx; + return error; + } + + error = css__stylesheet_style_append(result, num); + } else { + error = CSS_INVALID; + } + + if (error != CSS_OK) + *ctx = orig_ctx; + + return error; +} + diff --git a/src/parse/properties/text_decoration.c b/src/parse/properties/text_decoration.c index 1345b8e..4849a12 100644 --- a/src/parse/properties/text_decoration.c +++ b/src/parse/properties/text_decoration.c @@ -28,10 +28,10 @@ * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_text_decoration(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error = CSS_INVALID; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 1e184f8..e6ab872 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -126,10 +126,10 @@ css_error css__parse_list_style_type_value(css_language *c, const css_token *ide * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum border_side_e side) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx; const css_token *token; css_error error = CSS_OK; @@ -366,10 +366,10 @@ static void HSL_to_RGB(css_fixed hue, css_fixed sat, css_fixed lit, uint8_t *r, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_colour_specifier(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, uint16_t *value, uint32_t *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; const css_token *token; bool match; css_error error; @@ -913,11 +913,11 @@ css_error css__parse_hash_colour(lwc_string *data, uint32_t *result) * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_unit_specifier(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, uint32_t default_unit, css_fixed *length, uint32_t *unit) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; const css_token *token; css_fixed num; size_t consumed = 0; @@ -938,7 +938,7 @@ css_error css__parse_unit_specifier(css_language *c, if (token->type == CSS_TOKEN_DIMENSION) { size_t len = lwc_string_length(token->idata); const char *data = lwc_string_data(token->idata); - css_unit temp_unit = CSS_UNIT_PX; + uint32_t temp_unit = CSS_UNIT_PX; error = css__parse_unit_keyword(data + consumed, len - consumed, &temp_unit); @@ -947,7 +947,7 @@ css_error css__parse_unit_specifier(css_language *c, return error; } - *unit = (uint32_t) temp_unit; + *unit = temp_unit; } else if (token->type == CSS_TOKEN_NUMBER) { /* Non-zero values are permitted in quirks mode */ if (num != 0) { @@ -966,8 +966,8 @@ css_error css__parse_unit_specifier(css_language *c, * dimensions separated from their units by whitespace * (e.g. "0 px") */ - int temp_ctx = *ctx; - css_unit temp_unit; + int32_t temp_ctx = *ctx; + uint32_t temp_unit; consumeWhitespace(vector, &temp_ctx); @@ -981,7 +981,7 @@ css_error css__parse_unit_specifier(css_language *c, if (error == CSS_OK) { c->sheet->quirks_used = true; *ctx = temp_ctx; - *unit = (uint32_t) temp_unit; + *unit = temp_unit; } } } @@ -1103,7 +1103,7 @@ css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit) * The resulting string's reference is passed to the caller */ css_error css__ident_list_or_string_to_string(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool (*reserved)(css_language *c, const css_token *ident), lwc_string **result) { @@ -1141,11 +1141,11 @@ css_error css__ident_list_or_string_to_string(css_language *c, * The resulting string's reference is passed to the caller */ css_error css__ident_list_to_string(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool (*reserved)(css_language *c, const css_token *ident), lwc_string **result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; const css_token *token; css_error error = CSS_OK; parserutils_buffer *buffer; @@ -1229,12 +1229,12 @@ cleanup: * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__comma_list_to_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool (*reserved)(css_language *c, const css_token *ident), css_code_t (*get_value)(css_language *c, const css_token *token, bool first), css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; int prev_ctx = orig_ctx; const css_token *token; bool first = true; diff --git a/src/parse/properties/utils.h b/src/parse/properties/utils.h index 54a3fd1..aab14e8 100644 --- a/src/parse/properties/utils.h +++ b/src/parse/properties/utils.h @@ -66,7 +66,7 @@ enum border_side_e { BORDER_SIDE_TOP = 0, BORDER_SIDE_RIGHT = 1, BORDER_SIDE_BOT * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum border_side_e side); /** @@ -85,7 +85,7 @@ css_error css__parse_border_side(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_side_color(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op); /** @@ -104,7 +104,7 @@ css_error css__parse_border_side_color(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_side_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op); @@ -124,7 +124,7 @@ css_error css__parse_border_side_style(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_border_side_width(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op); @@ -144,7 +144,7 @@ css_error css__parse_border_side_width(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op); @@ -163,7 +163,7 @@ css_error css__parse_side(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_margin_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op); /** @@ -181,7 +181,7 @@ css_error css__parse_margin_side(css_language *c, * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_padding_side(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op); @@ -194,7 +194,7 @@ css_error css__parse_list_style_type_value(css_language *c, const css_token *token, uint16_t *value); css_error css__parse_colour_specifier(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, uint16_t *value, uint32_t *result); css_error css__parse_named_colour(css_language *c, lwc_string *data, @@ -203,7 +203,7 @@ css_error css__parse_named_colour(css_language *c, lwc_string *data, css_error css__parse_hash_colour(lwc_string *data, uint32_t *result); css_error css__parse_unit_specifier(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, uint32_t default_unit, css_fixed *length, uint32_t *unit); @@ -211,17 +211,17 @@ css_error css__parse_unit_keyword(const char *ptr, size_t len, uint32_t *unit); css_error css__ident_list_or_string_to_string(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool (*reserved)(css_language *c, const css_token *ident), lwc_string **result); css_error css__ident_list_to_string(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool (*reserved)(css_language *c, const css_token *ident), lwc_string **result); css_error css__comma_list_to_style(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, bool (*reserved)(css_language *c, const css_token *ident), css_code_t (*get_value)(css_language *c, const css_token *token, diff --git a/src/parse/properties/voice_family.c b/src/parse/properties/voice_family.c index f62ba15..45d63f1 100644 --- a/src/parse/properties/voice_family.c +++ b/src/parse/properties/voice_family.c @@ -84,10 +84,10 @@ static css_code_t voice_family_value(css_language *c, const css_token *token, bo * If the input is invalid, then \a *ctx remains unchanged. */ css_error css__parse_voice_family(css_language *c, - const parserutils_vector *vector, int *ctx, + const parserutils_vector *vector, int32_t *ctx, css_style *result) { - int orig_ctx = *ctx; + int32_t orig_ctx = *ctx; css_error error; const css_token *token; enum flag_value flag_value; diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c index dd579f1..c57bc1b 100644 --- a/src/parse/propstrings.c +++ b/src/parse/propstrings.c @@ -148,6 +148,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = { SMAP("display"), SMAP("elevation"), SMAP("empty-cells"), + SMAP("fill-opacity"), SMAP("flex"), SMAP("flex-basis"), SMAP("flex-direction"), @@ -214,6 +215,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = { SMAP("speak"), SMAP("speech-rate"), SMAP("stress"), + SMAP("stroke-opacity"), SMAP("table-layout"), SMAP("text-align"), SMAP("text-decoration"), @@ -486,6 +488,9 @@ const stringmap_entry stringmap[LAST_KNOWN] = { SMAP("or"), SMAP("only"), SMAP("infinite"), + SMAP("grid"), + SMAP("inline-grid"), + SMAP("sticky"), SMAP("aliceblue"), SMAP("antiquewhite"), diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h index df3bcf1..8491e72 100644 --- a/src/parse/propstrings.h +++ b/src/parse/propstrings.h @@ -51,22 +51,23 @@ 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, 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, + CURSOR, DIRECTION, DISPLAY, ELEVATION, EMPTY_CELLS, FILL_OPACITY, 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, STROKE_OPACITY, 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, @@ -109,6 +110,7 @@ enum { 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, AND, OR, ONLY, INFINITE, + GRID, INLINE_GRID, STICKY, /* Named colours */ FIRST_COLOUR, diff --git a/src/select/Makefile b/src/select/Makefile index b9e7390..e237d46 100644 --- a/src/select/Makefile +++ b/src/select/Makefile @@ -1,4 +1,5 @@ # Sources +.PHONY: select_generator select_generator: python3 src/select/select_generator.py diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h index 7765f35..40005c1 100644 --- a/src/select/autogenerated_computed.h +++ b/src/select/autogenerated_computed.h @@ -52,6 +52,7 @@ struct css_computed_style_i { * direction 2 * display 5 * empty_cells 2 + * fill_opacity 1 4 * flex_basis 2 + 5 4 * flex_direction 3 * flex_grow 1 4 @@ -95,6 +96,7 @@ struct css_computed_style_i { * page_break_inside 2 * position 3 * right 2 + 5 4 + * stroke_opacity 1 4 * table_layout 2 * text_align 4 * text_decoration 5 @@ -140,66 +142,67 @@ struct css_computed_style_i { * quotes 1 sizeof(ptr) * * --- --- --- - * 462 bits 228 + 8sizeof(ptr) bytes + * 464 bits 236 + 8sizeof(ptr) bytes * =================== - * 286 + 8sizeof(ptr) bytes + * 294 + 8sizeof(ptr) bytes * * Bit allocations: * * 0 bbbbbbbboooooooorrrrrrrrdddddddd - * border_left_width; border_top_width; border_bottom_width; border_right_width + * border_top_width; border_right_width; border_left_width; border_bottom_width * - * 1 vvvvvvvvvooooooooccccccccmmmmmmm - * vertical_align; outline_width; column_rule_width; margin_top + * 1 fffffffffooooooooccccccccwwwwwww + * font_size; outline_width; column_rule_width; word_spacing * - * 2 ccccccccccccccccccccccccccpppppp - * clip; padding_left + * 2 cccccccccccccccccccccccccctttttt + * clip; text_indent * - * 3 mmmmmmmrrrrrrrwwwwwwwttttttddddd - * max_height; right; width; text_indent; display + * 3 cccccccooooooobbbbbbbppppppttttt + * column_width; column_gap; bottom; padding_top; text_decoration * - * 4 fffffffmmmmmmmcccccccllllllltttt - * flex_basis; min_height; column_gap; left; text_align + * 4 wwwwwwwtttttttrrrrrrrmmmmmmmeeee + * width; top; right; min_width; text_align * - * 5 cccccccmmmmmmmlllllllwwwwwwwbbbb - * column_width; margin_bottom; line_height; word_spacing; break_inside + * 5 mmmmmmmaaaaaaaxxxxxxxrrrrrrroooo + * min_height; max_width; max_height; margin_top; outline_style * - * 6 hhhhhhhlllllllmmmmmmmaaaaaaabbbb - * height; letter_spacing; min_width; margin_right; border_bottom_style + * 6 mmmmmmmaaaaaaarrrrrrrlllllllffff + * margin_right; margin_left; margin_bottom; line_height; font_weight * - * 7 tttttttmmmmmmmbbbbbbbaaaaaaaoooo - * top; margin_left; bottom; max_width; border_top_style + * 7 llllllleeeeeeehhhhhhhfffffffcccc + * letter_spacing; left; height; flex_basis; column_rule_style * - * 8 llllllppppppaaaaaaddddddtttttggg - * list_style_type; padding_top; padding_right; padding_bottom; - * text_decoration; page_break_after + * 8 ppppppaaaaaaddddddlllllliiiiiwww + * padding_right; padding_left; padding_bottom; list_style_type; display; + * white_space * - * 9 cccccbbbbooooffffrrrruuuullllnnn - * cursor; break_before; border_left_style; font_weight; break_after; - * outline_style; column_rule_style; font_family + * 9 cccccbbbbrrrreeeeooooddddllllttt + * cursor; break_inside; break_before; break_after; border_top_style; + * border_right_style; border_left_style; text_transform * - * 10 aaallliiipppbbccttoouuzzffeerrmm - * align_content; align_items; align_self; position; border_bottom_color; - * column_rule_color; table_layout; box_sizing; column_span; z_index; - * flex_wrap; empty_cells; border_left_color; column_count + * 10 bbbaaallliiizzwwvvuuttppoossffnn + * background_repeat; align_self; align_items; align_content; z_index; + * writing_mode; visibility; unicode_bidi; table_layout; page_break_inside; + * outline_color; list_style_position; font_variant; font_style * - * 11 ffoobbppaannccrrddeeuulliittUUvv - * float; font_variant; background_attachment; page_break_inside; - * background_color; font_style; content; border_top_color; border_collapse; - * border_right_color; outline_color; column_fill; list_style_position; - * caption_side; unicode_bidi; visibility + * 11 fflleeddccoouummnnaabbrriittppBB + * float; flex_wrap; empty_cells; direction; content; column_span; + * column_rule_color; column_fill; column_count; caption_side; box_sizing; + * border_top_color; border_right_color; border_left_color; border_collapse; + * border_bottom_color * - * 12 bbbbbbbbbbbaaaaaaaaaaafffffffffl - * border_spacing; background_position; font_size; flex_grow + * 12 bbbbbbbbbbbaaaaaaaaaaavvvvvvvvvw + * border_spacing; background_position; vertical_align; widows * - * 13 bbbboooaaawwwvvvtttcccpppjjjfffr - * border_right_style; overflow_y; background_repeat; white_space; overflow_x; - * text_transform; clear; page_break_before; justify_content; flex_direction; - * order + * 13 bbbbpppaaagggooovvvjjjffflllcccs + * border_bottom_style; position; page_break_before; page_break_after; + * overflow_y; overflow_x; justify_content; font_family; flex_direction; clear; + * stroke_opacity * - * 14 wwddlicobfqupr.................. - * writing_mode; direction; list_style_image; widows; counter_reset; orphans; - * background_image; flex_shrink; quotes; counter_increment; opacity; color + * 14 bbaaqorplfeicuCk................ + * background_color; background_attachment; quotes; orphans; order; opacity; + * list_style_image; flex_shrink; flex_grow; fill_opacity; counter_reset; + * counter_increment; color; background_image */ uint32_t bits[15]; @@ -228,6 +231,7 @@ struct css_computed_style_i { css_color column_rule_color; css_fixed column_rule_width; css_fixed column_width; + css_fixed fill_opacity; css_fixed flex_basis; css_fixed flex_grow; css_fixed flex_shrink; @@ -255,6 +259,7 @@ struct css_computed_style_i { css_fixed padding_right; css_fixed padding_top; css_fixed right; + css_fixed stroke_opacity; css_fixed text_indent; css_fixed top; css_fixed vertical_align; @@ -262,7 +267,6 @@ struct css_computed_style_i { css_fixed width; css_fixed word_spacing; int32_t z_index; - }; struct css_computed_style { diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h index 39ce62a..d1f7ffb 100644 --- a/src/select/autogenerated_propget.h +++ b/src/select/autogenerated_propget.h @@ -7,8 +7,17 @@ #define ALIGN_CONTENT_INDEX 10 -#define ALIGN_CONTENT_SHIFT 29 -#define ALIGN_CONTENT_MASK 0xe0000000 +#define ALIGN_CONTENT_SHIFT 20 +#define ALIGN_CONTENT_MASK 0x700000 +static inline uint8_t get_align_content_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX]; + bits &= ALIGN_CONTENT_MASK; + bits >>= ALIGN_CONTENT_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_align_content(const css_computed_style *style) { uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX]; @@ -24,8 +33,17 @@ static inline uint8_t get_align_content(const css_computed_style *style) #undef ALIGN_CONTENT_MASK #define ALIGN_ITEMS_INDEX 10 -#define ALIGN_ITEMS_SHIFT 26 -#define ALIGN_ITEMS_MASK 0x1c000000 +#define ALIGN_ITEMS_SHIFT 23 +#define ALIGN_ITEMS_MASK 0x3800000 +static inline uint8_t get_align_items_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX]; + bits &= ALIGN_ITEMS_MASK; + bits >>= ALIGN_ITEMS_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_align_items(const css_computed_style *style) { uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX]; @@ -41,8 +59,17 @@ static inline uint8_t get_align_items(const css_computed_style *style) #undef ALIGN_ITEMS_MASK #define ALIGN_SELF_INDEX 10 -#define ALIGN_SELF_SHIFT 23 -#define ALIGN_SELF_MASK 0x3800000 +#define ALIGN_SELF_SHIFT 26 +#define ALIGN_SELF_MASK 0x1c000000 +static inline uint8_t get_align_self_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[ALIGN_SELF_INDEX]; + bits &= ALIGN_SELF_MASK; + bits >>= ALIGN_SELF_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_align_self(const css_computed_style *style) { uint32_t bits = style->i.bits[ALIGN_SELF_INDEX]; @@ -57,9 +84,19 @@ static inline uint8_t get_align_self(const css_computed_style *style) #undef ALIGN_SELF_SHIFT #undef ALIGN_SELF_MASK -#define BACKGROUND_ATTACHMENT_INDEX 11 -#define BACKGROUND_ATTACHMENT_SHIFT 26 -#define BACKGROUND_ATTACHMENT_MASK 0xc000000 +#define BACKGROUND_ATTACHMENT_INDEX 14 +#define BACKGROUND_ATTACHMENT_SHIFT 28 +#define BACKGROUND_ATTACHMENT_MASK 0x30000000 +static inline uint8_t get_background_attachment_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX]; + bits &= BACKGROUND_ATTACHMENT_MASK; + bits >>= BACKGROUND_ATTACHMENT_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_background_attachment(const css_computed_style *style) { uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX]; @@ -74,9 +111,18 @@ static inline uint8_t get_background_attachment(const css_computed_style *style) #undef BACKGROUND_ATTACHMENT_SHIFT #undef BACKGROUND_ATTACHMENT_MASK -#define BACKGROUND_COLOR_INDEX 11 -#define BACKGROUND_COLOR_SHIFT 22 -#define BACKGROUND_COLOR_MASK 0xc00000 +#define BACKGROUND_COLOR_INDEX 14 +#define BACKGROUND_COLOR_SHIFT 30 +#define BACKGROUND_COLOR_MASK 0xc0000000 +static inline uint8_t get_background_color_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BACKGROUND_COLOR_INDEX]; + bits &= BACKGROUND_COLOR_MASK; + bits >>= BACKGROUND_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_background_color(const css_computed_style *style, css_color *color) { @@ -94,8 +140,17 @@ static inline uint8_t get_background_color(const css_computed_style *style, #undef BACKGROUND_COLOR_MASK #define BACKGROUND_IMAGE_INDEX 14 -#define BACKGROUND_IMAGE_SHIFT 23 -#define BACKGROUND_IMAGE_MASK 0x800000 +#define BACKGROUND_IMAGE_SHIFT 16 +#define BACKGROUND_IMAGE_MASK 0x10000 +static inline uint8_t get_background_image_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX]; + bits &= BACKGROUND_IMAGE_MASK; + bits >>= BACKGROUND_IMAGE_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_background_image(const css_computed_style *style, lwc_string **string) { @@ -115,6 +170,16 @@ static inline uint8_t get_background_image(const css_computed_style *style, #define BACKGROUND_POSITION_INDEX 12 #define BACKGROUND_POSITION_SHIFT 10 #define BACKGROUND_POSITION_MASK 0x1ffc00 +static inline uint8_t get_background_position_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BACKGROUND_POSITION_INDEX]; + bits &= BACKGROUND_POSITION_MASK; + bits >>= BACKGROUND_POSITION_SHIFT; + + /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ + return (bits & 0x1); +} static inline uint8_t get_background_position(const css_computed_style *style, css_fixed *length_a, css_unit *unit_a, css_fixed *length_b, css_unit *unit_b) @@ -137,9 +202,19 @@ static inline uint8_t get_background_position(const css_computed_style *style, #undef BACKGROUND_POSITION_SHIFT #undef BACKGROUND_POSITION_MASK -#define BACKGROUND_REPEAT_INDEX 13 -#define BACKGROUND_REPEAT_SHIFT 22 -#define BACKGROUND_REPEAT_MASK 0x1c00000 +#define BACKGROUND_REPEAT_INDEX 10 +#define BACKGROUND_REPEAT_SHIFT 29 +#define BACKGROUND_REPEAT_MASK 0xe0000000 +static inline uint8_t get_background_repeat_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX]; + bits &= BACKGROUND_REPEAT_MASK; + bits >>= BACKGROUND_REPEAT_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_background_repeat(const css_computed_style *style) { uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX]; @@ -154,9 +229,19 @@ static inline uint8_t get_background_repeat(const css_computed_style *style) #undef BACKGROUND_REPEAT_SHIFT #undef BACKGROUND_REPEAT_MASK -#define BORDER_BOTTOM_COLOR_INDEX 10 -#define BORDER_BOTTOM_COLOR_SHIFT 18 -#define BORDER_BOTTOM_COLOR_MASK 0xc0000 +#define BORDER_BOTTOM_COLOR_INDEX 11 +#define BORDER_BOTTOM_COLOR_SHIFT 0 +#define BORDER_BOTTOM_COLOR_MASK 0x3 +static inline uint8_t get_border_bottom_color_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX]; + bits &= BORDER_BOTTOM_COLOR_MASK; + bits >>= BORDER_BOTTOM_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_border_bottom_color(const css_computed_style *style, css_color *color) { @@ -173,9 +258,19 @@ static inline uint8_t get_border_bottom_color(const css_computed_style *style, #undef BORDER_BOTTOM_COLOR_SHIFT #undef BORDER_BOTTOM_COLOR_MASK -#define BORDER_BOTTOM_STYLE_INDEX 6 -#define BORDER_BOTTOM_STYLE_SHIFT 0 -#define BORDER_BOTTOM_STYLE_MASK 0xf +#define BORDER_BOTTOM_STYLE_INDEX 13 +#define BORDER_BOTTOM_STYLE_SHIFT 28 +#define BORDER_BOTTOM_STYLE_MASK 0xf0000000 +static inline uint8_t get_border_bottom_style_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX]; + bits &= BORDER_BOTTOM_STYLE_MASK; + bits >>= BORDER_BOTTOM_STYLE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_border_bottom_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX]; @@ -191,8 +286,18 @@ static inline uint8_t get_border_bottom_style(const css_computed_style *style) #undef BORDER_BOTTOM_STYLE_MASK #define BORDER_BOTTOM_WIDTH_INDEX 0 -#define BORDER_BOTTOM_WIDTH_SHIFT 8 -#define BORDER_BOTTOM_WIDTH_MASK 0xff00 +#define BORDER_BOTTOM_WIDTH_SHIFT 0 +#define BORDER_BOTTOM_WIDTH_MASK 0xff +static inline uint8_t get_border_bottom_width_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX]; + bits &= BORDER_BOTTOM_WIDTH_MASK; + bits >>= BORDER_BOTTOM_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + return (bits & 0x7); +} static inline uint8_t get_border_bottom_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -213,8 +318,17 @@ static inline uint8_t get_border_bottom_width(const css_computed_style *style, #undef BORDER_BOTTOM_WIDTH_MASK #define BORDER_COLLAPSE_INDEX 11 -#define BORDER_COLLAPSE_SHIFT 14 -#define BORDER_COLLAPSE_MASK 0xc000 +#define BORDER_COLLAPSE_SHIFT 2 +#define BORDER_COLLAPSE_MASK 0xc +static inline uint8_t get_border_collapse_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX]; + bits &= BORDER_COLLAPSE_MASK; + bits >>= BORDER_COLLAPSE_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_border_collapse(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX]; @@ -229,9 +343,19 @@ static inline uint8_t get_border_collapse(const css_computed_style *style) #undef BORDER_COLLAPSE_SHIFT #undef BORDER_COLLAPSE_MASK -#define BORDER_LEFT_COLOR_INDEX 10 -#define BORDER_LEFT_COLOR_SHIFT 2 -#define BORDER_LEFT_COLOR_MASK 0xc +#define BORDER_LEFT_COLOR_INDEX 11 +#define BORDER_LEFT_COLOR_SHIFT 4 +#define BORDER_LEFT_COLOR_MASK 0x30 +static inline uint8_t get_border_left_color_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX]; + bits &= BORDER_LEFT_COLOR_MASK; + bits >>= BORDER_LEFT_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_border_left_color(const css_computed_style *style, css_color *color) { @@ -249,8 +373,18 @@ static inline uint8_t get_border_left_color(const css_computed_style *style, #undef BORDER_LEFT_COLOR_MASK #define BORDER_LEFT_STYLE_INDEX 9 -#define BORDER_LEFT_STYLE_SHIFT 19 -#define BORDER_LEFT_STYLE_MASK 0x780000 +#define BORDER_LEFT_STYLE_SHIFT 3 +#define BORDER_LEFT_STYLE_MASK 0x78 +static inline uint8_t get_border_left_style_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX]; + bits &= BORDER_LEFT_STYLE_MASK; + bits >>= BORDER_LEFT_STYLE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_border_left_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX]; @@ -266,8 +400,18 @@ static inline uint8_t get_border_left_style(const css_computed_style *style) #undef BORDER_LEFT_STYLE_MASK #define BORDER_LEFT_WIDTH_INDEX 0 -#define BORDER_LEFT_WIDTH_SHIFT 24 -#define BORDER_LEFT_WIDTH_MASK 0xff000000 +#define BORDER_LEFT_WIDTH_SHIFT 8 +#define BORDER_LEFT_WIDTH_MASK 0xff00 +static inline uint8_t get_border_left_width_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX]; + bits &= BORDER_LEFT_WIDTH_MASK; + bits >>= BORDER_LEFT_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + return (bits & 0x7); +} static inline uint8_t get_border_left_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -288,8 +432,18 @@ static inline uint8_t get_border_left_width(const css_computed_style *style, #undef BORDER_LEFT_WIDTH_MASK #define BORDER_RIGHT_COLOR_INDEX 11 -#define BORDER_RIGHT_COLOR_SHIFT 12 -#define BORDER_RIGHT_COLOR_MASK 0x3000 +#define BORDER_RIGHT_COLOR_SHIFT 6 +#define BORDER_RIGHT_COLOR_MASK 0xc0 +static inline uint8_t get_border_right_color_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX]; + bits &= BORDER_RIGHT_COLOR_MASK; + bits >>= BORDER_RIGHT_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_border_right_color(const css_computed_style *style, css_color *color) { @@ -306,9 +460,19 @@ static inline uint8_t get_border_right_color(const css_computed_style *style, #undef BORDER_RIGHT_COLOR_SHIFT #undef BORDER_RIGHT_COLOR_MASK -#define BORDER_RIGHT_STYLE_INDEX 13 -#define BORDER_RIGHT_STYLE_SHIFT 28 -#define BORDER_RIGHT_STYLE_MASK 0xf0000000 +#define BORDER_RIGHT_STYLE_INDEX 9 +#define BORDER_RIGHT_STYLE_SHIFT 7 +#define BORDER_RIGHT_STYLE_MASK 0x780 +static inline uint8_t get_border_right_style_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX]; + bits &= BORDER_RIGHT_STYLE_MASK; + bits >>= BORDER_RIGHT_STYLE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_border_right_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX]; @@ -324,8 +488,18 @@ static inline uint8_t get_border_right_style(const css_computed_style *style) #undef BORDER_RIGHT_STYLE_MASK #define BORDER_RIGHT_WIDTH_INDEX 0 -#define BORDER_RIGHT_WIDTH_SHIFT 0 -#define BORDER_RIGHT_WIDTH_MASK 0xff +#define BORDER_RIGHT_WIDTH_SHIFT 16 +#define BORDER_RIGHT_WIDTH_MASK 0xff0000 +static inline uint8_t get_border_right_width_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX]; + bits &= BORDER_RIGHT_WIDTH_MASK; + bits >>= BORDER_RIGHT_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + return (bits & 0x7); +} static inline uint8_t get_border_right_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -348,6 +522,15 @@ static inline uint8_t get_border_right_width(const css_computed_style *style, #define BORDER_SPACING_INDEX 12 #define BORDER_SPACING_SHIFT 21 #define BORDER_SPACING_MASK 0xffe00000 +static inline uint8_t get_border_spacing_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BORDER_SPACING_INDEX]; + bits &= BORDER_SPACING_MASK; + bits >>= BORDER_SPACING_SHIFT; + + /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ + return (bits & 0x1); +} static inline uint8_t get_border_spacing(const css_computed_style *style, css_fixed *length_a, css_unit *unit_a, css_fixed *length_b, css_unit *unit_b) @@ -371,8 +554,17 @@ static inline uint8_t get_border_spacing(const css_computed_style *style, #undef BORDER_SPACING_MASK #define BORDER_TOP_COLOR_INDEX 11 -#define BORDER_TOP_COLOR_SHIFT 16 -#define BORDER_TOP_COLOR_MASK 0x30000 +#define BORDER_TOP_COLOR_SHIFT 8 +#define BORDER_TOP_COLOR_MASK 0x300 +static inline uint8_t get_border_top_color_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX]; + bits &= BORDER_TOP_COLOR_MASK; + bits >>= BORDER_TOP_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_border_top_color(const css_computed_style *style, css_color *color) { @@ -389,9 +581,18 @@ static inline uint8_t get_border_top_color(const css_computed_style *style, #undef BORDER_TOP_COLOR_SHIFT #undef BORDER_TOP_COLOR_MASK -#define BORDER_TOP_STYLE_INDEX 7 -#define BORDER_TOP_STYLE_SHIFT 0 -#define BORDER_TOP_STYLE_MASK 0xf +#define BORDER_TOP_STYLE_INDEX 9 +#define BORDER_TOP_STYLE_SHIFT 11 +#define BORDER_TOP_STYLE_MASK 0x7800 +static inline uint8_t get_border_top_style_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX]; + bits &= BORDER_TOP_STYLE_MASK; + bits >>= BORDER_TOP_STYLE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_border_top_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX]; @@ -407,8 +608,17 @@ static inline uint8_t get_border_top_style(const css_computed_style *style) #undef BORDER_TOP_STYLE_MASK #define BORDER_TOP_WIDTH_INDEX 0 -#define BORDER_TOP_WIDTH_SHIFT 16 -#define BORDER_TOP_WIDTH_MASK 0xff0000 +#define BORDER_TOP_WIDTH_SHIFT 24 +#define BORDER_TOP_WIDTH_MASK 0xff000000 +static inline uint8_t get_border_top_width_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX]; + bits &= BORDER_TOP_WIDTH_MASK; + bits >>= BORDER_TOP_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + return (bits & 0x7); +} static inline uint8_t get_border_top_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -428,42 +638,49 @@ static inline uint8_t get_border_top_width(const css_computed_style *style, #undef BORDER_TOP_WIDTH_SHIFT #undef BORDER_TOP_WIDTH_MASK -#define BOTTOM_INDEX 7 +#define BOTTOM_INDEX 3 #define BOTTOM_SHIFT 11 #define BOTTOM_MASK 0x3f800 -static inline uint8_t get_bottom( - const css_computed_style *style, - css_fixed *length, css_unit *unit) +static inline uint8_t get_bottom_bits(const css_computed_style *style) { uint32_t bits = style->i.bits[BOTTOM_INDEX]; bits &= BOTTOM_MASK; bits >>= BOTTOM_SHIFT; - - /* 7bits: uuuuutt : units | type */ - if ((bits & 0x3) == CSS_BOTTOM_SET) { - *length = style->i.bottom; - *unit = bits >> 2; - } - + + /* 7bits: uuuuutt : unit | type */ return (bits & 0x3); } -static inline uint8_t get_bottom_bits( - const css_computed_style *style) +static inline uint8_t get_bottom(const css_computed_style *style, css_fixed + *length, css_unit *unit) { uint32_t bits = style->i.bits[BOTTOM_INDEX]; bits &= BOTTOM_MASK; bits >>= BOTTOM_SHIFT; - - /* 7bits: uuuuutt : units | type */ - return bits; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_BOTTOM_SET) { + *length = style->i.bottom; + *unit = bits >> 2; + } + + return (bits & 0x3); } #undef BOTTOM_INDEX #undef BOTTOM_SHIFT #undef BOTTOM_MASK -#define BOX_SIZING_INDEX 10 -#define BOX_SIZING_SHIFT 12 -#define BOX_SIZING_MASK 0x3000 +#define BOX_SIZING_INDEX 11 +#define BOX_SIZING_SHIFT 10 +#define BOX_SIZING_MASK 0xc00 +static inline uint8_t get_box_sizing_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BOX_SIZING_INDEX]; + bits &= BOX_SIZING_MASK; + bits >>= BOX_SIZING_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_box_sizing(const css_computed_style *style) { uint32_t bits = style->i.bits[BOX_SIZING_INDEX]; @@ -479,8 +696,17 @@ static inline uint8_t get_box_sizing(const css_computed_style *style) #undef BOX_SIZING_MASK #define BREAK_AFTER_INDEX 9 -#define BREAK_AFTER_SHIFT 11 -#define BREAK_AFTER_MASK 0x7800 +#define BREAK_AFTER_SHIFT 15 +#define BREAK_AFTER_MASK 0x78000 +static inline uint8_t get_break_after_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BREAK_AFTER_INDEX]; + bits &= BREAK_AFTER_MASK; + bits >>= BREAK_AFTER_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_break_after(const css_computed_style *style) { uint32_t bits = style->i.bits[BREAK_AFTER_INDEX]; @@ -496,8 +722,17 @@ static inline uint8_t get_break_after(const css_computed_style *style) #undef BREAK_AFTER_MASK #define BREAK_BEFORE_INDEX 9 -#define BREAK_BEFORE_SHIFT 23 -#define BREAK_BEFORE_MASK 0x7800000 +#define BREAK_BEFORE_SHIFT 19 +#define BREAK_BEFORE_MASK 0x780000 +static inline uint8_t get_break_before_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX]; + bits &= BREAK_BEFORE_MASK; + bits >>= BREAK_BEFORE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_break_before(const css_computed_style *style) { uint32_t bits = style->i.bits[BREAK_BEFORE_INDEX]; @@ -512,9 +747,18 @@ static inline uint8_t get_break_before(const css_computed_style *style) #undef BREAK_BEFORE_SHIFT #undef BREAK_BEFORE_MASK -#define BREAK_INSIDE_INDEX 5 -#define BREAK_INSIDE_SHIFT 0 -#define BREAK_INSIDE_MASK 0xf +#define BREAK_INSIDE_INDEX 9 +#define BREAK_INSIDE_SHIFT 23 +#define BREAK_INSIDE_MASK 0x7800000 +static inline uint8_t get_break_inside_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX]; + bits &= BREAK_INSIDE_MASK; + bits >>= BREAK_INSIDE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_break_inside(const css_computed_style *style) { uint32_t bits = style->i.bits[BREAK_INSIDE_INDEX]; @@ -530,8 +774,17 @@ static inline uint8_t get_break_inside(const css_computed_style *style) #undef BREAK_INSIDE_MASK #define CAPTION_SIDE_INDEX 11 -#define CAPTION_SIDE_SHIFT 4 -#define CAPTION_SIDE_MASK 0x30 +#define CAPTION_SIDE_SHIFT 12 +#define CAPTION_SIDE_MASK 0x3000 +static inline uint8_t get_caption_side_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX]; + bits &= CAPTION_SIDE_MASK; + bits >>= CAPTION_SIDE_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_caption_side(const css_computed_style *style) { uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX]; @@ -547,8 +800,17 @@ static inline uint8_t get_caption_side(const css_computed_style *style) #undef CAPTION_SIDE_MASK #define CLEAR_INDEX 13 -#define CLEAR_SHIFT 10 -#define CLEAR_MASK 0x1c00 +#define CLEAR_SHIFT 1 +#define CLEAR_MASK 0xe +static inline uint8_t get_clear_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[CLEAR_INDEX]; + bits &= CLEAR_MASK; + bits >>= CLEAR_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_clear(const css_computed_style *style) { uint32_t bits = style->i.bits[CLEAR_INDEX]; @@ -566,6 +828,16 @@ static inline uint8_t get_clear(const css_computed_style *style) #define CLIP_INDEX 2 #define CLIP_SHIFT 6 #define CLIP_MASK 0xffffffc0 +static inline uint8_t get_clip_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[CLIP_INDEX]; + bits &= CLIP_MASK; + bits >>= CLIP_SHIFT; + + /* 26bits: aaaaabbbbbcccccdddddtttttt : unit_a | unit_b | unit_c | + unit_d | type */ + return (bits & 0x3f); +} static inline uint8_t get_clip( const css_computed_style *style, css_computed_clip_rect *rect) @@ -606,8 +878,17 @@ static inline uint8_t get_clip( #undef CLIP_MASK #define COLOR_INDEX 14 -#define COLOR_SHIFT 18 -#define COLOR_MASK 0x40000 +#define COLOR_SHIFT 17 +#define COLOR_MASK 0x20000 +static inline uint8_t get_color_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COLOR_INDEX]; + bits &= COLOR_MASK; + bits >>= COLOR_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_color(const css_computed_style *style, css_color *color) { @@ -624,9 +905,18 @@ static inline uint8_t get_color(const css_computed_style *style, css_color #undef COLOR_SHIFT #undef COLOR_MASK -#define COLUMN_COUNT_INDEX 10 -#define COLUMN_COUNT_SHIFT 0 -#define COLUMN_COUNT_MASK 0x3 +#define COLUMN_COUNT_INDEX 11 +#define COLUMN_COUNT_SHIFT 14 +#define COLUMN_COUNT_MASK 0xc000 +static inline uint8_t get_column_count_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COLUMN_COUNT_INDEX]; + bits &= COLUMN_COUNT_MASK; + bits >>= COLUMN_COUNT_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_column_count(const css_computed_style *style, int32_t *integer) { @@ -644,8 +934,17 @@ static inline uint8_t get_column_count(const css_computed_style *style, int32_t #undef COLUMN_COUNT_MASK #define COLUMN_FILL_INDEX 11 -#define COLUMN_FILL_SHIFT 8 -#define COLUMN_FILL_MASK 0x300 +#define COLUMN_FILL_SHIFT 16 +#define COLUMN_FILL_MASK 0x30000 +static inline uint8_t get_column_fill_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COLUMN_FILL_INDEX]; + bits &= COLUMN_FILL_MASK; + bits >>= COLUMN_FILL_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_column_fill(const css_computed_style *style) { uint32_t bits = style->i.bits[COLUMN_FILL_INDEX]; @@ -660,9 +959,18 @@ static inline uint8_t get_column_fill(const css_computed_style *style) #undef COLUMN_FILL_SHIFT #undef COLUMN_FILL_MASK -#define COLUMN_GAP_INDEX 4 -#define COLUMN_GAP_SHIFT 11 -#define COLUMN_GAP_MASK 0x3f800 +#define COLUMN_GAP_INDEX 3 +#define COLUMN_GAP_SHIFT 18 +#define COLUMN_GAP_MASK 0x1fc0000 +static inline uint8_t get_column_gap_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COLUMN_GAP_INDEX]; + bits &= COLUMN_GAP_MASK; + bits >>= COLUMN_GAP_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -682,9 +990,19 @@ static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed #undef COLUMN_GAP_SHIFT #undef COLUMN_GAP_MASK -#define COLUMN_RULE_COLOR_INDEX 10 -#define COLUMN_RULE_COLOR_SHIFT 16 -#define COLUMN_RULE_COLOR_MASK 0x30000 +#define COLUMN_RULE_COLOR_INDEX 11 +#define COLUMN_RULE_COLOR_SHIFT 18 +#define COLUMN_RULE_COLOR_MASK 0xc0000 +static inline uint8_t get_column_rule_color_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[COLUMN_RULE_COLOR_INDEX]; + bits &= COLUMN_RULE_COLOR_MASK; + bits >>= COLUMN_RULE_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_column_rule_color(const css_computed_style *style, css_color *color) { @@ -701,9 +1019,19 @@ static inline uint8_t get_column_rule_color(const css_computed_style *style, #undef COLUMN_RULE_COLOR_SHIFT #undef COLUMN_RULE_COLOR_MASK -#define COLUMN_RULE_STYLE_INDEX 9 -#define COLUMN_RULE_STYLE_SHIFT 3 -#define COLUMN_RULE_STYLE_MASK 0x78 +#define COLUMN_RULE_STYLE_INDEX 7 +#define COLUMN_RULE_STYLE_SHIFT 0 +#define COLUMN_RULE_STYLE_MASK 0xf +static inline uint8_t get_column_rule_style_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX]; + bits &= COLUMN_RULE_STYLE_MASK; + bits >>= COLUMN_RULE_STYLE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_column_rule_style(const css_computed_style *style) { uint32_t bits = style->i.bits[COLUMN_RULE_STYLE_INDEX]; @@ -721,6 +1049,16 @@ static inline uint8_t get_column_rule_style(const css_computed_style *style) #define COLUMN_RULE_WIDTH_INDEX 1 #define COLUMN_RULE_WIDTH_SHIFT 7 #define COLUMN_RULE_WIDTH_MASK 0x7f80 +static inline uint8_t get_column_rule_width_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[COLUMN_RULE_WIDTH_INDEX]; + bits &= COLUMN_RULE_WIDTH_MASK; + bits >>= COLUMN_RULE_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + return (bits & 0x7); +} static inline uint8_t get_column_rule_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -740,9 +1078,18 @@ static inline uint8_t get_column_rule_width(const css_computed_style *style, #undef COLUMN_RULE_WIDTH_SHIFT #undef COLUMN_RULE_WIDTH_MASK -#define COLUMN_SPAN_INDEX 10 -#define COLUMN_SPAN_SHIFT 10 -#define COLUMN_SPAN_MASK 0xc00 +#define COLUMN_SPAN_INDEX 11 +#define COLUMN_SPAN_SHIFT 20 +#define COLUMN_SPAN_MASK 0x300000 +static inline uint8_t get_column_span_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX]; + bits &= COLUMN_SPAN_MASK; + bits >>= COLUMN_SPAN_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_column_span(const css_computed_style *style) { uint32_t bits = style->i.bits[COLUMN_SPAN_INDEX]; @@ -757,9 +1104,18 @@ static inline uint8_t get_column_span(const css_computed_style *style) #undef COLUMN_SPAN_SHIFT #undef COLUMN_SPAN_MASK -#define COLUMN_WIDTH_INDEX 5 +#define COLUMN_WIDTH_INDEX 3 #define COLUMN_WIDTH_SHIFT 25 #define COLUMN_WIDTH_MASK 0xfe000000 +static inline uint8_t get_column_width_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COLUMN_WIDTH_INDEX]; + bits &= COLUMN_WIDTH_MASK; + bits >>= COLUMN_WIDTH_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_column_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -780,8 +1136,17 @@ static inline uint8_t get_column_width(const css_computed_style *style, #undef COLUMN_WIDTH_MASK #define CONTENT_INDEX 11 -#define CONTENT_SHIFT 18 -#define CONTENT_MASK 0xc0000 +#define CONTENT_SHIFT 22 +#define CONTENT_MASK 0xc00000 +static inline uint8_t get_content_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[CONTENT_INDEX]; + bits &= CONTENT_MASK; + bits >>= CONTENT_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_content(const css_computed_style *style, const css_computed_content_item **content_item) { @@ -801,8 +1166,18 @@ static inline uint8_t get_content(const css_computed_style *style, const #undef CONTENT_MASK #define COUNTER_INCREMENT_INDEX 14 -#define COUNTER_INCREMENT_SHIFT 20 -#define COUNTER_INCREMENT_MASK 0x100000 +#define COUNTER_INCREMENT_SHIFT 18 +#define COUNTER_INCREMENT_MASK 0x40000 +static inline uint8_t get_counter_increment_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[COUNTER_INCREMENT_INDEX]; + bits &= COUNTER_INCREMENT_MASK; + bits >>= COUNTER_INCREMENT_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_counter_increment(const css_computed_style *style, const css_computed_counter **counter_arr) { @@ -820,8 +1195,17 @@ static inline uint8_t get_counter_increment(const css_computed_style *style, #undef COUNTER_INCREMENT_MASK #define COUNTER_RESET_INDEX 14 -#define COUNTER_RESET_SHIFT 25 -#define COUNTER_RESET_MASK 0x2000000 +#define COUNTER_RESET_SHIFT 19 +#define COUNTER_RESET_MASK 0x80000 +static inline uint8_t get_counter_reset_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[COUNTER_RESET_INDEX]; + bits &= COUNTER_RESET_MASK; + bits >>= COUNTER_RESET_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_counter_reset(const css_computed_style *style, const css_computed_counter **counter_arr) { @@ -841,6 +1225,15 @@ static inline uint8_t get_counter_reset(const css_computed_style *style, const #define CURSOR_INDEX 9 #define CURSOR_SHIFT 27 #define CURSOR_MASK 0xf8000000 +static inline uint8_t get_cursor_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[CURSOR_INDEX]; + bits &= CURSOR_MASK; + bits >>= CURSOR_SHIFT; + + /* 5bits: ttttt : type */ + return (bits & 0x1f); +} static inline uint8_t get_cursor(const css_computed_style *style, lwc_string ***string_arr) { @@ -857,9 +1250,18 @@ static inline uint8_t get_cursor(const css_computed_style *style, lwc_string #undef CURSOR_SHIFT #undef CURSOR_MASK -#define DIRECTION_INDEX 14 -#define DIRECTION_SHIFT 28 -#define DIRECTION_MASK 0x30000000 +#define DIRECTION_INDEX 11 +#define DIRECTION_SHIFT 24 +#define DIRECTION_MASK 0x3000000 +static inline uint8_t get_direction_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[DIRECTION_INDEX]; + bits &= DIRECTION_MASK; + bits >>= DIRECTION_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_direction(const css_computed_style *style) { uint32_t bits = style->i.bits[DIRECTION_INDEX]; @@ -874,9 +1276,18 @@ static inline uint8_t get_direction(const css_computed_style *style) #undef DIRECTION_SHIFT #undef DIRECTION_MASK -#define DISPLAY_INDEX 3 -#define DISPLAY_SHIFT 0 -#define DISPLAY_MASK 0x1f +#define DISPLAY_INDEX 8 +#define DISPLAY_SHIFT 3 +#define DISPLAY_MASK 0xf8 +static inline uint8_t get_display_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[DISPLAY_INDEX]; + bits &= DISPLAY_MASK; + bits >>= DISPLAY_SHIFT; + + /* 5bits: ttttt : type */ + return (bits & 0x1f); +} static inline uint8_t get_display(const css_computed_style *style) { uint32_t bits = style->i.bits[DISPLAY_INDEX]; @@ -891,9 +1302,18 @@ static inline uint8_t get_display(const css_computed_style *style) #undef DISPLAY_SHIFT #undef DISPLAY_MASK -#define EMPTY_CELLS_INDEX 10 -#define EMPTY_CELLS_SHIFT 4 -#define EMPTY_CELLS_MASK 0x30 +#define EMPTY_CELLS_INDEX 11 +#define EMPTY_CELLS_SHIFT 26 +#define EMPTY_CELLS_MASK 0xc000000 +static inline uint8_t get_empty_cells_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX]; + bits &= EMPTY_CELLS_MASK; + bits >>= EMPTY_CELLS_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_empty_cells(const css_computed_style *style) { uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX]; @@ -908,9 +1328,48 @@ static inline uint8_t get_empty_cells(const css_computed_style *style) #undef EMPTY_CELLS_SHIFT #undef EMPTY_CELLS_MASK -#define FLEX_BASIS_INDEX 4 -#define FLEX_BASIS_SHIFT 25 -#define FLEX_BASIS_MASK 0xfe000000 +#define FILL_OPACITY_INDEX 14 +#define FILL_OPACITY_SHIFT 20 +#define FILL_OPACITY_MASK 0x100000 +static inline uint8_t get_fill_opacity_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FILL_OPACITY_INDEX]; + bits &= FILL_OPACITY_MASK; + bits >>= FILL_OPACITY_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} +static inline uint8_t get_fill_opacity(const css_computed_style *style, + css_fixed *fixed) +{ + uint32_t bits = style->i.bits[FILL_OPACITY_INDEX]; + bits &= FILL_OPACITY_MASK; + bits >>= FILL_OPACITY_SHIFT; + + /* 1bit: t : type */ + if ((bits & 0x1) == CSS_FILL_OPACITY_SET) { + *fixed = style->i.fill_opacity; + } + + return (bits & 0x1); +} +#undef FILL_OPACITY_INDEX +#undef FILL_OPACITY_SHIFT +#undef FILL_OPACITY_MASK + +#define FLEX_BASIS_INDEX 7 +#define FLEX_BASIS_SHIFT 4 +#define FLEX_BASIS_MASK 0x7f0 +static inline uint8_t get_flex_basis_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FLEX_BASIS_INDEX]; + bits &= FLEX_BASIS_MASK; + bits >>= FLEX_BASIS_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -931,8 +1390,17 @@ static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed #undef FLEX_BASIS_MASK #define FLEX_DIRECTION_INDEX 13 -#define FLEX_DIRECTION_SHIFT 1 -#define FLEX_DIRECTION_MASK 0xe +#define FLEX_DIRECTION_SHIFT 4 +#define FLEX_DIRECTION_MASK 0x70 +static inline uint8_t get_flex_direction_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX]; + bits &= FLEX_DIRECTION_MASK; + bits >>= FLEX_DIRECTION_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_flex_direction(const css_computed_style *style) { uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX]; @@ -947,9 +1415,18 @@ static inline uint8_t get_flex_direction(const css_computed_style *style) #undef FLEX_DIRECTION_SHIFT #undef FLEX_DIRECTION_MASK -#define FLEX_GROW_INDEX 12 -#define FLEX_GROW_SHIFT 0 -#define FLEX_GROW_MASK 0x1 +#define FLEX_GROW_INDEX 14 +#define FLEX_GROW_SHIFT 21 +#define FLEX_GROW_MASK 0x200000 +static inline uint8_t get_flex_grow_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FLEX_GROW_INDEX]; + bits &= FLEX_GROW_MASK; + bits >>= FLEX_GROW_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed *fixed) { @@ -971,6 +1448,15 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed #define FLEX_SHRINK_INDEX 14 #define FLEX_SHRINK_SHIFT 22 #define FLEX_SHRINK_MASK 0x400000 +static inline uint8_t get_flex_shrink_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FLEX_SHRINK_INDEX]; + bits &= FLEX_SHRINK_MASK; + bits >>= FLEX_SHRINK_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_flex_shrink(const css_computed_style *style, css_fixed *fixed) { @@ -989,9 +1475,18 @@ static inline uint8_t get_flex_shrink(const css_computed_style *style, #undef FLEX_SHRINK_SHIFT #undef FLEX_SHRINK_MASK -#define FLEX_WRAP_INDEX 10 -#define FLEX_WRAP_SHIFT 6 -#define FLEX_WRAP_MASK 0xc0 +#define FLEX_WRAP_INDEX 11 +#define FLEX_WRAP_SHIFT 28 +#define FLEX_WRAP_MASK 0x30000000 +static inline uint8_t get_flex_wrap_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FLEX_WRAP_INDEX]; + bits &= FLEX_WRAP_MASK; + bits >>= FLEX_WRAP_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_flex_wrap(const css_computed_style *style) { uint32_t bits = style->i.bits[FLEX_WRAP_INDEX]; @@ -1009,6 +1504,15 @@ static inline uint8_t get_flex_wrap(const css_computed_style *style) #define FLOAT_INDEX 11 #define FLOAT_SHIFT 30 #define FLOAT_MASK 0xc0000000 +static inline uint8_t get_float_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FLOAT_INDEX]; + bits &= FLOAT_MASK; + bits >>= FLOAT_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_float(const css_computed_style *style) { uint32_t bits = style->i.bits[FLOAT_INDEX]; @@ -1023,9 +1527,18 @@ static inline uint8_t get_float(const css_computed_style *style) #undef FLOAT_SHIFT #undef FLOAT_MASK -#define FONT_FAMILY_INDEX 9 -#define FONT_FAMILY_SHIFT 0 -#define FONT_FAMILY_MASK 0x7 +#define FONT_FAMILY_INDEX 13 +#define FONT_FAMILY_SHIFT 7 +#define FONT_FAMILY_MASK 0x380 +static inline uint8_t get_font_family_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FONT_FAMILY_INDEX]; + bits &= FONT_FAMILY_MASK; + bits >>= FONT_FAMILY_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_font_family(const css_computed_style *style, lwc_string ***string_arr) { @@ -1042,9 +1555,18 @@ static inline uint8_t get_font_family(const css_computed_style *style, #undef FONT_FAMILY_SHIFT #undef FONT_FAMILY_MASK -#define FONT_SIZE_INDEX 12 -#define FONT_SIZE_SHIFT 1 -#define FONT_SIZE_MASK 0x3fe +#define FONT_SIZE_INDEX 1 +#define FONT_SIZE_SHIFT 23 +#define FONT_SIZE_MASK 0xff800000 +static inline uint8_t get_font_size_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FONT_SIZE_INDEX]; + bits &= FONT_SIZE_MASK; + bits >>= FONT_SIZE_SHIFT; + + /* 9bits: uuuuutttt : unit | type */ + return (bits & 0xf); +} static inline uint8_t get_font_size(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1064,9 +1586,18 @@ static inline uint8_t get_font_size(const css_computed_style *style, css_fixed #undef FONT_SIZE_SHIFT #undef FONT_SIZE_MASK -#define FONT_STYLE_INDEX 11 -#define FONT_STYLE_SHIFT 20 -#define FONT_STYLE_MASK 0x300000 +#define FONT_STYLE_INDEX 10 +#define FONT_STYLE_SHIFT 0 +#define FONT_STYLE_MASK 0x3 +static inline uint8_t get_font_style_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FONT_STYLE_INDEX]; + bits &= FONT_STYLE_MASK; + bits >>= FONT_STYLE_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_font_style(const css_computed_style *style) { uint32_t bits = style->i.bits[FONT_STYLE_INDEX]; @@ -1081,9 +1612,18 @@ static inline uint8_t get_font_style(const css_computed_style *style) #undef FONT_STYLE_SHIFT #undef FONT_STYLE_MASK -#define FONT_VARIANT_INDEX 11 -#define FONT_VARIANT_SHIFT 28 -#define FONT_VARIANT_MASK 0x30000000 +#define FONT_VARIANT_INDEX 10 +#define FONT_VARIANT_SHIFT 2 +#define FONT_VARIANT_MASK 0xc +static inline uint8_t get_font_variant_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FONT_VARIANT_INDEX]; + bits &= FONT_VARIANT_MASK; + bits >>= FONT_VARIANT_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_font_variant(const css_computed_style *style) { uint32_t bits = style->i.bits[FONT_VARIANT_INDEX]; @@ -1098,9 +1638,18 @@ static inline uint8_t get_font_variant(const css_computed_style *style) #undef FONT_VARIANT_SHIFT #undef FONT_VARIANT_MASK -#define FONT_WEIGHT_INDEX 9 -#define FONT_WEIGHT_SHIFT 15 -#define FONT_WEIGHT_MASK 0x78000 +#define FONT_WEIGHT_INDEX 6 +#define FONT_WEIGHT_SHIFT 0 +#define FONT_WEIGHT_MASK 0xf +static inline uint8_t get_font_weight_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX]; + bits &= FONT_WEIGHT_MASK; + bits >>= FONT_WEIGHT_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_font_weight(const css_computed_style *style) { uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX]; @@ -1115,9 +1664,18 @@ static inline uint8_t get_font_weight(const css_computed_style *style) #undef FONT_WEIGHT_SHIFT #undef FONT_WEIGHT_MASK -#define HEIGHT_INDEX 6 -#define HEIGHT_SHIFT 25 -#define HEIGHT_MASK 0xfe000000 +#define HEIGHT_INDEX 7 +#define HEIGHT_SHIFT 11 +#define HEIGHT_MASK 0x3f800 +static inline uint8_t get_height_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[HEIGHT_INDEX]; + bits &= HEIGHT_MASK; + bits >>= HEIGHT_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1138,8 +1696,17 @@ static inline uint8_t get_height(const css_computed_style *style, css_fixed #undef HEIGHT_MASK #define JUSTIFY_CONTENT_INDEX 13 -#define JUSTIFY_CONTENT_SHIFT 4 -#define JUSTIFY_CONTENT_MASK 0x70 +#define JUSTIFY_CONTENT_SHIFT 10 +#define JUSTIFY_CONTENT_MASK 0x1c00 +static inline uint8_t get_justify_content_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX]; + bits &= JUSTIFY_CONTENT_MASK; + bits >>= JUSTIFY_CONTENT_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_justify_content(const css_computed_style *style) { uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX]; @@ -1154,42 +1721,49 @@ static inline uint8_t get_justify_content(const css_computed_style *style) #undef JUSTIFY_CONTENT_SHIFT #undef JUSTIFY_CONTENT_MASK -#define LEFT_INDEX 4 -#define LEFT_SHIFT 4 -#define LEFT_MASK 0x7f0 -static inline uint8_t get_left( - const css_computed_style *style, - css_fixed *length, css_unit *unit) +#define LEFT_INDEX 7 +#define LEFT_SHIFT 18 +#define LEFT_MASK 0x1fc0000 +static inline uint8_t get_left_bits(const css_computed_style *style) { uint32_t bits = style->i.bits[LEFT_INDEX]; bits &= LEFT_MASK; bits >>= LEFT_SHIFT; - - /* 7bits: uuuuutt : units | type */ - if ((bits & 0x3) == CSS_LEFT_SET) { - *length = style->i.left; - *unit = bits >> 2; - } - + + /* 7bits: uuuuutt : unit | type */ return (bits & 0x3); } -static inline uint8_t get_left_bits( - const css_computed_style *style) +static inline uint8_t get_left(const css_computed_style *style, css_fixed + *length, css_unit *unit) { uint32_t bits = style->i.bits[LEFT_INDEX]; bits &= LEFT_MASK; bits >>= LEFT_SHIFT; - - /* 7bits: uuuuutt : units | type */ - return bits; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_LEFT_SET) { + *length = style->i.left; + *unit = bits >> 2; + } + + return (bits & 0x3); } #undef LEFT_INDEX #undef LEFT_SHIFT #undef LEFT_MASK -#define LETTER_SPACING_INDEX 6 -#define LETTER_SPACING_SHIFT 18 -#define LETTER_SPACING_MASK 0x1fc0000 +#define LETTER_SPACING_INDEX 7 +#define LETTER_SPACING_SHIFT 25 +#define LETTER_SPACING_MASK 0xfe000000 +static inline uint8_t get_letter_spacing_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[LETTER_SPACING_INDEX]; + bits &= LETTER_SPACING_MASK; + bits >>= LETTER_SPACING_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_letter_spacing(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1209,9 +1783,18 @@ static inline uint8_t get_letter_spacing(const css_computed_style *style, #undef LETTER_SPACING_SHIFT #undef LETTER_SPACING_MASK -#define LINE_HEIGHT_INDEX 5 -#define LINE_HEIGHT_SHIFT 11 -#define LINE_HEIGHT_MASK 0x3f800 +#define LINE_HEIGHT_INDEX 6 +#define LINE_HEIGHT_SHIFT 4 +#define LINE_HEIGHT_MASK 0x7f0 +static inline uint8_t get_line_height_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[LINE_HEIGHT_INDEX]; + bits &= LINE_HEIGHT_MASK; + bits >>= LINE_HEIGHT_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_line_height( const css_computed_style *style, css_fixed *length, css_unit *unit) @@ -1237,8 +1820,17 @@ static inline uint8_t get_line_height( #undef LINE_HEIGHT_MASK #define LIST_STYLE_IMAGE_INDEX 14 -#define LIST_STYLE_IMAGE_SHIFT 27 -#define LIST_STYLE_IMAGE_MASK 0x8000000 +#define LIST_STYLE_IMAGE_SHIFT 23 +#define LIST_STYLE_IMAGE_MASK 0x800000 +static inline uint8_t get_list_style_image_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX]; + bits &= LIST_STYLE_IMAGE_MASK; + bits >>= LIST_STYLE_IMAGE_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_list_style_image(const css_computed_style *style, lwc_string **string) { @@ -1255,9 +1847,19 @@ static inline uint8_t get_list_style_image(const css_computed_style *style, #undef LIST_STYLE_IMAGE_SHIFT #undef LIST_STYLE_IMAGE_MASK -#define LIST_STYLE_POSITION_INDEX 11 -#define LIST_STYLE_POSITION_SHIFT 6 -#define LIST_STYLE_POSITION_MASK 0xc0 +#define LIST_STYLE_POSITION_INDEX 10 +#define LIST_STYLE_POSITION_SHIFT 4 +#define LIST_STYLE_POSITION_MASK 0x30 +static inline uint8_t get_list_style_position_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX]; + bits &= LIST_STYLE_POSITION_MASK; + bits >>= LIST_STYLE_POSITION_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_list_style_position(const css_computed_style *style) { uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX]; @@ -1273,8 +1875,17 @@ static inline uint8_t get_list_style_position(const css_computed_style *style) #undef LIST_STYLE_POSITION_MASK #define LIST_STYLE_TYPE_INDEX 8 -#define LIST_STYLE_TYPE_SHIFT 26 -#define LIST_STYLE_TYPE_MASK 0xfc000000 +#define LIST_STYLE_TYPE_SHIFT 8 +#define LIST_STYLE_TYPE_MASK 0x3f00 +static inline uint8_t get_list_style_type_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX]; + bits &= LIST_STYLE_TYPE_MASK; + bits >>= LIST_STYLE_TYPE_SHIFT; + + /* 6bits: tttttt : type */ + return (bits & 0x3f); +} static inline uint8_t get_list_style_type(const css_computed_style *style) { uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX]; @@ -1289,9 +1900,18 @@ static inline uint8_t get_list_style_type(const css_computed_style *style) #undef LIST_STYLE_TYPE_SHIFT #undef LIST_STYLE_TYPE_MASK -#define MARGIN_BOTTOM_INDEX 5 -#define MARGIN_BOTTOM_SHIFT 18 -#define MARGIN_BOTTOM_MASK 0x1fc0000 +#define MARGIN_BOTTOM_INDEX 6 +#define MARGIN_BOTTOM_SHIFT 11 +#define MARGIN_BOTTOM_MASK 0x3f800 +static inline uint8_t get_margin_bottom_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MARGIN_BOTTOM_INDEX]; + bits &= MARGIN_BOTTOM_MASK; + bits >>= MARGIN_BOTTOM_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_margin_bottom(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1311,9 +1931,18 @@ static inline uint8_t get_margin_bottom(const css_computed_style *style, #undef MARGIN_BOTTOM_SHIFT #undef MARGIN_BOTTOM_MASK -#define MARGIN_LEFT_INDEX 7 +#define MARGIN_LEFT_INDEX 6 #define MARGIN_LEFT_SHIFT 18 #define MARGIN_LEFT_MASK 0x1fc0000 +static inline uint8_t get_margin_left_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MARGIN_LEFT_INDEX]; + bits &= MARGIN_LEFT_MASK; + bits >>= MARGIN_LEFT_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_margin_left(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1334,8 +1963,17 @@ static inline uint8_t get_margin_left(const css_computed_style *style, #undef MARGIN_LEFT_MASK #define MARGIN_RIGHT_INDEX 6 -#define MARGIN_RIGHT_SHIFT 4 -#define MARGIN_RIGHT_MASK 0x7f0 +#define MARGIN_RIGHT_SHIFT 25 +#define MARGIN_RIGHT_MASK 0xfe000000 +static inline uint8_t get_margin_right_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MARGIN_RIGHT_INDEX]; + bits &= MARGIN_RIGHT_MASK; + bits >>= MARGIN_RIGHT_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_margin_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1355,9 +1993,18 @@ static inline uint8_t get_margin_right(const css_computed_style *style, #undef MARGIN_RIGHT_SHIFT #undef MARGIN_RIGHT_MASK -#define MARGIN_TOP_INDEX 1 -#define MARGIN_TOP_SHIFT 0 -#define MARGIN_TOP_MASK 0x7f +#define MARGIN_TOP_INDEX 5 +#define MARGIN_TOP_SHIFT 4 +#define MARGIN_TOP_MASK 0x7f0 +static inline uint8_t get_margin_top_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MARGIN_TOP_INDEX]; + bits &= MARGIN_TOP_MASK; + bits >>= MARGIN_TOP_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1377,9 +2024,18 @@ static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed #undef MARGIN_TOP_SHIFT #undef MARGIN_TOP_MASK -#define MAX_HEIGHT_INDEX 3 -#define MAX_HEIGHT_SHIFT 25 -#define MAX_HEIGHT_MASK 0xfe000000 +#define MAX_HEIGHT_INDEX 5 +#define MAX_HEIGHT_SHIFT 11 +#define MAX_HEIGHT_MASK 0x3f800 +static inline uint8_t get_max_height_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MAX_HEIGHT_INDEX]; + bits &= MAX_HEIGHT_MASK; + bits >>= MAX_HEIGHT_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_max_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1399,9 +2055,18 @@ static inline uint8_t get_max_height(const css_computed_style *style, css_fixed #undef MAX_HEIGHT_SHIFT #undef MAX_HEIGHT_MASK -#define MAX_WIDTH_INDEX 7 -#define MAX_WIDTH_SHIFT 4 -#define MAX_WIDTH_MASK 0x7f0 +#define MAX_WIDTH_INDEX 5 +#define MAX_WIDTH_SHIFT 18 +#define MAX_WIDTH_MASK 0x1fc0000 +static inline uint8_t get_max_width_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MAX_WIDTH_INDEX]; + bits &= MAX_WIDTH_MASK; + bits >>= MAX_WIDTH_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_max_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1421,9 +2086,18 @@ static inline uint8_t get_max_width(const css_computed_style *style, css_fixed #undef MAX_WIDTH_SHIFT #undef MAX_WIDTH_MASK -#define MIN_HEIGHT_INDEX 4 -#define MIN_HEIGHT_SHIFT 18 -#define MIN_HEIGHT_MASK 0x1fc0000 +#define MIN_HEIGHT_INDEX 5 +#define MIN_HEIGHT_SHIFT 25 +#define MIN_HEIGHT_MASK 0xfe000000 +static inline uint8_t get_min_height_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MIN_HEIGHT_INDEX]; + bits &= MIN_HEIGHT_MASK; + bits >>= MIN_HEIGHT_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1443,9 +2117,18 @@ static inline uint8_t get_min_height(const css_computed_style *style, css_fixed #undef MIN_HEIGHT_SHIFT #undef MIN_HEIGHT_MASK -#define MIN_WIDTH_INDEX 6 -#define MIN_WIDTH_SHIFT 11 -#define MIN_WIDTH_MASK 0x3f800 +#define MIN_WIDTH_INDEX 4 +#define MIN_WIDTH_SHIFT 4 +#define MIN_WIDTH_MASK 0x7f0 +static inline uint8_t get_min_width_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[MIN_WIDTH_INDEX]; + bits &= MIN_WIDTH_MASK; + bits >>= MIN_WIDTH_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1466,8 +2149,17 @@ static inline uint8_t get_min_width(const css_computed_style *style, css_fixed #undef MIN_WIDTH_MASK #define OPACITY_INDEX 14 -#define OPACITY_SHIFT 19 -#define OPACITY_MASK 0x80000 +#define OPACITY_SHIFT 24 +#define OPACITY_MASK 0x1000000 +static inline uint8_t get_opacity_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[OPACITY_INDEX]; + bits &= OPACITY_MASK; + bits >>= OPACITY_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_opacity(const css_computed_style *style, css_fixed *fixed) { @@ -1486,9 +2178,18 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed #undef OPACITY_SHIFT #undef OPACITY_MASK -#define ORDER_INDEX 13 -#define ORDER_SHIFT 0 -#define ORDER_MASK 0x1 +#define ORDER_INDEX 14 +#define ORDER_SHIFT 25 +#define ORDER_MASK 0x2000000 +static inline uint8_t get_order_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[ORDER_INDEX]; + bits &= ORDER_MASK; + bits >>= ORDER_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_order(const css_computed_style *style, int32_t *integer) { @@ -1508,8 +2209,17 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t #undef ORDER_MASK #define ORPHANS_INDEX 14 -#define ORPHANS_SHIFT 24 -#define ORPHANS_MASK 0x1000000 +#define ORPHANS_SHIFT 26 +#define ORPHANS_MASK 0x4000000 +static inline uint8_t get_orphans_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[ORPHANS_INDEX]; + bits &= ORPHANS_MASK; + bits >>= ORPHANS_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_orphans(const css_computed_style *style, int32_t *integer) { @@ -1526,9 +2236,18 @@ static inline uint8_t get_orphans(const css_computed_style *style, int32_t #undef ORPHANS_SHIFT #undef ORPHANS_MASK -#define OUTLINE_COLOR_INDEX 11 -#define OUTLINE_COLOR_SHIFT 10 -#define OUTLINE_COLOR_MASK 0xc00 +#define OUTLINE_COLOR_INDEX 10 +#define OUTLINE_COLOR_SHIFT 6 +#define OUTLINE_COLOR_MASK 0xc0 +static inline uint8_t get_outline_color_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[OUTLINE_COLOR_INDEX]; + bits &= OUTLINE_COLOR_MASK; + bits >>= OUTLINE_COLOR_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_outline_color(const css_computed_style *style, css_color *color) { @@ -1547,9 +2266,18 @@ static inline uint8_t get_outline_color(const css_computed_style *style, #undef OUTLINE_COLOR_SHIFT #undef OUTLINE_COLOR_MASK -#define OUTLINE_STYLE_INDEX 9 -#define OUTLINE_STYLE_SHIFT 7 -#define OUTLINE_STYLE_MASK 0x780 +#define OUTLINE_STYLE_INDEX 5 +#define OUTLINE_STYLE_SHIFT 0 +#define OUTLINE_STYLE_MASK 0xf +static inline uint8_t get_outline_style_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX]; + bits &= OUTLINE_STYLE_MASK; + bits >>= OUTLINE_STYLE_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_outline_style(const css_computed_style *style) { uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX]; @@ -1567,6 +2295,15 @@ static inline uint8_t get_outline_style(const css_computed_style *style) #define OUTLINE_WIDTH_INDEX 1 #define OUTLINE_WIDTH_SHIFT 15 #define OUTLINE_WIDTH_MASK 0x7f8000 +static inline uint8_t get_outline_width_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[OUTLINE_WIDTH_INDEX]; + bits &= OUTLINE_WIDTH_MASK; + bits >>= OUTLINE_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + return (bits & 0x7); +} static inline uint8_t get_outline_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1587,8 +2324,17 @@ static inline uint8_t get_outline_width(const css_computed_style *style, #undef OUTLINE_WIDTH_MASK #define OVERFLOW_X_INDEX 13 -#define OVERFLOW_X_SHIFT 16 -#define OVERFLOW_X_MASK 0x70000 +#define OVERFLOW_X_SHIFT 13 +#define OVERFLOW_X_MASK 0xe000 +static inline uint8_t get_overflow_x_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[OVERFLOW_X_INDEX]; + bits &= OVERFLOW_X_MASK; + bits >>= OVERFLOW_X_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_overflow_x(const css_computed_style *style) { uint32_t bits = style->i.bits[OVERFLOW_X_INDEX]; @@ -1604,8 +2350,17 @@ static inline uint8_t get_overflow_x(const css_computed_style *style) #undef OVERFLOW_X_MASK #define OVERFLOW_Y_INDEX 13 -#define OVERFLOW_Y_SHIFT 25 -#define OVERFLOW_Y_MASK 0xe000000 +#define OVERFLOW_Y_SHIFT 16 +#define OVERFLOW_Y_MASK 0x70000 +static inline uint8_t get_overflow_y_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX]; + bits &= OVERFLOW_Y_MASK; + bits >>= OVERFLOW_Y_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_overflow_y(const css_computed_style *style) { uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX]; @@ -1621,8 +2376,17 @@ static inline uint8_t get_overflow_y(const css_computed_style *style) #undef OVERFLOW_Y_MASK #define PADDING_BOTTOM_INDEX 8 -#define PADDING_BOTTOM_SHIFT 8 -#define PADDING_BOTTOM_MASK 0x3f00 +#define PADDING_BOTTOM_SHIFT 14 +#define PADDING_BOTTOM_MASK 0xfc000 +static inline uint8_t get_padding_bottom_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[PADDING_BOTTOM_INDEX]; + bits &= PADDING_BOTTOM_MASK; + bits >>= PADDING_BOTTOM_SHIFT; + + /* 6bits: uuuuut : unit | type */ + return (bits & 0x1); +} static inline uint8_t get_padding_bottom(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1642,9 +2406,18 @@ static inline uint8_t get_padding_bottom(const css_computed_style *style, #undef PADDING_BOTTOM_SHIFT #undef PADDING_BOTTOM_MASK -#define PADDING_LEFT_INDEX 2 -#define PADDING_LEFT_SHIFT 0 -#define PADDING_LEFT_MASK 0x3f +#define PADDING_LEFT_INDEX 8 +#define PADDING_LEFT_SHIFT 20 +#define PADDING_LEFT_MASK 0x3f00000 +static inline uint8_t get_padding_left_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[PADDING_LEFT_INDEX]; + bits &= PADDING_LEFT_MASK; + bits >>= PADDING_LEFT_SHIFT; + + /* 6bits: uuuuut : unit | type */ + return (bits & 0x1); +} static inline uint8_t get_padding_left(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1665,8 +2438,17 @@ static inline uint8_t get_padding_left(const css_computed_style *style, #undef PADDING_LEFT_MASK #define PADDING_RIGHT_INDEX 8 -#define PADDING_RIGHT_SHIFT 14 -#define PADDING_RIGHT_MASK 0xfc000 +#define PADDING_RIGHT_SHIFT 26 +#define PADDING_RIGHT_MASK 0xfc000000 +static inline uint8_t get_padding_right_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[PADDING_RIGHT_INDEX]; + bits &= PADDING_RIGHT_MASK; + bits >>= PADDING_RIGHT_SHIFT; + + /* 6bits: uuuuut : unit | type */ + return (bits & 0x1); +} static inline uint8_t get_padding_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1686,9 +2468,18 @@ static inline uint8_t get_padding_right(const css_computed_style *style, #undef PADDING_RIGHT_SHIFT #undef PADDING_RIGHT_MASK -#define PADDING_TOP_INDEX 8 -#define PADDING_TOP_SHIFT 20 -#define PADDING_TOP_MASK 0x3f00000 +#define PADDING_TOP_INDEX 3 +#define PADDING_TOP_SHIFT 5 +#define PADDING_TOP_MASK 0x7e0 +static inline uint8_t get_padding_top_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[PADDING_TOP_INDEX]; + bits &= PADDING_TOP_MASK; + bits >>= PADDING_TOP_SHIFT; + + /* 6bits: uuuuut : unit | type */ + return (bits & 0x1); +} static inline uint8_t get_padding_top(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1708,9 +2499,18 @@ static inline uint8_t get_padding_top(const css_computed_style *style, #undef PADDING_TOP_SHIFT #undef PADDING_TOP_MASK -#define PAGE_BREAK_AFTER_INDEX 8 -#define PAGE_BREAK_AFTER_SHIFT 0 -#define PAGE_BREAK_AFTER_MASK 0x7 +#define PAGE_BREAK_AFTER_INDEX 13 +#define PAGE_BREAK_AFTER_SHIFT 19 +#define PAGE_BREAK_AFTER_MASK 0x380000 +static inline uint8_t get_page_break_after_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX]; + bits &= PAGE_BREAK_AFTER_MASK; + bits >>= PAGE_BREAK_AFTER_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_page_break_after(const css_computed_style *style) { uint32_t bits = style->i.bits[PAGE_BREAK_AFTER_INDEX]; @@ -1726,8 +2526,18 @@ static inline uint8_t get_page_break_after(const css_computed_style *style) #undef PAGE_BREAK_AFTER_MASK #define PAGE_BREAK_BEFORE_INDEX 13 -#define PAGE_BREAK_BEFORE_SHIFT 7 -#define PAGE_BREAK_BEFORE_MASK 0x380 +#define PAGE_BREAK_BEFORE_SHIFT 22 +#define PAGE_BREAK_BEFORE_MASK 0x1c00000 +static inline uint8_t get_page_break_before_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX]; + bits &= PAGE_BREAK_BEFORE_MASK; + bits >>= PAGE_BREAK_BEFORE_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_page_break_before(const css_computed_style *style) { uint32_t bits = style->i.bits[PAGE_BREAK_BEFORE_INDEX]; @@ -1742,9 +2552,19 @@ static inline uint8_t get_page_break_before(const css_computed_style *style) #undef PAGE_BREAK_BEFORE_SHIFT #undef PAGE_BREAK_BEFORE_MASK -#define PAGE_BREAK_INSIDE_INDEX 11 -#define PAGE_BREAK_INSIDE_SHIFT 24 -#define PAGE_BREAK_INSIDE_MASK 0x3000000 +#define PAGE_BREAK_INSIDE_INDEX 10 +#define PAGE_BREAK_INSIDE_SHIFT 8 +#define PAGE_BREAK_INSIDE_MASK 0x300 +static inline uint8_t get_page_break_inside_bits(const css_computed_style + *style) +{ + uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX]; + bits &= PAGE_BREAK_INSIDE_MASK; + bits >>= PAGE_BREAK_INSIDE_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_page_break_inside(const css_computed_style *style) { uint32_t bits = style->i.bits[PAGE_BREAK_INSIDE_INDEX]; @@ -1759,9 +2579,18 @@ static inline uint8_t get_page_break_inside(const css_computed_style *style) #undef PAGE_BREAK_INSIDE_SHIFT #undef PAGE_BREAK_INSIDE_MASK -#define POSITION_INDEX 10 -#define POSITION_SHIFT 20 -#define POSITION_MASK 0x700000 +#define POSITION_INDEX 13 +#define POSITION_SHIFT 25 +#define POSITION_MASK 0xe000000 +static inline uint8_t get_position_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[POSITION_INDEX]; + bits &= POSITION_MASK; + bits >>= POSITION_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_position(const css_computed_style *style) { uint32_t bits = style->i.bits[POSITION_INDEX]; @@ -1777,8 +2606,17 @@ static inline uint8_t get_position(const css_computed_style *style) #undef POSITION_MASK #define QUOTES_INDEX 14 -#define QUOTES_SHIFT 21 -#define QUOTES_MASK 0x200000 +#define QUOTES_SHIFT 27 +#define QUOTES_MASK 0x8000000 +static inline uint8_t get_quotes_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[QUOTES_INDEX]; + bits &= QUOTES_MASK; + bits >>= QUOTES_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_quotes(const css_computed_style *style, lwc_string ***string_arr) { @@ -1795,42 +2633,79 @@ static inline uint8_t get_quotes(const css_computed_style *style, lwc_string #undef QUOTES_SHIFT #undef QUOTES_MASK -#define RIGHT_INDEX 3 -#define RIGHT_SHIFT 18 -#define RIGHT_MASK 0x1fc0000 -static inline uint8_t get_right( - const css_computed_style *style, - css_fixed *length, css_unit *unit) +#define RIGHT_INDEX 4 +#define RIGHT_SHIFT 11 +#define RIGHT_MASK 0x3f800 +static inline uint8_t get_right_bits(const css_computed_style *style) { uint32_t bits = style->i.bits[RIGHT_INDEX]; bits &= RIGHT_MASK; bits >>= RIGHT_SHIFT; - - /* 7bits: uuuuutt : units | type */ - if ((bits & 0x3) == CSS_RIGHT_SET) { - *length = style->i.right; - *unit = bits >> 2; - } - + + /* 7bits: uuuuutt : unit | type */ return (bits & 0x3); } -static inline uint8_t get_right_bits( - const css_computed_style *style) +static inline uint8_t get_right(const css_computed_style *style, css_fixed + *length, css_unit *unit) { uint32_t bits = style->i.bits[RIGHT_INDEX]; bits &= RIGHT_MASK; bits >>= RIGHT_SHIFT; - - /* 7bits: uuuuutt : units | type */ - return bits; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_RIGHT_SET) { + *length = style->i.right; + *unit = bits >> 2; + } + + return (bits & 0x3); } #undef RIGHT_INDEX #undef RIGHT_SHIFT #undef RIGHT_MASK +#define STROKE_OPACITY_INDEX 13 +#define STROKE_OPACITY_SHIFT 0 +#define STROKE_OPACITY_MASK 0x1 +static inline uint8_t get_stroke_opacity_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[STROKE_OPACITY_INDEX]; + bits &= STROKE_OPACITY_MASK; + bits >>= STROKE_OPACITY_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} +static inline uint8_t get_stroke_opacity(const css_computed_style *style, + css_fixed *fixed) +{ + uint32_t bits = style->i.bits[STROKE_OPACITY_INDEX]; + bits &= STROKE_OPACITY_MASK; + bits >>= STROKE_OPACITY_SHIFT; + + /* 1bit: t : type */ + if ((bits & 0x1) == CSS_STROKE_OPACITY_SET) { + *fixed = style->i.stroke_opacity; + } + + return (bits & 0x1); +} +#undef STROKE_OPACITY_INDEX +#undef STROKE_OPACITY_SHIFT +#undef STROKE_OPACITY_MASK + #define TABLE_LAYOUT_INDEX 10 -#define TABLE_LAYOUT_SHIFT 14 -#define TABLE_LAYOUT_MASK 0xc000 +#define TABLE_LAYOUT_SHIFT 10 +#define TABLE_LAYOUT_MASK 0xc00 +static inline uint8_t get_table_layout_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX]; + bits &= TABLE_LAYOUT_MASK; + bits >>= TABLE_LAYOUT_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_table_layout(const css_computed_style *style) { uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX]; @@ -1848,6 +2723,15 @@ static inline uint8_t get_table_layout(const css_computed_style *style) #define TEXT_ALIGN_INDEX 4 #define TEXT_ALIGN_SHIFT 0 #define TEXT_ALIGN_MASK 0xf +static inline uint8_t get_text_align_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX]; + bits &= TEXT_ALIGN_MASK; + bits >>= TEXT_ALIGN_SHIFT; + + /* 4bits: tttt : type */ + return (bits & 0xf); +} static inline uint8_t get_text_align(const css_computed_style *style) { uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX]; @@ -1862,9 +2746,18 @@ static inline uint8_t get_text_align(const css_computed_style *style) #undef TEXT_ALIGN_SHIFT #undef TEXT_ALIGN_MASK -#define TEXT_DECORATION_INDEX 8 -#define TEXT_DECORATION_SHIFT 3 -#define TEXT_DECORATION_MASK 0xf8 +#define TEXT_DECORATION_INDEX 3 +#define TEXT_DECORATION_SHIFT 0 +#define TEXT_DECORATION_MASK 0x1f +static inline uint8_t get_text_decoration_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX]; + bits &= TEXT_DECORATION_MASK; + bits >>= TEXT_DECORATION_SHIFT; + + /* 5bits: ttttt : type */ + return (bits & 0x1f); +} static inline uint8_t get_text_decoration(const css_computed_style *style) { uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX]; @@ -1879,9 +2772,18 @@ static inline uint8_t get_text_decoration(const css_computed_style *style) #undef TEXT_DECORATION_SHIFT #undef TEXT_DECORATION_MASK -#define TEXT_INDENT_INDEX 3 -#define TEXT_INDENT_SHIFT 5 -#define TEXT_INDENT_MASK 0x7e0 +#define TEXT_INDENT_INDEX 2 +#define TEXT_INDENT_SHIFT 0 +#define TEXT_INDENT_MASK 0x3f +static inline uint8_t get_text_indent_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[TEXT_INDENT_INDEX]; + bits &= TEXT_INDENT_MASK; + bits >>= TEXT_INDENT_SHIFT; + + /* 6bits: uuuuut : unit | type */ + return (bits & 0x1); +} static inline uint8_t get_text_indent(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1901,9 +2803,18 @@ static inline uint8_t get_text_indent(const css_computed_style *style, #undef TEXT_INDENT_SHIFT #undef TEXT_INDENT_MASK -#define TEXT_TRANSFORM_INDEX 13 -#define TEXT_TRANSFORM_SHIFT 13 -#define TEXT_TRANSFORM_MASK 0xe000 +#define TEXT_TRANSFORM_INDEX 9 +#define TEXT_TRANSFORM_SHIFT 0 +#define TEXT_TRANSFORM_MASK 0x7 +static inline uint8_t get_text_transform_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX]; + bits &= TEXT_TRANSFORM_MASK; + bits >>= TEXT_TRANSFORM_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_text_transform(const css_computed_style *style) { uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX]; @@ -1918,42 +2829,49 @@ static inline uint8_t get_text_transform(const css_computed_style *style) #undef TEXT_TRANSFORM_SHIFT #undef TEXT_TRANSFORM_MASK -#define TOP_INDEX 7 -#define TOP_SHIFT 25 -#define TOP_MASK 0xfe000000 -static inline uint8_t get_top( - const css_computed_style *style, - css_fixed *length, css_unit *unit) +#define TOP_INDEX 4 +#define TOP_SHIFT 18 +#define TOP_MASK 0x1fc0000 +static inline uint8_t get_top_bits(const css_computed_style *style) { uint32_t bits = style->i.bits[TOP_INDEX]; bits &= TOP_MASK; bits >>= TOP_SHIFT; - - /* 7bits: uuuuutt : units | type */ - if ((bits & 0x3) == CSS_TOP_SET) { - *length = style->i.top; - *unit = bits >> 2; - } - + + /* 7bits: uuuuutt : unit | type */ return (bits & 0x3); } -static inline uint8_t get_top_bits( - const css_computed_style *style) +static inline uint8_t get_top(const css_computed_style *style, css_fixed + *length, css_unit *unit) { uint32_t bits = style->i.bits[TOP_INDEX]; bits &= TOP_MASK; bits >>= TOP_SHIFT; - - /* 7bits: uuuuutt : units | type */ - return bits; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_TOP_SET) { + *length = style->i.top; + *unit = bits >> 2; + } + + return (bits & 0x3); } #undef TOP_INDEX #undef TOP_SHIFT #undef TOP_MASK -#define UNICODE_BIDI_INDEX 11 -#define UNICODE_BIDI_SHIFT 2 -#define UNICODE_BIDI_MASK 0xc +#define UNICODE_BIDI_INDEX 10 +#define UNICODE_BIDI_SHIFT 12 +#define UNICODE_BIDI_MASK 0x3000 +static inline uint8_t get_unicode_bidi_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX]; + bits &= UNICODE_BIDI_MASK; + bits >>= UNICODE_BIDI_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_unicode_bidi(const css_computed_style *style) { uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX]; @@ -1968,9 +2886,18 @@ static inline uint8_t get_unicode_bidi(const css_computed_style *style) #undef UNICODE_BIDI_SHIFT #undef UNICODE_BIDI_MASK -#define VERTICAL_ALIGN_INDEX 1 -#define VERTICAL_ALIGN_SHIFT 23 -#define VERTICAL_ALIGN_MASK 0xff800000 +#define VERTICAL_ALIGN_INDEX 12 +#define VERTICAL_ALIGN_SHIFT 1 +#define VERTICAL_ALIGN_MASK 0x3fe +static inline uint8_t get_vertical_align_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[VERTICAL_ALIGN_INDEX]; + bits &= VERTICAL_ALIGN_MASK; + bits >>= VERTICAL_ALIGN_SHIFT; + + /* 9bits: uuuuutttt : unit | type */ + return (bits & 0xf); +} static inline uint8_t get_vertical_align(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1990,9 +2917,18 @@ static inline uint8_t get_vertical_align(const css_computed_style *style, #undef VERTICAL_ALIGN_SHIFT #undef VERTICAL_ALIGN_MASK -#define VISIBILITY_INDEX 11 -#define VISIBILITY_SHIFT 0 -#define VISIBILITY_MASK 0x3 +#define VISIBILITY_INDEX 10 +#define VISIBILITY_SHIFT 14 +#define VISIBILITY_MASK 0xc000 +static inline uint8_t get_visibility_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[VISIBILITY_INDEX]; + bits &= VISIBILITY_MASK; + bits >>= VISIBILITY_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_visibility(const css_computed_style *style) { uint32_t bits = style->i.bits[VISIBILITY_INDEX]; @@ -2007,9 +2943,18 @@ static inline uint8_t get_visibility(const css_computed_style *style) #undef VISIBILITY_SHIFT #undef VISIBILITY_MASK -#define WHITE_SPACE_INDEX 13 -#define WHITE_SPACE_SHIFT 19 -#define WHITE_SPACE_MASK 0x380000 +#define WHITE_SPACE_INDEX 8 +#define WHITE_SPACE_SHIFT 0 +#define WHITE_SPACE_MASK 0x7 +static inline uint8_t get_white_space_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[WHITE_SPACE_INDEX]; + bits &= WHITE_SPACE_MASK; + bits >>= WHITE_SPACE_SHIFT; + + /* 3bits: ttt : type */ + return (bits & 0x7); +} static inline uint8_t get_white_space(const css_computed_style *style) { uint32_t bits = style->i.bits[WHITE_SPACE_INDEX]; @@ -2024,9 +2969,18 @@ static inline uint8_t get_white_space(const css_computed_style *style) #undef WHITE_SPACE_SHIFT #undef WHITE_SPACE_MASK -#define WIDOWS_INDEX 14 -#define WIDOWS_SHIFT 26 -#define WIDOWS_MASK 0x4000000 +#define WIDOWS_INDEX 12 +#define WIDOWS_SHIFT 0 +#define WIDOWS_MASK 0x1 +static inline uint8_t get_widows_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[WIDOWS_INDEX]; + bits &= WIDOWS_MASK; + bits >>= WIDOWS_SHIFT; + + /* 1bit: t : type */ + return (bits & 0x1); +} static inline uint8_t get_widows(const css_computed_style *style, int32_t *integer) { @@ -2043,9 +2997,18 @@ static inline uint8_t get_widows(const css_computed_style *style, int32_t #undef WIDOWS_SHIFT #undef WIDOWS_MASK -#define WIDTH_INDEX 3 -#define WIDTH_SHIFT 11 -#define WIDTH_MASK 0x3f800 +#define WIDTH_INDEX 4 +#define WIDTH_SHIFT 25 +#define WIDTH_MASK 0xfe000000 +static inline uint8_t get_width_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[WIDTH_INDEX]; + bits &= WIDTH_MASK; + bits >>= WIDTH_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -2065,9 +3028,18 @@ static inline uint8_t get_width(const css_computed_style *style, css_fixed #undef WIDTH_SHIFT #undef WIDTH_MASK -#define WORD_SPACING_INDEX 5 -#define WORD_SPACING_SHIFT 4 -#define WORD_SPACING_MASK 0x7f0 +#define WORD_SPACING_INDEX 1 +#define WORD_SPACING_SHIFT 0 +#define WORD_SPACING_MASK 0x7f +static inline uint8_t get_word_spacing_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[WORD_SPACING_INDEX]; + bits &= WORD_SPACING_MASK; + bits >>= WORD_SPACING_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + return (bits & 0x3); +} static inline uint8_t get_word_spacing(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -2087,9 +3059,18 @@ static inline uint8_t get_word_spacing(const css_computed_style *style, #undef WORD_SPACING_SHIFT #undef WORD_SPACING_MASK -#define WRITING_MODE_INDEX 14 -#define WRITING_MODE_SHIFT 30 -#define WRITING_MODE_MASK 0xc0000000 +#define WRITING_MODE_INDEX 10 +#define WRITING_MODE_SHIFT 16 +#define WRITING_MODE_MASK 0x30000 +static inline uint8_t get_writing_mode_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[WRITING_MODE_INDEX]; + bits &= WRITING_MODE_MASK; + bits >>= WRITING_MODE_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_writing_mode(const css_computed_style *style) { uint32_t bits = style->i.bits[WRITING_MODE_INDEX]; @@ -2105,8 +3086,17 @@ static inline uint8_t get_writing_mode(const css_computed_style *style) #undef WRITING_MODE_MASK #define Z_INDEX_INDEX 10 -#define Z_INDEX_SHIFT 8 -#define Z_INDEX_MASK 0x300 +#define Z_INDEX_SHIFT 18 +#define Z_INDEX_MASK 0xc0000 +static inline uint8_t get_z_index_bits(const css_computed_style *style) +{ + uint32_t bits = style->i.bits[Z_INDEX_INDEX]; + bits &= Z_INDEX_MASK; + bits >>= Z_INDEX_SHIFT; + + /* 2bits: tt : type */ + return (bits & 0x3); +} static inline uint8_t get_z_index(const css_computed_style *style, int32_t *integer) { diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h index 56ff7c6..198bc1e 100644 --- a/src/select/autogenerated_propset.h +++ b/src/select/autogenerated_propset.h @@ -9,15 +9,13 @@ * in which case it is 'inherit'. */ #define ALIGN_CONTENT_INDEX 10 -#define ALIGN_CONTENT_SHIFT 29 -#define ALIGN_CONTENT_MASK 0xe0000000 +#define ALIGN_CONTENT_SHIFT 20 +#define ALIGN_CONTENT_MASK 0x700000 static inline css_error set_align_content(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[ALIGN_CONTENT_INDEX]; + uint32_t *bits = &style->i.bits[ALIGN_CONTENT_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~ALIGN_CONTENT_MASK) | (((uint32_t)type & 0x7) << @@ -30,14 +28,12 @@ static inline css_error set_align_content(css_computed_style *style, uint8_t #undef ALIGN_CONTENT_MASK #define ALIGN_ITEMS_INDEX 10 -#define ALIGN_ITEMS_SHIFT 26 -#define ALIGN_ITEMS_MASK 0x1c000000 +#define ALIGN_ITEMS_SHIFT 23 +#define ALIGN_ITEMS_MASK 0x3800000 static inline css_error set_align_items(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[ALIGN_ITEMS_INDEX]; + uint32_t *bits = &style->i.bits[ALIGN_ITEMS_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~ALIGN_ITEMS_MASK) | (((uint32_t)type & 0x7) << @@ -50,14 +46,12 @@ static inline css_error set_align_items(css_computed_style *style, uint8_t type) #undef ALIGN_ITEMS_MASK #define ALIGN_SELF_INDEX 10 -#define ALIGN_SELF_SHIFT 23 -#define ALIGN_SELF_MASK 0x3800000 +#define ALIGN_SELF_SHIFT 26 +#define ALIGN_SELF_MASK 0x1c000000 static inline css_error set_align_self(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[ALIGN_SELF_INDEX]; + uint32_t *bits = &style->i.bits[ALIGN_SELF_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~ALIGN_SELF_MASK) | (((uint32_t)type & 0x7) << @@ -69,16 +63,14 @@ static inline css_error set_align_self(css_computed_style *style, uint8_t type) #undef ALIGN_SELF_SHIFT #undef ALIGN_SELF_MASK -#define BACKGROUND_ATTACHMENT_INDEX 11 -#define BACKGROUND_ATTACHMENT_SHIFT 26 -#define BACKGROUND_ATTACHMENT_MASK 0xc000000 +#define BACKGROUND_ATTACHMENT_INDEX 14 +#define BACKGROUND_ATTACHMENT_SHIFT 28 +#define BACKGROUND_ATTACHMENT_MASK 0x30000000 static inline css_error set_background_attachment(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX]; + uint32_t *bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BACKGROUND_ATTACHMENT_MASK) | (((uint32_t)type & 0x3) @@ -90,16 +82,14 @@ static inline css_error set_background_attachment(css_computed_style *style, #undef BACKGROUND_ATTACHMENT_SHIFT #undef BACKGROUND_ATTACHMENT_MASK -#define BACKGROUND_COLOR_INDEX 11 -#define BACKGROUND_COLOR_SHIFT 22 -#define BACKGROUND_COLOR_MASK 0xc00000 +#define BACKGROUND_COLOR_INDEX 14 +#define BACKGROUND_COLOR_SHIFT 30 +#define BACKGROUND_COLOR_MASK 0xc0000000 static inline css_error set_background_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[BACKGROUND_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[BACKGROUND_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BACKGROUND_COLOR_MASK) | (((uint32_t)type & 0x3) << @@ -114,15 +104,13 @@ static inline css_error set_background_color(css_computed_style *style, uint8_t #undef BACKGROUND_COLOR_MASK #define BACKGROUND_IMAGE_INDEX 14 -#define BACKGROUND_IMAGE_SHIFT 23 -#define BACKGROUND_IMAGE_MASK 0x800000 +#define BACKGROUND_IMAGE_SHIFT 16 +#define BACKGROUND_IMAGE_MASK 0x10000 static inline css_error set_background_image(css_computed_style *style, uint8_t type, lwc_string *string) { - uint32_t *bits; - - bits = &style->i.bits[BACKGROUND_IMAGE_INDEX]; + uint32_t *bits = &style->i.bits[BACKGROUND_IMAGE_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~BACKGROUND_IMAGE_MASK) | (((uint32_t)type & 0x1) << @@ -153,9 +141,7 @@ static inline css_error set_background_position(css_computed_style *style, uint8_t type, css_fixed length_a, css_unit unit_a, css_fixed length_b, css_unit unit_b) { - uint32_t *bits; - - bits = &style->i.bits[BACKGROUND_POSITION_INDEX]; + uint32_t *bits = &style->i.bits[BACKGROUND_POSITION_INDEX]; /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ *bits = (*bits & ~BACKGROUND_POSITION_MASK) | ((((uint32_t)type & 0x1) @@ -172,16 +158,14 @@ static inline css_error set_background_position(css_computed_style *style, #undef BACKGROUND_POSITION_SHIFT #undef BACKGROUND_POSITION_MASK -#define BACKGROUND_REPEAT_INDEX 13 -#define BACKGROUND_REPEAT_SHIFT 22 -#define BACKGROUND_REPEAT_MASK 0x1c00000 +#define BACKGROUND_REPEAT_INDEX 10 +#define BACKGROUND_REPEAT_SHIFT 29 +#define BACKGROUND_REPEAT_MASK 0xe0000000 static inline css_error set_background_repeat(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BACKGROUND_REPEAT_INDEX]; + uint32_t *bits = &style->i.bits[BACKGROUND_REPEAT_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~BACKGROUND_REPEAT_MASK) | (((uint32_t)type & 0x7) << @@ -193,16 +177,14 @@ static inline css_error set_background_repeat(css_computed_style *style, #undef BACKGROUND_REPEAT_SHIFT #undef BACKGROUND_REPEAT_MASK -#define BORDER_BOTTOM_COLOR_INDEX 10 -#define BORDER_BOTTOM_COLOR_SHIFT 18 -#define BORDER_BOTTOM_COLOR_MASK 0xc0000 +#define BORDER_BOTTOM_COLOR_INDEX 11 +#define BORDER_BOTTOM_COLOR_SHIFT 0 +#define BORDER_BOTTOM_COLOR_MASK 0x3 static inline css_error set_border_bottom_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BORDER_BOTTOM_COLOR_MASK) | (((uint32_t)type & 0x3) @@ -216,16 +198,14 @@ static inline css_error set_border_bottom_color(css_computed_style *style, #undef BORDER_BOTTOM_COLOR_SHIFT #undef BORDER_BOTTOM_COLOR_MASK -#define BORDER_BOTTOM_STYLE_INDEX 6 -#define BORDER_BOTTOM_STYLE_SHIFT 0 -#define BORDER_BOTTOM_STYLE_MASK 0xf +#define BORDER_BOTTOM_STYLE_INDEX 13 +#define BORDER_BOTTOM_STYLE_SHIFT 28 +#define BORDER_BOTTOM_STYLE_MASK 0xf0000000 static inline css_error set_border_bottom_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BORDER_BOTTOM_STYLE_MASK) | (((uint32_t)type & 0xf) @@ -238,15 +218,13 @@ static inline css_error set_border_bottom_style(css_computed_style *style, #undef BORDER_BOTTOM_STYLE_MASK #define BORDER_BOTTOM_WIDTH_INDEX 0 -#define BORDER_BOTTOM_WIDTH_SHIFT 8 -#define BORDER_BOTTOM_WIDTH_MASK 0xff00 +#define BORDER_BOTTOM_WIDTH_SHIFT 0 +#define BORDER_BOTTOM_WIDTH_MASK 0xff static inline css_error set_border_bottom_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX]; /* 8bits: uuuuuttt : unit | type */ *bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | ((((uint32_t)type & 0x7) @@ -261,15 +239,13 @@ static inline css_error set_border_bottom_width(css_computed_style *style, #undef BORDER_BOTTOM_WIDTH_MASK #define BORDER_COLLAPSE_INDEX 11 -#define BORDER_COLLAPSE_SHIFT 14 -#define BORDER_COLLAPSE_MASK 0xc000 +#define BORDER_COLLAPSE_SHIFT 2 +#define BORDER_COLLAPSE_MASK 0xc static inline css_error set_border_collapse(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_COLLAPSE_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_COLLAPSE_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BORDER_COLLAPSE_MASK) | (((uint32_t)type & 0x3) << @@ -281,16 +257,14 @@ static inline css_error set_border_collapse(css_computed_style *style, uint8_t #undef BORDER_COLLAPSE_SHIFT #undef BORDER_COLLAPSE_MASK -#define BORDER_LEFT_COLOR_INDEX 10 -#define BORDER_LEFT_COLOR_SHIFT 2 -#define BORDER_LEFT_COLOR_MASK 0xc +#define BORDER_LEFT_COLOR_INDEX 11 +#define BORDER_LEFT_COLOR_SHIFT 4 +#define BORDER_LEFT_COLOR_MASK 0x30 static inline css_error set_border_left_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BORDER_LEFT_COLOR_MASK) | (((uint32_t)type & 0x3) << @@ -305,15 +279,13 @@ static inline css_error set_border_left_color(css_computed_style *style, #undef BORDER_LEFT_COLOR_MASK #define BORDER_LEFT_STYLE_INDEX 9 -#define BORDER_LEFT_STYLE_SHIFT 19 -#define BORDER_LEFT_STYLE_MASK 0x780000 +#define BORDER_LEFT_STYLE_SHIFT 3 +#define BORDER_LEFT_STYLE_MASK 0x78 static inline css_error set_border_left_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BORDER_LEFT_STYLE_MASK) | (((uint32_t)type & 0xf) << @@ -326,15 +298,13 @@ static inline css_error set_border_left_style(css_computed_style *style, #undef BORDER_LEFT_STYLE_MASK #define BORDER_LEFT_WIDTH_INDEX 0 -#define BORDER_LEFT_WIDTH_SHIFT 24 -#define BORDER_LEFT_WIDTH_MASK 0xff000000 +#define BORDER_LEFT_WIDTH_SHIFT 8 +#define BORDER_LEFT_WIDTH_MASK 0xff00 static inline css_error set_border_left_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX]; /* 8bits: uuuuuttt : unit | type */ *bits = (*bits & ~BORDER_LEFT_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( @@ -349,15 +319,13 @@ static inline css_error set_border_left_width(css_computed_style *style, #undef BORDER_LEFT_WIDTH_MASK #define BORDER_RIGHT_COLOR_INDEX 11 -#define BORDER_RIGHT_COLOR_SHIFT 12 -#define BORDER_RIGHT_COLOR_MASK 0x3000 +#define BORDER_RIGHT_COLOR_SHIFT 6 +#define BORDER_RIGHT_COLOR_MASK 0xc0 static inline css_error set_border_right_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BORDER_RIGHT_COLOR_MASK) | (((uint32_t)type & 0x3) << @@ -371,16 +339,14 @@ static inline css_error set_border_right_color(css_computed_style *style, #undef BORDER_RIGHT_COLOR_SHIFT #undef BORDER_RIGHT_COLOR_MASK -#define BORDER_RIGHT_STYLE_INDEX 13 -#define BORDER_RIGHT_STYLE_SHIFT 28 -#define BORDER_RIGHT_STYLE_MASK 0xf0000000 +#define BORDER_RIGHT_STYLE_INDEX 9 +#define BORDER_RIGHT_STYLE_SHIFT 7 +#define BORDER_RIGHT_STYLE_MASK 0x780 static inline css_error set_border_right_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BORDER_RIGHT_STYLE_MASK) | (((uint32_t)type & 0xf) << @@ -393,15 +359,13 @@ static inline css_error set_border_right_style(css_computed_style *style, #undef BORDER_RIGHT_STYLE_MASK #define BORDER_RIGHT_WIDTH_INDEX 0 -#define BORDER_RIGHT_WIDTH_SHIFT 0 -#define BORDER_RIGHT_WIDTH_MASK 0xff +#define BORDER_RIGHT_WIDTH_SHIFT 16 +#define BORDER_RIGHT_WIDTH_MASK 0xff0000 static inline css_error set_border_right_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX]; /* 8bits: uuuuuttt : unit | type */ *bits = (*bits & ~BORDER_RIGHT_WIDTH_MASK) | ((((uint32_t)type & 0x7) | @@ -423,9 +387,7 @@ static inline css_error set_border_spacing(css_computed_style *style, uint8_t type, css_fixed length_a, css_unit unit_a, css_fixed length_b, css_unit unit_b) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_SPACING_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_SPACING_INDEX]; /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ *bits = (*bits & ~BORDER_SPACING_MASK) | ((((uint32_t)type & 0x1) | ( @@ -442,15 +404,13 @@ static inline css_error set_border_spacing(css_computed_style *style, uint8_t #undef BORDER_SPACING_MASK #define BORDER_TOP_COLOR_INDEX 11 -#define BORDER_TOP_COLOR_SHIFT 16 -#define BORDER_TOP_COLOR_MASK 0x30000 +#define BORDER_TOP_COLOR_SHIFT 8 +#define BORDER_TOP_COLOR_MASK 0x300 static inline css_error set_border_top_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_TOP_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_TOP_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BORDER_TOP_COLOR_MASK) | (((uint32_t)type & 0x3) << @@ -464,16 +424,14 @@ static inline css_error set_border_top_color(css_computed_style *style, uint8_t #undef BORDER_TOP_COLOR_SHIFT #undef BORDER_TOP_COLOR_MASK -#define BORDER_TOP_STYLE_INDEX 7 -#define BORDER_TOP_STYLE_SHIFT 0 -#define BORDER_TOP_STYLE_MASK 0xf +#define BORDER_TOP_STYLE_INDEX 9 +#define BORDER_TOP_STYLE_SHIFT 11 +#define BORDER_TOP_STYLE_MASK 0x7800 static inline css_error set_border_top_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_TOP_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_TOP_STYLE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BORDER_TOP_STYLE_MASK) | (((uint32_t)type & 0xf) << @@ -486,15 +444,13 @@ static inline css_error set_border_top_style(css_computed_style *style, uint8_t #undef BORDER_TOP_STYLE_MASK #define BORDER_TOP_WIDTH_INDEX 0 -#define BORDER_TOP_WIDTH_SHIFT 16 -#define BORDER_TOP_WIDTH_MASK 0xff0000 +#define BORDER_TOP_WIDTH_SHIFT 24 +#define BORDER_TOP_WIDTH_MASK 0xff000000 static inline css_error set_border_top_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX]; /* 8bits: uuuuuttt : unit | type */ *bits = (*bits & ~BORDER_TOP_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( @@ -508,16 +464,14 @@ static inline css_error set_border_top_width(css_computed_style *style, uint8_t #undef BORDER_TOP_WIDTH_SHIFT #undef BORDER_TOP_WIDTH_MASK -#define BOTTOM_INDEX 7 +#define BOTTOM_INDEX 3 #define BOTTOM_SHIFT 11 #define BOTTOM_MASK 0x3f800 static inline css_error set_bottom(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[BOTTOM_INDEX]; + uint32_t *bits = &style->i.bits[BOTTOM_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~BOTTOM_MASK) | ((((uint32_t)type & 0x3) | (unit << @@ -531,15 +485,13 @@ static inline css_error set_bottom(css_computed_style *style, uint8_t type, #undef BOTTOM_SHIFT #undef BOTTOM_MASK -#define BOX_SIZING_INDEX 10 -#define BOX_SIZING_SHIFT 12 -#define BOX_SIZING_MASK 0x3000 +#define BOX_SIZING_INDEX 11 +#define BOX_SIZING_SHIFT 10 +#define BOX_SIZING_MASK 0xc00 static inline css_error set_box_sizing(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BOX_SIZING_INDEX]; + uint32_t *bits = &style->i.bits[BOX_SIZING_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~BOX_SIZING_MASK) | (((uint32_t)type & 0x3) << @@ -552,14 +504,12 @@ static inline css_error set_box_sizing(css_computed_style *style, uint8_t type) #undef BOX_SIZING_MASK #define BREAK_AFTER_INDEX 9 -#define BREAK_AFTER_SHIFT 11 -#define BREAK_AFTER_MASK 0x7800 +#define BREAK_AFTER_SHIFT 15 +#define BREAK_AFTER_MASK 0x78000 static inline css_error set_break_after(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BREAK_AFTER_INDEX]; + uint32_t *bits = &style->i.bits[BREAK_AFTER_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BREAK_AFTER_MASK) | (((uint32_t)type & 0xf) << @@ -572,15 +522,13 @@ static inline css_error set_break_after(css_computed_style *style, uint8_t type) #undef BREAK_AFTER_MASK #define BREAK_BEFORE_INDEX 9 -#define BREAK_BEFORE_SHIFT 23 -#define BREAK_BEFORE_MASK 0x7800000 +#define BREAK_BEFORE_SHIFT 19 +#define BREAK_BEFORE_MASK 0x780000 static inline css_error set_break_before(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BREAK_BEFORE_INDEX]; + uint32_t *bits = &style->i.bits[BREAK_BEFORE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BREAK_BEFORE_MASK) | (((uint32_t)type & 0xf) << @@ -592,16 +540,14 @@ static inline css_error set_break_before(css_computed_style *style, uint8_t #undef BREAK_BEFORE_SHIFT #undef BREAK_BEFORE_MASK -#define BREAK_INSIDE_INDEX 5 -#define BREAK_INSIDE_SHIFT 0 -#define BREAK_INSIDE_MASK 0xf +#define BREAK_INSIDE_INDEX 9 +#define BREAK_INSIDE_SHIFT 23 +#define BREAK_INSIDE_MASK 0x7800000 static inline css_error set_break_inside(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[BREAK_INSIDE_INDEX]; + uint32_t *bits = &style->i.bits[BREAK_INSIDE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~BREAK_INSIDE_MASK) | (((uint32_t)type & 0xf) << @@ -614,15 +560,13 @@ static inline css_error set_break_inside(css_computed_style *style, uint8_t #undef BREAK_INSIDE_MASK #define CAPTION_SIDE_INDEX 11 -#define CAPTION_SIDE_SHIFT 4 -#define CAPTION_SIDE_MASK 0x30 +#define CAPTION_SIDE_SHIFT 12 +#define CAPTION_SIDE_MASK 0x3000 static inline css_error set_caption_side(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[CAPTION_SIDE_INDEX]; + uint32_t *bits = &style->i.bits[CAPTION_SIDE_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~CAPTION_SIDE_MASK) | (((uint32_t)type & 0x3) << @@ -635,14 +579,12 @@ static inline css_error set_caption_side(css_computed_style *style, uint8_t #undef CAPTION_SIDE_MASK #define CLEAR_INDEX 13 -#define CLEAR_SHIFT 10 -#define CLEAR_MASK 0x1c00 +#define CLEAR_SHIFT 1 +#define CLEAR_MASK 0xe static inline css_error set_clear(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[CLEAR_INDEX]; + uint32_t *bits = &style->i.bits[CLEAR_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~CLEAR_MASK) | (((uint32_t)type & 0x7) << CLEAR_SHIFT); @@ -697,15 +639,13 @@ static inline css_error set_clip( #undef CLIP_MASK #define COLOR_INDEX 14 -#define COLOR_SHIFT 18 -#define COLOR_MASK 0x40000 +#define COLOR_SHIFT 17 +#define COLOR_MASK 0x20000 static inline css_error set_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[COLOR_INDEX]; + uint32_t *bits = &style->i.bits[COLOR_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~COLOR_MASK) | (((uint32_t)type & 0x1) << COLOR_SHIFT); @@ -718,16 +658,14 @@ static inline css_error set_color(css_computed_style *style, uint8_t type, #undef COLOR_SHIFT #undef COLOR_MASK -#define COLUMN_COUNT_INDEX 10 -#define COLUMN_COUNT_SHIFT 0 -#define COLUMN_COUNT_MASK 0x3 +#define COLUMN_COUNT_INDEX 11 +#define COLUMN_COUNT_SHIFT 14 +#define COLUMN_COUNT_MASK 0xc000 static inline css_error set_column_count(css_computed_style *style, uint8_t type, int32_t integer) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_COUNT_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_COUNT_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~COLUMN_COUNT_MASK) | (((uint32_t)type & 0x3) << @@ -742,14 +680,12 @@ static inline css_error set_column_count(css_computed_style *style, uint8_t #undef COLUMN_COUNT_MASK #define COLUMN_FILL_INDEX 11 -#define COLUMN_FILL_SHIFT 8 -#define COLUMN_FILL_MASK 0x300 +#define COLUMN_FILL_SHIFT 16 +#define COLUMN_FILL_MASK 0x30000 static inline css_error set_column_fill(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_FILL_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_FILL_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~COLUMN_FILL_MASK) | (((uint32_t)type & 0x3) << @@ -761,16 +697,14 @@ static inline css_error set_column_fill(css_computed_style *style, uint8_t type) #undef COLUMN_FILL_SHIFT #undef COLUMN_FILL_MASK -#define COLUMN_GAP_INDEX 4 -#define COLUMN_GAP_SHIFT 11 -#define COLUMN_GAP_MASK 0x3f800 +#define COLUMN_GAP_INDEX 3 +#define COLUMN_GAP_SHIFT 18 +#define COLUMN_GAP_MASK 0x1fc0000 static inline css_error set_column_gap(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_GAP_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_GAP_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~COLUMN_GAP_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -784,16 +718,14 @@ static inline css_error set_column_gap(css_computed_style *style, uint8_t type, #undef COLUMN_GAP_SHIFT #undef COLUMN_GAP_MASK -#define COLUMN_RULE_COLOR_INDEX 10 -#define COLUMN_RULE_COLOR_SHIFT 16 -#define COLUMN_RULE_COLOR_MASK 0x30000 +#define COLUMN_RULE_COLOR_INDEX 11 +#define COLUMN_RULE_COLOR_SHIFT 18 +#define COLUMN_RULE_COLOR_MASK 0xc0000 static inline css_error set_column_rule_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_RULE_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_RULE_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | (((uint32_t)type & 0x3) << @@ -807,16 +739,14 @@ static inline css_error set_column_rule_color(css_computed_style *style, #undef COLUMN_RULE_COLOR_SHIFT #undef COLUMN_RULE_COLOR_MASK -#define COLUMN_RULE_STYLE_INDEX 9 -#define COLUMN_RULE_STYLE_SHIFT 3 -#define COLUMN_RULE_STYLE_MASK 0x78 +#define COLUMN_RULE_STYLE_INDEX 7 +#define COLUMN_RULE_STYLE_SHIFT 0 +#define COLUMN_RULE_STYLE_MASK 0xf static inline css_error set_column_rule_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_RULE_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_RULE_STYLE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~COLUMN_RULE_STYLE_MASK) | (((uint32_t)type & 0xf) << @@ -835,9 +765,7 @@ static inline css_error set_column_rule_style(css_computed_style *style, static inline css_error set_column_rule_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_RULE_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_RULE_WIDTH_INDEX]; /* 8bits: uuuuuttt : unit | type */ *bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( @@ -851,15 +779,13 @@ static inline css_error set_column_rule_width(css_computed_style *style, #undef COLUMN_RULE_WIDTH_SHIFT #undef COLUMN_RULE_WIDTH_MASK -#define COLUMN_SPAN_INDEX 10 -#define COLUMN_SPAN_SHIFT 10 -#define COLUMN_SPAN_MASK 0xc00 +#define COLUMN_SPAN_INDEX 11 +#define COLUMN_SPAN_SHIFT 20 +#define COLUMN_SPAN_MASK 0x300000 static inline css_error set_column_span(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_SPAN_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_SPAN_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~COLUMN_SPAN_MASK) | (((uint32_t)type & 0x3) << @@ -871,16 +797,14 @@ static inline css_error set_column_span(css_computed_style *style, uint8_t type) #undef COLUMN_SPAN_SHIFT #undef COLUMN_SPAN_MASK -#define COLUMN_WIDTH_INDEX 5 +#define COLUMN_WIDTH_INDEX 3 #define COLUMN_WIDTH_SHIFT 25 #define COLUMN_WIDTH_MASK 0xfe000000 static inline css_error set_column_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[COLUMN_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[COLUMN_WIDTH_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~COLUMN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -895,8 +819,8 @@ static inline css_error set_column_width(css_computed_style *style, uint8_t #undef COLUMN_WIDTH_MASK #define CONTENT_INDEX 11 -#define CONTENT_SHIFT 18 -#define CONTENT_MASK 0xc0000 +#define CONTENT_SHIFT 22 +#define CONTENT_MASK 0xc00000 static inline css_error set_content( css_computed_style *style, uint8_t type, css_computed_content_item *content) @@ -978,15 +902,13 @@ static inline css_error set_content( #undef CONTENT_MASK #define COUNTER_INCREMENT_INDEX 14 -#define COUNTER_INCREMENT_SHIFT 20 -#define COUNTER_INCREMENT_MASK 0x100000 +#define COUNTER_INCREMENT_SHIFT 18 +#define COUNTER_INCREMENT_MASK 0x40000 static inline css_error set_counter_increment(css_computed_style *style, uint8_t type, css_computed_counter *counter_arr) { - uint32_t *bits; - - bits = &style->i.bits[COUNTER_INCREMENT_INDEX]; + uint32_t *bits = &style->i.bits[COUNTER_INCREMENT_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~COUNTER_INCREMENT_MASK) | (((uint32_t)type & 0x1) << @@ -1016,15 +938,13 @@ static inline css_error set_counter_increment(css_computed_style *style, #undef COUNTER_INCREMENT_MASK #define COUNTER_RESET_INDEX 14 -#define COUNTER_RESET_SHIFT 25 -#define COUNTER_RESET_MASK 0x2000000 +#define COUNTER_RESET_SHIFT 19 +#define COUNTER_RESET_MASK 0x80000 static inline css_error set_counter_reset(css_computed_style *style, uint8_t type, css_computed_counter *counter_arr) { - uint32_t *bits; - - bits = &style->i.bits[COUNTER_RESET_INDEX]; + uint32_t *bits = &style->i.bits[COUNTER_RESET_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~COUNTER_RESET_MASK) | (((uint32_t)type & 0x1) << @@ -1060,9 +980,7 @@ static inline css_error set_counter_reset(css_computed_style *style, uint8_t static inline css_error set_cursor(css_computed_style *style, uint8_t type, lwc_string **string_arr) { - uint32_t *bits; - - bits = &style->i.bits[CURSOR_INDEX]; + uint32_t *bits = &style->i.bits[CURSOR_INDEX]; /* 5bits: ttttt : type */ *bits = (*bits & ~CURSOR_MASK) | (((uint32_t)type & 0x1f) << @@ -1091,15 +1009,13 @@ static inline css_error set_cursor(css_computed_style *style, uint8_t type, #undef CURSOR_SHIFT #undef CURSOR_MASK -#define DIRECTION_INDEX 14 -#define DIRECTION_SHIFT 28 -#define DIRECTION_MASK 0x30000000 +#define DIRECTION_INDEX 11 +#define DIRECTION_SHIFT 24 +#define DIRECTION_MASK 0x3000000 static inline css_error set_direction(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[DIRECTION_INDEX]; + uint32_t *bits = &style->i.bits[DIRECTION_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~DIRECTION_MASK) | (((uint32_t)type & 0x3) << @@ -1111,15 +1027,13 @@ static inline css_error set_direction(css_computed_style *style, uint8_t type) #undef DIRECTION_SHIFT #undef DIRECTION_MASK -#define DISPLAY_INDEX 3 -#define DISPLAY_SHIFT 0 -#define DISPLAY_MASK 0x1f +#define DISPLAY_INDEX 8 +#define DISPLAY_SHIFT 3 +#define DISPLAY_MASK 0xf8 static inline css_error set_display(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[DISPLAY_INDEX]; + uint32_t *bits = &style->i.bits[DISPLAY_INDEX]; /* 5bits: ttttt : type */ *bits = (*bits & ~DISPLAY_MASK) | (((uint32_t)type & 0x1f) << @@ -1131,15 +1045,13 @@ static inline css_error set_display(css_computed_style *style, uint8_t type) #undef DISPLAY_SHIFT #undef DISPLAY_MASK -#define EMPTY_CELLS_INDEX 10 -#define EMPTY_CELLS_SHIFT 4 -#define EMPTY_CELLS_MASK 0x30 +#define EMPTY_CELLS_INDEX 11 +#define EMPTY_CELLS_SHIFT 26 +#define EMPTY_CELLS_MASK 0xc000000 static inline css_error set_empty_cells(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[EMPTY_CELLS_INDEX]; + uint32_t *bits = &style->i.bits[EMPTY_CELLS_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~EMPTY_CELLS_MASK) | (((uint32_t)type & 0x3) << @@ -1151,16 +1063,35 @@ static inline css_error set_empty_cells(css_computed_style *style, uint8_t type) #undef EMPTY_CELLS_SHIFT #undef EMPTY_CELLS_MASK -#define FLEX_BASIS_INDEX 4 -#define FLEX_BASIS_SHIFT 25 -#define FLEX_BASIS_MASK 0xfe000000 +#define FILL_OPACITY_INDEX 14 +#define FILL_OPACITY_SHIFT 20 +#define FILL_OPACITY_MASK 0x100000 + +static inline css_error set_fill_opacity(css_computed_style *style, uint8_t + type, css_fixed fixed) +{ + uint32_t *bits = &style->i.bits[FILL_OPACITY_INDEX]; + + /* 1bit: t : type */ + *bits = (*bits & ~FILL_OPACITY_MASK) | (((uint32_t)type & 0x1) << + FILL_OPACITY_SHIFT); + + style->i.fill_opacity = fixed; + + return CSS_OK; +} +#undef FILL_OPACITY_INDEX +#undef FILL_OPACITY_SHIFT +#undef FILL_OPACITY_MASK + +#define FLEX_BASIS_INDEX 7 +#define FLEX_BASIS_SHIFT 4 +#define FLEX_BASIS_MASK 0x7f0 static inline css_error set_flex_basis(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[FLEX_BASIS_INDEX]; + uint32_t *bits = &style->i.bits[FLEX_BASIS_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~FLEX_BASIS_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1175,15 +1106,13 @@ static inline css_error set_flex_basis(css_computed_style *style, uint8_t type, #undef FLEX_BASIS_MASK #define FLEX_DIRECTION_INDEX 13 -#define FLEX_DIRECTION_SHIFT 1 -#define FLEX_DIRECTION_MASK 0xe +#define FLEX_DIRECTION_SHIFT 4 +#define FLEX_DIRECTION_MASK 0x70 static inline css_error set_flex_direction(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[FLEX_DIRECTION_INDEX]; + uint32_t *bits = &style->i.bits[FLEX_DIRECTION_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~FLEX_DIRECTION_MASK) | (((uint32_t)type & 0x7) << @@ -1195,16 +1124,14 @@ static inline css_error set_flex_direction(css_computed_style *style, uint8_t #undef FLEX_DIRECTION_SHIFT #undef FLEX_DIRECTION_MASK -#define FLEX_GROW_INDEX 12 -#define FLEX_GROW_SHIFT 0 -#define FLEX_GROW_MASK 0x1 +#define FLEX_GROW_INDEX 14 +#define FLEX_GROW_SHIFT 21 +#define FLEX_GROW_MASK 0x200000 static inline css_error set_flex_grow(css_computed_style *style, uint8_t type, css_fixed fixed) { - uint32_t *bits; - - bits = &style->i.bits[FLEX_GROW_INDEX]; + uint32_t *bits = &style->i.bits[FLEX_GROW_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~FLEX_GROW_MASK) | (((uint32_t)type & 0x1) << @@ -1225,9 +1152,7 @@ static inline css_error set_flex_grow(css_computed_style *style, uint8_t type, static inline css_error set_flex_shrink(css_computed_style *style, uint8_t type, css_fixed fixed) { - uint32_t *bits; - - bits = &style->i.bits[FLEX_SHRINK_INDEX]; + uint32_t *bits = &style->i.bits[FLEX_SHRINK_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~FLEX_SHRINK_MASK) | (((uint32_t)type & 0x1) << @@ -1241,15 +1166,13 @@ static inline css_error set_flex_shrink(css_computed_style *style, uint8_t #undef FLEX_SHRINK_SHIFT #undef FLEX_SHRINK_MASK -#define FLEX_WRAP_INDEX 10 -#define FLEX_WRAP_SHIFT 6 -#define FLEX_WRAP_MASK 0xc0 +#define FLEX_WRAP_INDEX 11 +#define FLEX_WRAP_SHIFT 28 +#define FLEX_WRAP_MASK 0x30000000 static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[FLEX_WRAP_INDEX]; + uint32_t *bits = &style->i.bits[FLEX_WRAP_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~FLEX_WRAP_MASK) | (((uint32_t)type & 0x3) << @@ -1267,9 +1190,7 @@ static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type) static inline css_error set_float(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[FLOAT_INDEX]; + uint32_t *bits = &style->i.bits[FLOAT_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~FLOAT_MASK) | (((uint32_t)type & 0x3) << FLOAT_SHIFT); @@ -1280,16 +1201,14 @@ static inline css_error set_float(css_computed_style *style, uint8_t type) #undef FLOAT_SHIFT #undef FLOAT_MASK -#define FONT_FAMILY_INDEX 9 -#define FONT_FAMILY_SHIFT 0 -#define FONT_FAMILY_MASK 0x7 +#define FONT_FAMILY_INDEX 13 +#define FONT_FAMILY_SHIFT 7 +#define FONT_FAMILY_MASK 0x380 static inline css_error set_font_family(css_computed_style *style, uint8_t type, lwc_string **string_arr) { - uint32_t *bits; - - bits = &style->i.bits[FONT_FAMILY_INDEX]; + uint32_t *bits = &style->i.bits[FONT_FAMILY_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~FONT_FAMILY_MASK) | (((uint32_t)type & 0x7) << @@ -1318,16 +1237,14 @@ static inline css_error set_font_family(css_computed_style *style, uint8_t #undef FONT_FAMILY_SHIFT #undef FONT_FAMILY_MASK -#define FONT_SIZE_INDEX 12 -#define FONT_SIZE_SHIFT 1 -#define FONT_SIZE_MASK 0x3fe +#define FONT_SIZE_INDEX 1 +#define FONT_SIZE_SHIFT 23 +#define FONT_SIZE_MASK 0xff800000 static inline css_error set_font_size(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[FONT_SIZE_INDEX]; + uint32_t *bits = &style->i.bits[FONT_SIZE_INDEX]; /* 9bits: uuuuutttt : unit | type */ *bits = (*bits & ~FONT_SIZE_MASK) | ((((uint32_t)type & 0xf) | (unit << @@ -1341,15 +1258,13 @@ static inline css_error set_font_size(css_computed_style *style, uint8_t type, #undef FONT_SIZE_SHIFT #undef FONT_SIZE_MASK -#define FONT_STYLE_INDEX 11 -#define FONT_STYLE_SHIFT 20 -#define FONT_STYLE_MASK 0x300000 +#define FONT_STYLE_INDEX 10 +#define FONT_STYLE_SHIFT 0 +#define FONT_STYLE_MASK 0x3 static inline css_error set_font_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[FONT_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[FONT_STYLE_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~FONT_STYLE_MASK) | (((uint32_t)type & 0x3) << @@ -1361,16 +1276,14 @@ static inline css_error set_font_style(css_computed_style *style, uint8_t type) #undef FONT_STYLE_SHIFT #undef FONT_STYLE_MASK -#define FONT_VARIANT_INDEX 11 -#define FONT_VARIANT_SHIFT 28 -#define FONT_VARIANT_MASK 0x30000000 +#define FONT_VARIANT_INDEX 10 +#define FONT_VARIANT_SHIFT 2 +#define FONT_VARIANT_MASK 0xc static inline css_error set_font_variant(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[FONT_VARIANT_INDEX]; + uint32_t *bits = &style->i.bits[FONT_VARIANT_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~FONT_VARIANT_MASK) | (((uint32_t)type & 0x3) << @@ -1382,15 +1295,13 @@ static inline css_error set_font_variant(css_computed_style *style, uint8_t #undef FONT_VARIANT_SHIFT #undef FONT_VARIANT_MASK -#define FONT_WEIGHT_INDEX 9 -#define FONT_WEIGHT_SHIFT 15 -#define FONT_WEIGHT_MASK 0x78000 +#define FONT_WEIGHT_INDEX 6 +#define FONT_WEIGHT_SHIFT 0 +#define FONT_WEIGHT_MASK 0xf static inline css_error set_font_weight(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[FONT_WEIGHT_INDEX]; + uint32_t *bits = &style->i.bits[FONT_WEIGHT_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~FONT_WEIGHT_MASK) | (((uint32_t)type & 0xf) << @@ -1402,16 +1313,14 @@ static inline css_error set_font_weight(css_computed_style *style, uint8_t type) #undef FONT_WEIGHT_SHIFT #undef FONT_WEIGHT_MASK -#define HEIGHT_INDEX 6 -#define HEIGHT_SHIFT 25 -#define HEIGHT_MASK 0xfe000000 +#define HEIGHT_INDEX 7 +#define HEIGHT_SHIFT 11 +#define HEIGHT_MASK 0x3f800 static inline css_error set_height(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[HEIGHT_INDEX]; + uint32_t *bits = &style->i.bits[HEIGHT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit << @@ -1426,15 +1335,13 @@ static inline css_error set_height(css_computed_style *style, uint8_t type, #undef HEIGHT_MASK #define JUSTIFY_CONTENT_INDEX 13 -#define JUSTIFY_CONTENT_SHIFT 4 -#define JUSTIFY_CONTENT_MASK 0x70 +#define JUSTIFY_CONTENT_SHIFT 10 +#define JUSTIFY_CONTENT_MASK 0x1c00 static inline css_error set_justify_content(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[JUSTIFY_CONTENT_INDEX]; + uint32_t *bits = &style->i.bits[JUSTIFY_CONTENT_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~JUSTIFY_CONTENT_MASK) | (((uint32_t)type & 0x7) << @@ -1446,16 +1353,14 @@ static inline css_error set_justify_content(css_computed_style *style, uint8_t #undef JUSTIFY_CONTENT_SHIFT #undef JUSTIFY_CONTENT_MASK -#define LEFT_INDEX 4 -#define LEFT_SHIFT 4 -#define LEFT_MASK 0x7f0 +#define LEFT_INDEX 7 +#define LEFT_SHIFT 18 +#define LEFT_MASK 0x1fc0000 static inline css_error set_left(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[LEFT_INDEX]; + uint32_t *bits = &style->i.bits[LEFT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2)) @@ -1469,16 +1374,14 @@ static inline css_error set_left(css_computed_style *style, uint8_t type, #undef LEFT_SHIFT #undef LEFT_MASK -#define LETTER_SPACING_INDEX 6 -#define LETTER_SPACING_SHIFT 18 -#define LETTER_SPACING_MASK 0x1fc0000 +#define LETTER_SPACING_INDEX 7 +#define LETTER_SPACING_SHIFT 25 +#define LETTER_SPACING_MASK 0xfe000000 static inline css_error set_letter_spacing(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[LETTER_SPACING_INDEX]; + uint32_t *bits = &style->i.bits[LETTER_SPACING_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~LETTER_SPACING_MASK) | ((((uint32_t)type & 0x3) | ( @@ -1492,16 +1395,14 @@ static inline css_error set_letter_spacing(css_computed_style *style, uint8_t #undef LETTER_SPACING_SHIFT #undef LETTER_SPACING_MASK -#define LINE_HEIGHT_INDEX 5 -#define LINE_HEIGHT_SHIFT 11 -#define LINE_HEIGHT_MASK 0x3f800 +#define LINE_HEIGHT_INDEX 6 +#define LINE_HEIGHT_SHIFT 4 +#define LINE_HEIGHT_MASK 0x7f0 static inline css_error set_line_height(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[LINE_HEIGHT_INDEX]; + uint32_t *bits = &style->i.bits[LINE_HEIGHT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~LINE_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1516,15 +1417,13 @@ static inline css_error set_line_height(css_computed_style *style, uint8_t #undef LINE_HEIGHT_MASK #define LIST_STYLE_IMAGE_INDEX 14 -#define LIST_STYLE_IMAGE_SHIFT 27 -#define LIST_STYLE_IMAGE_MASK 0x8000000 +#define LIST_STYLE_IMAGE_SHIFT 23 +#define LIST_STYLE_IMAGE_MASK 0x800000 static inline css_error set_list_style_image(css_computed_style *style, uint8_t type, lwc_string *string) { - uint32_t *bits; - - bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX]; + uint32_t *bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~LIST_STYLE_IMAGE_MASK) | (((uint32_t)type & 0x1) << @@ -1547,16 +1446,14 @@ static inline css_error set_list_style_image(css_computed_style *style, uint8_t #undef LIST_STYLE_IMAGE_SHIFT #undef LIST_STYLE_IMAGE_MASK -#define LIST_STYLE_POSITION_INDEX 11 -#define LIST_STYLE_POSITION_SHIFT 6 -#define LIST_STYLE_POSITION_MASK 0xc0 +#define LIST_STYLE_POSITION_INDEX 10 +#define LIST_STYLE_POSITION_SHIFT 4 +#define LIST_STYLE_POSITION_MASK 0x30 static inline css_error set_list_style_position(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[LIST_STYLE_POSITION_INDEX]; + uint32_t *bits = &style->i.bits[LIST_STYLE_POSITION_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~LIST_STYLE_POSITION_MASK) | (((uint32_t)type & 0x3) @@ -1569,15 +1466,13 @@ static inline css_error set_list_style_position(css_computed_style *style, #undef LIST_STYLE_POSITION_MASK #define LIST_STYLE_TYPE_INDEX 8 -#define LIST_STYLE_TYPE_SHIFT 26 -#define LIST_STYLE_TYPE_MASK 0xfc000000 +#define LIST_STYLE_TYPE_SHIFT 8 +#define LIST_STYLE_TYPE_MASK 0x3f00 static inline css_error set_list_style_type(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[LIST_STYLE_TYPE_INDEX]; + uint32_t *bits = &style->i.bits[LIST_STYLE_TYPE_INDEX]; /* 6bits: tttttt : type */ *bits = (*bits & ~LIST_STYLE_TYPE_MASK) | (((uint32_t)type & 0x3f) << @@ -1589,16 +1484,14 @@ static inline css_error set_list_style_type(css_computed_style *style, uint8_t #undef LIST_STYLE_TYPE_SHIFT #undef LIST_STYLE_TYPE_MASK -#define MARGIN_BOTTOM_INDEX 5 -#define MARGIN_BOTTOM_SHIFT 18 -#define MARGIN_BOTTOM_MASK 0x1fc0000 +#define MARGIN_BOTTOM_INDEX 6 +#define MARGIN_BOTTOM_SHIFT 11 +#define MARGIN_BOTTOM_MASK 0x3f800 static inline css_error set_margin_bottom(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MARGIN_BOTTOM_INDEX]; + uint32_t *bits = &style->i.bits[MARGIN_BOTTOM_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MARGIN_BOTTOM_MASK) | ((((uint32_t)type & 0x3) | ( @@ -1612,16 +1505,14 @@ static inline css_error set_margin_bottom(css_computed_style *style, uint8_t #undef MARGIN_BOTTOM_SHIFT #undef MARGIN_BOTTOM_MASK -#define MARGIN_LEFT_INDEX 7 +#define MARGIN_LEFT_INDEX 6 #define MARGIN_LEFT_SHIFT 18 #define MARGIN_LEFT_MASK 0x1fc0000 static inline css_error set_margin_left(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MARGIN_LEFT_INDEX]; + uint32_t *bits = &style->i.bits[MARGIN_LEFT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MARGIN_LEFT_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1636,15 +1527,13 @@ static inline css_error set_margin_left(css_computed_style *style, uint8_t #undef MARGIN_LEFT_MASK #define MARGIN_RIGHT_INDEX 6 -#define MARGIN_RIGHT_SHIFT 4 -#define MARGIN_RIGHT_MASK 0x7f0 +#define MARGIN_RIGHT_SHIFT 25 +#define MARGIN_RIGHT_MASK 0xfe000000 static inline css_error set_margin_right(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MARGIN_RIGHT_INDEX]; + uint32_t *bits = &style->i.bits[MARGIN_RIGHT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MARGIN_RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1658,16 +1547,14 @@ static inline css_error set_margin_right(css_computed_style *style, uint8_t #undef MARGIN_RIGHT_SHIFT #undef MARGIN_RIGHT_MASK -#define MARGIN_TOP_INDEX 1 -#define MARGIN_TOP_SHIFT 0 -#define MARGIN_TOP_MASK 0x7f +#define MARGIN_TOP_INDEX 5 +#define MARGIN_TOP_SHIFT 4 +#define MARGIN_TOP_MASK 0x7f0 static inline css_error set_margin_top(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MARGIN_TOP_INDEX]; + uint32_t *bits = &style->i.bits[MARGIN_TOP_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MARGIN_TOP_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1681,16 +1568,14 @@ static inline css_error set_margin_top(css_computed_style *style, uint8_t type, #undef MARGIN_TOP_SHIFT #undef MARGIN_TOP_MASK -#define MAX_HEIGHT_INDEX 3 -#define MAX_HEIGHT_SHIFT 25 -#define MAX_HEIGHT_MASK 0xfe000000 +#define MAX_HEIGHT_INDEX 5 +#define MAX_HEIGHT_SHIFT 11 +#define MAX_HEIGHT_MASK 0x3f800 static inline css_error set_max_height(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MAX_HEIGHT_INDEX]; + uint32_t *bits = &style->i.bits[MAX_HEIGHT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MAX_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1704,16 +1589,14 @@ static inline css_error set_max_height(css_computed_style *style, uint8_t type, #undef MAX_HEIGHT_SHIFT #undef MAX_HEIGHT_MASK -#define MAX_WIDTH_INDEX 7 -#define MAX_WIDTH_SHIFT 4 -#define MAX_WIDTH_MASK 0x7f0 +#define MAX_WIDTH_INDEX 5 +#define MAX_WIDTH_SHIFT 18 +#define MAX_WIDTH_MASK 0x1fc0000 static inline css_error set_max_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MAX_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[MAX_WIDTH_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MAX_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << @@ -1727,16 +1610,14 @@ static inline css_error set_max_width(css_computed_style *style, uint8_t type, #undef MAX_WIDTH_SHIFT #undef MAX_WIDTH_MASK -#define MIN_HEIGHT_INDEX 4 -#define MIN_HEIGHT_SHIFT 18 -#define MIN_HEIGHT_MASK 0x1fc0000 +#define MIN_HEIGHT_INDEX 5 +#define MIN_HEIGHT_SHIFT 25 +#define MIN_HEIGHT_MASK 0xfe000000 static inline css_error set_min_height(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MIN_HEIGHT_INDEX]; + uint32_t *bits = &style->i.bits[MIN_HEIGHT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MIN_HEIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -1750,16 +1631,14 @@ static inline css_error set_min_height(css_computed_style *style, uint8_t type, #undef MIN_HEIGHT_SHIFT #undef MIN_HEIGHT_MASK -#define MIN_WIDTH_INDEX 6 -#define MIN_WIDTH_SHIFT 11 -#define MIN_WIDTH_MASK 0x3f800 +#define MIN_WIDTH_INDEX 4 +#define MIN_WIDTH_SHIFT 4 +#define MIN_WIDTH_MASK 0x7f0 static inline css_error set_min_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[MIN_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[MIN_WIDTH_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~MIN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << @@ -1774,15 +1653,13 @@ static inline css_error set_min_width(css_computed_style *style, uint8_t type, #undef MIN_WIDTH_MASK #define OPACITY_INDEX 14 -#define OPACITY_SHIFT 19 -#define OPACITY_MASK 0x80000 +#define OPACITY_SHIFT 24 +#define OPACITY_MASK 0x1000000 static inline css_error set_opacity(css_computed_style *style, uint8_t type, css_fixed fixed) { - uint32_t *bits; - - bits = &style->i.bits[OPACITY_INDEX]; + uint32_t *bits = &style->i.bits[OPACITY_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~OPACITY_MASK) | (((uint32_t)type & 0x1) << @@ -1796,16 +1673,14 @@ static inline css_error set_opacity(css_computed_style *style, uint8_t type, #undef OPACITY_SHIFT #undef OPACITY_MASK -#define ORDER_INDEX 13 -#define ORDER_SHIFT 0 -#define ORDER_MASK 0x1 +#define ORDER_INDEX 14 +#define ORDER_SHIFT 25 +#define ORDER_MASK 0x2000000 static inline css_error set_order(css_computed_style *style, uint8_t type, int32_t integer) { - uint32_t *bits; - - bits = &style->i.bits[ORDER_INDEX]; + uint32_t *bits = &style->i.bits[ORDER_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~ORDER_MASK) | (((uint32_t)type & 0x1) << ORDER_SHIFT); @@ -1819,15 +1694,13 @@ static inline css_error set_order(css_computed_style *style, uint8_t type, #undef ORDER_MASK #define ORPHANS_INDEX 14 -#define ORPHANS_SHIFT 24 -#define ORPHANS_MASK 0x1000000 +#define ORPHANS_SHIFT 26 +#define ORPHANS_MASK 0x4000000 static inline css_error set_orphans(css_computed_style *style, uint8_t type, int32_t integer) { - uint32_t *bits; - - bits = &style->i.bits[ORPHANS_INDEX]; + uint32_t *bits = &style->i.bits[ORPHANS_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~ORPHANS_MASK) | (((uint32_t)type & 0x1) << @@ -1841,16 +1714,14 @@ static inline css_error set_orphans(css_computed_style *style, uint8_t type, #undef ORPHANS_SHIFT #undef ORPHANS_MASK -#define OUTLINE_COLOR_INDEX 11 -#define OUTLINE_COLOR_SHIFT 10 -#define OUTLINE_COLOR_MASK 0xc00 +#define OUTLINE_COLOR_INDEX 10 +#define OUTLINE_COLOR_SHIFT 6 +#define OUTLINE_COLOR_MASK 0xc0 static inline css_error set_outline_color(css_computed_style *style, uint8_t type, css_color color) { - uint32_t *bits; - - bits = &style->i.bits[OUTLINE_COLOR_INDEX]; + uint32_t *bits = &style->i.bits[OUTLINE_COLOR_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~OUTLINE_COLOR_MASK) | (((uint32_t)type & 0x3) << @@ -1864,16 +1735,14 @@ static inline css_error set_outline_color(css_computed_style *style, uint8_t #undef OUTLINE_COLOR_SHIFT #undef OUTLINE_COLOR_MASK -#define OUTLINE_STYLE_INDEX 9 -#define OUTLINE_STYLE_SHIFT 7 -#define OUTLINE_STYLE_MASK 0x780 +#define OUTLINE_STYLE_INDEX 5 +#define OUTLINE_STYLE_SHIFT 0 +#define OUTLINE_STYLE_MASK 0xf static inline css_error set_outline_style(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[OUTLINE_STYLE_INDEX]; + uint32_t *bits = &style->i.bits[OUTLINE_STYLE_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~OUTLINE_STYLE_MASK) | (((uint32_t)type & 0xf) << @@ -1892,9 +1761,7 @@ static inline css_error set_outline_style(css_computed_style *style, uint8_t static inline css_error set_outline_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[OUTLINE_WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[OUTLINE_WIDTH_INDEX]; /* 8bits: uuuuuttt : unit | type */ *bits = (*bits & ~OUTLINE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( @@ -1909,14 +1776,12 @@ static inline css_error set_outline_width(css_computed_style *style, uint8_t #undef OUTLINE_WIDTH_MASK #define OVERFLOW_X_INDEX 13 -#define OVERFLOW_X_SHIFT 16 -#define OVERFLOW_X_MASK 0x70000 +#define OVERFLOW_X_SHIFT 13 +#define OVERFLOW_X_MASK 0xe000 static inline css_error set_overflow_x(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[OVERFLOW_X_INDEX]; + uint32_t *bits = &style->i.bits[OVERFLOW_X_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~OVERFLOW_X_MASK) | (((uint32_t)type & 0x7) << @@ -1929,14 +1794,12 @@ static inline css_error set_overflow_x(css_computed_style *style, uint8_t type) #undef OVERFLOW_X_MASK #define OVERFLOW_Y_INDEX 13 -#define OVERFLOW_Y_SHIFT 25 -#define OVERFLOW_Y_MASK 0xe000000 +#define OVERFLOW_Y_SHIFT 16 +#define OVERFLOW_Y_MASK 0x70000 static inline css_error set_overflow_y(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[OVERFLOW_Y_INDEX]; + uint32_t *bits = &style->i.bits[OVERFLOW_Y_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~OVERFLOW_Y_MASK) | (((uint32_t)type & 0x7) << @@ -1949,15 +1812,13 @@ static inline css_error set_overflow_y(css_computed_style *style, uint8_t type) #undef OVERFLOW_Y_MASK #define PADDING_BOTTOM_INDEX 8 -#define PADDING_BOTTOM_SHIFT 8 -#define PADDING_BOTTOM_MASK 0x3f00 +#define PADDING_BOTTOM_SHIFT 14 +#define PADDING_BOTTOM_MASK 0xfc000 static inline css_error set_padding_bottom(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[PADDING_BOTTOM_INDEX]; + uint32_t *bits = &style->i.bits[PADDING_BOTTOM_INDEX]; /* 6bits: uuuuut : unit | type */ *bits = (*bits & ~PADDING_BOTTOM_MASK) | ((((uint32_t)type & 0x1) | ( @@ -1971,16 +1832,14 @@ static inline css_error set_padding_bottom(css_computed_style *style, uint8_t #undef PADDING_BOTTOM_SHIFT #undef PADDING_BOTTOM_MASK -#define PADDING_LEFT_INDEX 2 -#define PADDING_LEFT_SHIFT 0 -#define PADDING_LEFT_MASK 0x3f +#define PADDING_LEFT_INDEX 8 +#define PADDING_LEFT_SHIFT 20 +#define PADDING_LEFT_MASK 0x3f00000 static inline css_error set_padding_left(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[PADDING_LEFT_INDEX]; + uint32_t *bits = &style->i.bits[PADDING_LEFT_INDEX]; /* 6bits: uuuuut : unit | type */ *bits = (*bits & ~PADDING_LEFT_MASK) | ((((uint32_t)type & 0x1) | (unit @@ -1995,15 +1854,13 @@ static inline css_error set_padding_left(css_computed_style *style, uint8_t #undef PADDING_LEFT_MASK #define PADDING_RIGHT_INDEX 8 -#define PADDING_RIGHT_SHIFT 14 -#define PADDING_RIGHT_MASK 0xfc000 +#define PADDING_RIGHT_SHIFT 26 +#define PADDING_RIGHT_MASK 0xfc000000 static inline css_error set_padding_right(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[PADDING_RIGHT_INDEX]; + uint32_t *bits = &style->i.bits[PADDING_RIGHT_INDEX]; /* 6bits: uuuuut : unit | type */ *bits = (*bits & ~PADDING_RIGHT_MASK) | ((((uint32_t)type & 0x1) | ( @@ -2017,16 +1874,14 @@ static inline css_error set_padding_right(css_computed_style *style, uint8_t #undef PADDING_RIGHT_SHIFT #undef PADDING_RIGHT_MASK -#define PADDING_TOP_INDEX 8 -#define PADDING_TOP_SHIFT 20 -#define PADDING_TOP_MASK 0x3f00000 +#define PADDING_TOP_INDEX 3 +#define PADDING_TOP_SHIFT 5 +#define PADDING_TOP_MASK 0x7e0 static inline css_error set_padding_top(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[PADDING_TOP_INDEX]; + uint32_t *bits = &style->i.bits[PADDING_TOP_INDEX]; /* 6bits: uuuuut : unit | type */ *bits = (*bits & ~PADDING_TOP_MASK) | ((((uint32_t)type & 0x1) | (unit @@ -2040,16 +1895,14 @@ static inline css_error set_padding_top(css_computed_style *style, uint8_t #undef PADDING_TOP_SHIFT #undef PADDING_TOP_MASK -#define PAGE_BREAK_AFTER_INDEX 8 -#define PAGE_BREAK_AFTER_SHIFT 0 -#define PAGE_BREAK_AFTER_MASK 0x7 +#define PAGE_BREAK_AFTER_INDEX 13 +#define PAGE_BREAK_AFTER_SHIFT 19 +#define PAGE_BREAK_AFTER_MASK 0x380000 static inline css_error set_page_break_after(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[PAGE_BREAK_AFTER_INDEX]; + uint32_t *bits = &style->i.bits[PAGE_BREAK_AFTER_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | (((uint32_t)type & 0x7) << @@ -2062,15 +1915,13 @@ static inline css_error set_page_break_after(css_computed_style *style, uint8_t #undef PAGE_BREAK_AFTER_MASK #define PAGE_BREAK_BEFORE_INDEX 13 -#define PAGE_BREAK_BEFORE_SHIFT 7 -#define PAGE_BREAK_BEFORE_MASK 0x380 +#define PAGE_BREAK_BEFORE_SHIFT 22 +#define PAGE_BREAK_BEFORE_MASK 0x1c00000 static inline css_error set_page_break_before(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[PAGE_BREAK_BEFORE_INDEX]; + uint32_t *bits = &style->i.bits[PAGE_BREAK_BEFORE_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | (((uint32_t)type & 0x7) << @@ -2082,16 +1933,14 @@ static inline css_error set_page_break_before(css_computed_style *style, #undef PAGE_BREAK_BEFORE_SHIFT #undef PAGE_BREAK_BEFORE_MASK -#define PAGE_BREAK_INSIDE_INDEX 11 -#define PAGE_BREAK_INSIDE_SHIFT 24 -#define PAGE_BREAK_INSIDE_MASK 0x3000000 +#define PAGE_BREAK_INSIDE_INDEX 10 +#define PAGE_BREAK_INSIDE_SHIFT 8 +#define PAGE_BREAK_INSIDE_MASK 0x300 static inline css_error set_page_break_inside(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[PAGE_BREAK_INSIDE_INDEX]; + uint32_t *bits = &style->i.bits[PAGE_BREAK_INSIDE_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | (((uint32_t)type & 0x3) << @@ -2103,15 +1952,13 @@ static inline css_error set_page_break_inside(css_computed_style *style, #undef PAGE_BREAK_INSIDE_SHIFT #undef PAGE_BREAK_INSIDE_MASK -#define POSITION_INDEX 10 -#define POSITION_SHIFT 20 -#define POSITION_MASK 0x700000 +#define POSITION_INDEX 13 +#define POSITION_SHIFT 25 +#define POSITION_MASK 0xe000000 static inline css_error set_position(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[POSITION_INDEX]; + uint32_t *bits = &style->i.bits[POSITION_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~POSITION_MASK) | (((uint32_t)type & 0x7) << @@ -2124,15 +1971,13 @@ static inline css_error set_position(css_computed_style *style, uint8_t type) #undef POSITION_MASK #define QUOTES_INDEX 14 -#define QUOTES_SHIFT 21 -#define QUOTES_MASK 0x200000 +#define QUOTES_SHIFT 27 +#define QUOTES_MASK 0x8000000 static inline css_error set_quotes(css_computed_style *style, uint8_t type, lwc_string **string_arr) { - uint32_t *bits; - - bits = &style->i.bits[QUOTES_INDEX]; + uint32_t *bits = &style->i.bits[QUOTES_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~QUOTES_MASK) | (((uint32_t)type & 0x1) << @@ -2161,16 +2006,14 @@ static inline css_error set_quotes(css_computed_style *style, uint8_t type, #undef QUOTES_SHIFT #undef QUOTES_MASK -#define RIGHT_INDEX 3 -#define RIGHT_SHIFT 18 -#define RIGHT_MASK 0x1fc0000 +#define RIGHT_INDEX 4 +#define RIGHT_SHIFT 11 +#define RIGHT_MASK 0x3f800 static inline css_error set_right(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[RIGHT_INDEX]; + uint32_t *bits = &style->i.bits[RIGHT_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~RIGHT_MASK) | ((((uint32_t)type & 0x3) | (unit << 2)) @@ -2184,16 +2027,35 @@ static inline css_error set_right(css_computed_style *style, uint8_t type, #undef RIGHT_SHIFT #undef RIGHT_MASK +#define STROKE_OPACITY_INDEX 13 +#define STROKE_OPACITY_SHIFT 0 +#define STROKE_OPACITY_MASK 0x1 + +static inline css_error set_stroke_opacity(css_computed_style *style, uint8_t + type, css_fixed fixed) +{ + uint32_t *bits = &style->i.bits[STROKE_OPACITY_INDEX]; + + /* 1bit: t : type */ + *bits = (*bits & ~STROKE_OPACITY_MASK) | (((uint32_t)type & 0x1) << + STROKE_OPACITY_SHIFT); + + style->i.stroke_opacity = fixed; + + return CSS_OK; +} +#undef STROKE_OPACITY_INDEX +#undef STROKE_OPACITY_SHIFT +#undef STROKE_OPACITY_MASK + #define TABLE_LAYOUT_INDEX 10 -#define TABLE_LAYOUT_SHIFT 14 -#define TABLE_LAYOUT_MASK 0xc000 +#define TABLE_LAYOUT_SHIFT 10 +#define TABLE_LAYOUT_MASK 0xc00 static inline css_error set_table_layout(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[TABLE_LAYOUT_INDEX]; + uint32_t *bits = &style->i.bits[TABLE_LAYOUT_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~TABLE_LAYOUT_MASK) | (((uint32_t)type & 0x3) << @@ -2211,9 +2073,7 @@ static inline css_error set_table_layout(css_computed_style *style, uint8_t static inline css_error set_text_align(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[TEXT_ALIGN_INDEX]; + uint32_t *bits = &style->i.bits[TEXT_ALIGN_INDEX]; /* 4bits: tttt : type */ *bits = (*bits & ~TEXT_ALIGN_MASK) | (((uint32_t)type & 0xf) << @@ -2225,16 +2085,14 @@ static inline css_error set_text_align(css_computed_style *style, uint8_t type) #undef TEXT_ALIGN_SHIFT #undef TEXT_ALIGN_MASK -#define TEXT_DECORATION_INDEX 8 -#define TEXT_DECORATION_SHIFT 3 -#define TEXT_DECORATION_MASK 0xf8 +#define TEXT_DECORATION_INDEX 3 +#define TEXT_DECORATION_SHIFT 0 +#define TEXT_DECORATION_MASK 0x1f static inline css_error set_text_decoration(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[TEXT_DECORATION_INDEX]; + uint32_t *bits = &style->i.bits[TEXT_DECORATION_INDEX]; /* 5bits: ttttt : type */ *bits = (*bits & ~TEXT_DECORATION_MASK) | (((uint32_t)type & 0x1f) << @@ -2246,16 +2104,14 @@ static inline css_error set_text_decoration(css_computed_style *style, uint8_t #undef TEXT_DECORATION_SHIFT #undef TEXT_DECORATION_MASK -#define TEXT_INDENT_INDEX 3 -#define TEXT_INDENT_SHIFT 5 -#define TEXT_INDENT_MASK 0x7e0 +#define TEXT_INDENT_INDEX 2 +#define TEXT_INDENT_SHIFT 0 +#define TEXT_INDENT_MASK 0x3f static inline css_error set_text_indent(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[TEXT_INDENT_INDEX]; + uint32_t *bits = &style->i.bits[TEXT_INDENT_INDEX]; /* 6bits: uuuuut : unit | type */ *bits = (*bits & ~TEXT_INDENT_MASK) | ((((uint32_t)type & 0x1) | (unit @@ -2269,16 +2125,14 @@ static inline css_error set_text_indent(css_computed_style *style, uint8_t #undef TEXT_INDENT_SHIFT #undef TEXT_INDENT_MASK -#define TEXT_TRANSFORM_INDEX 13 -#define TEXT_TRANSFORM_SHIFT 13 -#define TEXT_TRANSFORM_MASK 0xe000 +#define TEXT_TRANSFORM_INDEX 9 +#define TEXT_TRANSFORM_SHIFT 0 +#define TEXT_TRANSFORM_MASK 0x7 static inline css_error set_text_transform(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[TEXT_TRANSFORM_INDEX]; + uint32_t *bits = &style->i.bits[TEXT_TRANSFORM_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~TEXT_TRANSFORM_MASK) | (((uint32_t)type & 0x7) << @@ -2290,16 +2144,14 @@ static inline css_error set_text_transform(css_computed_style *style, uint8_t #undef TEXT_TRANSFORM_SHIFT #undef TEXT_TRANSFORM_MASK -#define TOP_INDEX 7 -#define TOP_SHIFT 25 -#define TOP_MASK 0xfe000000 +#define TOP_INDEX 4 +#define TOP_SHIFT 18 +#define TOP_MASK 0x1fc0000 static inline css_error set_top(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[TOP_INDEX]; + uint32_t *bits = &style->i.bits[TOP_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~TOP_MASK) | ((((uint32_t)type & 0x3) | (unit << 2)) @@ -2313,16 +2165,14 @@ static inline css_error set_top(css_computed_style *style, uint8_t type, #undef TOP_SHIFT #undef TOP_MASK -#define UNICODE_BIDI_INDEX 11 -#define UNICODE_BIDI_SHIFT 2 -#define UNICODE_BIDI_MASK 0xc +#define UNICODE_BIDI_INDEX 10 +#define UNICODE_BIDI_SHIFT 12 +#define UNICODE_BIDI_MASK 0x3000 static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[UNICODE_BIDI_INDEX]; + uint32_t *bits = &style->i.bits[UNICODE_BIDI_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~UNICODE_BIDI_MASK) | (((uint32_t)type & 0x3) << @@ -2334,16 +2184,14 @@ static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t #undef UNICODE_BIDI_SHIFT #undef UNICODE_BIDI_MASK -#define VERTICAL_ALIGN_INDEX 1 -#define VERTICAL_ALIGN_SHIFT 23 -#define VERTICAL_ALIGN_MASK 0xff800000 +#define VERTICAL_ALIGN_INDEX 12 +#define VERTICAL_ALIGN_SHIFT 1 +#define VERTICAL_ALIGN_MASK 0x3fe static inline css_error set_vertical_align(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[VERTICAL_ALIGN_INDEX]; + uint32_t *bits = &style->i.bits[VERTICAL_ALIGN_INDEX]; /* 9bits: uuuuutttt : unit | type */ *bits = (*bits & ~VERTICAL_ALIGN_MASK) | ((((uint32_t)type & 0xf) | ( @@ -2357,15 +2205,13 @@ static inline css_error set_vertical_align(css_computed_style *style, uint8_t #undef VERTICAL_ALIGN_SHIFT #undef VERTICAL_ALIGN_MASK -#define VISIBILITY_INDEX 11 -#define VISIBILITY_SHIFT 0 -#define VISIBILITY_MASK 0x3 +#define VISIBILITY_INDEX 10 +#define VISIBILITY_SHIFT 14 +#define VISIBILITY_MASK 0xc000 static inline css_error set_visibility(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[VISIBILITY_INDEX]; + uint32_t *bits = &style->i.bits[VISIBILITY_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~VISIBILITY_MASK) | (((uint32_t)type & 0x3) << @@ -2377,15 +2223,13 @@ static inline css_error set_visibility(css_computed_style *style, uint8_t type) #undef VISIBILITY_SHIFT #undef VISIBILITY_MASK -#define WHITE_SPACE_INDEX 13 -#define WHITE_SPACE_SHIFT 19 -#define WHITE_SPACE_MASK 0x380000 +#define WHITE_SPACE_INDEX 8 +#define WHITE_SPACE_SHIFT 0 +#define WHITE_SPACE_MASK 0x7 static inline css_error set_white_space(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[WHITE_SPACE_INDEX]; + uint32_t *bits = &style->i.bits[WHITE_SPACE_INDEX]; /* 3bits: ttt : type */ *bits = (*bits & ~WHITE_SPACE_MASK) | (((uint32_t)type & 0x7) << @@ -2397,16 +2241,14 @@ static inline css_error set_white_space(css_computed_style *style, uint8_t type) #undef WHITE_SPACE_SHIFT #undef WHITE_SPACE_MASK -#define WIDOWS_INDEX 14 -#define WIDOWS_SHIFT 26 -#define WIDOWS_MASK 0x4000000 +#define WIDOWS_INDEX 12 +#define WIDOWS_SHIFT 0 +#define WIDOWS_MASK 0x1 static inline css_error set_widows(css_computed_style *style, uint8_t type, int32_t integer) { - uint32_t *bits; - - bits = &style->i.bits[WIDOWS_INDEX]; + uint32_t *bits = &style->i.bits[WIDOWS_INDEX]; /* 1bit: t : type */ *bits = (*bits & ~WIDOWS_MASK) | (((uint32_t)type & 0x1) << @@ -2420,16 +2262,14 @@ static inline css_error set_widows(css_computed_style *style, uint8_t type, #undef WIDOWS_SHIFT #undef WIDOWS_MASK -#define WIDTH_INDEX 3 -#define WIDTH_SHIFT 11 -#define WIDTH_MASK 0x3f800 +#define WIDTH_INDEX 4 +#define WIDTH_SHIFT 25 +#define WIDTH_MASK 0xfe000000 static inline css_error set_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[WIDTH_INDEX]; + uint32_t *bits = &style->i.bits[WIDTH_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit << 2)) @@ -2443,16 +2283,14 @@ static inline css_error set_width(css_computed_style *style, uint8_t type, #undef WIDTH_SHIFT #undef WIDTH_MASK -#define WORD_SPACING_INDEX 5 -#define WORD_SPACING_SHIFT 4 -#define WORD_SPACING_MASK 0x7f0 +#define WORD_SPACING_INDEX 1 +#define WORD_SPACING_SHIFT 0 +#define WORD_SPACING_MASK 0x7f static inline css_error set_word_spacing(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) { - uint32_t *bits; - - bits = &style->i.bits[WORD_SPACING_INDEX]; + uint32_t *bits = &style->i.bits[WORD_SPACING_INDEX]; /* 7bits: uuuuutt : unit | type */ *bits = (*bits & ~WORD_SPACING_MASK) | ((((uint32_t)type & 0x3) | (unit @@ -2466,16 +2304,14 @@ static inline css_error set_word_spacing(css_computed_style *style, uint8_t #undef WORD_SPACING_SHIFT #undef WORD_SPACING_MASK -#define WRITING_MODE_INDEX 14 -#define WRITING_MODE_SHIFT 30 -#define WRITING_MODE_MASK 0xc0000000 +#define WRITING_MODE_INDEX 10 +#define WRITING_MODE_SHIFT 16 +#define WRITING_MODE_MASK 0x30000 static inline css_error set_writing_mode(css_computed_style *style, uint8_t type) { - uint32_t *bits; - - bits = &style->i.bits[WRITING_MODE_INDEX]; + uint32_t *bits = &style->i.bits[WRITING_MODE_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~WRITING_MODE_MASK) | (((uint32_t)type & 0x3) << @@ -2488,15 +2324,13 @@ static inline css_error set_writing_mode(css_computed_style *style, uint8_t #undef WRITING_MODE_MASK #define Z_INDEX_INDEX 10 -#define Z_INDEX_SHIFT 8 -#define Z_INDEX_MASK 0x300 +#define Z_INDEX_SHIFT 18 +#define Z_INDEX_MASK 0xc0000 static inline css_error set_z_index(css_computed_style *style, uint8_t type, int32_t integer) { - uint32_t *bits; - - bits = &style->i.bits[Z_INDEX_INDEX]; + uint32_t *bits = &style->i.bits[Z_INDEX_INDEX]; /* 2bits: tt : type */ *bits = (*bits & ~Z_INDEX_MASK) | (((uint32_t)type & 0x3) << diff --git a/src/select/computed.c b/src/select/computed.c index 89d6efb..78f3b80 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -810,6 +810,18 @@ uint8_t css_computed_opacity(const css_computed_style *style, return get_opacity(style, opacity); } +uint8_t css_computed_fill_opacity(const css_computed_style *style, + css_fixed *fill_opacity) +{ + return get_fill_opacity(style, fill_opacity); +} + +uint8_t css_computed_stroke_opacity(const css_computed_style *style, + css_fixed *stroke_opacity) +{ + return get_stroke_opacity(style, stroke_opacity); +} + uint8_t css_computed_text_transform(const css_computed_style *style) { return get_text_transform(style); @@ -926,6 +938,8 @@ uint8_t css_computed_display(const css_computed_style *style, return CSS_DISPLAY_TABLE; } else if (display == CSS_DISPLAY_INLINE_FLEX) { return CSS_DISPLAY_FLEX; + } else if (display == CSS_DISPLAY_INLINE_GRID) { + return CSS_DISPLAY_GRID; } else if (display == CSS_DISPLAY_INLINE || display == CSS_DISPLAY_RUN_IN || display == CSS_DISPLAY_TABLE_ROW_GROUP || diff --git a/src/select/dispatch.c b/src/select/dispatch.c index a6c868d..cee9335 100644 --- a/src/select/dispatch.c +++ b/src/select/dispatch.c @@ -514,5 +514,13 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = { { PROPERTY_FUNCS(order), 0, + }, + { + PROPERTY_FUNCS(fill_opacity), + 1, + }, + { + PROPERTY_FUNCS(stroke_opacity), + 1, } }; diff --git a/src/select/overrides.py b/src/select/overrides.py index b4d349a..869d6ec 100644 --- a/src/select/overrides.py +++ b/src/select/overrides.py @@ -183,35 +183,3 @@ static inline css_error set_content( return CSS_OK; }''' - -get_side = '''\ -static inline uint8_t get_{0}( - const css_computed_style *style, - css_fixed *length, css_unit *unit) -{{ - uint32_t bits = style->i.bits[{1}_INDEX]; - bits &= {1}_MASK; - bits >>= {1}_SHIFT; - - /* 7bits: uuuuutt : units | type */ - if ((bits & 0x3) == CSS_{1}_SET) {{ - *length = style->i.{0}; - *unit = bits >> 2; - }} - - return (bits & 0x3); -}} -static inline uint8_t get_{0}_bits( - const css_computed_style *style) -{{ - uint32_t bits = style->i.bits[{1}_INDEX]; - bits &= {1}_MASK; - bits >>= {1}_SHIFT; - - /* 7bits: uuuuutt : units | type */ - return bits; -}}''' -overrides['get']['top'] = get_side.format('top', 'TOP') -overrides['get']['right'] = get_side.format('right', 'RIGHT') -overrides['get']['bottom'] = get_side.format('bottom', 'BOTTOM') -overrides['get']['left'] = get_side.format('left', 'LEFT') diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile index 6c6cf84..eee6cc3 100644 --- a/src/select/properties/Makefile +++ b/src/select/properties/Makefile @@ -50,6 +50,7 @@ direction.c \ display.c \ elevation.c \ empty_cells.c \ +fill_opacity.c \ flex_basis.c \ flex_direction.c \ flex_grow.c \ @@ -107,6 +108,7 @@ speak_header.c \ speak_numeral.c \ speak_punctuation.c \ stress.c \ +stroke_opacity.c \ table_layout.c \ text_align.c \ text_decoration.c \ diff --git a/src/select/properties/display.c b/src/select/properties/display.c index bfe0a5f..5455d20 100644 --- a/src/select/properties/display.c +++ b/src/select/properties/display.c @@ -77,6 +77,12 @@ css_error css__cascade_display(uint32_t opv, css_style *style, case DISPLAY_INLINE_FLEX: value = CSS_DISPLAY_INLINE_FLEX; break; + case DISPLAY_GRID: + value = CSS_DISPLAY_GRID; + break; + case DISPLAY_INLINE_GRID: + value = CSS_DISPLAY_INLINE_GRID; + break; } } diff --git a/src/select/properties/fill_opacity.c b/src/select/properties/fill_opacity.c new file mode 100644 index 0000000..af0b52b --- /dev/null +++ b/src/select/properties/fill_opacity.c @@ -0,0 +1,73 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#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_fill_opacity(uint32_t opv, css_style *style, + css_select_state *state) +{ + uint16_t value = CSS_FILL_OPACITY_INHERIT; + css_fixed fill_opacity = 0; + + if (hasFlagValue(opv) == false) { + value = CSS_FILL_OPACITY_SET; + + fill_opacity = *((css_fixed *) style->bytecode); + advance_bytecode(style, sizeof(fill_opacity)); + } + + if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, + getFlagValue(opv))) { + return set_fill_opacity(state->computed, value, fill_opacity); + } + + return CSS_OK; +} + +css_error css__set_fill_opacity_from_hint(const css_hint *hint, + css_computed_style *style) +{ + return set_fill_opacity(style, hint->status, hint->data.fixed); +} + +css_error css__initial_fill_opacity(css_select_state *state) +{ + return set_fill_opacity(state->computed, CSS_FILL_OPACITY_SET, INTTOFIX(1)); +} + +css_error css__copy_fill_opacity( + const css_computed_style *from, + css_computed_style *to) +{ + css_fixed fill_opacity = 0; + uint8_t type = get_fill_opacity(from, &fill_opacity); + + if (from == to) { + return CSS_OK; + } + + return set_fill_opacity(to, type, fill_opacity); +} + +css_error css__compose_fill_opacity(const css_computed_style *parent, + const css_computed_style *child, + css_computed_style *result) +{ + css_fixed fill_opacity = 0; + uint8_t type = get_fill_opacity(child, &fill_opacity); + + return css__copy_fill_opacity( + type == CSS_FILL_OPACITY_INHERIT ? parent : child, + result); +} + diff --git a/src/select/properties/opacity.c b/src/select/properties/opacity.c index 818af62..3e875f9 100644 --- a/src/select/properties/opacity.c +++ b/src/select/properties/opacity.c @@ -21,7 +21,7 @@ css_error css__cascade_opacity(uint32_t opv, css_style *style, css_fixed opacity = 0; if (hasFlagValue(opv) == false) { - value = CSS_Z_INDEX_SET; + value = CSS_OPACITY_SET; opacity = *((css_fixed *) style->bytecode); advance_bytecode(style, sizeof(opacity)); diff --git a/src/select/properties/position.c b/src/select/properties/position.c index 738dbff..cc4b3e7 100644 --- a/src/select/properties/position.c +++ b/src/select/properties/position.c @@ -35,6 +35,9 @@ css_error css__cascade_position(uint32_t opv, css_style *style, case POSITION_FIXED: value = CSS_POSITION_FIXED; break; + case POSITION_STICKY: + value = CSS_POSITION_STICKY; + break; } } diff --git a/src/select/properties/properties.h b/src/select/properties/properties.h index be31d0b..cb0b213 100644 --- a/src/select/properties/properties.h +++ b/src/select/properties/properties.h @@ -72,6 +72,7 @@ PROPERTY_FUNCS(direction); PROPERTY_FUNCS(display); PROPERTY_FUNCS(elevation); PROPERTY_FUNCS(empty_cells); +PROPERTY_FUNCS(fill_opacity); PROPERTY_FUNCS(flex_basis); PROPERTY_FUNCS(flex_direction); PROPERTY_FUNCS(flex_grow); @@ -129,6 +130,7 @@ PROPERTY_FUNCS(speak_punctuation); PROPERTY_FUNCS(speak); PROPERTY_FUNCS(speech_rate); PROPERTY_FUNCS(stress); +PROPERTY_FUNCS(stroke_opacity); PROPERTY_FUNCS(table_layout); PROPERTY_FUNCS(text_align); PROPERTY_FUNCS(text_decoration); diff --git a/src/select/properties/stroke_opacity.c b/src/select/properties/stroke_opacity.c new file mode 100644 index 0000000..c27e127 --- /dev/null +++ b/src/select/properties/stroke_opacity.c @@ -0,0 +1,73 @@ +/* + * This file is part of LibCSS + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#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_stroke_opacity(uint32_t opv, css_style *style, + css_select_state *state) +{ + uint16_t value = CSS_STROKE_OPACITY_INHERIT; + css_fixed stroke_opacity = 0; + + if (hasFlagValue(opv) == false) { + value = CSS_STROKE_OPACITY_SET; + + stroke_opacity = *((css_fixed *) style->bytecode); + advance_bytecode(style, sizeof(stroke_opacity)); + } + + if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, + getFlagValue(opv))) { + return set_stroke_opacity(state->computed, value, stroke_opacity); + } + + return CSS_OK; +} + +css_error css__set_stroke_opacity_from_hint(const css_hint *hint, + css_computed_style *style) +{ + return set_stroke_opacity(style, hint->status, hint->data.fixed); +} + +css_error css__initial_stroke_opacity(css_select_state *state) +{ + return set_stroke_opacity(state->computed, CSS_STROKE_OPACITY_SET, INTTOFIX(1)); +} + +css_error css__copy_stroke_opacity( + const css_computed_style *from, + css_computed_style *to) +{ + css_fixed stroke_opacity = 0; + uint8_t type = get_stroke_opacity(from, &stroke_opacity); + + if (from == to) { + return CSS_OK; + } + + return set_stroke_opacity(to, type, stroke_opacity); +} + +css_error css__compose_stroke_opacity(const css_computed_style *parent, + const css_computed_style *child, + css_computed_style *result) +{ + css_fixed stroke_opacity = 0; + uint8_t type = get_stroke_opacity(child, &stroke_opacity); + + return css__copy_stroke_opacity( + type == CSS_STROKE_OPACITY_INHERIT ? parent : child, + result); +} + diff --git a/src/select/select.c b/src/select/select.c index f7dc098..da0aa61 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -53,6 +53,8 @@ struct css_select_ctx { void *pw; /**< Client's private selection context */ + bool uses_revert; /**< A sheet used revert property value */ + css_select_strings str; /* Interned default style */ @@ -355,6 +357,8 @@ css_error css_select_ctx_insert_sheet(css_select_ctx *ctx, ctx->sheets[index].origin = origin; ctx->sheets[index].media = mq; + ctx->uses_revert |= sheet->uses_revert; + ctx->n_sheets++; return CSS_OK; @@ -1157,6 +1161,14 @@ static css_error css__select_revert_property_to_origin( { css_error error; + if (select_state->results->styles[pseudo] == NULL) { + return CSS_OK; + } + + if (select_state->revert[origin].style[pseudo] == NULL) { + return prop_dispatch[property].initial(select_state); + } + error = prop_dispatch[property].copy( select_state->revert[origin].style[pseudo], select_state->results->styles[pseudo]); @@ -1289,10 +1301,14 @@ css_error css_select_style(css_select_ctx *ctx, void *node, #endif /* Not sharing; need to select. */ - state.revert = calloc(CSS_ORIGIN_AUTHOR, sizeof(*state.revert)); - if (state.revert == NULL) { - error = CSS_NOMEM; - goto cleanup; + if (ctx->uses_revert || + (inline_style != NULL && inline_style->uses_revert)) { + /* Need to track UA and USER origin styles for revert. */ + state.revert = calloc(CSS_ORIGIN_AUTHOR, sizeof(*state.revert)); + if (state.revert == NULL) { + error = CSS_NOMEM; + goto cleanup; + } } /* Base element style is guaranteed to exist @@ -1326,7 +1342,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node, for (i = 0; i < ctx->n_sheets; i++) { const css_select_sheet s = ctx->sheets[i]; - if (s.origin != origin) { + if (state.revert != NULL && s.origin != origin) { for (j = 0; j < CSS_PSEUDO_ELEMENT_COUNT; j++) { if (state.results->styles[j] == NULL) { continue; diff --git a/src/select/select_config.py b/src/select/select_config.py index fd9e765..1cfe05c 100644 --- a/src/select/select_config.py +++ b/src/select/select_config.py @@ -95,6 +95,8 @@ style = { ('min_height', 2, 'length', 'CSS_MIN_HEIGHT_SET'), ('min_width', 2, 'length', 'CSS_MIN_WIDTH_SET'), ('opacity', 1, 'fixed', 'CSS_OPACITY_SET'), + ('fill_opacity', 1, 'fixed', 'CSS_FILL_OPACITY_SET'), + ('stroke_opacity', 1, 'fixed', 'CSS_STROKE_OPACITY_SET'), ('order', 1, 'integer', 'CSS_ORDER_SET'), ('padding_top', 1, 'length', 'CSS_PADDING_SET'), ('padding_right', 1, 'length', 'CSS_PADDING_SET'), diff --git a/src/select/select_generator.py b/src/select/select_generator.py index 2d6afe8..9e92909 100644 --- a/src/select/select_generator.py +++ b/src/select/select_generator.py @@ -29,8 +29,8 @@ def shift_star(value_type, prop_name): `lwc_string **str_array` """ star_i = value_type.find('*') - v_type = value_type if star_i is -1 else value_type[:star_i] - v_name = prop_name if star_i is -1 else value_type[star_i:] + prop_name + v_type = value_type if star_i == -1 else value_type[:star_i] + v_name = prop_name if star_i == -1 else value_type[star_i:] + prop_name return (v_type, v_name) class Text: @@ -233,7 +233,7 @@ class CSSProperty: for x in values: if x[0] == v[0]: value = CSSValue(*x) - if len(v) is 2: + if len(v) == 2: value.defaults = v[1] if len(vals) > 1: value.suffix = '_' + string.ascii_lowercase[i] @@ -322,18 +322,16 @@ class CSSProperty: """ vals = [] for v in self.values: + star = '*' if pointer else '' vt, vn = shift_star(v.type, v.name) - vn += v.suffix + vn = star + vn + v.suffix if pointer: - vn = '*' + vn if v.name == 'counter_arr' or v.name == 'content_item': vt = 'const ' + vt vals.append((vt, vn)) if v.bits is not None: - bt, bn = shift_star(v.bits['type'], v.bits['name']) - bn += v.suffix - if pointer: - bn = '*' + bn + bt = v.bits['type'] + bn = star + v.bits['name'] + v.suffix vals.append((bt, bn)) return vals @@ -348,7 +346,7 @@ class CSSProperty: bits_len = sum([ x['size'] for x in bits ]) comment = '/* {}bit{}: {} : {} */'.format( bits_len, - ('' if bits_len is 1 else 's'), + ('' if bits_len == 1 else 's'), ''.join([ b['letter'] * b['size'] for b in bits ]), ' | '.join([ b['name'] for b in bits ])) rev_bits = list(reversed(bits)) @@ -406,7 +404,7 @@ class CSSGroup: bin_size = 32 # We're using uint32_t as concrete bins. bits_array = [] - props = sorted(self.props, key=(lambda x: x.bits_size), reverse=True) + props = sorted(self.props, key=(lambda x: (x.bits_size, x.name)), reverse=True) for p in props: for b in bits_array: @@ -429,21 +427,12 @@ class CSSGroup: return bits_array - def get_idot_grp(self): - """Make parameters for accessing bits and values in this group.""" - i_dot = '' if self.name is 'page' else 'i.' - grp = '' if self.name is 'style' else '->{}{}'.format( - '' if self.name is 'page' else i_dot, self.name) - return (i_dot, grp) - def make_computed_h(self): """Output this group's text for the computed.h file.""" t = Text() t.append() - typedef = 'typedef ' if self.name is 'page' else '' - t.append('{}struct css_computed_{}{} {{'.format( - typedef, self.name, '' if self.name is 'page' else '_i')) + t.append('struct css_computed_style_i {') t.comment() commented = [] @@ -490,103 +479,28 @@ class CSSGroup: t.append() t.append(self.make_value_declaration(for_commented=False)) - if self.name is 'style': - t.append() - for g in css_groups: - if g.name is not 'style' and g.name is not 'page': - t.append('css_computed_{0} *{0};'.format(g.name)) - t.indent(-1) - t.append('}}{};'.format( - ' css_computed_' + self.name if typedef else '')) + t.append('};') - if self.name is not 'page': - typedef = 'typedef ' if self.name is not 'style' else '' - t.append() - t.append('{}struct css_computed_{} {{'.format( - typedef, self.name)) - t.indent(1) - t.append('struct css_computed_' + self.name + '_i i;') - t.append() - t.append(self.make_value_declaration(for_commented=True)) - t.append() + t.append() + t.append('struct css_computed_style {') + t.indent(1) + t.append('struct css_computed_style_i i;') + t.append() + t.append(self.make_value_declaration(for_commented=True)) + t.append() - t.append('struct css_computed_' + self.name + ' *next;') - t.append('uint32_t count;') - t.append('uint32_t bin;') - t.indent(-1) - t.append('}}{};'.format( - ' css_computed_' + self.name if typedef else '')) + t.append('struct css_computed_style *next;') + t.append('uint32_t count;') + t.append('uint32_t bin;') + t.indent(-1) + t.append('};') return t.to_string() def make_propset_h(self): - """Output this group's property functions for the propset.h file. - - If group is not `style`, will also output the defaults - and the ENSURE_{group} texts. - """ + """Output this group's property functions for the propset.h file.""" t = Text() - i_dot, grp = self.get_idot_grp() - - if self.name is not 'style': - t.append('static const css_computed_{0} default_{0} = {{'.format( - self.name)) - t.indent(1) - - if self.name is not 'page': - t.append('.i = {') - t.indent(1) - - t.append('.bits = {') - t.indent(1) - - bits_ops = [] - for b in self.bits_array: - or_ops = [] - for p in b.contents: - or_ops.append('({} << {})'.format(p.defaults, str(p.shift)) - if p.shift else p.defaults) - bits_ops.append(' | '.join(or_ops)) - - t.append(',\n'.join(bits_ops).split('\n')) - t.indent(-1) - t.append('},') - t.append(',\n'.join( - self.make_value_declaration(False, True)).split('\n')) - - if self.name is not 'page': - t.indent(-1) - t.append('},') - t.append(',\n'.join( - self.make_value_declaration(True, True) + - [ '.next = NULL', '.count = 0', '.bin = UINT32_MAX' ] - ).split('\n')) - - t.indent(-1) - t.append('};') - - t.append() - t.escape_newline() - t.append('#define ENSURE_{} do {{'.format(self.name.upper())) - t.indent(1) - t.append('if (style->{}{} == NULL) {{'.format(i_dot, self.name)) - t.indent(1) - t.append('style->{}{n} = malloc(sizeof(css_computed_{n}));'.format( - i_dot, n=self.name)) - t.append('if (style->{}{} == NULL)'.format(i_dot, self.name)) - t.indent(1) - t.append('return CSS_NOMEM;') - t.indent(-1) - t.append() - t.append('memcpy(style->{}{n}, &default_{n}, ' - 'sizeof(css_computed_{n}));'.format(i_dot, n=self.name)) - t.indent(-1) - t.append('}') - t.indent(-1) - t.append('} while(0)') - t.escape_newline() - t.append() for p in sorted(self.props, key=(lambda x: x.name)): defines, undefs = p.def_undefs @@ -608,15 +522,7 @@ class CSSGroup: t.append('{') t.indent(1) - t.append('uint32_t *bits;') - t.append() - - if self.name is not 'style': - t.append('ENSURE_{};'.format(self.name.upper())) - t.append() - - t.append('bits = &style{}->{}bits[{}_INDEX];'.format( - grp, i_dot, p.name.upper())) + t.append('uint32_t *bits = &style->i.bits[{}_INDEX];'.format(p.name.upper())) t.append() type_mask, shift_list, bits_comment = p.get_bits() @@ -636,20 +542,18 @@ class CSSGroup: old_n = 'old_' + v.name + v.suffix old_t, old_n_shift = shift_star(v.type, old_n) - if v.name is 'string': - t.append('{} {} = style{}->{}{};'.format( - old_t, old_n_shift, - grp, i_dot, p.name + v.suffix)) + if v.name == 'string': + t.append('{} {} = style->i.{};'.format( + old_t, old_n_shift, p.name + v.suffix)) t.append() t.append('if ({} != NULL) {{'.format(v.name + v.suffix)) t.indent(1) - t.append('style{}->{}{} = lwc_string_ref({});'.format( - grp, i_dot, p.name + v.suffix, v.name + v.suffix)) + t.append('style->i.{} = lwc_string_ref({});'.format( + p.name + v.suffix, v.name + v.suffix)) t.indent(-1) t.append('} else {') t.indent(1) - t.append('style{}->{}{} = NULL;'.format( - grp, i_dot, p.name + v.suffix)) + t.append('style->i.{} = NULL;'.format(p.name + v.suffix)) t.indent(-1) t.append('}') t.append() @@ -658,12 +562,12 @@ class CSSGroup: t.append('lwc_string_unref({});'.format(old_n)) t.indent(-1) - elif v.name is 'string_arr' or v.name is 'counter_arr': - iter_var = 's' if v.name is 'string_arr' else 'c' - iter_deref = '*s' if v.name is 'string_arr' else 'c->name' - t.append('{} {} = style{}->{};'.format( + elif v.name == 'string_arr' or v.name == 'counter_arr': + iter_var = 's' if v.name == 'string_arr' else 'c' + iter_deref = '*s' if v.name == 'string_arr' else 'c->name' + t.append('{} {} = style->{};'.format( old_t, old_n_shift, - grp, p.name + v.suffix)) + p.name + v.suffix)) t.append('{} {};'.format(old_t, shift_star(v.type, iter_var)[1])) t.append() @@ -674,8 +578,8 @@ class CSSGroup: t.append('{0} = lwc_string_ref({0});'.format(iter_deref)) t.indent(-1) t.append() - t.append('style{}->{} = {};'.format( - grp, p.name + v.suffix, v.name + v.suffix)) + t.append('style->{} = {};'.format( + p.name + v.suffix, v.name + v.suffix)) t.append() t.append('/* Free existing array */') t.append('if ({} != NULL) {{'.format(old_n)) @@ -693,8 +597,8 @@ class CSSGroup: t.append('}') elif not v.is_ptr: - t.append('style{}->{}{} = {};'.format( - grp, i_dot, p.name + v.suffix, v.name + v.suffix)) + t.append('style->i.{} = {};'.format( + p.name + v.suffix, v.name + v.suffix)) else: raise ValueError('Cannot handle value ' + v.name +'!') @@ -707,54 +611,38 @@ class CSSGroup: return t.to_string() - def make_propget_h(self): - """Output this group's property functions for the propget.h file.""" - t = Text() - i_dot, grp = self.get_idot_grp() - - for p in sorted(self.props, key=(lambda x: x.name)): - defines, undefs = p.def_undefs - - t.append() - t.append(defines) - - if p.name in overrides['get']: - t.append(overrides['get'][p.name], pre_formatted=True) - t.append(undefs) - continue + def print_propget(self, t, p, only_bits=False): + vals = [] if only_bits else p.get_param_values(pointer=True) + params = ', '.join([ 'css_computed_style *style' ] + + [ ' '.join(x) for x in vals ]) - vals = p.get_param_values(pointer=True) - params = ', '.join([ 'css_computed_style *style' ] - + [ ' '.join(x) for x in vals ]) - t.append('static inline uint8_t get_{}(const {})'.format( - p.name, params)) - t.append('{') - t.indent(1) - - if self.name is not 'style': - t.append('if (style{} != NULL) {{'.format(grp)) - t.indent(1) + underscore_bits = '_bits' if only_bits else '' + t.append('static inline uint8_t get_{}{}(const {})'.format( + p.name, underscore_bits, params)) + t.append('{') + t.indent(1) - t.append('uint32_t bits = style{}->{}bits[{}_INDEX];'.format( - grp, i_dot, p.name.upper())) - t.append('bits &= {}_MASK;'.format(p.name.upper())) - t.append('bits >>= {}_SHIFT;'.format(p.name.upper())) - t.append() + t.append('uint32_t bits = style->i.bits[{}_INDEX];'.format( + p.name.upper())) + t.append('bits &= {}_MASK;'.format(p.name.upper())) + t.append('bits >>= {}_SHIFT;'.format(p.name.upper())) + t.append() - type_mask, shift_list, bits_comment = p.get_bits() - t.append(bits_comment) + type_mask, shift_list, bits_comment = p.get_bits() + t.append(bits_comment) + if only_bits == False: if p.condition: t.append('if ((bits & {}) == {}) {{'.format( type_mask, p.condition)) t.indent(1) for v in p.values: - this_idot = '' if v.is_ptr and v.name != 'string' else i_dot - t.append('*{} = style{}->{}{};'.format( - v.name + v.suffix, grp, this_idot, p.name + v.suffix)) + i_dot = '' if v.is_ptr and v.name != 'string' else 'i.' + t.append('*{} = style->{}{};'.format( + v.name + v.suffix, i_dot, p.name + v.suffix)) for i, v in enumerate(list(reversed(shift_list))): - if i is 0: + if i == 0: t.append('*{} = bits >> {};'.format(v[0], v[1])) else: t.append('*{} = (bits & 0x{:x}) >> {};'.format( @@ -763,29 +651,35 @@ class CSSGroup: if p.condition: t.indent(-1) t.append('}') + t.append() + + t.append('return (bits & {});'.format(type_mask)) + + t.indent(-1) + t.append('}') + + def make_propget_h(self): + """Output this group's property functions for the propget.h file.""" + t = Text() + + for p in sorted(self.props, key=(lambda x: x.name)): + defines, undefs = p.def_undefs t.append() - t.append('return (bits & {});'.format(type_mask)) + t.append(defines) - if self.name is not 'style': - t.indent(-1) - t.append('}') - t.append() - t.append('/* Initial value */') - for v in p.values: - t.append('*{} = {};'.format(v.name + v.suffix, v.defaults)) - if v.bits is not None: - t.append('*{} = {};'.format( - v.bits['name'] + v.suffix, v.bits['defaults'])) - t.append('return {};'.format(p.defaults)) + self.print_propget(t, p, True) + + if p.name in overrides['get']: + t.append(overrides['get'][p.name], pre_formatted=True) + else: + self.print_propget(t, p) - t.indent(-1) - t.append('}') t.append(undefs) return t.to_string() - def make_value_declaration(self, for_commented, defaults=False): + def make_value_declaration(self, for_commented): """Output declarations of values for this group's properties. Args: @@ -797,12 +691,8 @@ class CSSGroup: for p in sorted(self.props, key=(lambda x: x.name)): if bool(p.comments) == for_commented: for v in p.values: - if defaults: - r.append('.{}{} = {}'.format(p.name, v.suffix, - v.defaults)) - else: - v_type, v_name = shift_star(v.type, p.name) - r.append('{} {}{};'.format(v_type, v_name, v.suffix)) + v_type, v_name = shift_star(v.type, p.name) + r.append('{} {}{};'.format(v_type, v_name, v.suffix)) return r def make_text(self, filename): diff --git a/src/stylesheet.h b/src/stylesheet.h index 070508f..673bc95 100644 --- a/src/stylesheet.h +++ b/src/stylesheet.h @@ -272,8 +272,12 @@ static inline css_error css_stylesheet_style_unset(css_style *style, static inline css_error css_stylesheet_style_flag_value(css_style *style, enum flag_value flag_value, opcode_t opcode) { + enum flag flag = flag_value << 1; + if (flag == FLAG_REVERT) { + style->sheet->uses_revert = true; + } return css__stylesheet_style_append(style, - buildOPV(opcode, flag_value << 1, 0)); + buildOPV(opcode, flag, 0)); } css_error css__stylesheet_selector_create(css_stylesheet *sheet, |