diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bytecode/opcodes.h | 4 | ||||
-rw-r--r-- | src/parse/important.c | 5 | ||||
-rw-r--r-- | src/parse/properties/Makefile | 1 | ||||
-rw-r--r-- | src/parse/properties/properties.c | 2 | ||||
-rw-r--r-- | src/parse/properties/properties.h | 4 | ||||
-rw-r--r-- | src/parse/properties/stroke_opacity.c | 82 | ||||
-rw-r--r-- | src/parse/propstrings.c | 1 | ||||
-rw-r--r-- | src/parse/propstrings.h | 8 | ||||
-rw-r--r-- | src/select/autogenerated_computed.h | 14 | ||||
-rw-r--r-- | src/select/autogenerated_propget.h | 80 | ||||
-rw-r--r-- | src/select/autogenerated_propset.h | 71 | ||||
-rw-r--r-- | src/select/computed.c | 6 | ||||
-rw-r--r-- | src/select/dispatch.c | 4 | ||||
-rw-r--r-- | src/select/properties/Makefile | 1 | ||||
-rw-r--r-- | src/select/properties/properties.h | 1 | ||||
-rw-r--r-- | src/select/properties/stroke_opacity.c | 73 | ||||
-rw-r--r-- | src/select/select_config.py | 1 |
17 files changed, 298 insertions, 60 deletions
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h index df062af..7a1377b 100644 --- a/src/bytecode/opcodes.h +++ b/src/bytecode/opcodes.h @@ -726,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/important.c b/src/parse/important.c index 6e2590e..02aafc4 100644 --- a/src/parse/important.c +++ b/src/parse/important.c @@ -351,6 +351,11 @@ void css__make_style_important(css_style *style) 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/properties/Makefile b/src/parse/properties/Makefile index fc7ac76..df84d49 100644 --- a/src/parse/properties/Makefile +++ b/src/parse/properties/Makefile @@ -62,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/properties.c b/src/parse/properties/properties.c index c1187ca..2cc849c 100644 --- a/src/parse/properties/properties.c +++ b/src/parse/properties/properties.c @@ -141,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, @@ -263,6 +264,7 @@ const uint32_t property_unit_mask[CSS_N_PROPERTIES] = { [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.h b/src/parse/properties/properties.h index 25ef60e..17b7f41 100644 --- a/src/parse/properties/properties.h +++ b/src/parse/properties/properties.h @@ -409,6 +409,9 @@ css_error css__parse_speech_rate(css_language *c, css_error css__parse_stress(css_language *c, 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, int32_t *ctx, css_style *result); @@ -550,6 +553,7 @@ extern const uint32_t property_unit_mask[CSS_N_PROPERTIES]; #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/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/propstrings.c b/src/parse/propstrings.c index 62c149a..c57bc1b 100644 --- a/src/parse/propstrings.c +++ b/src/parse/propstrings.c @@ -215,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"), diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h index 2725df2..8491e72 100644 --- a/src/parse/propstrings.h +++ b/src/parse/propstrings.h @@ -64,10 +64,10 @@ enum { 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, + 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, diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h index e5d05c7..40005c1 100644 --- a/src/select/autogenerated_computed.h +++ b/src/select/autogenerated_computed.h @@ -96,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 @@ -141,9 +142,9 @@ struct css_computed_style_i { * quotes 1 sizeof(ptr) * * --- --- --- - * 463 bits 232 + 8sizeof(ptr) bytes + * 464 bits 236 + 8sizeof(ptr) bytes * =================== - * 290 + 8sizeof(ptr) bytes + * 294 + 8sizeof(ptr) bytes * * Bit allocations: * @@ -193,13 +194,13 @@ struct css_computed_style_i { * 12 bbbbbbbbbbbaaaaaaaaaaavvvvvvvvvw * border_spacing; background_position; vertical_align; widows * - * 13 bbbbpppaaagggooovvvjjjffflllcccq + * 13 bbbbpppaaagggooovvvjjjffflllcccs * border_bottom_style; position; page_break_before; page_break_after; * overflow_y; overflow_x; justify_content; font_family; flex_direction; clear; - * quotes + * stroke_opacity * - * 14 bbaaorplfeicuCk................. - * background_color; background_attachment; orphans; order; opacity; + * 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 */ @@ -258,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; diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h index 206c7ee..d1f7ffb 100644 --- a/src/select/autogenerated_propget.h +++ b/src/select/autogenerated_propget.h @@ -140,8 +140,8 @@ 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 17 -#define BACKGROUND_IMAGE_MASK 0x20000 +#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]; @@ -878,8 +878,8 @@ 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]; @@ -1166,8 +1166,8 @@ static inline uint8_t get_content(const css_computed_style *style, const #undef CONTENT_MASK #define COUNTER_INCREMENT_INDEX 14 -#define COUNTER_INCREMENT_SHIFT 19 -#define COUNTER_INCREMENT_MASK 0x80000 +#define COUNTER_INCREMENT_SHIFT 18 +#define COUNTER_INCREMENT_MASK 0x40000 static inline uint8_t get_counter_increment_bits(const css_computed_style *style) { @@ -1195,8 +1195,8 @@ 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 20 -#define COUNTER_RESET_MASK 0x100000 +#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]; @@ -1329,8 +1329,8 @@ static inline uint8_t get_empty_cells(const css_computed_style *style) #undef EMPTY_CELLS_MASK #define FILL_OPACITY_INDEX 14 -#define FILL_OPACITY_SHIFT 21 -#define FILL_OPACITY_MASK 0x200000 +#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]; @@ -1416,8 +1416,8 @@ static inline uint8_t get_flex_direction(const css_computed_style *style) #undef FLEX_DIRECTION_MASK #define FLEX_GROW_INDEX 14 -#define FLEX_GROW_SHIFT 22 -#define FLEX_GROW_MASK 0x400000 +#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]; @@ -1446,8 +1446,8 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed #undef FLEX_GROW_MASK #define FLEX_SHRINK_INDEX 14 -#define FLEX_SHRINK_SHIFT 23 -#define FLEX_SHRINK_MASK 0x800000 +#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]; @@ -1820,8 +1820,8 @@ static inline uint8_t get_line_height( #undef LINE_HEIGHT_MASK #define LIST_STYLE_IMAGE_INDEX 14 -#define LIST_STYLE_IMAGE_SHIFT 24 -#define LIST_STYLE_IMAGE_MASK 0x1000000 +#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]; @@ -2149,8 +2149,8 @@ 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 25 -#define OPACITY_MASK 0x2000000 +#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]; @@ -2179,8 +2179,8 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed #undef OPACITY_MASK #define ORDER_INDEX 14 -#define ORDER_SHIFT 26 -#define ORDER_MASK 0x4000000 +#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]; @@ -2209,8 +2209,8 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t #undef ORDER_MASK #define ORPHANS_INDEX 14 -#define ORPHANS_SHIFT 27 -#define ORPHANS_MASK 0x8000000 +#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]; @@ -2605,9 +2605,9 @@ static inline uint8_t get_position(const css_computed_style *style) #undef POSITION_SHIFT #undef POSITION_MASK -#define QUOTES_INDEX 13 -#define QUOTES_SHIFT 0 -#define QUOTES_MASK 0x1 +#define QUOTES_INDEX 14 +#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]; @@ -2664,6 +2664,36 @@ static inline uint8_t get_right(const css_computed_style *style, css_fixed #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 10 #define TABLE_LAYOUT_MASK 0xc00 diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h index 850545c..198bc1e 100644 --- a/src/select/autogenerated_propset.h +++ b/src/select/autogenerated_propset.h @@ -104,8 +104,8 @@ 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 17 -#define BACKGROUND_IMAGE_MASK 0x20000 +#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) @@ -639,8 +639,8 @@ 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) @@ -902,8 +902,8 @@ static inline css_error set_content( #undef CONTENT_MASK #define COUNTER_INCREMENT_INDEX 14 -#define COUNTER_INCREMENT_SHIFT 19 -#define COUNTER_INCREMENT_MASK 0x80000 +#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) @@ -938,8 +938,8 @@ static inline css_error set_counter_increment(css_computed_style *style, #undef COUNTER_INCREMENT_MASK #define COUNTER_RESET_INDEX 14 -#define COUNTER_RESET_SHIFT 20 -#define COUNTER_RESET_MASK 0x100000 +#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) @@ -1064,8 +1064,8 @@ static inline css_error set_empty_cells(css_computed_style *style, uint8_t type) #undef EMPTY_CELLS_MASK #define FILL_OPACITY_INDEX 14 -#define FILL_OPACITY_SHIFT 21 -#define FILL_OPACITY_MASK 0x200000 +#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) @@ -1125,8 +1125,8 @@ static inline css_error set_flex_direction(css_computed_style *style, uint8_t #undef FLEX_DIRECTION_MASK #define FLEX_GROW_INDEX 14 -#define FLEX_GROW_SHIFT 22 -#define FLEX_GROW_MASK 0x400000 +#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) @@ -1146,8 +1146,8 @@ static inline css_error set_flex_grow(css_computed_style *style, uint8_t type, #undef FLEX_GROW_MASK #define FLEX_SHRINK_INDEX 14 -#define FLEX_SHRINK_SHIFT 23 -#define FLEX_SHRINK_MASK 0x800000 +#define FLEX_SHRINK_SHIFT 22 +#define FLEX_SHRINK_MASK 0x400000 static inline css_error set_flex_shrink(css_computed_style *style, uint8_t type, css_fixed fixed) @@ -1417,8 +1417,8 @@ 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 24 -#define LIST_STYLE_IMAGE_MASK 0x1000000 +#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) @@ -1653,8 +1653,8 @@ 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 25 -#define OPACITY_MASK 0x2000000 +#define OPACITY_SHIFT 24 +#define OPACITY_MASK 0x1000000 static inline css_error set_opacity(css_computed_style *style, uint8_t type, css_fixed fixed) @@ -1674,8 +1674,8 @@ static inline css_error set_opacity(css_computed_style *style, uint8_t type, #undef OPACITY_MASK #define ORDER_INDEX 14 -#define ORDER_SHIFT 26 -#define ORDER_MASK 0x4000000 +#define ORDER_SHIFT 25 +#define ORDER_MASK 0x2000000 static inline css_error set_order(css_computed_style *style, uint8_t type, int32_t integer) @@ -1694,8 +1694,8 @@ static inline css_error set_order(css_computed_style *style, uint8_t type, #undef ORDER_MASK #define ORPHANS_INDEX 14 -#define ORPHANS_SHIFT 27 -#define ORPHANS_MASK 0x8000000 +#define ORPHANS_SHIFT 26 +#define ORPHANS_MASK 0x4000000 static inline css_error set_orphans(css_computed_style *style, uint8_t type, int32_t integer) @@ -1970,9 +1970,9 @@ static inline css_error set_position(css_computed_style *style, uint8_t type) #undef POSITION_SHIFT #undef POSITION_MASK -#define QUOTES_INDEX 13 -#define QUOTES_SHIFT 0 -#define QUOTES_MASK 0x1 +#define QUOTES_INDEX 14 +#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) @@ -2027,6 +2027,27 @@ 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 10 #define TABLE_LAYOUT_MASK 0xc00 diff --git a/src/select/computed.c b/src/select/computed.c index a0c92bb..78f3b80 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -816,6 +816,12 @@ uint8_t css_computed_fill_opacity(const css_computed_style *style, 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); diff --git a/src/select/dispatch.c b/src/select/dispatch.c index c8efa44..74bc6ed 100644 --- a/src/select/dispatch.c +++ b/src/select/dispatch.c @@ -518,5 +518,9 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = { { PROPERTY_FUNCS(fill_opacity), 0, + }, + { + PROPERTY_FUNCS(stroke_opacity), + 0, } }; diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile index 2e10f4a..eee6cc3 100644 --- a/src/select/properties/Makefile +++ b/src/select/properties/Makefile @@ -108,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/properties.h b/src/select/properties/properties.h index fba5be8..cb0b213 100644 --- a/src/select/properties/properties.h +++ b/src/select/properties/properties.h @@ -130,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_config.py b/src/select/select_config.py index 5feed6c..1cfe05c 100644 --- a/src/select/select_config.py +++ b/src/select/select_config.py @@ -96,6 +96,7 @@ style = { ('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'), |