diff options
Diffstat (limited to 'src/select')
24 files changed, 2059 insertions, 2732 deletions
diff --git a/src/select/arena.c b/src/select/arena.c index baadc9f..c2e22f6 100644 --- a/src/select/arena.c +++ b/src/select/arena.c @@ -15,37 +15,15 @@ #define TU_SIZE 3037 #define TS_SIZE 5101 -struct css_computed_uncommon *table_u[TU_SIZE]; struct css_computed_style *table_s[TS_SIZE]; -static inline uint32_t css__arena_hash_uncommon(struct css_computed_uncommon *u) -{ - return css__arena_hash((const uint8_t *) &u->i, sizeof(u->i)); -} - - static inline uint32_t css__arena_hash_style(struct css_computed_style *s) { return css__arena_hash((const uint8_t *) &s->i, sizeof(s->i)); } -static inline bool arena__compare_computed_page( - const struct css_computed_page *a, - const struct css_computed_page *b) -{ - if (a == NULL && b == NULL) { - return true; - - } else if (a == NULL || b == NULL) { - return false; - } - - return memcmp(a, b, sizeof(struct css_computed_page)) == 0; -} - - static inline bool arena__compare_computed_content_item( const struct css_computed_content_item *a, const struct css_computed_content_item *b) @@ -119,11 +97,17 @@ static inline bool arena__compare_string_list( } -static inline bool css__arena_uncommon_is_equal( - struct css_computed_uncommon *a, - struct css_computed_uncommon *b) +static inline bool css__arena_style_is_equal( + struct css_computed_style *a, + struct css_computed_style *b) { - if (memcmp(&a->i, &b->i, sizeof(struct css_computed_uncommon_i)) != 0) { + if (memcmp(&a->i, &b->i, sizeof(struct css_computed_style_i)) != 0) { + return false; + } + + if (!arena__compare_string_list( + a->font_family, + b->font_family)) { return false; } @@ -151,82 +135,16 @@ static inline bool css__arena_uncommon_is_equal( return false; } - return true; -} - - -static inline bool css__arena_style_is_equal( - struct css_computed_style *a, - struct css_computed_style *b) -{ - if (memcmp(&a->i, &b->i, sizeof(struct css_computed_style_i)) != 0) { - return false; - } - - if (!arena__compare_string_list( - a->font_family, - b->font_family)) { - return false; - } - if (!arena__compare_string_list( a->quotes, b->quotes)) { return false; } - if (!arena__compare_computed_page( - a->page, - b->page)) { - return false; - } - return true; } -static void css__arena_intern_uncommon( - struct css_computed_uncommon **uncommon) -{ - struct css_computed_uncommon *u = *uncommon; - uint32_t hash, index; - - /* Need to intern the uncommon block */ - hash = css__arena_hash_uncommon(u); - index = hash % TU_SIZE; - u->bin = index; - - if (table_u[index] == NULL) { - /* Can just insert */ - table_u[index] = u; - u->count = 1; - } else { - /* Check for existing */ - struct css_computed_uncommon *l = table_u[index]; - struct css_computed_uncommon *existing = NULL; - - do { - if (css__arena_uncommon_is_equal(l, u)) { - existing = l; - break; - } - l = l->next; - } while (l != NULL); - - if (existing != NULL) { - css__computed_uncommon_destroy(u); - existing->count++; - *uncommon = existing; - } else { - /* Add to list */ - u->next = table_u[index]; - table_u[index] = u; - u->count = 1; - } - } -} - - /* Internally exported function, documented in src/select/arena.h */ css_error css__arena_intern_style(struct css_computed_style **style) { @@ -238,13 +156,6 @@ css_error css__arena_intern_style(struct css_computed_style **style) return CSS_BADPARM; } - if (s->i.uncommon != NULL) { - if (s->i.uncommon->count != 0) { - return CSS_BADPARM; - } - css__arena_intern_uncommon(&s->i.uncommon); - } - /* Need to intern the style block */ hash = css__arena_hash_style(s); index = hash % TS_SIZE; @@ -268,7 +179,6 @@ css_error css__arena_intern_style(struct css_computed_style **style) } while (l != NULL); if (existing != NULL) { - s->i.uncommon = NULL; css_computed_style_destroy(s); existing->count++; *style = existing; @@ -320,43 +230,3 @@ enum css_error css__arena_remove_style(struct css_computed_style *style) return CSS_OK; } - - -/* Internally exported function, documented in src/select/arena.h */ -enum css_error css__arena_remove_uncommon_style( - struct css_computed_uncommon *uncommon) -{ - uint32_t index = uncommon->bin; - - if (table_u[index] == NULL) { - return CSS_BADPARM; - - } else { - /* Check for existing */ - struct css_computed_uncommon *l = table_u[index]; - struct css_computed_uncommon *existing = NULL; - struct css_computed_uncommon *prev = NULL; - - do { - if (css__arena_uncommon_is_equal(l, uncommon)) { - existing = l; - break; - } - prev = l; - l = l->next; - } while (l != NULL); - - if (existing != NULL) { - if (prev != NULL) { - prev->next = existing->next; - } else { - table_u[index] = existing->next; - } - } else { - return CSS_BADPARM; - } - } - - return CSS_OK; -} - diff --git a/src/select/arena.h b/src/select/arena.h index af06050..5da5a5d 100644 --- a/src/select/arena.h +++ b/src/select/arena.h @@ -10,7 +10,6 @@ #define css_select_arena_h_ struct css_computed_style; -struct css_computed_uncommon; /* * Add computed style to the style sharing arena, or exchange for existing @@ -32,14 +31,5 @@ enum css_error css__arena_intern_style(struct css_computed_style **style); */ enum css_error css__arena_remove_style(struct css_computed_style *style); -/* - * Remove a computed style's uncommon block from the style sharing arena - * - * \params uncommon The uncommon style to remove from the style sharing arena - * \return CSS_OK on success or appropriate error otherwise. - */ -enum css_error css__arena_remove_uncommon_style( - struct css_computed_uncommon *uncommon); - #endif diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h index 0c2dff1..fab3ae2 100644 --- a/src/select/autogenerated_computed.h +++ b/src/select/autogenerated_computed.h @@ -6,127 +6,6 @@ */ -struct css_computed_uncommon_i { -/* - * Property Size (bits) Size (bytes) - * --- --- --- - * border_spacing 1 + 10 8 - * break_after 4 - * break_before 4 - * break_inside 4 - * clip 6 + 20 16 - * column_count 2 4 - * column_fill 2 - * column_gap 2 + 5 4 - * column_rule_color 2 4 - * column_rule_style 4 - * column_rule_width 3 + 5 4 - * column_span 2 - * column_width 2 + 5 4 - * letter_spacing 2 + 5 4 - * outline_color 2 4 - * outline_width 3 + 5 4 - * word_spacing 2 + 5 4 - * writing_mode 2 - * - * Encode content as an array of content items, terminated with a blank entry. - * - * content 2 sizeof(ptr) - * - * Encode counter_increment as an array of name, value pairs, terminated with a - * blank entry. - * - * counter_increment 1 sizeof(ptr) - * - * Encode counter_reset as an array of name, value pairs, terminated with a - * blank entry. - * - * counter_reset 1 sizeof(ptr) - * - * Encode cursor uri(s) as an array of string objects, terminated with a blank - * entry - * - * cursor 5 sizeof(ptr) - * - * --- --- --- - * 118 bits 60 + 4sizeof(ptr) bytes - * =================== - * 75 + 4sizeof(ptr) bytes - * - * Bit allocations: - * - * 0 bbbbbbbbbbbooooooooccccccccuuuuu - * border_spacing; outline_width; column_rule_width; cursor - * - * 1 cccccccooooooolllllllwwwwwwwbbbb - * column_width; column_gap; letter_spacing; word_spacing; break_before - * - * 2 ccccccccccccccccccccccccccooooll - * clip; column_rule_style; column_rule_color - * - * 3 bbbbrrrrccwwoolluuttne.......... - * break_after; break_inside; content; writing_mode; column_fill; column_span; - * column_count; outline_color; counter_increment; counter_reset - */ - uint32_t bits[4]; - - css_fixed border_spacing_a; - css_fixed border_spacing_b; - css_fixed clip_a; - css_fixed clip_b; - css_fixed clip_c; - css_fixed clip_d; - int32_t column_count; - css_fixed column_gap; - css_color column_rule_color; - css_fixed column_rule_width; - css_fixed column_width; - css_fixed letter_spacing; - css_color outline_color; - css_fixed outline_width; - css_fixed word_spacing; -}; - -typedef struct css_computed_uncommon { - struct css_computed_uncommon_i i; - - css_computed_content_item *content; - css_computed_counter *counter_increment; - css_computed_counter *counter_reset; - lwc_string **cursor; - - struct css_computed_uncommon *next; - uint32_t count; - uint32_t bin; -} css_computed_uncommon; - -typedef struct css_computed_page { -/* - * Property Size (bits) Size (bytes) - * --- --- --- - * orphans 1 4 - * page_break_after 3 - * page_break_before 3 - * page_break_inside 2 - * widows 1 4 - * - * - * --- --- --- - * 10 bits 8 bytes - * =================== - * 10 bytes - * - * Bit allocations: - * - * 0 pppaaaggwo...................... - * page_break_before; page_break_after; page_break_inside; widows; orphans - */ - uint32_t bits[1]; - - int32_t orphans; - int32_t widows; -} css_computed_page; - struct css_computed_style_i { /* * Property Size (bits) Size (bytes) @@ -149,14 +28,27 @@ struct css_computed_style_i { * border_right_color 2 4 * border_right_style 4 * border_right_width 3 + 5 4 + * border_spacing 1 + 10 8 * border_top_color 2 4 * border_top_style 4 * border_top_width 3 + 5 4 * bottom 2 + 5 4 * box_sizing 2 + * break_after 4 + * break_before 4 + * break_inside 4 * caption_side 2 * clear 3 + * clip 6 + 20 16 * color 1 4 + * column_count 2 4 + * column_fill 2 + * column_gap 2 + 5 4 + * column_rule_color 2 4 + * column_rule_style 4 + * column_rule_width 3 + 5 4 + * column_span 2 + * column_width 2 + 5 4 * direction 2 * display 5 * empty_cells 2 @@ -173,6 +65,7 @@ struct css_computed_style_i { * height 2 + 5 4 * justify_content 3 * left 2 + 5 4 + * letter_spacing 2 + 5 4 * line_height 2 + 5 4 * list_style_image 1 sizeof(ptr) * list_style_position 2 @@ -187,13 +80,19 @@ struct css_computed_style_i { * min_width 2 + 5 4 * opacity 1 4 * order 1 4 + * orphans 1 4 + * outline_color 2 4 * outline_style 4 + * outline_width 3 + 5 4 * overflow_x 3 * overflow_y 3 * padding_bottom 1 + 5 4 * padding_left 1 + 5 4 * padding_right 1 + 5 4 * padding_top 1 + 5 4 + * page_break_after 3 + * page_break_before 3 + * page_break_inside 2 * position 3 * right 2 + 5 4 * table_layout 2 @@ -206,9 +105,31 @@ struct css_computed_style_i { * vertical_align 4 + 5 4 * visibility 2 * white_space 3 + * widows 1 4 * width 2 + 5 4 + * word_spacing 2 + 5 4 + * writing_mode 2 * z_index 2 4 * + * Encode content as an array of content items, terminated with a blank entry. + * + * content 2 sizeof(ptr) + * + * Encode counter_increment as an array of name, value pairs, terminated with a + * blank entry. + * + * counter_increment 1 sizeof(ptr) + * + * Encode counter_reset as an array of name, value pairs, terminated with a + * blank entry. + * + * counter_reset 1 sizeof(ptr) + * + * Encode cursor uri(s) as an array of string objects, terminated with a blank + * entry + * + * cursor 5 sizeof(ptr) + * * Encode font family as an array of string objects, terminated with a blank * entry. * @@ -219,54 +140,67 @@ struct css_computed_style_i { * quotes 1 sizeof(ptr) * * --- --- --- - * 332 bits 160 + 4sizeof(ptr) bytes + * 460 bits 228 + 8sizeof(ptr) bytes * =================== - * 202 + 4sizeof(ptr) bytes + * 286 + 8sizeof(ptr) bytes * * Bit allocations: * - * 0 bbbbbbbboooooooorrrrrrrrdddddddd - * border_top_width; border_bottom_width; border_right_width; border_left_width + * 0 bbbbbbbboooooooorrrrrrrruuuuuuuu + * border_top_width; border_left_width; border_bottom_width; outline_width * - * 1 lllllllrrrrrrrmmmmmmmaaaaaaaoooo - * line_height; right; min_width; margin_left; outline_style + * 1 fffffffffbbbbbbbbccccccccttttttt + * font_size; border_right_width; column_rule_width; top * - * 2 mmmmmmmaaaaaaafffffffxxxxxxxtttt - * max_width; margin_right; flex_basis; max_height; text_align + * 2 ccccccccccccccccccccccccccpppppp + * clip; padding_right * - * 3 tttttttmmmmmmmiiiiiiiaaaaaaaffff - * top; margin_top; min_height; margin_bottom; font_weight + * 3 mmmmmmmfffffffwwwwwwwttttttccccc + * min_height; flex_basis; word_spacing; text_indent; cursor * - * 4 lllllllwwwwwwwbbbbbbbhhhhhhhoooo - * left; width; bottom; height; border_left_style + * 4 lllllllhhhhhhhwwwwwwwmmmmmmmbbbb + * line_height; height; width; margin_bottom; break_inside * - * 5 bbbbbbbbbbbvvvvvvvvvfffffffffppp - * background_position; vertical_align; font_size; position + * 5 cccccccmmmmmmmaaaaaaalllllllbbbb + * column_gap; margin_top; max_height; left; border_top_style * - * 6 dddddtttttllllbbbboooorrrreeewww - * display; text_decoration; list_style_type; border_right_style; - * border_top_style; border_bottom_style; text_transform; white_space + * 6 mmmmmmmcccccccbbbbbbbaaaaaaarrrr + * max_width; column_width; bottom; margin_left; break_after * - * 7 ppppppaaaaaaddddddiiiiiittttttff - * padding_left; padding_bottom; padding_top; padding_right; text_indent; - * font_style + * 7 mmmmmmmrrrrrrrlllllllaaaaaaabbbb + * min_width; right; letter_spacing; margin_right; border_right_style * - * 8 ooofffaaalllbbbiiieeejjjvvvcccrr - * overflow_y; font_family; align_items; align_self; background_repeat; - * align_content; flex_direction; justify_content; overflow_x; clear; - * border_top_color + * 8 ppppppaaaaaaddddddiiiiitttttllll + * padding_bottom; padding_top; padding_left; display; text_decoration; + * list_style_type * - * 9 bbffoorrddcceeuuaaxxnnllkkttiiyy - * border_right_color; flex_wrap; border_collapse; border_left_color; - * direction; caption_side; empty_cells; unicode_bidi; background_color; - * box_sizing; font_variant; float; background_attachment; border_bottom_color; - * list_style_position; table_layout + * 9 fffpppwwwcccaaajjjlllgggiiieeebb + * font_family; position; white_space; clear; align_items; justify_content; + * flex_direction; page_break_after; align_self; page_break_before; box_sizing * - * 10 zzvvolbcfpeq.................... - * z_index; visibility; order; list_style_image; background_image; color; - * flex_shrink; opacity; flex_grow; quotes + * 10 ooobbbtttvvviirrddffaaeewwzzccpp + * overflow_x; background_repeat; text_transform; overflow_y; visibility; + * border_right_color; border_collapse; float; background_attachment; + * border_bottom_color; writing_mode; z_index; column_count; border_top_color + * + * 11 cceeddooffuuttllaabbiinnUUvvkkpp + * column_rule_color; empty_cells; direction; column_span; font_style; + * outline_color; table_layout; column_fill; caption_side; border_left_color; + * list_style_position; content; unicode_bidi; font_variant; background_color; + * page_break_inside + * + * 12 bbbbbbbbbbbooooooooooovvvvvvvvvr + * background_position; border_spacing; vertical_align; order + * + * 13 ffffoooobbbbccccrrrrddddttttaaaq + * font_weight; outline_style; border_left_style; column_rule_style; + * break_before; border_bottom_style; text_align; align_content; quotes + * + * 14 fflbceworuip.................... + * flex_wrap; flex_grow; background_image; counter_reset; flex_shrink; widows; + * opacity; color; counter_increment; list_style_image; orphans */ - uint32_t bits[11]; + uint32_t bits[15]; css_color background_color; lwc_string *background_image; @@ -278,16 +212,28 @@ struct css_computed_style_i { css_fixed border_left_width; css_color border_right_color; css_fixed border_right_width; + css_fixed border_spacing_a; + css_fixed border_spacing_b; css_color border_top_color; css_fixed border_top_width; css_fixed bottom; + css_fixed clip_a; + css_fixed clip_b; + css_fixed clip_c; + css_fixed clip_d; css_color color; + int32_t column_count; + css_fixed column_gap; + css_color column_rule_color; + css_fixed column_rule_width; + css_fixed column_width; css_fixed flex_basis; css_fixed flex_grow; css_fixed flex_shrink; css_fixed font_size; css_fixed height; css_fixed left; + css_fixed letter_spacing; css_fixed line_height; lwc_string *list_style_image; css_fixed margin_bottom; @@ -300,6 +246,9 @@ struct css_computed_style_i { css_fixed min_width; css_fixed opacity; int32_t order; + int32_t orphans; + css_color outline_color; + css_fixed outline_width; css_fixed padding_bottom; css_fixed padding_left; css_fixed padding_right; @@ -308,20 +257,24 @@ struct css_computed_style_i { css_fixed text_indent; css_fixed top; css_fixed vertical_align; + int32_t widows; css_fixed width; + css_fixed word_spacing; int32_t z_index; - css_computed_uncommon *uncommon; void *aural; }; struct css_computed_style { struct css_computed_style_i i; + css_computed_content_item *content; + css_computed_counter *counter_increment; + css_computed_counter *counter_reset; + lwc_string **cursor; lwc_string **font_family; lwc_string **quotes; - css_computed_page *page; struct css_computed_style *next; uint32_t count; uint32_t bin; diff --git a/src/select/autogenerated_propget.h b/src/select/autogenerated_propget.h index 5c63c5e..ff67f7c 100644 --- a/src/select/autogenerated_propget.h +++ b/src/select/autogenerated_propget.h @@ -6,717 +6,9 @@ */ -#define BORDER_SPACING_INDEX 0 -#define BORDER_SPACING_SHIFT 21 -#define BORDER_SPACING_MASK 0xffe00000 -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) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[BORDER_SPACING_INDEX]; - bits &= BORDER_SPACING_MASK; - bits >>= BORDER_SPACING_SHIFT; - - /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ - if ((bits & 0x1) == CSS_BORDER_SPACING_SET) { - *length_a = style->i.uncommon->i.border_spacing_a; - *length_b = style->i.uncommon->i.border_spacing_b; - *unit_a = bits >> 6; - *unit_b = (bits & 0x3e) >> 1; - } - - return (bits & 0x1); - } - - /* Initial value */ - *length_a = 0; - *unit_a = CSS_UNIT_PX; - *length_b = 0; - *unit_b = CSS_UNIT_PX; - return CSS_BORDER_SPACING_SET; -} -#undef BORDER_SPACING_INDEX -#undef BORDER_SPACING_SHIFT -#undef BORDER_SPACING_MASK - -#define BREAK_AFTER_INDEX 3 -#define BREAK_AFTER_SHIFT 28 -#define BREAK_AFTER_MASK 0xf0000000 -static inline uint8_t get_break_after(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[BREAK_AFTER_INDEX]; - bits &= BREAK_AFTER_MASK; - bits >>= BREAK_AFTER_SHIFT; - - /* 4bits: tttt : type */ - - return (bits & 0xf); - } - - /* Initial value */ - return CSS_BREAK_AFTER_AUTO; -} -#undef BREAK_AFTER_INDEX -#undef BREAK_AFTER_SHIFT -#undef BREAK_AFTER_MASK - -#define BREAK_BEFORE_INDEX 1 -#define BREAK_BEFORE_SHIFT 0 -#define BREAK_BEFORE_MASK 0xf -static inline uint8_t get_break_before(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[BREAK_BEFORE_INDEX]; - bits &= BREAK_BEFORE_MASK; - bits >>= BREAK_BEFORE_SHIFT; - - /* 4bits: tttt : type */ - - return (bits & 0xf); - } - - /* Initial value */ - return CSS_BREAK_BEFORE_AUTO; -} -#undef BREAK_BEFORE_INDEX -#undef BREAK_BEFORE_SHIFT -#undef BREAK_BEFORE_MASK - -#define BREAK_INSIDE_INDEX 3 -#define BREAK_INSIDE_SHIFT 24 -#define BREAK_INSIDE_MASK 0xf000000 -static inline uint8_t get_break_inside(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[BREAK_INSIDE_INDEX]; - bits &= BREAK_INSIDE_MASK; - bits >>= BREAK_INSIDE_SHIFT; - - /* 4bits: tttt : type */ - - return (bits & 0xf); - } - - /* Initial value */ - return CSS_BREAK_INSIDE_AUTO; -} -#undef BREAK_INSIDE_INDEX -#undef BREAK_INSIDE_SHIFT -#undef BREAK_INSIDE_MASK - -#define CLIP_INDEX 2 -#define CLIP_SHIFT 6 -#define CLIP_MASK 0xffffffc0 -static inline uint8_t get_clip( - const css_computed_style *style, - css_computed_clip_rect *rect) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[CLIP_INDEX]; - bits &= CLIP_MASK; - bits >>= CLIP_SHIFT; - - /* - 26bits: tt tttr rrrr bbbb blll llTR BLyy: - units: top | right | bottom | left - opcodes: top | right | bottom | left | type - */ - - if ((bits & 0x3) == CSS_CLIP_RECT) { - rect->left_auto = (bits & 0x4); - rect->bottom_auto = (bits & 0x8); - rect->right_auto = (bits & 0x10); - rect->top_auto = (bits & 0x20); - - rect->top = style->i.uncommon->i.clip_a; - rect->tunit = bits & 0x3e00000 >> 21; - - rect->right = style->i.uncommon->i.clip_b; - rect->runit = bits & 0x1f0000 >> 16; - - rect->bottom = style->i.uncommon->i.clip_c; - rect->bunit = (bits & 0xf800) >> 11; - - rect->left = style->i.uncommon->i.clip_d; - rect->lunit = (bits & 0x7c0) >> 6; - } - - return (bits & 0x3); - } - - /* Initial value */ - return CSS_CLIP_AUTO; -} -#undef CLIP_INDEX -#undef CLIP_SHIFT -#undef CLIP_MASK - -#define COLUMN_COUNT_INDEX 3 -#define COLUMN_COUNT_SHIFT 14 -#define COLUMN_COUNT_MASK 0xc000 -static inline uint8_t get_column_count(const css_computed_style *style, int32_t - *integer) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[COLUMN_COUNT_INDEX]; - bits &= COLUMN_COUNT_MASK; - bits >>= COLUMN_COUNT_SHIFT; - - /* 2bits: tt : type */ - *integer = style->i.uncommon->i.column_count; - - return (bits & 0x3); - } - - /* Initial value */ - *integer = 0; - return CSS_COLUMN_COUNT_AUTO; -} -#undef COLUMN_COUNT_INDEX -#undef COLUMN_COUNT_SHIFT -#undef COLUMN_COUNT_MASK - -#define COLUMN_FILL_INDEX 3 -#define COLUMN_FILL_SHIFT 18 -#define COLUMN_FILL_MASK 0xc0000 -static inline uint8_t get_column_fill(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[COLUMN_FILL_INDEX]; - bits &= COLUMN_FILL_MASK; - bits >>= COLUMN_FILL_SHIFT; - - /* 2bits: tt : type */ - - return (bits & 0x3); - } - - /* Initial value */ - return CSS_COLUMN_FILL_BALANCE; -} -#undef COLUMN_FILL_INDEX -#undef COLUMN_FILL_SHIFT -#undef COLUMN_FILL_MASK - -#define COLUMN_GAP_INDEX 1 -#define COLUMN_GAP_SHIFT 18 -#define COLUMN_GAP_MASK 0x1fc0000 -static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed - *length, css_unit *unit) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[COLUMN_GAP_INDEX]; - bits &= COLUMN_GAP_MASK; - bits >>= COLUMN_GAP_SHIFT; - - /* 7bits: uuuuutt : unit | type */ - if ((bits & 0x3) == CSS_COLUMN_GAP_SET) { - *length = style->i.uncommon->i.column_gap; - *unit = bits >> 2; - } - - return (bits & 0x3); - } - - /* Initial value */ - *length = 0; - *unit = CSS_UNIT_PX; - return CSS_COLUMN_GAP_NORMAL; -} -#undef COLUMN_GAP_INDEX -#undef COLUMN_GAP_SHIFT -#undef COLUMN_GAP_MASK - -#define COLUMN_RULE_COLOR_INDEX 2 -#define COLUMN_RULE_COLOR_SHIFT 0 -#define COLUMN_RULE_COLOR_MASK 0x3 -static inline uint8_t get_column_rule_color(const css_computed_style *style, - css_color *color) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[ - COLUMN_RULE_COLOR_INDEX]; - bits &= COLUMN_RULE_COLOR_MASK; - bits >>= COLUMN_RULE_COLOR_SHIFT; - - /* 2bits: tt : type */ - *color = style->i.uncommon->i.column_rule_color; - - return (bits & 0x3); - } - - /* Initial value */ - *color = 0; - return CSS_COLUMN_RULE_COLOR_CURRENT_COLOR; -} -#undef COLUMN_RULE_COLOR_INDEX -#undef COLUMN_RULE_COLOR_SHIFT -#undef COLUMN_RULE_COLOR_MASK - -#define COLUMN_RULE_STYLE_INDEX 2 -#define COLUMN_RULE_STYLE_SHIFT 2 -#define COLUMN_RULE_STYLE_MASK 0x3c -static inline uint8_t get_column_rule_style(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[ - COLUMN_RULE_STYLE_INDEX]; - bits &= COLUMN_RULE_STYLE_MASK; - bits >>= COLUMN_RULE_STYLE_SHIFT; - - /* 4bits: tttt : type */ - - return (bits & 0xf); - } - - /* Initial value */ - return CSS_COLUMN_RULE_STYLE_NONE; -} -#undef COLUMN_RULE_STYLE_INDEX -#undef COLUMN_RULE_STYLE_SHIFT -#undef COLUMN_RULE_STYLE_MASK - -#define COLUMN_RULE_WIDTH_INDEX 0 -#define COLUMN_RULE_WIDTH_SHIFT 5 -#define COLUMN_RULE_WIDTH_MASK 0x1fe0 -static inline uint8_t get_column_rule_width(const css_computed_style *style, - css_fixed *length, css_unit *unit) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[ - COLUMN_RULE_WIDTH_INDEX]; - bits &= COLUMN_RULE_WIDTH_MASK; - bits >>= COLUMN_RULE_WIDTH_SHIFT; - - /* 8bits: uuuuuttt : unit | type */ - if ((bits & 0x7) == CSS_COLUMN_RULE_WIDTH_WIDTH) { - *length = style->i.uncommon->i.column_rule_width; - *unit = bits >> 3; - } - - return (bits & 0x7); - } - - /* Initial value */ - *length = 0; - *unit = CSS_UNIT_PX; - return CSS_COLUMN_RULE_WIDTH_MEDIUM; -} -#undef COLUMN_RULE_WIDTH_INDEX -#undef COLUMN_RULE_WIDTH_SHIFT -#undef COLUMN_RULE_WIDTH_MASK - -#define COLUMN_SPAN_INDEX 3 -#define COLUMN_SPAN_SHIFT 16 -#define COLUMN_SPAN_MASK 0x30000 -static inline uint8_t get_column_span(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[COLUMN_SPAN_INDEX]; - bits &= COLUMN_SPAN_MASK; - bits >>= COLUMN_SPAN_SHIFT; - - /* 2bits: tt : type */ - - return (bits & 0x3); - } - - /* Initial value */ - return CSS_COLUMN_SPAN_NONE; -} -#undef COLUMN_SPAN_INDEX -#undef COLUMN_SPAN_SHIFT -#undef COLUMN_SPAN_MASK - -#define COLUMN_WIDTH_INDEX 1 -#define COLUMN_WIDTH_SHIFT 25 -#define COLUMN_WIDTH_MASK 0xfe000000 -static inline uint8_t get_column_width(const css_computed_style *style, - css_fixed *length, css_unit *unit) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[COLUMN_WIDTH_INDEX]; - bits &= COLUMN_WIDTH_MASK; - bits >>= COLUMN_WIDTH_SHIFT; - - /* 7bits: uuuuutt : unit | type */ - if ((bits & 0x3) == CSS_COLUMN_WIDTH_SET) { - *length = style->i.uncommon->i.column_width; - *unit = bits >> 2; - } - - return (bits & 0x3); - } - - /* Initial value */ - *length = 0; - *unit = CSS_UNIT_PX; - return CSS_COLUMN_WIDTH_AUTO; -} -#undef COLUMN_WIDTH_INDEX -#undef COLUMN_WIDTH_SHIFT -#undef COLUMN_WIDTH_MASK - -#define CONTENT_INDEX 3 -#define CONTENT_SHIFT 22 -#define CONTENT_MASK 0xc00000 -static inline uint8_t get_content(const css_computed_style *style, const - css_computed_content_item **content_item) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[CONTENT_INDEX]; - bits &= CONTENT_MASK; - bits >>= CONTENT_SHIFT; - - /* 2bits: tt : type */ - if ((bits & 0x3) == CSS_CONTENT_SET) { - *content_item = style->i.uncommon->content; - } - - return (bits & 0x3); - } - - /* Initial value */ - *content_item = NULL; - return CSS_CONTENT_NORMAL; -} -#undef CONTENT_INDEX -#undef CONTENT_SHIFT -#undef CONTENT_MASK - -#define COUNTER_INCREMENT_INDEX 3 -#define COUNTER_INCREMENT_SHIFT 11 -#define COUNTER_INCREMENT_MASK 0x800 -static inline uint8_t get_counter_increment(const css_computed_style *style, - const css_computed_counter **counter_arr) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[ - COUNTER_INCREMENT_INDEX]; - bits &= COUNTER_INCREMENT_MASK; - bits >>= COUNTER_INCREMENT_SHIFT; - - /* 1bit: t : type */ - *counter_arr = style->i.uncommon->counter_increment; - - return (bits & 0x1); - } - - /* Initial value */ - *counter_arr = NULL; - return CSS_COUNTER_INCREMENT_NONE; -} -#undef COUNTER_INCREMENT_INDEX -#undef COUNTER_INCREMENT_SHIFT -#undef COUNTER_INCREMENT_MASK - -#define COUNTER_RESET_INDEX 3 -#define COUNTER_RESET_SHIFT 10 -#define COUNTER_RESET_MASK 0x400 -static inline uint8_t get_counter_reset(const css_computed_style *style, const - css_computed_counter **counter_arr) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[COUNTER_RESET_INDEX]; - bits &= COUNTER_RESET_MASK; - bits >>= COUNTER_RESET_SHIFT; - - /* 1bit: t : type */ - *counter_arr = style->i.uncommon->counter_reset; - - return (bits & 0x1); - } - - /* Initial value */ - *counter_arr = NULL; - return CSS_COUNTER_RESET_NONE; -} -#undef COUNTER_RESET_INDEX -#undef COUNTER_RESET_SHIFT -#undef COUNTER_RESET_MASK - -#define CURSOR_INDEX 0 -#define CURSOR_SHIFT 0 -#define CURSOR_MASK 0x1f -static inline uint8_t get_cursor(const css_computed_style *style, lwc_string - ***string_arr) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[CURSOR_INDEX]; - bits &= CURSOR_MASK; - bits >>= CURSOR_SHIFT; - - /* 5bits: ttttt : type */ - *string_arr = style->i.uncommon->cursor; - - return (bits & 0x1f); - } - - /* Initial value */ - *string_arr = NULL; - return CSS_CURSOR_AUTO; -} -#undef CURSOR_INDEX -#undef CURSOR_SHIFT -#undef CURSOR_MASK - -#define LETTER_SPACING_INDEX 1 -#define LETTER_SPACING_SHIFT 11 -#define LETTER_SPACING_MASK 0x3f800 -static inline uint8_t get_letter_spacing(const css_computed_style *style, - css_fixed *length, css_unit *unit) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[LETTER_SPACING_INDEX]; - bits &= LETTER_SPACING_MASK; - bits >>= LETTER_SPACING_SHIFT; - - /* 7bits: uuuuutt : unit | type */ - if ((bits & 0x3) == CSS_LETTER_SPACING_SET) { - *length = style->i.uncommon->i.letter_spacing; - *unit = bits >> 2; - } - - return (bits & 0x3); - } - - /* Initial value */ - *length = 0; - *unit = CSS_UNIT_PX; - return CSS_LETTER_SPACING_NORMAL; -} -#undef LETTER_SPACING_INDEX -#undef LETTER_SPACING_SHIFT -#undef LETTER_SPACING_MASK - -#define OUTLINE_COLOR_INDEX 3 -#define OUTLINE_COLOR_SHIFT 12 -#define OUTLINE_COLOR_MASK 0x3000 -static inline uint8_t get_outline_color(const css_computed_style *style, - css_color *color) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[OUTLINE_COLOR_INDEX]; - bits &= OUTLINE_COLOR_MASK; - bits >>= OUTLINE_COLOR_SHIFT; - - /* 2bits: tt : type */ - if ((bits & 0x3) == CSS_OUTLINE_COLOR_COLOR) { - *color = style->i.uncommon->i.outline_color; - } - - return (bits & 0x3); - } - - /* Initial value */ - *color = 0; - return CSS_OUTLINE_COLOR_INVERT; -} -#undef OUTLINE_COLOR_INDEX -#undef OUTLINE_COLOR_SHIFT -#undef OUTLINE_COLOR_MASK - -#define OUTLINE_WIDTH_INDEX 0 -#define OUTLINE_WIDTH_SHIFT 13 -#define OUTLINE_WIDTH_MASK 0x1fe000 -static inline uint8_t get_outline_width(const css_computed_style *style, - css_fixed *length, css_unit *unit) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[OUTLINE_WIDTH_INDEX]; - bits &= OUTLINE_WIDTH_MASK; - bits >>= OUTLINE_WIDTH_SHIFT; - - /* 8bits: uuuuuttt : unit | type */ - if ((bits & 0x7) == CSS_OUTLINE_WIDTH_WIDTH) { - *length = style->i.uncommon->i.outline_width; - *unit = bits >> 3; - } - - return (bits & 0x7); - } - - /* Initial value */ - *length = 0; - *unit = CSS_UNIT_PX; - return CSS_OUTLINE_WIDTH_MEDIUM; -} -#undef OUTLINE_WIDTH_INDEX -#undef OUTLINE_WIDTH_SHIFT -#undef OUTLINE_WIDTH_MASK - -#define WORD_SPACING_INDEX 1 -#define WORD_SPACING_SHIFT 4 -#define WORD_SPACING_MASK 0x7f0 -static inline uint8_t get_word_spacing(const css_computed_style *style, - css_fixed *length, css_unit *unit) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[WORD_SPACING_INDEX]; - bits &= WORD_SPACING_MASK; - bits >>= WORD_SPACING_SHIFT; - - /* 7bits: uuuuutt : unit | type */ - if ((bits & 0x3) == CSS_WORD_SPACING_SET) { - *length = style->i.uncommon->i.word_spacing; - *unit = bits >> 2; - } - - return (bits & 0x3); - } - - /* Initial value */ - *length = 0; - *unit = CSS_UNIT_PX; - return CSS_WORD_SPACING_NORMAL; -} -#undef WORD_SPACING_INDEX -#undef WORD_SPACING_SHIFT -#undef WORD_SPACING_MASK - -#define WRITING_MODE_INDEX 3 -#define WRITING_MODE_SHIFT 20 -#define WRITING_MODE_MASK 0x300000 -static inline uint8_t get_writing_mode(const css_computed_style *style) -{ - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[WRITING_MODE_INDEX]; - bits &= WRITING_MODE_MASK; - bits >>= WRITING_MODE_SHIFT; - - /* 2bits: tt : type */ - - return (bits & 0x3); - } - - /* Initial value */ - return CSS_WRITING_MODE_HORIZONTAL_TB; -} -#undef WRITING_MODE_INDEX -#undef WRITING_MODE_SHIFT -#undef WRITING_MODE_MASK - -#define ORPHANS_INDEX 0 -#define ORPHANS_SHIFT 22 -#define ORPHANS_MASK 0x400000 -static inline uint8_t get_orphans(const css_computed_style *style, int32_t - *integer) -{ - if (style->page != NULL) { - uint32_t bits = style->page->bits[ORPHANS_INDEX]; - bits &= ORPHANS_MASK; - bits >>= ORPHANS_SHIFT; - - /* 1bit: t : type */ - *integer = style->page->orphans; - - return (bits & 0x1); - } - - /* Initial value */ - *integer = 2; - return CSS_ORPHANS_SET; -} -#undef ORPHANS_INDEX -#undef ORPHANS_SHIFT -#undef ORPHANS_MASK - -#define PAGE_BREAK_AFTER_INDEX 0 -#define PAGE_BREAK_AFTER_SHIFT 26 -#define PAGE_BREAK_AFTER_MASK 0x1c000000 -static inline uint8_t get_page_break_after(const css_computed_style *style) -{ - if (style->page != NULL) { - uint32_t bits = style->page->bits[PAGE_BREAK_AFTER_INDEX]; - bits &= PAGE_BREAK_AFTER_MASK; - bits >>= PAGE_BREAK_AFTER_SHIFT; - - /* 3bits: ttt : type */ - - return (bits & 0x7); - } - - /* Initial value */ - return CSS_PAGE_BREAK_AFTER_AUTO; -} -#undef PAGE_BREAK_AFTER_INDEX -#undef PAGE_BREAK_AFTER_SHIFT -#undef PAGE_BREAK_AFTER_MASK - -#define PAGE_BREAK_BEFORE_INDEX 0 -#define PAGE_BREAK_BEFORE_SHIFT 29 -#define PAGE_BREAK_BEFORE_MASK 0xe0000000 -static inline uint8_t get_page_break_before(const css_computed_style *style) -{ - if (style->page != NULL) { - uint32_t bits = style->page->bits[PAGE_BREAK_BEFORE_INDEX]; - bits &= PAGE_BREAK_BEFORE_MASK; - bits >>= PAGE_BREAK_BEFORE_SHIFT; - - /* 3bits: ttt : type */ - - return (bits & 0x7); - } - - /* Initial value */ - return CSS_PAGE_BREAK_BEFORE_AUTO; -} -#undef PAGE_BREAK_BEFORE_INDEX -#undef PAGE_BREAK_BEFORE_SHIFT -#undef PAGE_BREAK_BEFORE_MASK - -#define PAGE_BREAK_INSIDE_INDEX 0 -#define PAGE_BREAK_INSIDE_SHIFT 24 -#define PAGE_BREAK_INSIDE_MASK 0x3000000 -static inline uint8_t get_page_break_inside(const css_computed_style *style) -{ - if (style->page != NULL) { - uint32_t bits = style->page->bits[PAGE_BREAK_INSIDE_INDEX]; - bits &= PAGE_BREAK_INSIDE_MASK; - bits >>= PAGE_BREAK_INSIDE_SHIFT; - - /* 2bits: tt : type */ - - return (bits & 0x3); - } - - /* Initial value */ - return CSS_PAGE_BREAK_INSIDE_AUTO; -} -#undef PAGE_BREAK_INSIDE_INDEX -#undef PAGE_BREAK_INSIDE_SHIFT -#undef PAGE_BREAK_INSIDE_MASK - -#define WIDOWS_INDEX 0 -#define WIDOWS_SHIFT 23 -#define WIDOWS_MASK 0x800000 -static inline uint8_t get_widows(const css_computed_style *style, int32_t - *integer) -{ - if (style->page != NULL) { - uint32_t bits = style->page->bits[WIDOWS_INDEX]; - bits &= WIDOWS_MASK; - bits >>= WIDOWS_SHIFT; - - /* 1bit: t : type */ - *integer = style->page->widows; - - return (bits & 0x1); - } - - /* Initial value */ - *integer = 2; - return CSS_WIDOWS_SET; -} -#undef WIDOWS_INDEX -#undef WIDOWS_SHIFT -#undef WIDOWS_MASK - -#define ALIGN_CONTENT_INDEX 8 -#define ALIGN_CONTENT_SHIFT 14 -#define ALIGN_CONTENT_MASK 0x1c000 +#define ALIGN_CONTENT_INDEX 13 +#define ALIGN_CONTENT_SHIFT 1 +#define ALIGN_CONTENT_MASK 0xe static inline uint8_t get_align_content(const css_computed_style *style) { uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX]; @@ -731,9 +23,9 @@ static inline uint8_t get_align_content(const css_computed_style *style) #undef ALIGN_CONTENT_SHIFT #undef ALIGN_CONTENT_MASK -#define ALIGN_ITEMS_INDEX 8 -#define ALIGN_ITEMS_SHIFT 23 -#define ALIGN_ITEMS_MASK 0x3800000 +#define ALIGN_ITEMS_INDEX 9 +#define ALIGN_ITEMS_SHIFT 17 +#define ALIGN_ITEMS_MASK 0xe0000 static inline uint8_t get_align_items(const css_computed_style *style) { uint32_t bits = style->i.bits[ALIGN_ITEMS_INDEX]; @@ -748,9 +40,9 @@ static inline uint8_t get_align_items(const css_computed_style *style) #undef ALIGN_ITEMS_SHIFT #undef ALIGN_ITEMS_MASK -#define ALIGN_SELF_INDEX 8 -#define ALIGN_SELF_SHIFT 20 -#define ALIGN_SELF_MASK 0x700000 +#define ALIGN_SELF_INDEX 9 +#define ALIGN_SELF_SHIFT 5 +#define ALIGN_SELF_MASK 0xe0 static inline uint8_t get_align_self(const css_computed_style *style) { uint32_t bits = style->i.bits[ALIGN_SELF_INDEX]; @@ -765,9 +57,9 @@ static inline uint8_t get_align_self(const css_computed_style *style) #undef ALIGN_SELF_SHIFT #undef ALIGN_SELF_MASK -#define BACKGROUND_ATTACHMENT_INDEX 9 -#define BACKGROUND_ATTACHMENT_SHIFT 6 -#define BACKGROUND_ATTACHMENT_MASK 0xc0 +#define BACKGROUND_ATTACHMENT_INDEX 10 +#define BACKGROUND_ATTACHMENT_SHIFT 10 +#define BACKGROUND_ATTACHMENT_MASK 0xc00 static inline uint8_t get_background_attachment(const css_computed_style *style) { uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX]; @@ -782,9 +74,9 @@ static inline uint8_t get_background_attachment(const css_computed_style *style) #undef BACKGROUND_ATTACHMENT_SHIFT #undef BACKGROUND_ATTACHMENT_MASK -#define BACKGROUND_COLOR_INDEX 9 -#define BACKGROUND_COLOR_SHIFT 14 -#define BACKGROUND_COLOR_MASK 0xc000 +#define BACKGROUND_COLOR_INDEX 11 +#define BACKGROUND_COLOR_SHIFT 2 +#define BACKGROUND_COLOR_MASK 0xc static inline uint8_t get_background_color(const css_computed_style *style, css_color *color) { @@ -801,9 +93,9 @@ static inline uint8_t get_background_color(const css_computed_style *style, #undef BACKGROUND_COLOR_SHIFT #undef BACKGROUND_COLOR_MASK -#define BACKGROUND_IMAGE_INDEX 10 -#define BACKGROUND_IMAGE_SHIFT 25 -#define BACKGROUND_IMAGE_MASK 0x2000000 +#define BACKGROUND_IMAGE_INDEX 14 +#define BACKGROUND_IMAGE_SHIFT 28 +#define BACKGROUND_IMAGE_MASK 0x10000000 static inline uint8_t get_background_image(const css_computed_style *style, lwc_string **string) { @@ -820,7 +112,7 @@ static inline uint8_t get_background_image(const css_computed_style *style, #undef BACKGROUND_IMAGE_SHIFT #undef BACKGROUND_IMAGE_MASK -#define BACKGROUND_POSITION_INDEX 5 +#define BACKGROUND_POSITION_INDEX 12 #define BACKGROUND_POSITION_SHIFT 21 #define BACKGROUND_POSITION_MASK 0xffe00000 static inline uint8_t get_background_position(const css_computed_style *style, @@ -845,9 +137,9 @@ static inline uint8_t get_background_position(const css_computed_style *style, #undef BACKGROUND_POSITION_SHIFT #undef BACKGROUND_POSITION_MASK -#define BACKGROUND_REPEAT_INDEX 8 -#define BACKGROUND_REPEAT_SHIFT 17 -#define BACKGROUND_REPEAT_MASK 0xe0000 +#define BACKGROUND_REPEAT_INDEX 10 +#define BACKGROUND_REPEAT_SHIFT 26 +#define BACKGROUND_REPEAT_MASK 0x1c000000 static inline uint8_t get_background_repeat(const css_computed_style *style) { uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX]; @@ -862,9 +154,9 @@ 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 9 -#define BORDER_BOTTOM_COLOR_SHIFT 4 -#define BORDER_BOTTOM_COLOR_MASK 0x30 +#define BORDER_BOTTOM_COLOR_INDEX 10 +#define BORDER_BOTTOM_COLOR_SHIFT 8 +#define BORDER_BOTTOM_COLOR_MASK 0x300 static inline uint8_t get_border_bottom_color(const css_computed_style *style, css_color *color) { @@ -881,9 +173,9 @@ 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 6 -#define BORDER_BOTTOM_STYLE_MASK 0x3c0 +#define BORDER_BOTTOM_STYLE_INDEX 13 +#define BORDER_BOTTOM_STYLE_SHIFT 8 +#define BORDER_BOTTOM_STYLE_MASK 0xf00 static inline uint8_t get_border_bottom_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX]; @@ -899,8 +191,8 @@ 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 16 -#define BORDER_BOTTOM_WIDTH_MASK 0xff0000 +#define BORDER_BOTTOM_WIDTH_SHIFT 8 +#define BORDER_BOTTOM_WIDTH_MASK 0xff00 static inline uint8_t get_border_bottom_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -920,9 +212,9 @@ static inline uint8_t get_border_bottom_width(const css_computed_style *style, #undef BORDER_BOTTOM_WIDTH_SHIFT #undef BORDER_BOTTOM_WIDTH_MASK -#define BORDER_COLLAPSE_INDEX 9 -#define BORDER_COLLAPSE_SHIFT 26 -#define BORDER_COLLAPSE_MASK 0xc000000 +#define BORDER_COLLAPSE_INDEX 10 +#define BORDER_COLLAPSE_SHIFT 14 +#define BORDER_COLLAPSE_MASK 0xc000 static inline uint8_t get_border_collapse(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX]; @@ -937,9 +229,9 @@ 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 9 -#define BORDER_LEFT_COLOR_SHIFT 24 -#define BORDER_LEFT_COLOR_MASK 0x3000000 +#define BORDER_LEFT_COLOR_INDEX 11 +#define BORDER_LEFT_COLOR_SHIFT 12 +#define BORDER_LEFT_COLOR_MASK 0x3000 static inline uint8_t get_border_left_color(const css_computed_style *style, css_color *color) { @@ -956,9 +248,9 @@ static inline uint8_t get_border_left_color(const css_computed_style *style, #undef BORDER_LEFT_COLOR_SHIFT #undef BORDER_LEFT_COLOR_MASK -#define BORDER_LEFT_STYLE_INDEX 4 -#define BORDER_LEFT_STYLE_SHIFT 0 -#define BORDER_LEFT_STYLE_MASK 0xf +#define BORDER_LEFT_STYLE_INDEX 13 +#define BORDER_LEFT_STYLE_SHIFT 20 +#define BORDER_LEFT_STYLE_MASK 0xf00000 static inline uint8_t get_border_left_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX]; @@ -974,8 +266,8 @@ 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 0 -#define BORDER_LEFT_WIDTH_MASK 0xff +#define BORDER_LEFT_WIDTH_SHIFT 16 +#define BORDER_LEFT_WIDTH_MASK 0xff0000 static inline uint8_t get_border_left_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -995,9 +287,9 @@ static inline uint8_t get_border_left_width(const css_computed_style *style, #undef BORDER_LEFT_WIDTH_SHIFT #undef BORDER_LEFT_WIDTH_MASK -#define BORDER_RIGHT_COLOR_INDEX 9 -#define BORDER_RIGHT_COLOR_SHIFT 30 -#define BORDER_RIGHT_COLOR_MASK 0xc0000000 +#define BORDER_RIGHT_COLOR_INDEX 10 +#define BORDER_RIGHT_COLOR_SHIFT 16 +#define BORDER_RIGHT_COLOR_MASK 0x30000 static inline uint8_t get_border_right_color(const css_computed_style *style, css_color *color) { @@ -1014,9 +306,9 @@ 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 6 -#define BORDER_RIGHT_STYLE_SHIFT 14 -#define BORDER_RIGHT_STYLE_MASK 0x3c000 +#define BORDER_RIGHT_STYLE_INDEX 7 +#define BORDER_RIGHT_STYLE_SHIFT 0 +#define BORDER_RIGHT_STYLE_MASK 0xf static inline uint8_t get_border_right_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_RIGHT_STYLE_INDEX]; @@ -1031,9 +323,9 @@ static inline uint8_t get_border_right_style(const css_computed_style *style) #undef BORDER_RIGHT_STYLE_SHIFT #undef BORDER_RIGHT_STYLE_MASK -#define BORDER_RIGHT_WIDTH_INDEX 0 -#define BORDER_RIGHT_WIDTH_SHIFT 8 -#define BORDER_RIGHT_WIDTH_MASK 0xff00 +#define BORDER_RIGHT_WIDTH_INDEX 1 +#define BORDER_RIGHT_WIDTH_SHIFT 15 +#define BORDER_RIGHT_WIDTH_MASK 0x7f8000 static inline uint8_t get_border_right_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1053,7 +345,32 @@ static inline uint8_t get_border_right_width(const css_computed_style *style, #undef BORDER_RIGHT_WIDTH_SHIFT #undef BORDER_RIGHT_WIDTH_MASK -#define BORDER_TOP_COLOR_INDEX 8 +#define BORDER_SPACING_INDEX 12 +#define BORDER_SPACING_SHIFT 10 +#define BORDER_SPACING_MASK 0x1ffc00 +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) +{ + uint32_t bits = style->i.bits[BORDER_SPACING_INDEX]; + bits &= BORDER_SPACING_MASK; + bits >>= BORDER_SPACING_SHIFT; + + /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ + if ((bits & 0x1) == CSS_BORDER_SPACING_SET) { + *length_a = style->i.border_spacing_a; + *length_b = style->i.border_spacing_b; + *unit_a = bits >> 6; + *unit_b = (bits & 0x3e) >> 1; + } + + return (bits & 0x1); +} +#undef BORDER_SPACING_INDEX +#undef BORDER_SPACING_SHIFT +#undef BORDER_SPACING_MASK + +#define BORDER_TOP_COLOR_INDEX 10 #define BORDER_TOP_COLOR_SHIFT 0 #define BORDER_TOP_COLOR_MASK 0x3 static inline uint8_t get_border_top_color(const css_computed_style *style, @@ -1072,9 +389,9 @@ 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 6 -#define BORDER_TOP_STYLE_SHIFT 10 -#define BORDER_TOP_STYLE_MASK 0x3c00 +#define BORDER_TOP_STYLE_INDEX 5 +#define BORDER_TOP_STYLE_SHIFT 0 +#define BORDER_TOP_STYLE_MASK 0xf static inline uint8_t get_border_top_style(const css_computed_style *style) { uint32_t bits = style->i.bits[BORDER_TOP_STYLE_INDEX]; @@ -1111,7 +428,7 @@ 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 4 +#define BOTTOM_INDEX 6 #define BOTTOM_SHIFT 11 #define BOTTOM_MASK 0x3f800 static inline uint8_t get_bottom( @@ -1145,8 +462,8 @@ static inline uint8_t get_bottom_bits( #undef BOTTOM_MASK #define BOX_SIZING_INDEX 9 -#define BOX_SIZING_SHIFT 12 -#define BOX_SIZING_MASK 0x3000 +#define BOX_SIZING_SHIFT 0 +#define BOX_SIZING_MASK 0x3 static inline uint8_t get_box_sizing(const css_computed_style *style) { uint32_t bits = style->i.bits[BOX_SIZING_INDEX]; @@ -1161,9 +478,60 @@ static inline uint8_t get_box_sizing(const css_computed_style *style) #undef BOX_SIZING_SHIFT #undef BOX_SIZING_MASK -#define CAPTION_SIDE_INDEX 9 -#define CAPTION_SIDE_SHIFT 20 -#define CAPTION_SIDE_MASK 0x300000 +#define BREAK_AFTER_INDEX 6 +#define BREAK_AFTER_SHIFT 0 +#define BREAK_AFTER_MASK 0xf +static inline uint8_t get_break_after(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); +} +#undef BREAK_AFTER_INDEX +#undef BREAK_AFTER_SHIFT +#undef BREAK_AFTER_MASK + +#define BREAK_BEFORE_INDEX 13 +#define BREAK_BEFORE_SHIFT 12 +#define BREAK_BEFORE_MASK 0xf000 +static inline uint8_t get_break_before(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); +} +#undef BREAK_BEFORE_INDEX +#undef BREAK_BEFORE_SHIFT +#undef BREAK_BEFORE_MASK + +#define BREAK_INSIDE_INDEX 4 +#define BREAK_INSIDE_SHIFT 0 +#define BREAK_INSIDE_MASK 0xf +static inline uint8_t get_break_inside(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); +} +#undef BREAK_INSIDE_INDEX +#undef BREAK_INSIDE_SHIFT +#undef BREAK_INSIDE_MASK + +#define CAPTION_SIDE_INDEX 11 +#define CAPTION_SIDE_SHIFT 14 +#define CAPTION_SIDE_MASK 0xc000 static inline uint8_t get_caption_side(const css_computed_style *style) { uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX]; @@ -1178,9 +546,9 @@ static inline uint8_t get_caption_side(const css_computed_style *style) #undef CAPTION_SIDE_SHIFT #undef CAPTION_SIDE_MASK -#define CLEAR_INDEX 8 -#define CLEAR_SHIFT 2 -#define CLEAR_MASK 0x1c +#define CLEAR_INDEX 9 +#define CLEAR_SHIFT 20 +#define CLEAR_MASK 0x700000 static inline uint8_t get_clear(const css_computed_style *style) { uint32_t bits = style->i.bits[CLEAR_INDEX]; @@ -1195,9 +563,51 @@ static inline uint8_t get_clear(const css_computed_style *style) #undef CLEAR_SHIFT #undef CLEAR_MASK -#define COLOR_INDEX 10 -#define COLOR_SHIFT 24 -#define COLOR_MASK 0x1000000 +#define CLIP_INDEX 2 +#define CLIP_SHIFT 6 +#define CLIP_MASK 0xffffffc0 +static inline uint8_t get_clip( + const css_computed_style *style, + css_computed_clip_rect *rect) +{ + uint32_t bits = style->i.bits[CLIP_INDEX]; + bits &= CLIP_MASK; + bits >>= CLIP_SHIFT; + + /* + 26bits: tt tttr rrrr bbbb blll llTR BLyy: + units: top | right | bottom | left + opcodes: top | right | bottom | left | type + */ + + if ((bits & 0x3) == CSS_CLIP_RECT) { + rect->left_auto = (bits & 0x4); + rect->bottom_auto = (bits & 0x8); + rect->right_auto = (bits & 0x10); + rect->top_auto = (bits & 0x20); + + rect->top = style->i.clip_a; + rect->tunit = bits & 0x3e00000 >> 21; + + rect->right = style->i.clip_b; + rect->runit = bits & 0x1f0000 >> 16; + + rect->bottom = style->i.clip_c; + rect->bunit = (bits & 0xf800) >> 11; + + rect->left = style->i.clip_d; + rect->lunit = (bits & 0x7c0) >> 6; + } + + return (bits & 0x3); +} +#undef CLIP_INDEX +#undef CLIP_SHIFT +#undef CLIP_MASK + +#define COLOR_INDEX 14 +#define COLOR_SHIFT 23 +#define COLOR_MASK 0x800000 static inline uint8_t get_color(const css_computed_style *style, css_color *color) { @@ -1214,9 +624,242 @@ static inline uint8_t get_color(const css_computed_style *style, css_color #undef COLOR_SHIFT #undef COLOR_MASK -#define DIRECTION_INDEX 9 -#define DIRECTION_SHIFT 22 -#define DIRECTION_MASK 0xc00000 +#define COLUMN_COUNT_INDEX 10 +#define COLUMN_COUNT_SHIFT 2 +#define COLUMN_COUNT_MASK 0xc +static inline uint8_t get_column_count(const css_computed_style *style, int32_t + *integer) +{ + uint32_t bits = style->i.bits[COLUMN_COUNT_INDEX]; + bits &= COLUMN_COUNT_MASK; + bits >>= COLUMN_COUNT_SHIFT; + + /* 2bits: tt : type */ + *integer = style->i.column_count; + + return (bits & 0x3); +} +#undef COLUMN_COUNT_INDEX +#undef COLUMN_COUNT_SHIFT +#undef COLUMN_COUNT_MASK + +#define COLUMN_FILL_INDEX 11 +#define COLUMN_FILL_SHIFT 16 +#define COLUMN_FILL_MASK 0x30000 +static inline uint8_t get_column_fill(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); +} +#undef COLUMN_FILL_INDEX +#undef COLUMN_FILL_SHIFT +#undef COLUMN_FILL_MASK + +#define COLUMN_GAP_INDEX 5 +#define COLUMN_GAP_SHIFT 25 +#define COLUMN_GAP_MASK 0xfe000000 +static inline uint8_t get_column_gap(const css_computed_style *style, css_fixed + *length, css_unit *unit) +{ + uint32_t bits = style->i.bits[COLUMN_GAP_INDEX]; + bits &= COLUMN_GAP_MASK; + bits >>= COLUMN_GAP_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_COLUMN_GAP_SET) { + *length = style->i.column_gap; + *unit = bits >> 2; + } + + return (bits & 0x3); +} +#undef COLUMN_GAP_INDEX +#undef COLUMN_GAP_SHIFT +#undef COLUMN_GAP_MASK + +#define COLUMN_RULE_COLOR_INDEX 11 +#define COLUMN_RULE_COLOR_SHIFT 30 +#define COLUMN_RULE_COLOR_MASK 0xc0000000 +static inline uint8_t get_column_rule_color(const css_computed_style *style, + css_color *color) +{ + uint32_t bits = style->i.bits[COLUMN_RULE_COLOR_INDEX]; + bits &= COLUMN_RULE_COLOR_MASK; + bits >>= COLUMN_RULE_COLOR_SHIFT; + + /* 2bits: tt : type */ + *color = style->i.column_rule_color; + + return (bits & 0x3); +} +#undef COLUMN_RULE_COLOR_INDEX +#undef COLUMN_RULE_COLOR_SHIFT +#undef COLUMN_RULE_COLOR_MASK + +#define COLUMN_RULE_STYLE_INDEX 13 +#define COLUMN_RULE_STYLE_SHIFT 16 +#define COLUMN_RULE_STYLE_MASK 0xf0000 +static inline uint8_t get_column_rule_style(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); +} +#undef COLUMN_RULE_STYLE_INDEX +#undef COLUMN_RULE_STYLE_SHIFT +#undef COLUMN_RULE_STYLE_MASK + +#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(const css_computed_style *style, + css_fixed *length, css_unit *unit) +{ + uint32_t bits = style->i.bits[COLUMN_RULE_WIDTH_INDEX]; + bits &= COLUMN_RULE_WIDTH_MASK; + bits >>= COLUMN_RULE_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + if ((bits & 0x7) == CSS_COLUMN_RULE_WIDTH_WIDTH) { + *length = style->i.column_rule_width; + *unit = bits >> 3; + } + + return (bits & 0x7); +} +#undef COLUMN_RULE_WIDTH_INDEX +#undef COLUMN_RULE_WIDTH_SHIFT +#undef COLUMN_RULE_WIDTH_MASK + +#define COLUMN_SPAN_INDEX 11 +#define COLUMN_SPAN_SHIFT 24 +#define COLUMN_SPAN_MASK 0x3000000 +static inline uint8_t get_column_span(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); +} +#undef COLUMN_SPAN_INDEX +#undef COLUMN_SPAN_SHIFT +#undef COLUMN_SPAN_MASK + +#define COLUMN_WIDTH_INDEX 6 +#define COLUMN_WIDTH_SHIFT 18 +#define COLUMN_WIDTH_MASK 0x1fc0000 +static inline uint8_t get_column_width(const css_computed_style *style, + css_fixed *length, css_unit *unit) +{ + uint32_t bits = style->i.bits[COLUMN_WIDTH_INDEX]; + bits &= COLUMN_WIDTH_MASK; + bits >>= COLUMN_WIDTH_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_COLUMN_WIDTH_SET) { + *length = style->i.column_width; + *unit = bits >> 2; + } + + return (bits & 0x3); +} +#undef COLUMN_WIDTH_INDEX +#undef COLUMN_WIDTH_SHIFT +#undef COLUMN_WIDTH_MASK + +#define CONTENT_INDEX 11 +#define CONTENT_SHIFT 8 +#define CONTENT_MASK 0x300 +static inline uint8_t get_content(const css_computed_style *style, const + css_computed_content_item **content_item) +{ + uint32_t bits = style->i.bits[CONTENT_INDEX]; + bits &= CONTENT_MASK; + bits >>= CONTENT_SHIFT; + + /* 2bits: tt : type */ + if ((bits & 0x3) == CSS_CONTENT_SET) { + *content_item = style->content; + } + + return (bits & 0x3); +} +#undef CONTENT_INDEX +#undef CONTENT_SHIFT +#undef CONTENT_MASK + +#define COUNTER_INCREMENT_INDEX 14 +#define COUNTER_INCREMENT_SHIFT 22 +#define COUNTER_INCREMENT_MASK 0x400000 +static inline uint8_t get_counter_increment(const css_computed_style *style, + const css_computed_counter **counter_arr) +{ + uint32_t bits = style->i.bits[COUNTER_INCREMENT_INDEX]; + bits &= COUNTER_INCREMENT_MASK; + bits >>= COUNTER_INCREMENT_SHIFT; + + /* 1bit: t : type */ + *counter_arr = style->counter_increment; + + return (bits & 0x1); +} +#undef COUNTER_INCREMENT_INDEX +#undef COUNTER_INCREMENT_SHIFT +#undef COUNTER_INCREMENT_MASK + +#define COUNTER_RESET_INDEX 14 +#define COUNTER_RESET_SHIFT 27 +#define COUNTER_RESET_MASK 0x8000000 +static inline uint8_t get_counter_reset(const css_computed_style *style, const + css_computed_counter **counter_arr) +{ + uint32_t bits = style->i.bits[COUNTER_RESET_INDEX]; + bits &= COUNTER_RESET_MASK; + bits >>= COUNTER_RESET_SHIFT; + + /* 1bit: t : type */ + *counter_arr = style->counter_reset; + + return (bits & 0x1); +} +#undef COUNTER_RESET_INDEX +#undef COUNTER_RESET_SHIFT +#undef COUNTER_RESET_MASK + +#define CURSOR_INDEX 3 +#define CURSOR_SHIFT 0 +#define CURSOR_MASK 0x1f +static inline uint8_t get_cursor(const css_computed_style *style, lwc_string + ***string_arr) +{ + uint32_t bits = style->i.bits[CURSOR_INDEX]; + bits &= CURSOR_MASK; + bits >>= CURSOR_SHIFT; + + /* 5bits: ttttt : type */ + *string_arr = style->cursor; + + return (bits & 0x1f); +} +#undef CURSOR_INDEX +#undef CURSOR_SHIFT +#undef CURSOR_MASK + +#define DIRECTION_INDEX 11 +#define DIRECTION_SHIFT 26 +#define DIRECTION_MASK 0xc000000 static inline uint8_t get_direction(const css_computed_style *style) { uint32_t bits = style->i.bits[DIRECTION_INDEX]; @@ -1231,9 +874,9 @@ static inline uint8_t get_direction(const css_computed_style *style) #undef DIRECTION_SHIFT #undef DIRECTION_MASK -#define DISPLAY_INDEX 6 -#define DISPLAY_SHIFT 27 -#define DISPLAY_MASK 0xf8000000 +#define DISPLAY_INDEX 8 +#define DISPLAY_SHIFT 9 +#define DISPLAY_MASK 0x3e00 static inline uint8_t get_display(const css_computed_style *style) { uint32_t bits = style->i.bits[DISPLAY_INDEX]; @@ -1248,9 +891,9 @@ static inline uint8_t get_display(const css_computed_style *style) #undef DISPLAY_SHIFT #undef DISPLAY_MASK -#define EMPTY_CELLS_INDEX 9 -#define EMPTY_CELLS_SHIFT 18 -#define EMPTY_CELLS_MASK 0xc0000 +#define EMPTY_CELLS_INDEX 11 +#define EMPTY_CELLS_SHIFT 28 +#define EMPTY_CELLS_MASK 0x30000000 static inline uint8_t get_empty_cells(const css_computed_style *style) { uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX]; @@ -1265,9 +908,9 @@ static inline uint8_t get_empty_cells(const css_computed_style *style) #undef EMPTY_CELLS_SHIFT #undef EMPTY_CELLS_MASK -#define FLEX_BASIS_INDEX 2 -#define FLEX_BASIS_SHIFT 11 -#define FLEX_BASIS_MASK 0x3f800 +#define FLEX_BASIS_INDEX 3 +#define FLEX_BASIS_SHIFT 18 +#define FLEX_BASIS_MASK 0x1fc0000 static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1287,7 +930,7 @@ static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed #undef FLEX_BASIS_SHIFT #undef FLEX_BASIS_MASK -#define FLEX_DIRECTION_INDEX 8 +#define FLEX_DIRECTION_INDEX 9 #define FLEX_DIRECTION_SHIFT 11 #define FLEX_DIRECTION_MASK 0x3800 static inline uint8_t get_flex_direction(const css_computed_style *style) @@ -1304,9 +947,9 @@ static inline uint8_t get_flex_direction(const css_computed_style *style) #undef FLEX_DIRECTION_SHIFT #undef FLEX_DIRECTION_MASK -#define FLEX_GROW_INDEX 10 -#define FLEX_GROW_SHIFT 21 -#define FLEX_GROW_MASK 0x200000 +#define FLEX_GROW_INDEX 14 +#define FLEX_GROW_SHIFT 29 +#define FLEX_GROW_MASK 0x20000000 static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed *fixed) { @@ -1325,9 +968,9 @@ static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed #undef FLEX_GROW_SHIFT #undef FLEX_GROW_MASK -#define FLEX_SHRINK_INDEX 10 -#define FLEX_SHRINK_SHIFT 23 -#define FLEX_SHRINK_MASK 0x800000 +#define FLEX_SHRINK_INDEX 14 +#define FLEX_SHRINK_SHIFT 26 +#define FLEX_SHRINK_MASK 0x4000000 static inline uint8_t get_flex_shrink(const css_computed_style *style, css_fixed *fixed) { @@ -1346,9 +989,9 @@ static inline uint8_t get_flex_shrink(const css_computed_style *style, #undef FLEX_SHRINK_SHIFT #undef FLEX_SHRINK_MASK -#define FLEX_WRAP_INDEX 9 -#define FLEX_WRAP_SHIFT 28 -#define FLEX_WRAP_MASK 0x30000000 +#define FLEX_WRAP_INDEX 14 +#define FLEX_WRAP_SHIFT 30 +#define FLEX_WRAP_MASK 0xc0000000 static inline uint8_t get_flex_wrap(const css_computed_style *style) { uint32_t bits = style->i.bits[FLEX_WRAP_INDEX]; @@ -1363,9 +1006,9 @@ static inline uint8_t get_flex_wrap(const css_computed_style *style) #undef FLEX_WRAP_SHIFT #undef FLEX_WRAP_MASK -#define FLOAT_INDEX 9 -#define FLOAT_SHIFT 8 -#define FLOAT_MASK 0x300 +#define FLOAT_INDEX 10 +#define FLOAT_SHIFT 12 +#define FLOAT_MASK 0x3000 static inline uint8_t get_float(const css_computed_style *style) { uint32_t bits = style->i.bits[FLOAT_INDEX]; @@ -1380,9 +1023,9 @@ static inline uint8_t get_float(const css_computed_style *style) #undef FLOAT_SHIFT #undef FLOAT_MASK -#define FONT_FAMILY_INDEX 8 -#define FONT_FAMILY_SHIFT 26 -#define FONT_FAMILY_MASK 0x1c000000 +#define FONT_FAMILY_INDEX 9 +#define FONT_FAMILY_SHIFT 29 +#define FONT_FAMILY_MASK 0xe0000000 static inline uint8_t get_font_family(const css_computed_style *style, lwc_string ***string_arr) { @@ -1399,9 +1042,9 @@ static inline uint8_t get_font_family(const css_computed_style *style, #undef FONT_FAMILY_SHIFT #undef FONT_FAMILY_MASK -#define FONT_SIZE_INDEX 5 -#define FONT_SIZE_SHIFT 3 -#define FONT_SIZE_MASK 0xff8 +#define FONT_SIZE_INDEX 1 +#define FONT_SIZE_SHIFT 23 +#define FONT_SIZE_MASK 0xff800000 static inline uint8_t get_font_size(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1421,9 +1064,9 @@ 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 7 -#define FONT_STYLE_SHIFT 0 -#define FONT_STYLE_MASK 0x3 +#define FONT_STYLE_INDEX 11 +#define FONT_STYLE_SHIFT 22 +#define FONT_STYLE_MASK 0xc00000 static inline uint8_t get_font_style(const css_computed_style *style) { uint32_t bits = style->i.bits[FONT_STYLE_INDEX]; @@ -1438,9 +1081,9 @@ static inline uint8_t get_font_style(const css_computed_style *style) #undef FONT_STYLE_SHIFT #undef FONT_STYLE_MASK -#define FONT_VARIANT_INDEX 9 -#define FONT_VARIANT_SHIFT 10 -#define FONT_VARIANT_MASK 0xc00 +#define FONT_VARIANT_INDEX 11 +#define FONT_VARIANT_SHIFT 4 +#define FONT_VARIANT_MASK 0x30 static inline uint8_t get_font_variant(const css_computed_style *style) { uint32_t bits = style->i.bits[FONT_VARIANT_INDEX]; @@ -1455,9 +1098,9 @@ static inline uint8_t get_font_variant(const css_computed_style *style) #undef FONT_VARIANT_SHIFT #undef FONT_VARIANT_MASK -#define FONT_WEIGHT_INDEX 3 -#define FONT_WEIGHT_SHIFT 0 -#define FONT_WEIGHT_MASK 0xf +#define FONT_WEIGHT_INDEX 13 +#define FONT_WEIGHT_SHIFT 28 +#define FONT_WEIGHT_MASK 0xf0000000 static inline uint8_t get_font_weight(const css_computed_style *style) { uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX]; @@ -1473,8 +1116,8 @@ static inline uint8_t get_font_weight(const css_computed_style *style) #undef FONT_WEIGHT_MASK #define HEIGHT_INDEX 4 -#define HEIGHT_SHIFT 4 -#define HEIGHT_MASK 0x7f0 +#define HEIGHT_SHIFT 18 +#define HEIGHT_MASK 0x1fc0000 static inline uint8_t get_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1494,9 +1137,9 @@ static inline uint8_t get_height(const css_computed_style *style, css_fixed #undef HEIGHT_SHIFT #undef HEIGHT_MASK -#define JUSTIFY_CONTENT_INDEX 8 -#define JUSTIFY_CONTENT_SHIFT 8 -#define JUSTIFY_CONTENT_MASK 0x700 +#define JUSTIFY_CONTENT_INDEX 9 +#define JUSTIFY_CONTENT_SHIFT 14 +#define JUSTIFY_CONTENT_MASK 0x1c000 static inline uint8_t get_justify_content(const css_computed_style *style) { uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX]; @@ -1511,9 +1154,9 @@ 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 25 -#define LEFT_MASK 0xfe000000 +#define LEFT_INDEX 5 +#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) @@ -1544,7 +1187,29 @@ static inline uint8_t get_left_bits( #undef LEFT_SHIFT #undef LEFT_MASK -#define LINE_HEIGHT_INDEX 1 +#define LETTER_SPACING_INDEX 7 +#define LETTER_SPACING_SHIFT 11 +#define LETTER_SPACING_MASK 0x3f800 +static inline uint8_t get_letter_spacing(const css_computed_style *style, + css_fixed *length, css_unit *unit) +{ + uint32_t bits = style->i.bits[LETTER_SPACING_INDEX]; + bits &= LETTER_SPACING_MASK; + bits >>= LETTER_SPACING_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_LETTER_SPACING_SET) { + *length = style->i.letter_spacing; + *unit = bits >> 2; + } + + return (bits & 0x3); +} +#undef LETTER_SPACING_INDEX +#undef LETTER_SPACING_SHIFT +#undef LETTER_SPACING_MASK + +#define LINE_HEIGHT_INDEX 4 #define LINE_HEIGHT_SHIFT 25 #define LINE_HEIGHT_MASK 0xfe000000 static inline uint8_t get_line_height( @@ -1571,9 +1236,9 @@ static inline uint8_t get_line_height( #undef LINE_HEIGHT_SHIFT #undef LINE_HEIGHT_MASK -#define LIST_STYLE_IMAGE_INDEX 10 -#define LIST_STYLE_IMAGE_SHIFT 26 -#define LIST_STYLE_IMAGE_MASK 0x4000000 +#define LIST_STYLE_IMAGE_INDEX 14 +#define LIST_STYLE_IMAGE_SHIFT 21 +#define LIST_STYLE_IMAGE_MASK 0x200000 static inline uint8_t get_list_style_image(const css_computed_style *style, lwc_string **string) { @@ -1590,9 +1255,9 @@ 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 9 -#define LIST_STYLE_POSITION_SHIFT 2 -#define LIST_STYLE_POSITION_MASK 0xc +#define LIST_STYLE_POSITION_INDEX 11 +#define LIST_STYLE_POSITION_SHIFT 10 +#define LIST_STYLE_POSITION_MASK 0xc00 static inline uint8_t get_list_style_position(const css_computed_style *style) { uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX]; @@ -1607,9 +1272,9 @@ static inline uint8_t get_list_style_position(const css_computed_style *style) #undef LIST_STYLE_POSITION_SHIFT #undef LIST_STYLE_POSITION_MASK -#define LIST_STYLE_TYPE_INDEX 6 -#define LIST_STYLE_TYPE_SHIFT 18 -#define LIST_STYLE_TYPE_MASK 0x3c0000 +#define LIST_STYLE_TYPE_INDEX 8 +#define LIST_STYLE_TYPE_SHIFT 0 +#define LIST_STYLE_TYPE_MASK 0xf static inline uint8_t get_list_style_type(const css_computed_style *style) { uint32_t bits = style->i.bits[LIST_STYLE_TYPE_INDEX]; @@ -1624,7 +1289,7 @@ 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 3 +#define MARGIN_BOTTOM_INDEX 4 #define MARGIN_BOTTOM_SHIFT 4 #define MARGIN_BOTTOM_MASK 0x7f0 static inline uint8_t get_margin_bottom(const css_computed_style *style, @@ -1646,7 +1311,7 @@ static inline uint8_t get_margin_bottom(const css_computed_style *style, #undef MARGIN_BOTTOM_SHIFT #undef MARGIN_BOTTOM_MASK -#define MARGIN_LEFT_INDEX 1 +#define MARGIN_LEFT_INDEX 6 #define MARGIN_LEFT_SHIFT 4 #define MARGIN_LEFT_MASK 0x7f0 static inline uint8_t get_margin_left(const css_computed_style *style, @@ -1668,9 +1333,9 @@ static inline uint8_t get_margin_left(const css_computed_style *style, #undef MARGIN_LEFT_SHIFT #undef MARGIN_LEFT_MASK -#define MARGIN_RIGHT_INDEX 2 -#define MARGIN_RIGHT_SHIFT 18 -#define MARGIN_RIGHT_MASK 0x1fc0000 +#define MARGIN_RIGHT_INDEX 7 +#define MARGIN_RIGHT_SHIFT 4 +#define MARGIN_RIGHT_MASK 0x7f0 static inline uint8_t get_margin_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1690,7 +1355,7 @@ static inline uint8_t get_margin_right(const css_computed_style *style, #undef MARGIN_RIGHT_SHIFT #undef MARGIN_RIGHT_MASK -#define MARGIN_TOP_INDEX 3 +#define MARGIN_TOP_INDEX 5 #define MARGIN_TOP_SHIFT 18 #define MARGIN_TOP_MASK 0x1fc0000 static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed @@ -1712,9 +1377,9 @@ 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 2 -#define MAX_HEIGHT_SHIFT 4 -#define MAX_HEIGHT_MASK 0x7f0 +#define MAX_HEIGHT_INDEX 5 +#define MAX_HEIGHT_SHIFT 11 +#define MAX_HEIGHT_MASK 0x3f800 static inline uint8_t get_max_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1734,7 +1399,7 @@ 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 2 +#define MAX_WIDTH_INDEX 6 #define MAX_WIDTH_SHIFT 25 #define MAX_WIDTH_MASK 0xfe000000 static inline uint8_t get_max_width(const css_computed_style *style, css_fixed @@ -1757,8 +1422,8 @@ static inline uint8_t get_max_width(const css_computed_style *style, css_fixed #undef MAX_WIDTH_MASK #define MIN_HEIGHT_INDEX 3 -#define MIN_HEIGHT_SHIFT 11 -#define MIN_HEIGHT_MASK 0x3f800 +#define MIN_HEIGHT_SHIFT 25 +#define MIN_HEIGHT_MASK 0xfe000000 static inline uint8_t get_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1778,9 +1443,9 @@ 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 1 -#define MIN_WIDTH_SHIFT 11 -#define MIN_WIDTH_MASK 0x3f800 +#define MIN_WIDTH_INDEX 7 +#define MIN_WIDTH_SHIFT 25 +#define MIN_WIDTH_MASK 0xfe000000 static inline uint8_t get_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1800,9 +1465,9 @@ static inline uint8_t get_min_width(const css_computed_style *style, css_fixed #undef MIN_WIDTH_SHIFT #undef MIN_WIDTH_MASK -#define OPACITY_INDEX 10 -#define OPACITY_SHIFT 22 -#define OPACITY_MASK 0x400000 +#define OPACITY_INDEX 14 +#define OPACITY_SHIFT 24 +#define OPACITY_MASK 0x1000000 static inline uint8_t get_opacity(const css_computed_style *style, css_fixed *fixed) { @@ -1821,9 +1486,9 @@ static inline uint8_t get_opacity(const css_computed_style *style, css_fixed #undef OPACITY_SHIFT #undef OPACITY_MASK -#define ORDER_INDEX 10 -#define ORDER_SHIFT 27 -#define ORDER_MASK 0x8000000 +#define ORDER_INDEX 12 +#define ORDER_SHIFT 0 +#define ORDER_MASK 0x1 static inline uint8_t get_order(const css_computed_style *style, int32_t *integer) { @@ -1842,9 +1507,49 @@ static inline uint8_t get_order(const css_computed_style *style, int32_t #undef ORDER_SHIFT #undef ORDER_MASK -#define OUTLINE_STYLE_INDEX 1 -#define OUTLINE_STYLE_SHIFT 0 -#define OUTLINE_STYLE_MASK 0xf +#define ORPHANS_INDEX 14 +#define ORPHANS_SHIFT 20 +#define ORPHANS_MASK 0x100000 +static inline uint8_t get_orphans(const css_computed_style *style, int32_t + *integer) +{ + uint32_t bits = style->i.bits[ORPHANS_INDEX]; + bits &= ORPHANS_MASK; + bits >>= ORPHANS_SHIFT; + + /* 1bit: t : type */ + *integer = style->i.orphans; + + return (bits & 0x1); +} +#undef ORPHANS_INDEX +#undef ORPHANS_SHIFT +#undef ORPHANS_MASK + +#define OUTLINE_COLOR_INDEX 11 +#define OUTLINE_COLOR_SHIFT 20 +#define OUTLINE_COLOR_MASK 0x300000 +static inline uint8_t get_outline_color(const css_computed_style *style, + css_color *color) +{ + uint32_t bits = style->i.bits[OUTLINE_COLOR_INDEX]; + bits &= OUTLINE_COLOR_MASK; + bits >>= OUTLINE_COLOR_SHIFT; + + /* 2bits: tt : type */ + if ((bits & 0x3) == CSS_OUTLINE_COLOR_COLOR) { + *color = style->i.outline_color; + } + + return (bits & 0x3); +} +#undef OUTLINE_COLOR_INDEX +#undef OUTLINE_COLOR_SHIFT +#undef OUTLINE_COLOR_MASK + +#define OUTLINE_STYLE_INDEX 13 +#define OUTLINE_STYLE_SHIFT 24 +#define OUTLINE_STYLE_MASK 0xf000000 static inline uint8_t get_outline_style(const css_computed_style *style) { uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX]; @@ -1859,9 +1564,31 @@ static inline uint8_t get_outline_style(const css_computed_style *style) #undef OUTLINE_STYLE_SHIFT #undef OUTLINE_STYLE_MASK -#define OVERFLOW_X_INDEX 8 -#define OVERFLOW_X_SHIFT 5 -#define OVERFLOW_X_MASK 0xe0 +#define OUTLINE_WIDTH_INDEX 0 +#define OUTLINE_WIDTH_SHIFT 0 +#define OUTLINE_WIDTH_MASK 0xff +static inline uint8_t get_outline_width(const css_computed_style *style, + css_fixed *length, css_unit *unit) +{ + uint32_t bits = style->i.bits[OUTLINE_WIDTH_INDEX]; + bits &= OUTLINE_WIDTH_MASK; + bits >>= OUTLINE_WIDTH_SHIFT; + + /* 8bits: uuuuuttt : unit | type */ + if ((bits & 0x7) == CSS_OUTLINE_WIDTH_WIDTH) { + *length = style->i.outline_width; + *unit = bits >> 3; + } + + return (bits & 0x7); +} +#undef OUTLINE_WIDTH_INDEX +#undef OUTLINE_WIDTH_SHIFT +#undef OUTLINE_WIDTH_MASK + +#define OVERFLOW_X_INDEX 10 +#define OVERFLOW_X_SHIFT 29 +#define OVERFLOW_X_MASK 0xe0000000 static inline uint8_t get_overflow_x(const css_computed_style *style) { uint32_t bits = style->i.bits[OVERFLOW_X_INDEX]; @@ -1876,9 +1603,9 @@ static inline uint8_t get_overflow_x(const css_computed_style *style) #undef OVERFLOW_X_SHIFT #undef OVERFLOW_X_MASK -#define OVERFLOW_Y_INDEX 8 -#define OVERFLOW_Y_SHIFT 29 -#define OVERFLOW_Y_MASK 0xe0000000 +#define OVERFLOW_Y_INDEX 10 +#define OVERFLOW_Y_SHIFT 20 +#define OVERFLOW_Y_MASK 0x700000 static inline uint8_t get_overflow_y(const css_computed_style *style) { uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX]; @@ -1893,9 +1620,9 @@ static inline uint8_t get_overflow_y(const css_computed_style *style) #undef OVERFLOW_Y_SHIFT #undef OVERFLOW_Y_MASK -#define PADDING_BOTTOM_INDEX 7 -#define PADDING_BOTTOM_SHIFT 20 -#define PADDING_BOTTOM_MASK 0x3f00000 +#define PADDING_BOTTOM_INDEX 8 +#define PADDING_BOTTOM_SHIFT 26 +#define PADDING_BOTTOM_MASK 0xfc000000 static inline uint8_t get_padding_bottom(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1915,9 +1642,9 @@ static inline uint8_t get_padding_bottom(const css_computed_style *style, #undef PADDING_BOTTOM_SHIFT #undef PADDING_BOTTOM_MASK -#define PADDING_LEFT_INDEX 7 -#define PADDING_LEFT_SHIFT 26 -#define PADDING_LEFT_MASK 0xfc000000 +#define PADDING_LEFT_INDEX 8 +#define PADDING_LEFT_SHIFT 14 +#define PADDING_LEFT_MASK 0xfc000 static inline uint8_t get_padding_left(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1937,9 +1664,9 @@ static inline uint8_t get_padding_left(const css_computed_style *style, #undef PADDING_LEFT_SHIFT #undef PADDING_LEFT_MASK -#define PADDING_RIGHT_INDEX 7 -#define PADDING_RIGHT_SHIFT 8 -#define PADDING_RIGHT_MASK 0x3f00 +#define PADDING_RIGHT_INDEX 2 +#define PADDING_RIGHT_SHIFT 0 +#define PADDING_RIGHT_MASK 0x3f static inline uint8_t get_padding_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1959,9 +1686,9 @@ static inline uint8_t get_padding_right(const css_computed_style *style, #undef PADDING_RIGHT_SHIFT #undef PADDING_RIGHT_MASK -#define PADDING_TOP_INDEX 7 -#define PADDING_TOP_SHIFT 14 -#define PADDING_TOP_MASK 0xfc000 +#define PADDING_TOP_INDEX 8 +#define PADDING_TOP_SHIFT 20 +#define PADDING_TOP_MASK 0x3f00000 static inline uint8_t get_padding_top(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -1981,9 +1708,60 @@ static inline uint8_t get_padding_top(const css_computed_style *style, #undef PADDING_TOP_SHIFT #undef PADDING_TOP_MASK -#define POSITION_INDEX 5 -#define POSITION_SHIFT 0 -#define POSITION_MASK 0x7 +#define PAGE_BREAK_AFTER_INDEX 9 +#define PAGE_BREAK_AFTER_SHIFT 8 +#define PAGE_BREAK_AFTER_MASK 0x700 +static inline uint8_t get_page_break_after(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); +} +#undef PAGE_BREAK_AFTER_INDEX +#undef PAGE_BREAK_AFTER_SHIFT +#undef PAGE_BREAK_AFTER_MASK + +#define PAGE_BREAK_BEFORE_INDEX 9 +#define PAGE_BREAK_BEFORE_SHIFT 2 +#define PAGE_BREAK_BEFORE_MASK 0x1c +static inline uint8_t get_page_break_before(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); +} +#undef PAGE_BREAK_BEFORE_INDEX +#undef PAGE_BREAK_BEFORE_SHIFT +#undef PAGE_BREAK_BEFORE_MASK + +#define PAGE_BREAK_INSIDE_INDEX 11 +#define PAGE_BREAK_INSIDE_SHIFT 0 +#define PAGE_BREAK_INSIDE_MASK 0x3 +static inline uint8_t get_page_break_inside(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); +} +#undef PAGE_BREAK_INSIDE_INDEX +#undef PAGE_BREAK_INSIDE_SHIFT +#undef PAGE_BREAK_INSIDE_MASK + +#define POSITION_INDEX 9 +#define POSITION_SHIFT 26 +#define POSITION_MASK 0x1c000000 static inline uint8_t get_position(const css_computed_style *style) { uint32_t bits = style->i.bits[POSITION_INDEX]; @@ -1998,9 +1776,9 @@ static inline uint8_t get_position(const css_computed_style *style) #undef POSITION_SHIFT #undef POSITION_MASK -#define QUOTES_INDEX 10 -#define QUOTES_SHIFT 20 -#define QUOTES_MASK 0x100000 +#define QUOTES_INDEX 13 +#define QUOTES_SHIFT 0 +#define QUOTES_MASK 0x1 static inline uint8_t get_quotes(const css_computed_style *style, lwc_string ***string_arr) { @@ -2017,7 +1795,7 @@ static inline uint8_t get_quotes(const css_computed_style *style, lwc_string #undef QUOTES_SHIFT #undef QUOTES_MASK -#define RIGHT_INDEX 1 +#define RIGHT_INDEX 7 #define RIGHT_SHIFT 18 #define RIGHT_MASK 0x1fc0000 static inline uint8_t get_right( @@ -2050,9 +1828,9 @@ static inline uint8_t get_right_bits( #undef RIGHT_SHIFT #undef RIGHT_MASK -#define TABLE_LAYOUT_INDEX 9 -#define TABLE_LAYOUT_SHIFT 0 -#define TABLE_LAYOUT_MASK 0x3 +#define TABLE_LAYOUT_INDEX 11 +#define TABLE_LAYOUT_SHIFT 18 +#define TABLE_LAYOUT_MASK 0xc0000 static inline uint8_t get_table_layout(const css_computed_style *style) { uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX]; @@ -2067,9 +1845,9 @@ static inline uint8_t get_table_layout(const css_computed_style *style) #undef TABLE_LAYOUT_SHIFT #undef TABLE_LAYOUT_MASK -#define TEXT_ALIGN_INDEX 2 -#define TEXT_ALIGN_SHIFT 0 -#define TEXT_ALIGN_MASK 0xf +#define TEXT_ALIGN_INDEX 13 +#define TEXT_ALIGN_SHIFT 4 +#define TEXT_ALIGN_MASK 0xf0 static inline uint8_t get_text_align(const css_computed_style *style) { uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX]; @@ -2084,9 +1862,9 @@ static inline uint8_t get_text_align(const css_computed_style *style) #undef TEXT_ALIGN_SHIFT #undef TEXT_ALIGN_MASK -#define TEXT_DECORATION_INDEX 6 -#define TEXT_DECORATION_SHIFT 22 -#define TEXT_DECORATION_MASK 0x7c00000 +#define TEXT_DECORATION_INDEX 8 +#define TEXT_DECORATION_SHIFT 4 +#define TEXT_DECORATION_MASK 0x1f0 static inline uint8_t get_text_decoration(const css_computed_style *style) { uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX]; @@ -2101,9 +1879,9 @@ static inline uint8_t get_text_decoration(const css_computed_style *style) #undef TEXT_DECORATION_SHIFT #undef TEXT_DECORATION_MASK -#define TEXT_INDENT_INDEX 7 -#define TEXT_INDENT_SHIFT 2 -#define TEXT_INDENT_MASK 0xfc +#define TEXT_INDENT_INDEX 3 +#define TEXT_INDENT_SHIFT 5 +#define TEXT_INDENT_MASK 0x7e0 static inline uint8_t get_text_indent(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -2123,9 +1901,9 @@ static inline uint8_t get_text_indent(const css_computed_style *style, #undef TEXT_INDENT_SHIFT #undef TEXT_INDENT_MASK -#define TEXT_TRANSFORM_INDEX 6 -#define TEXT_TRANSFORM_SHIFT 3 -#define TEXT_TRANSFORM_MASK 0x38 +#define TEXT_TRANSFORM_INDEX 10 +#define TEXT_TRANSFORM_SHIFT 23 +#define TEXT_TRANSFORM_MASK 0x3800000 static inline uint8_t get_text_transform(const css_computed_style *style) { uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX]; @@ -2140,9 +1918,9 @@ static inline uint8_t get_text_transform(const css_computed_style *style) #undef TEXT_TRANSFORM_SHIFT #undef TEXT_TRANSFORM_MASK -#define TOP_INDEX 3 -#define TOP_SHIFT 25 -#define TOP_MASK 0xfe000000 +#define TOP_INDEX 1 +#define TOP_SHIFT 0 +#define TOP_MASK 0x7f static inline uint8_t get_top( const css_computed_style *style, css_fixed *length, css_unit *unit) @@ -2173,9 +1951,9 @@ static inline uint8_t get_top_bits( #undef TOP_SHIFT #undef TOP_MASK -#define UNICODE_BIDI_INDEX 9 -#define UNICODE_BIDI_SHIFT 16 -#define UNICODE_BIDI_MASK 0x30000 +#define UNICODE_BIDI_INDEX 11 +#define UNICODE_BIDI_SHIFT 6 +#define UNICODE_BIDI_MASK 0xc0 static inline uint8_t get_unicode_bidi(const css_computed_style *style) { uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX]; @@ -2190,9 +1968,9 @@ static inline uint8_t get_unicode_bidi(const css_computed_style *style) #undef UNICODE_BIDI_SHIFT #undef UNICODE_BIDI_MASK -#define VERTICAL_ALIGN_INDEX 5 -#define VERTICAL_ALIGN_SHIFT 12 -#define VERTICAL_ALIGN_MASK 0x1ff000 +#define VERTICAL_ALIGN_INDEX 12 +#define VERTICAL_ALIGN_SHIFT 1 +#define VERTICAL_ALIGN_MASK 0x3fe static inline uint8_t get_vertical_align(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -2213,8 +1991,8 @@ static inline uint8_t get_vertical_align(const css_computed_style *style, #undef VERTICAL_ALIGN_MASK #define VISIBILITY_INDEX 10 -#define VISIBILITY_SHIFT 28 -#define VISIBILITY_MASK 0x30000000 +#define VISIBILITY_SHIFT 18 +#define VISIBILITY_MASK 0xc0000 static inline uint8_t get_visibility(const css_computed_style *style) { uint32_t bits = style->i.bits[VISIBILITY_INDEX]; @@ -2229,9 +2007,9 @@ static inline uint8_t get_visibility(const css_computed_style *style) #undef VISIBILITY_SHIFT #undef VISIBILITY_MASK -#define WHITE_SPACE_INDEX 6 -#define WHITE_SPACE_SHIFT 0 -#define WHITE_SPACE_MASK 0x7 +#define WHITE_SPACE_INDEX 9 +#define WHITE_SPACE_SHIFT 23 +#define WHITE_SPACE_MASK 0x3800000 static inline uint8_t get_white_space(const css_computed_style *style) { uint32_t bits = style->i.bits[WHITE_SPACE_INDEX]; @@ -2246,9 +2024,28 @@ 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 25 +#define WIDOWS_MASK 0x2000000 +static inline uint8_t get_widows(const css_computed_style *style, int32_t + *integer) +{ + uint32_t bits = style->i.bits[WIDOWS_INDEX]; + bits &= WIDOWS_MASK; + bits >>= WIDOWS_SHIFT; + + /* 1bit: t : type */ + *integer = style->i.widows; + + return (bits & 0x1); +} +#undef WIDOWS_INDEX +#undef WIDOWS_SHIFT +#undef WIDOWS_MASK + #define WIDTH_INDEX 4 -#define WIDTH_SHIFT 18 -#define WIDTH_MASK 0x1fc0000 +#define WIDTH_SHIFT 11 +#define WIDTH_MASK 0x3f800 static inline uint8_t get_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { @@ -2268,9 +2065,48 @@ static inline uint8_t get_width(const css_computed_style *style, css_fixed #undef WIDTH_SHIFT #undef WIDTH_MASK +#define WORD_SPACING_INDEX 3 +#define WORD_SPACING_SHIFT 11 +#define WORD_SPACING_MASK 0x3f800 +static inline uint8_t get_word_spacing(const css_computed_style *style, + css_fixed *length, css_unit *unit) +{ + uint32_t bits = style->i.bits[WORD_SPACING_INDEX]; + bits &= WORD_SPACING_MASK; + bits >>= WORD_SPACING_SHIFT; + + /* 7bits: uuuuutt : unit | type */ + if ((bits & 0x3) == CSS_WORD_SPACING_SET) { + *length = style->i.word_spacing; + *unit = bits >> 2; + } + + return (bits & 0x3); +} +#undef WORD_SPACING_INDEX +#undef WORD_SPACING_SHIFT +#undef WORD_SPACING_MASK + +#define WRITING_MODE_INDEX 10 +#define WRITING_MODE_SHIFT 6 +#define WRITING_MODE_MASK 0xc0 +static inline uint8_t get_writing_mode(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); +} +#undef WRITING_MODE_INDEX +#undef WRITING_MODE_SHIFT +#undef WRITING_MODE_MASK + #define Z_INDEX_INDEX 10 -#define Z_INDEX_SHIFT 30 -#define Z_INDEX_MASK 0xc0000000 +#define Z_INDEX_SHIFT 4 +#define Z_INDEX_MASK 0x30 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 94fc887..4e0d29d 100644 --- a/src/select/autogenerated_propset.h +++ b/src/select/autogenerated_propset.h @@ -7,874 +7,10 @@ /** Default values are 'initial value', unless the property is inherited, * in which case it is 'inherit'. */ -static const css_computed_uncommon default_uncommon = { - .i = { - .bits = { - (CSS_BORDER_SPACING_SET << 21) | ( - CSS_OUTLINE_WIDTH_MEDIUM << 13) | ( - CSS_COLUMN_RULE_WIDTH_MEDIUM << 5) | - CSS_CURSOR_AUTO, - (CSS_COLUMN_WIDTH_AUTO << 25) | (CSS_COLUMN_GAP_NORMAL - << 18) | (CSS_LETTER_SPACING_NORMAL << - 11) | (CSS_WORD_SPACING_NORMAL << 4) | - CSS_BREAK_BEFORE_AUTO, - (CSS_CLIP_AUTO << 6) | (CSS_COLUMN_RULE_STYLE_NONE << - 2) | - CSS_COLUMN_RULE_COLOR_CURRENT_COLOR, - (CSS_BREAK_AFTER_AUTO << 28) | (CSS_BREAK_INSIDE_AUTO - << 24) | (CSS_CONTENT_NORMAL << 22) | ( - CSS_WRITING_MODE_HORIZONTAL_TB << 20) | - (CSS_COLUMN_FILL_BALANCE << 18) | ( - CSS_COLUMN_SPAN_NONE << 16) | ( - CSS_COLUMN_COUNT_AUTO << 14) | ( - CSS_OUTLINE_COLOR_INVERT << 12) | ( - CSS_COUNTER_INCREMENT_NONE << 11) | ( - CSS_COUNTER_RESET_NONE << 10) - }, - .border_spacing_a = 0, - .border_spacing_b = 0, - .clip_a = 0, - .clip_b = 0, - .clip_c = 0, - .clip_d = 0, - .column_count = 0, - .column_gap = 0, - .column_rule_color = 0, - .column_rule_width = 0, - .column_width = 0, - .letter_spacing = 0, - .outline_color = 0, - .outline_width = 0, - .word_spacing = 0 - }, - .content = NULL, - .counter_increment = NULL, - .counter_reset = NULL, - .cursor = NULL, - .next = NULL, - .count = 0, - .bin = UINT32_MAX -}; - -#define ENSURE_UNCOMMON do { \ - if (style->i.uncommon == NULL) { \ - style->i.uncommon = malloc(sizeof( \ - css_computed_uncommon)); \ - if (style->i.uncommon == NULL) \ - return CSS_NOMEM; \ - \ - memcpy(style->i.uncommon, &default_uncommon, sizeof( \ - css_computed_uncommon)); \ - } \ -} while(0) \ - - -#define BORDER_SPACING_INDEX 0 -#define BORDER_SPACING_SHIFT 21 -#define BORDER_SPACING_MASK 0xffe00000 -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; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[BORDER_SPACING_INDEX]; - - /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ - *bits = (*bits & ~BORDER_SPACING_MASK) | ((((uint32_t)type & 0x1) | ( - unit_b << 1) | (unit_a << 6)) << BORDER_SPACING_SHIFT); - - style->i.uncommon->i.border_spacing_a = length_a; - - style->i.uncommon->i.border_spacing_b = length_b; - - return CSS_OK; -} -#undef BORDER_SPACING_INDEX -#undef BORDER_SPACING_SHIFT -#undef BORDER_SPACING_MASK - -#define BREAK_AFTER_INDEX 3 -#define BREAK_AFTER_SHIFT 28 -#define BREAK_AFTER_MASK 0xf0000000 - -static inline css_error set_break_after(css_computed_style *style, uint8_t type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[BREAK_AFTER_INDEX]; - - /* 4bits: tttt : type */ - *bits = (*bits & ~BREAK_AFTER_MASK) | (((uint32_t)type & 0xf) << - BREAK_AFTER_SHIFT); - - return CSS_OK; -} -#undef BREAK_AFTER_INDEX -#undef BREAK_AFTER_SHIFT -#undef BREAK_AFTER_MASK - -#define BREAK_BEFORE_INDEX 1 -#define BREAK_BEFORE_SHIFT 0 -#define BREAK_BEFORE_MASK 0xf - -static inline css_error set_break_before(css_computed_style *style, uint8_t - type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[BREAK_BEFORE_INDEX]; - - /* 4bits: tttt : type */ - *bits = (*bits & ~BREAK_BEFORE_MASK) | (((uint32_t)type & 0xf) << - BREAK_BEFORE_SHIFT); - - return CSS_OK; -} -#undef BREAK_BEFORE_INDEX -#undef BREAK_BEFORE_SHIFT -#undef BREAK_BEFORE_MASK - -#define BREAK_INSIDE_INDEX 3 -#define BREAK_INSIDE_SHIFT 24 -#define BREAK_INSIDE_MASK 0xf000000 - -static inline css_error set_break_inside(css_computed_style *style, uint8_t - type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[BREAK_INSIDE_INDEX]; - - /* 4bits: tttt : type */ - *bits = (*bits & ~BREAK_INSIDE_MASK) | (((uint32_t)type & 0xf) << - BREAK_INSIDE_SHIFT); - - return CSS_OK; -} -#undef BREAK_INSIDE_INDEX -#undef BREAK_INSIDE_SHIFT -#undef BREAK_INSIDE_MASK - -#define CLIP_INDEX 2 -#define CLIP_SHIFT 6 -#define CLIP_MASK 0xffffffc0 -static inline css_error set_clip( - css_computed_style *style, uint8_t type, - css_computed_clip_rect *rect) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[CLIP_INDEX]; - - /* - 26bits: tt tttr rrrr bbbb blll llTR BLyy: - units: top | right | bottom | left - opcodes: top | right | bottom | left | type - */ - *bits = (*bits & ~CLIP_MASK) | - ((type & 0x3) << CLIP_SHIFT); - - if (type == CSS_CLIP_RECT) { - *bits |= (((rect->top_auto ? 0x20 : 0) | - (rect->right_auto ? 0x10 : 0) | - (rect->bottom_auto ? 0x8 : 0) | - (rect->left_auto ? 0x4 : 0)) << CLIP_SHIFT); - - *bits |= (((rect->tunit << 5) | rect->runit) - << (CLIP_SHIFT + 16)); - - *bits |= (((rect->bunit << 5) | rect->lunit) - << (CLIP_SHIFT + 6)); - - style->i.uncommon->i.clip_a = rect->top; - style->i.uncommon->i.clip_b = rect->right; - style->i.uncommon->i.clip_c = rect->bottom; - style->i.uncommon->i.clip_d = rect->left; - } - - return CSS_OK; -} -#undef CLIP_INDEX -#undef CLIP_SHIFT -#undef CLIP_MASK - -#define COLUMN_COUNT_INDEX 3 -#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; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_COUNT_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~COLUMN_COUNT_MASK) | (((uint32_t)type & 0x3) << - COLUMN_COUNT_SHIFT); - - style->i.uncommon->i.column_count = integer; - - return CSS_OK; -} -#undef COLUMN_COUNT_INDEX -#undef COLUMN_COUNT_SHIFT -#undef COLUMN_COUNT_MASK - -#define COLUMN_FILL_INDEX 3 -#define COLUMN_FILL_SHIFT 18 -#define COLUMN_FILL_MASK 0xc0000 - -static inline css_error set_column_fill(css_computed_style *style, uint8_t type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_FILL_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~COLUMN_FILL_MASK) | (((uint32_t)type & 0x3) << - COLUMN_FILL_SHIFT); - - return CSS_OK; -} -#undef COLUMN_FILL_INDEX -#undef COLUMN_FILL_SHIFT -#undef COLUMN_FILL_MASK - -#define COLUMN_GAP_INDEX 1 -#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; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_GAP_INDEX]; - - /* 7bits: uuuuutt : unit | type */ - *bits = (*bits & ~COLUMN_GAP_MASK) | ((((uint32_t)type & 0x3) | (unit - << 2)) << COLUMN_GAP_SHIFT); - - style->i.uncommon->i.column_gap = length; - - return CSS_OK; -} -#undef COLUMN_GAP_INDEX -#undef COLUMN_GAP_SHIFT -#undef COLUMN_GAP_MASK - -#define COLUMN_RULE_COLOR_INDEX 2 -#define COLUMN_RULE_COLOR_SHIFT 0 -#define COLUMN_RULE_COLOR_MASK 0x3 - -static inline css_error set_column_rule_color(css_computed_style *style, - uint8_t type, css_color color) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_RULE_COLOR_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | (((uint32_t)type & 0x3) << - COLUMN_RULE_COLOR_SHIFT); - - style->i.uncommon->i.column_rule_color = color; - - return CSS_OK; -} -#undef COLUMN_RULE_COLOR_INDEX -#undef COLUMN_RULE_COLOR_SHIFT -#undef COLUMN_RULE_COLOR_MASK - -#define COLUMN_RULE_STYLE_INDEX 2 -#define COLUMN_RULE_STYLE_SHIFT 2 -#define COLUMN_RULE_STYLE_MASK 0x3c - -static inline css_error set_column_rule_style(css_computed_style *style, - uint8_t type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_RULE_STYLE_INDEX]; - - /* 4bits: tttt : type */ - *bits = (*bits & ~COLUMN_RULE_STYLE_MASK) | (((uint32_t)type & 0xf) << - COLUMN_RULE_STYLE_SHIFT); - - return CSS_OK; -} -#undef COLUMN_RULE_STYLE_INDEX -#undef COLUMN_RULE_STYLE_SHIFT -#undef COLUMN_RULE_STYLE_MASK - -#define COLUMN_RULE_WIDTH_INDEX 0 -#define COLUMN_RULE_WIDTH_SHIFT 5 -#define COLUMN_RULE_WIDTH_MASK 0x1fe0 - -static inline css_error set_column_rule_width(css_computed_style *style, - uint8_t type, css_fixed length, css_unit unit) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_RULE_WIDTH_INDEX]; - - /* 8bits: uuuuuttt : unit | type */ - *bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( - unit << 3)) << COLUMN_RULE_WIDTH_SHIFT); - - style->i.uncommon->i.column_rule_width = length; - - return CSS_OK; -} -#undef COLUMN_RULE_WIDTH_INDEX -#undef COLUMN_RULE_WIDTH_SHIFT -#undef COLUMN_RULE_WIDTH_MASK - -#define COLUMN_SPAN_INDEX 3 -#define COLUMN_SPAN_SHIFT 16 -#define COLUMN_SPAN_MASK 0x30000 - -static inline css_error set_column_span(css_computed_style *style, uint8_t type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_SPAN_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~COLUMN_SPAN_MASK) | (((uint32_t)type & 0x3) << - COLUMN_SPAN_SHIFT); - - return CSS_OK; -} -#undef COLUMN_SPAN_INDEX -#undef COLUMN_SPAN_SHIFT -#undef COLUMN_SPAN_MASK - -#define COLUMN_WIDTH_INDEX 1 -#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; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COLUMN_WIDTH_INDEX]; - - /* 7bits: uuuuutt : unit | type */ - *bits = (*bits & ~COLUMN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit - << 2)) << COLUMN_WIDTH_SHIFT); - - style->i.uncommon->i.column_width = length; - - return CSS_OK; -} -#undef COLUMN_WIDTH_INDEX -#undef COLUMN_WIDTH_SHIFT -#undef COLUMN_WIDTH_MASK - -#define CONTENT_INDEX 3 -#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) -{ - uint32_t *bits; - css_computed_content_item *oldcontent; - css_computed_content_item *c; - - ENSURE_UNCOMMON; - - /* 2bits: type */ - bits = &style->i.uncommon->i.bits[CONTENT_INDEX]; - oldcontent = style->i.uncommon->content; - - *bits = (*bits & ~CONTENT_MASK) | - ((type & 0x3) << CONTENT_SHIFT); - - for (c = content; c != NULL && - c->type != CSS_COMPUTED_CONTENT_NONE; c++) { - switch (c->type) { - case CSS_COMPUTED_CONTENT_STRING: - c->data.string = lwc_string_ref(c->data.string); - break; - case CSS_COMPUTED_CONTENT_URI: - c->data.uri = lwc_string_ref(c->data.uri); - break; - case CSS_COMPUTED_CONTENT_ATTR: - c->data.attr = lwc_string_ref(c->data.attr); - break; - case CSS_COMPUTED_CONTENT_COUNTER: - c->data.counter.name = - lwc_string_ref(c->data.counter.name); - break; - case CSS_COMPUTED_CONTENT_COUNTERS: - c->data.counters.name = - lwc_string_ref(c->data.counters.name); - c->data.counters.sep = - lwc_string_ref(c->data.counters.sep); - break; - default: - break; - } - } - - style->i.uncommon->content = content; - - /* Free existing array */ - if (oldcontent != NULL) { - for (c = oldcontent; - c->type != CSS_COMPUTED_CONTENT_NONE; c++) { - switch (c->type) { - case CSS_COMPUTED_CONTENT_STRING: - lwc_string_unref(c->data.string); - break; - case CSS_COMPUTED_CONTENT_URI: - lwc_string_unref(c->data.uri); - break; - case CSS_COMPUTED_CONTENT_ATTR: - lwc_string_unref(c->data.attr); - break; - case CSS_COMPUTED_CONTENT_COUNTER: - lwc_string_unref(c->data.counter.name); - break; - case CSS_COMPUTED_CONTENT_COUNTERS: - lwc_string_unref(c->data.counters.name); - lwc_string_unref(c->data.counters.sep); - break; - default: - break; - } - } - - if (oldcontent != content) - free(oldcontent); - } - - return CSS_OK; -} -#undef CONTENT_INDEX -#undef CONTENT_SHIFT -#undef CONTENT_MASK - -#define COUNTER_INCREMENT_INDEX 3 -#define COUNTER_INCREMENT_SHIFT 11 -#define COUNTER_INCREMENT_MASK 0x800 - -static inline css_error set_counter_increment(css_computed_style *style, - uint8_t type, css_computed_counter *counter_arr) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COUNTER_INCREMENT_INDEX]; - - /* 1bit: t : type */ - *bits = (*bits & ~COUNTER_INCREMENT_MASK) | (((uint32_t)type & 0x1) << - COUNTER_INCREMENT_SHIFT); - - css_computed_counter *old_counter_arr = - style->i.uncommon->counter_increment; - css_computed_counter *c; - - for (c = counter_arr; c != NULL && c->name != NULL; c++) - c->name = lwc_string_ref(c->name); - - style->i.uncommon->counter_increment = counter_arr; - - /* Free existing array */ - if (old_counter_arr != NULL) { - for (c = old_counter_arr; c->name != NULL; c++) - lwc_string_unref(c->name); - - if (old_counter_arr != counter_arr) - free(old_counter_arr); - } - - return CSS_OK; -} -#undef COUNTER_INCREMENT_INDEX -#undef COUNTER_INCREMENT_SHIFT -#undef COUNTER_INCREMENT_MASK - -#define COUNTER_RESET_INDEX 3 -#define COUNTER_RESET_SHIFT 10 -#define COUNTER_RESET_MASK 0x400 - -static inline css_error set_counter_reset(css_computed_style *style, uint8_t - type, css_computed_counter *counter_arr) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[COUNTER_RESET_INDEX]; - - /* 1bit: t : type */ - *bits = (*bits & ~COUNTER_RESET_MASK) | (((uint32_t)type & 0x1) << - COUNTER_RESET_SHIFT); - - css_computed_counter *old_counter_arr = - style->i.uncommon->counter_reset; - css_computed_counter *c; - - for (c = counter_arr; c != NULL && c->name != NULL; c++) - c->name = lwc_string_ref(c->name); - - style->i.uncommon->counter_reset = counter_arr; - - /* Free existing array */ - if (old_counter_arr != NULL) { - for (c = old_counter_arr; c->name != NULL; c++) - lwc_string_unref(c->name); - - if (old_counter_arr != counter_arr) - free(old_counter_arr); - } - - return CSS_OK; -} -#undef COUNTER_RESET_INDEX -#undef COUNTER_RESET_SHIFT -#undef COUNTER_RESET_MASK - -#define CURSOR_INDEX 0 -#define CURSOR_SHIFT 0 -#define CURSOR_MASK 0x1f - -static inline css_error set_cursor(css_computed_style *style, uint8_t type, - lwc_string **string_arr) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[CURSOR_INDEX]; - - /* 5bits: ttttt : type */ - *bits = (*bits & ~CURSOR_MASK) | (((uint32_t)type & 0x1f) << - CURSOR_SHIFT); - - lwc_string **old_string_arr = style->i.uncommon->cursor; - lwc_string **s; - - for (s = string_arr; s != NULL && *s != NULL; s++) - *s = lwc_string_ref(*s); - - style->i.uncommon->cursor = string_arr; - - /* Free existing array */ - if (old_string_arr != NULL) { - for (s = old_string_arr; *s != NULL; s++) - lwc_string_unref(*s); - - if (old_string_arr != string_arr) - free(old_string_arr); - } - - return CSS_OK; -} -#undef CURSOR_INDEX -#undef CURSOR_SHIFT -#undef CURSOR_MASK - -#define LETTER_SPACING_INDEX 1 -#define LETTER_SPACING_SHIFT 11 -#define LETTER_SPACING_MASK 0x3f800 - -static inline css_error set_letter_spacing(css_computed_style *style, uint8_t - type, css_fixed length, css_unit unit) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[LETTER_SPACING_INDEX]; - - /* 7bits: uuuuutt : unit | type */ - *bits = (*bits & ~LETTER_SPACING_MASK) | ((((uint32_t)type & 0x3) | ( - unit << 2)) << LETTER_SPACING_SHIFT); - - style->i.uncommon->i.letter_spacing = length; - - return CSS_OK; -} -#undef LETTER_SPACING_INDEX -#undef LETTER_SPACING_SHIFT -#undef LETTER_SPACING_MASK - -#define OUTLINE_COLOR_INDEX 3 -#define OUTLINE_COLOR_SHIFT 12 -#define OUTLINE_COLOR_MASK 0x3000 - -static inline css_error set_outline_color(css_computed_style *style, uint8_t - type, css_color color) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[OUTLINE_COLOR_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~OUTLINE_COLOR_MASK) | (((uint32_t)type & 0x3) << - OUTLINE_COLOR_SHIFT); - - style->i.uncommon->i.outline_color = color; - - return CSS_OK; -} -#undef OUTLINE_COLOR_INDEX -#undef OUTLINE_COLOR_SHIFT -#undef OUTLINE_COLOR_MASK - -#define OUTLINE_WIDTH_INDEX 0 -#define OUTLINE_WIDTH_SHIFT 13 -#define OUTLINE_WIDTH_MASK 0x1fe000 - -static inline css_error set_outline_width(css_computed_style *style, uint8_t - type, css_fixed length, css_unit unit) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[OUTLINE_WIDTH_INDEX]; - - /* 8bits: uuuuuttt : unit | type */ - *bits = (*bits & ~OUTLINE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( - unit << 3)) << OUTLINE_WIDTH_SHIFT); - - style->i.uncommon->i.outline_width = length; - - return CSS_OK; -} -#undef OUTLINE_WIDTH_INDEX -#undef OUTLINE_WIDTH_SHIFT -#undef OUTLINE_WIDTH_MASK - -#define WORD_SPACING_INDEX 1 -#define WORD_SPACING_SHIFT 4 -#define WORD_SPACING_MASK 0x7f0 - -static inline css_error set_word_spacing(css_computed_style *style, uint8_t - type, css_fixed length, css_unit unit) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[WORD_SPACING_INDEX]; - - /* 7bits: uuuuutt : unit | type */ - *bits = (*bits & ~WORD_SPACING_MASK) | ((((uint32_t)type & 0x3) | (unit - << 2)) << WORD_SPACING_SHIFT); - - style->i.uncommon->i.word_spacing = length; - - return CSS_OK; -} -#undef WORD_SPACING_INDEX -#undef WORD_SPACING_SHIFT -#undef WORD_SPACING_MASK - -#define WRITING_MODE_INDEX 3 -#define WRITING_MODE_SHIFT 20 -#define WRITING_MODE_MASK 0x300000 - -static inline css_error set_writing_mode(css_computed_style *style, uint8_t - type) -{ - uint32_t *bits; - - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[WRITING_MODE_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~WRITING_MODE_MASK) | (((uint32_t)type & 0x3) << - WRITING_MODE_SHIFT); - - return CSS_OK; -} -#undef WRITING_MODE_INDEX -#undef WRITING_MODE_SHIFT -#undef WRITING_MODE_MASK -static const css_computed_page default_page = { - .bits = { - (CSS_PAGE_BREAK_BEFORE_AUTO << 29) | (CSS_PAGE_BREAK_AFTER_AUTO - << 26) | (CSS_PAGE_BREAK_INSIDE_AUTO << 24) | ( - CSS_WIDOWS_SET << 23) | (CSS_ORPHANS_SET << 22) - }, - .orphans = 2, - .widows = 2 -}; - -#define ENSURE_PAGE do { \ - if (style->page == NULL) { \ - style->page = malloc(sizeof(css_computed_page)); \ - if (style->page == NULL) \ - return CSS_NOMEM; \ - \ - memcpy(style->page, &default_page, sizeof( \ - css_computed_page)); \ - } \ -} while(0) \ - - -#define ORPHANS_INDEX 0 -#define ORPHANS_SHIFT 22 -#define ORPHANS_MASK 0x400000 - -static inline css_error set_orphans(css_computed_style *style, uint8_t type, - int32_t integer) -{ - uint32_t *bits; - - ENSURE_PAGE; - - bits = &style->page->bits[ORPHANS_INDEX]; - - /* 1bit: t : type */ - *bits = (*bits & ~ORPHANS_MASK) | (((uint32_t)type & 0x1) << - ORPHANS_SHIFT); - - style->page->orphans = integer; - - return CSS_OK; -} -#undef ORPHANS_INDEX -#undef ORPHANS_SHIFT -#undef ORPHANS_MASK - -#define PAGE_BREAK_AFTER_INDEX 0 -#define PAGE_BREAK_AFTER_SHIFT 26 -#define PAGE_BREAK_AFTER_MASK 0x1c000000 - -static inline css_error set_page_break_after(css_computed_style *style, uint8_t - type) -{ - uint32_t *bits; - - ENSURE_PAGE; - - bits = &style->page->bits[PAGE_BREAK_AFTER_INDEX]; - - /* 3bits: ttt : type */ - *bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | (((uint32_t)type & 0x7) << - PAGE_BREAK_AFTER_SHIFT); - - return CSS_OK; -} -#undef PAGE_BREAK_AFTER_INDEX -#undef PAGE_BREAK_AFTER_SHIFT -#undef PAGE_BREAK_AFTER_MASK - -#define PAGE_BREAK_BEFORE_INDEX 0 -#define PAGE_BREAK_BEFORE_SHIFT 29 -#define PAGE_BREAK_BEFORE_MASK 0xe0000000 - -static inline css_error set_page_break_before(css_computed_style *style, - uint8_t type) -{ - uint32_t *bits; - - ENSURE_PAGE; - - bits = &style->page->bits[PAGE_BREAK_BEFORE_INDEX]; - - /* 3bits: ttt : type */ - *bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | (((uint32_t)type & 0x7) << - PAGE_BREAK_BEFORE_SHIFT); - - return CSS_OK; -} -#undef PAGE_BREAK_BEFORE_INDEX -#undef PAGE_BREAK_BEFORE_SHIFT -#undef PAGE_BREAK_BEFORE_MASK - -#define PAGE_BREAK_INSIDE_INDEX 0 -#define PAGE_BREAK_INSIDE_SHIFT 24 -#define PAGE_BREAK_INSIDE_MASK 0x3000000 - -static inline css_error set_page_break_inside(css_computed_style *style, - uint8_t type) -{ - uint32_t *bits; - - ENSURE_PAGE; - - bits = &style->page->bits[PAGE_BREAK_INSIDE_INDEX]; - - /* 2bits: tt : type */ - *bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | (((uint32_t)type & 0x3) << - PAGE_BREAK_INSIDE_SHIFT); - - return CSS_OK; -} -#undef PAGE_BREAK_INSIDE_INDEX -#undef PAGE_BREAK_INSIDE_SHIFT -#undef PAGE_BREAK_INSIDE_MASK - -#define WIDOWS_INDEX 0 -#define WIDOWS_SHIFT 23 -#define WIDOWS_MASK 0x800000 - -static inline css_error set_widows(css_computed_style *style, uint8_t type, - int32_t integer) -{ - uint32_t *bits; - - ENSURE_PAGE; - - bits = &style->page->bits[WIDOWS_INDEX]; - - /* 1bit: t : type */ - *bits = (*bits & ~WIDOWS_MASK) | (((uint32_t)type & 0x1) << - WIDOWS_SHIFT); - - style->page->widows = integer; - - return CSS_OK; -} -#undef WIDOWS_INDEX -#undef WIDOWS_SHIFT -#undef WIDOWS_MASK - -#define ALIGN_CONTENT_INDEX 8 -#define ALIGN_CONTENT_SHIFT 14 -#define ALIGN_CONTENT_MASK 0x1c000 +#define ALIGN_CONTENT_INDEX 13 +#define ALIGN_CONTENT_SHIFT 1 +#define ALIGN_CONTENT_MASK 0xe static inline css_error set_align_content(css_computed_style *style, uint8_t type) @@ -893,9 +29,9 @@ static inline css_error set_align_content(css_computed_style *style, uint8_t #undef ALIGN_CONTENT_SHIFT #undef ALIGN_CONTENT_MASK -#define ALIGN_ITEMS_INDEX 8 -#define ALIGN_ITEMS_SHIFT 23 -#define ALIGN_ITEMS_MASK 0x3800000 +#define ALIGN_ITEMS_INDEX 9 +#define ALIGN_ITEMS_SHIFT 17 +#define ALIGN_ITEMS_MASK 0xe0000 static inline css_error set_align_items(css_computed_style *style, uint8_t type) { @@ -913,9 +49,9 @@ static inline css_error set_align_items(css_computed_style *style, uint8_t type) #undef ALIGN_ITEMS_SHIFT #undef ALIGN_ITEMS_MASK -#define ALIGN_SELF_INDEX 8 -#define ALIGN_SELF_SHIFT 20 -#define ALIGN_SELF_MASK 0x700000 +#define ALIGN_SELF_INDEX 9 +#define ALIGN_SELF_SHIFT 5 +#define ALIGN_SELF_MASK 0xe0 static inline css_error set_align_self(css_computed_style *style, uint8_t type) { @@ -933,9 +69,9 @@ 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 9 -#define BACKGROUND_ATTACHMENT_SHIFT 6 -#define BACKGROUND_ATTACHMENT_MASK 0xc0 +#define BACKGROUND_ATTACHMENT_INDEX 10 +#define BACKGROUND_ATTACHMENT_SHIFT 10 +#define BACKGROUND_ATTACHMENT_MASK 0xc00 static inline css_error set_background_attachment(css_computed_style *style, uint8_t type) @@ -954,9 +90,9 @@ static inline css_error set_background_attachment(css_computed_style *style, #undef BACKGROUND_ATTACHMENT_SHIFT #undef BACKGROUND_ATTACHMENT_MASK -#define BACKGROUND_COLOR_INDEX 9 -#define BACKGROUND_COLOR_SHIFT 14 -#define BACKGROUND_COLOR_MASK 0xc000 +#define BACKGROUND_COLOR_INDEX 11 +#define BACKGROUND_COLOR_SHIFT 2 +#define BACKGROUND_COLOR_MASK 0xc static inline css_error set_background_color(css_computed_style *style, uint8_t type, css_color color) @@ -977,9 +113,9 @@ static inline css_error set_background_color(css_computed_style *style, uint8_t #undef BACKGROUND_COLOR_SHIFT #undef BACKGROUND_COLOR_MASK -#define BACKGROUND_IMAGE_INDEX 10 -#define BACKGROUND_IMAGE_SHIFT 25 -#define BACKGROUND_IMAGE_MASK 0x2000000 +#define BACKGROUND_IMAGE_INDEX 14 +#define BACKGROUND_IMAGE_SHIFT 28 +#define BACKGROUND_IMAGE_MASK 0x10000000 static inline css_error set_background_image(css_computed_style *style, uint8_t type, lwc_string *string) @@ -1009,7 +145,7 @@ static inline css_error set_background_image(css_computed_style *style, uint8_t #undef BACKGROUND_IMAGE_SHIFT #undef BACKGROUND_IMAGE_MASK -#define BACKGROUND_POSITION_INDEX 5 +#define BACKGROUND_POSITION_INDEX 12 #define BACKGROUND_POSITION_SHIFT 21 #define BACKGROUND_POSITION_MASK 0xffe00000 @@ -1036,9 +172,9 @@ static inline css_error set_background_position(css_computed_style *style, #undef BACKGROUND_POSITION_SHIFT #undef BACKGROUND_POSITION_MASK -#define BACKGROUND_REPEAT_INDEX 8 -#define BACKGROUND_REPEAT_SHIFT 17 -#define BACKGROUND_REPEAT_MASK 0xe0000 +#define BACKGROUND_REPEAT_INDEX 10 +#define BACKGROUND_REPEAT_SHIFT 26 +#define BACKGROUND_REPEAT_MASK 0x1c000000 static inline css_error set_background_repeat(css_computed_style *style, uint8_t type) @@ -1057,9 +193,9 @@ static inline css_error set_background_repeat(css_computed_style *style, #undef BACKGROUND_REPEAT_SHIFT #undef BACKGROUND_REPEAT_MASK -#define BORDER_BOTTOM_COLOR_INDEX 9 -#define BORDER_BOTTOM_COLOR_SHIFT 4 -#define BORDER_BOTTOM_COLOR_MASK 0x30 +#define BORDER_BOTTOM_COLOR_INDEX 10 +#define BORDER_BOTTOM_COLOR_SHIFT 8 +#define BORDER_BOTTOM_COLOR_MASK 0x300 static inline css_error set_border_bottom_color(css_computed_style *style, uint8_t type, css_color color) @@ -1080,9 +216,9 @@ 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 6 -#define BORDER_BOTTOM_STYLE_MASK 0x3c0 +#define BORDER_BOTTOM_STYLE_INDEX 13 +#define BORDER_BOTTOM_STYLE_SHIFT 8 +#define BORDER_BOTTOM_STYLE_MASK 0xf00 static inline css_error set_border_bottom_style(css_computed_style *style, uint8_t type) @@ -1102,8 +238,8 @@ 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 16 -#define BORDER_BOTTOM_WIDTH_MASK 0xff0000 +#define BORDER_BOTTOM_WIDTH_SHIFT 8 +#define BORDER_BOTTOM_WIDTH_MASK 0xff00 static inline css_error set_border_bottom_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1124,9 +260,9 @@ static inline css_error set_border_bottom_width(css_computed_style *style, #undef BORDER_BOTTOM_WIDTH_SHIFT #undef BORDER_BOTTOM_WIDTH_MASK -#define BORDER_COLLAPSE_INDEX 9 -#define BORDER_COLLAPSE_SHIFT 26 -#define BORDER_COLLAPSE_MASK 0xc000000 +#define BORDER_COLLAPSE_INDEX 10 +#define BORDER_COLLAPSE_SHIFT 14 +#define BORDER_COLLAPSE_MASK 0xc000 static inline css_error set_border_collapse(css_computed_style *style, uint8_t type) @@ -1145,9 +281,9 @@ 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 9 -#define BORDER_LEFT_COLOR_SHIFT 24 -#define BORDER_LEFT_COLOR_MASK 0x3000000 +#define BORDER_LEFT_COLOR_INDEX 11 +#define BORDER_LEFT_COLOR_SHIFT 12 +#define BORDER_LEFT_COLOR_MASK 0x3000 static inline css_error set_border_left_color(css_computed_style *style, uint8_t type, css_color color) @@ -1168,9 +304,9 @@ static inline css_error set_border_left_color(css_computed_style *style, #undef BORDER_LEFT_COLOR_SHIFT #undef BORDER_LEFT_COLOR_MASK -#define BORDER_LEFT_STYLE_INDEX 4 -#define BORDER_LEFT_STYLE_SHIFT 0 -#define BORDER_LEFT_STYLE_MASK 0xf +#define BORDER_LEFT_STYLE_INDEX 13 +#define BORDER_LEFT_STYLE_SHIFT 20 +#define BORDER_LEFT_STYLE_MASK 0xf00000 static inline css_error set_border_left_style(css_computed_style *style, uint8_t type) @@ -1190,8 +326,8 @@ 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 0 -#define BORDER_LEFT_WIDTH_MASK 0xff +#define BORDER_LEFT_WIDTH_SHIFT 16 +#define BORDER_LEFT_WIDTH_MASK 0xff0000 static inline css_error set_border_left_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1212,9 +348,9 @@ static inline css_error set_border_left_width(css_computed_style *style, #undef BORDER_LEFT_WIDTH_SHIFT #undef BORDER_LEFT_WIDTH_MASK -#define BORDER_RIGHT_COLOR_INDEX 9 -#define BORDER_RIGHT_COLOR_SHIFT 30 -#define BORDER_RIGHT_COLOR_MASK 0xc0000000 +#define BORDER_RIGHT_COLOR_INDEX 10 +#define BORDER_RIGHT_COLOR_SHIFT 16 +#define BORDER_RIGHT_COLOR_MASK 0x30000 static inline css_error set_border_right_color(css_computed_style *style, uint8_t type, css_color color) @@ -1235,9 +371,9 @@ 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 6 -#define BORDER_RIGHT_STYLE_SHIFT 14 -#define BORDER_RIGHT_STYLE_MASK 0x3c000 +#define BORDER_RIGHT_STYLE_INDEX 7 +#define BORDER_RIGHT_STYLE_SHIFT 0 +#define BORDER_RIGHT_STYLE_MASK 0xf static inline css_error set_border_right_style(css_computed_style *style, uint8_t type) @@ -1256,9 +392,9 @@ static inline css_error set_border_right_style(css_computed_style *style, #undef BORDER_RIGHT_STYLE_SHIFT #undef BORDER_RIGHT_STYLE_MASK -#define BORDER_RIGHT_WIDTH_INDEX 0 -#define BORDER_RIGHT_WIDTH_SHIFT 8 -#define BORDER_RIGHT_WIDTH_MASK 0xff00 +#define BORDER_RIGHT_WIDTH_INDEX 1 +#define BORDER_RIGHT_WIDTH_SHIFT 15 +#define BORDER_RIGHT_WIDTH_MASK 0x7f8000 static inline css_error set_border_right_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1279,7 +415,33 @@ static inline css_error set_border_right_width(css_computed_style *style, #undef BORDER_RIGHT_WIDTH_SHIFT #undef BORDER_RIGHT_WIDTH_MASK -#define BORDER_TOP_COLOR_INDEX 8 +#define BORDER_SPACING_INDEX 12 +#define BORDER_SPACING_SHIFT 10 +#define BORDER_SPACING_MASK 0x1ffc00 + +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]; + + /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */ + *bits = (*bits & ~BORDER_SPACING_MASK) | ((((uint32_t)type & 0x1) | ( + unit_b << 1) | (unit_a << 6)) << BORDER_SPACING_SHIFT); + + style->i.border_spacing_a = length_a; + + style->i.border_spacing_b = length_b; + + return CSS_OK; +} +#undef BORDER_SPACING_INDEX +#undef BORDER_SPACING_SHIFT +#undef BORDER_SPACING_MASK + +#define BORDER_TOP_COLOR_INDEX 10 #define BORDER_TOP_COLOR_SHIFT 0 #define BORDER_TOP_COLOR_MASK 0x3 @@ -1302,9 +464,9 @@ 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 6 -#define BORDER_TOP_STYLE_SHIFT 10 -#define BORDER_TOP_STYLE_MASK 0x3c00 +#define BORDER_TOP_STYLE_INDEX 5 +#define BORDER_TOP_STYLE_SHIFT 0 +#define BORDER_TOP_STYLE_MASK 0xf static inline css_error set_border_top_style(css_computed_style *style, uint8_t type) @@ -1346,7 +508,7 @@ 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 4 +#define BOTTOM_INDEX 6 #define BOTTOM_SHIFT 11 #define BOTTOM_MASK 0x3f800 @@ -1370,8 +532,8 @@ static inline css_error set_bottom(css_computed_style *style, uint8_t type, #undef BOTTOM_MASK #define BOX_SIZING_INDEX 9 -#define BOX_SIZING_SHIFT 12 -#define BOX_SIZING_MASK 0x3000 +#define BOX_SIZING_SHIFT 0 +#define BOX_SIZING_MASK 0x3 static inline css_error set_box_sizing(css_computed_style *style, uint8_t type) { @@ -1389,9 +551,71 @@ static inline css_error set_box_sizing(css_computed_style *style, uint8_t type) #undef BOX_SIZING_SHIFT #undef BOX_SIZING_MASK -#define CAPTION_SIDE_INDEX 9 -#define CAPTION_SIDE_SHIFT 20 -#define CAPTION_SIDE_MASK 0x300000 +#define BREAK_AFTER_INDEX 6 +#define BREAK_AFTER_SHIFT 0 +#define BREAK_AFTER_MASK 0xf + +static inline css_error set_break_after(css_computed_style *style, uint8_t type) +{ + uint32_t *bits; + + bits = &style->i.bits[BREAK_AFTER_INDEX]; + + /* 4bits: tttt : type */ + *bits = (*bits & ~BREAK_AFTER_MASK) | (((uint32_t)type & 0xf) << + BREAK_AFTER_SHIFT); + + return CSS_OK; +} +#undef BREAK_AFTER_INDEX +#undef BREAK_AFTER_SHIFT +#undef BREAK_AFTER_MASK + +#define BREAK_BEFORE_INDEX 13 +#define BREAK_BEFORE_SHIFT 12 +#define BREAK_BEFORE_MASK 0xf000 + +static inline css_error set_break_before(css_computed_style *style, uint8_t + type) +{ + uint32_t *bits; + + bits = &style->i.bits[BREAK_BEFORE_INDEX]; + + /* 4bits: tttt : type */ + *bits = (*bits & ~BREAK_BEFORE_MASK) | (((uint32_t)type & 0xf) << + BREAK_BEFORE_SHIFT); + + return CSS_OK; +} +#undef BREAK_BEFORE_INDEX +#undef BREAK_BEFORE_SHIFT +#undef BREAK_BEFORE_MASK + +#define BREAK_INSIDE_INDEX 4 +#define BREAK_INSIDE_SHIFT 0 +#define BREAK_INSIDE_MASK 0xf + +static inline css_error set_break_inside(css_computed_style *style, uint8_t + type) +{ + uint32_t *bits; + + bits = &style->i.bits[BREAK_INSIDE_INDEX]; + + /* 4bits: tttt : type */ + *bits = (*bits & ~BREAK_INSIDE_MASK) | (((uint32_t)type & 0xf) << + BREAK_INSIDE_SHIFT); + + return CSS_OK; +} +#undef BREAK_INSIDE_INDEX +#undef BREAK_INSIDE_SHIFT +#undef BREAK_INSIDE_MASK + +#define CAPTION_SIDE_INDEX 11 +#define CAPTION_SIDE_SHIFT 14 +#define CAPTION_SIDE_MASK 0xc000 static inline css_error set_caption_side(css_computed_style *style, uint8_t type) @@ -1410,9 +634,9 @@ static inline css_error set_caption_side(css_computed_style *style, uint8_t #undef CAPTION_SIDE_SHIFT #undef CAPTION_SIDE_MASK -#define CLEAR_INDEX 8 -#define CLEAR_SHIFT 2 -#define CLEAR_MASK 0x1c +#define CLEAR_INDEX 9 +#define CLEAR_SHIFT 20 +#define CLEAR_MASK 0x700000 static inline css_error set_clear(css_computed_style *style, uint8_t type) { @@ -1429,9 +653,52 @@ static inline css_error set_clear(css_computed_style *style, uint8_t type) #undef CLEAR_SHIFT #undef CLEAR_MASK -#define COLOR_INDEX 10 -#define COLOR_SHIFT 24 -#define COLOR_MASK 0x1000000 +#define CLIP_INDEX 2 +#define CLIP_SHIFT 6 +#define CLIP_MASK 0xffffffc0 +static inline css_error set_clip( + css_computed_style *style, uint8_t type, + css_computed_clip_rect *rect) +{ + uint32_t *bits; + + bits = &style->i.bits[CLIP_INDEX]; + + /* + 26bits: tt tttr rrrr bbbb blll llTR BLyy: + units: top | right | bottom | left + opcodes: top | right | bottom | left | type + */ + *bits = (*bits & ~CLIP_MASK) | + ((type & 0x3) << CLIP_SHIFT); + + if (type == CSS_CLIP_RECT) { + *bits |= (((rect->top_auto ? 0x20 : 0) | + (rect->right_auto ? 0x10 : 0) | + (rect->bottom_auto ? 0x8 : 0) | + (rect->left_auto ? 0x4 : 0)) << CLIP_SHIFT); + + *bits |= (((rect->tunit << 5) | rect->runit) + << (CLIP_SHIFT + 16)); + + *bits |= (((rect->bunit << 5) | rect->lunit) + << (CLIP_SHIFT + 6)); + + style->i.clip_a = rect->top; + style->i.clip_b = rect->right; + style->i.clip_c = rect->bottom; + style->i.clip_d = rect->left; + } + + return CSS_OK; +} +#undef CLIP_INDEX +#undef CLIP_SHIFT +#undef CLIP_MASK + +#define COLOR_INDEX 14 +#define COLOR_SHIFT 23 +#define COLOR_MASK 0x800000 static inline css_error set_color(css_computed_style *style, uint8_t type, css_color color) @@ -1451,9 +718,382 @@ static inline css_error set_color(css_computed_style *style, uint8_t type, #undef COLOR_SHIFT #undef COLOR_MASK -#define DIRECTION_INDEX 9 -#define DIRECTION_SHIFT 22 -#define DIRECTION_MASK 0xc00000 +#define COLUMN_COUNT_INDEX 10 +#define COLUMN_COUNT_SHIFT 2 +#define COLUMN_COUNT_MASK 0xc + +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]; + + /* 2bits: tt : type */ + *bits = (*bits & ~COLUMN_COUNT_MASK) | (((uint32_t)type & 0x3) << + COLUMN_COUNT_SHIFT); + + style->i.column_count = integer; + + return CSS_OK; +} +#undef COLUMN_COUNT_INDEX +#undef COLUMN_COUNT_SHIFT +#undef COLUMN_COUNT_MASK + +#define COLUMN_FILL_INDEX 11 +#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]; + + /* 2bits: tt : type */ + *bits = (*bits & ~COLUMN_FILL_MASK) | (((uint32_t)type & 0x3) << + COLUMN_FILL_SHIFT); + + return CSS_OK; +} +#undef COLUMN_FILL_INDEX +#undef COLUMN_FILL_SHIFT +#undef COLUMN_FILL_MASK + +#define COLUMN_GAP_INDEX 5 +#define COLUMN_GAP_SHIFT 25 +#define COLUMN_GAP_MASK 0xfe000000 + +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]; + + /* 7bits: uuuuutt : unit | type */ + *bits = (*bits & ~COLUMN_GAP_MASK) | ((((uint32_t)type & 0x3) | (unit + << 2)) << COLUMN_GAP_SHIFT); + + style->i.column_gap = length; + + return CSS_OK; +} +#undef COLUMN_GAP_INDEX +#undef COLUMN_GAP_SHIFT +#undef COLUMN_GAP_MASK + +#define COLUMN_RULE_COLOR_INDEX 11 +#define COLUMN_RULE_COLOR_SHIFT 30 +#define COLUMN_RULE_COLOR_MASK 0xc0000000 + +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]; + + /* 2bits: tt : type */ + *bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | (((uint32_t)type & 0x3) << + COLUMN_RULE_COLOR_SHIFT); + + style->i.column_rule_color = color; + + return CSS_OK; +} +#undef COLUMN_RULE_COLOR_INDEX +#undef COLUMN_RULE_COLOR_SHIFT +#undef COLUMN_RULE_COLOR_MASK + +#define COLUMN_RULE_STYLE_INDEX 13 +#define COLUMN_RULE_STYLE_SHIFT 16 +#define COLUMN_RULE_STYLE_MASK 0xf0000 + +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]; + + /* 4bits: tttt : type */ + *bits = (*bits & ~COLUMN_RULE_STYLE_MASK) | (((uint32_t)type & 0xf) << + COLUMN_RULE_STYLE_SHIFT); + + return CSS_OK; +} +#undef COLUMN_RULE_STYLE_INDEX +#undef COLUMN_RULE_STYLE_SHIFT +#undef COLUMN_RULE_STYLE_MASK + +#define COLUMN_RULE_WIDTH_INDEX 1 +#define COLUMN_RULE_WIDTH_SHIFT 7 +#define COLUMN_RULE_WIDTH_MASK 0x7f80 + +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]; + + /* 8bits: uuuuuttt : unit | type */ + *bits = (*bits & ~COLUMN_RULE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( + unit << 3)) << COLUMN_RULE_WIDTH_SHIFT); + + style->i.column_rule_width = length; + + return CSS_OK; +} +#undef COLUMN_RULE_WIDTH_INDEX +#undef COLUMN_RULE_WIDTH_SHIFT +#undef COLUMN_RULE_WIDTH_MASK + +#define COLUMN_SPAN_INDEX 11 +#define COLUMN_SPAN_SHIFT 24 +#define COLUMN_SPAN_MASK 0x3000000 + +static inline css_error set_column_span(css_computed_style *style, uint8_t type) +{ + uint32_t *bits; + + bits = &style->i.bits[COLUMN_SPAN_INDEX]; + + /* 2bits: tt : type */ + *bits = (*bits & ~COLUMN_SPAN_MASK) | (((uint32_t)type & 0x3) << + COLUMN_SPAN_SHIFT); + + return CSS_OK; +} +#undef COLUMN_SPAN_INDEX +#undef COLUMN_SPAN_SHIFT +#undef COLUMN_SPAN_MASK + +#define COLUMN_WIDTH_INDEX 6 +#define COLUMN_WIDTH_SHIFT 18 +#define COLUMN_WIDTH_MASK 0x1fc0000 + +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]; + + /* 7bits: uuuuutt : unit | type */ + *bits = (*bits & ~COLUMN_WIDTH_MASK) | ((((uint32_t)type & 0x3) | (unit + << 2)) << COLUMN_WIDTH_SHIFT); + + style->i.column_width = length; + + return CSS_OK; +} +#undef COLUMN_WIDTH_INDEX +#undef COLUMN_WIDTH_SHIFT +#undef COLUMN_WIDTH_MASK + +#define CONTENT_INDEX 11 +#define CONTENT_SHIFT 8 +#define CONTENT_MASK 0x300 +static inline css_error set_content( + css_computed_style *style, uint8_t type, + css_computed_content_item *content) +{ + uint32_t *bits; + css_computed_content_item *oldcontent; + css_computed_content_item *c; + + /* 2bits: type */ + bits = &style->i.bits[CONTENT_INDEX]; + oldcontent = style->content; + + *bits = (*bits & ~CONTENT_MASK) | + ((type & 0x3) << CONTENT_SHIFT); + + for (c = content; c != NULL && + c->type != CSS_COMPUTED_CONTENT_NONE; c++) { + switch (c->type) { + case CSS_COMPUTED_CONTENT_STRING: + c->data.string = lwc_string_ref(c->data.string); + break; + case CSS_COMPUTED_CONTENT_URI: + c->data.uri = lwc_string_ref(c->data.uri); + break; + case CSS_COMPUTED_CONTENT_ATTR: + c->data.attr = lwc_string_ref(c->data.attr); + break; + case CSS_COMPUTED_CONTENT_COUNTER: + c->data.counter.name = + lwc_string_ref(c->data.counter.name); + break; + case CSS_COMPUTED_CONTENT_COUNTERS: + c->data.counters.name = + lwc_string_ref(c->data.counters.name); + c->data.counters.sep = + lwc_string_ref(c->data.counters.sep); + break; + default: + break; + } + } + + style->content = content; + + /* Free existing array */ + if (oldcontent != NULL) { + for (c = oldcontent; + c->type != CSS_COMPUTED_CONTENT_NONE; c++) { + switch (c->type) { + case CSS_COMPUTED_CONTENT_STRING: + lwc_string_unref(c->data.string); + break; + case CSS_COMPUTED_CONTENT_URI: + lwc_string_unref(c->data.uri); + break; + case CSS_COMPUTED_CONTENT_ATTR: + lwc_string_unref(c->data.attr); + break; + case CSS_COMPUTED_CONTENT_COUNTER: + lwc_string_unref(c->data.counter.name); + break; + case CSS_COMPUTED_CONTENT_COUNTERS: + lwc_string_unref(c->data.counters.name); + lwc_string_unref(c->data.counters.sep); + break; + default: + break; + } + } + + if (oldcontent != content) + free(oldcontent); + } + + return CSS_OK; +} +#undef CONTENT_INDEX +#undef CONTENT_SHIFT +#undef CONTENT_MASK + +#define COUNTER_INCREMENT_INDEX 14 +#define COUNTER_INCREMENT_SHIFT 22 +#define COUNTER_INCREMENT_MASK 0x400000 + +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]; + + /* 1bit: t : type */ + *bits = (*bits & ~COUNTER_INCREMENT_MASK) | (((uint32_t)type & 0x1) << + COUNTER_INCREMENT_SHIFT); + + css_computed_counter *old_counter_arr = style->counter_increment; + css_computed_counter *c; + + for (c = counter_arr; c != NULL && c->name != NULL; c++) + c->name = lwc_string_ref(c->name); + + style->counter_increment = counter_arr; + + /* Free existing array */ + if (old_counter_arr != NULL) { + for (c = old_counter_arr; c->name != NULL; c++) + lwc_string_unref(c->name); + + if (old_counter_arr != counter_arr) + free(old_counter_arr); + } + + return CSS_OK; +} +#undef COUNTER_INCREMENT_INDEX +#undef COUNTER_INCREMENT_SHIFT +#undef COUNTER_INCREMENT_MASK + +#define COUNTER_RESET_INDEX 14 +#define COUNTER_RESET_SHIFT 27 +#define COUNTER_RESET_MASK 0x8000000 + +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]; + + /* 1bit: t : type */ + *bits = (*bits & ~COUNTER_RESET_MASK) | (((uint32_t)type & 0x1) << + COUNTER_RESET_SHIFT); + + css_computed_counter *old_counter_arr = style->counter_reset; + css_computed_counter *c; + + for (c = counter_arr; c != NULL && c->name != NULL; c++) + c->name = lwc_string_ref(c->name); + + style->counter_reset = counter_arr; + + /* Free existing array */ + if (old_counter_arr != NULL) { + for (c = old_counter_arr; c->name != NULL; c++) + lwc_string_unref(c->name); + + if (old_counter_arr != counter_arr) + free(old_counter_arr); + } + + return CSS_OK; +} +#undef COUNTER_RESET_INDEX +#undef COUNTER_RESET_SHIFT +#undef COUNTER_RESET_MASK + +#define CURSOR_INDEX 3 +#define CURSOR_SHIFT 0 +#define CURSOR_MASK 0x1f + +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]; + + /* 5bits: ttttt : type */ + *bits = (*bits & ~CURSOR_MASK) | (((uint32_t)type & 0x1f) << + CURSOR_SHIFT); + + lwc_string **old_string_arr = style->cursor; + lwc_string **s; + + for (s = string_arr; s != NULL && *s != NULL; s++) + *s = lwc_string_ref(*s); + + style->cursor = string_arr; + + /* Free existing array */ + if (old_string_arr != NULL) { + for (s = old_string_arr; *s != NULL; s++) + lwc_string_unref(*s); + + if (old_string_arr != string_arr) + free(old_string_arr); + } + + return CSS_OK; +} +#undef CURSOR_INDEX +#undef CURSOR_SHIFT +#undef CURSOR_MASK + +#define DIRECTION_INDEX 11 +#define DIRECTION_SHIFT 26 +#define DIRECTION_MASK 0xc000000 static inline css_error set_direction(css_computed_style *style, uint8_t type) { @@ -1471,9 +1111,9 @@ static inline css_error set_direction(css_computed_style *style, uint8_t type) #undef DIRECTION_SHIFT #undef DIRECTION_MASK -#define DISPLAY_INDEX 6 -#define DISPLAY_SHIFT 27 -#define DISPLAY_MASK 0xf8000000 +#define DISPLAY_INDEX 8 +#define DISPLAY_SHIFT 9 +#define DISPLAY_MASK 0x3e00 static inline css_error set_display(css_computed_style *style, uint8_t type) { @@ -1491,9 +1131,9 @@ static inline css_error set_display(css_computed_style *style, uint8_t type) #undef DISPLAY_SHIFT #undef DISPLAY_MASK -#define EMPTY_CELLS_INDEX 9 -#define EMPTY_CELLS_SHIFT 18 -#define EMPTY_CELLS_MASK 0xc0000 +#define EMPTY_CELLS_INDEX 11 +#define EMPTY_CELLS_SHIFT 28 +#define EMPTY_CELLS_MASK 0x30000000 static inline css_error set_empty_cells(css_computed_style *style, uint8_t type) { @@ -1511,9 +1151,9 @@ 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 2 -#define FLEX_BASIS_SHIFT 11 -#define FLEX_BASIS_MASK 0x3f800 +#define FLEX_BASIS_INDEX 3 +#define FLEX_BASIS_SHIFT 18 +#define FLEX_BASIS_MASK 0x1fc0000 static inline css_error set_flex_basis(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1534,7 +1174,7 @@ static inline css_error set_flex_basis(css_computed_style *style, uint8_t type, #undef FLEX_BASIS_SHIFT #undef FLEX_BASIS_MASK -#define FLEX_DIRECTION_INDEX 8 +#define FLEX_DIRECTION_INDEX 9 #define FLEX_DIRECTION_SHIFT 11 #define FLEX_DIRECTION_MASK 0x3800 @@ -1555,9 +1195,9 @@ 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 10 -#define FLEX_GROW_SHIFT 21 -#define FLEX_GROW_MASK 0x200000 +#define FLEX_GROW_INDEX 14 +#define FLEX_GROW_SHIFT 29 +#define FLEX_GROW_MASK 0x20000000 static inline css_error set_flex_grow(css_computed_style *style, uint8_t type, css_fixed fixed) @@ -1578,9 +1218,9 @@ static inline css_error set_flex_grow(css_computed_style *style, uint8_t type, #undef FLEX_GROW_SHIFT #undef FLEX_GROW_MASK -#define FLEX_SHRINK_INDEX 10 -#define FLEX_SHRINK_SHIFT 23 -#define FLEX_SHRINK_MASK 0x800000 +#define FLEX_SHRINK_INDEX 14 +#define FLEX_SHRINK_SHIFT 26 +#define FLEX_SHRINK_MASK 0x4000000 static inline css_error set_flex_shrink(css_computed_style *style, uint8_t type, css_fixed fixed) @@ -1601,9 +1241,9 @@ 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 9 -#define FLEX_WRAP_SHIFT 28 -#define FLEX_WRAP_MASK 0x30000000 +#define FLEX_WRAP_INDEX 14 +#define FLEX_WRAP_SHIFT 30 +#define FLEX_WRAP_MASK 0xc0000000 static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type) { @@ -1621,9 +1261,9 @@ static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type) #undef FLEX_WRAP_SHIFT #undef FLEX_WRAP_MASK -#define FLOAT_INDEX 9 -#define FLOAT_SHIFT 8 -#define FLOAT_MASK 0x300 +#define FLOAT_INDEX 10 +#define FLOAT_SHIFT 12 +#define FLOAT_MASK 0x3000 static inline css_error set_float(css_computed_style *style, uint8_t type) { @@ -1640,9 +1280,9 @@ static inline css_error set_float(css_computed_style *style, uint8_t type) #undef FLOAT_SHIFT #undef FLOAT_MASK -#define FONT_FAMILY_INDEX 8 -#define FONT_FAMILY_SHIFT 26 -#define FONT_FAMILY_MASK 0x1c000000 +#define FONT_FAMILY_INDEX 9 +#define FONT_FAMILY_SHIFT 29 +#define FONT_FAMILY_MASK 0xe0000000 static inline css_error set_font_family(css_computed_style *style, uint8_t type, lwc_string **string_arr) @@ -1678,9 +1318,9 @@ 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 5 -#define FONT_SIZE_SHIFT 3 -#define FONT_SIZE_MASK 0xff8 +#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) @@ -1701,9 +1341,9 @@ 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 7 -#define FONT_STYLE_SHIFT 0 -#define FONT_STYLE_MASK 0x3 +#define FONT_STYLE_INDEX 11 +#define FONT_STYLE_SHIFT 22 +#define FONT_STYLE_MASK 0xc00000 static inline css_error set_font_style(css_computed_style *style, uint8_t type) { @@ -1721,9 +1361,9 @@ 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 9 -#define FONT_VARIANT_SHIFT 10 -#define FONT_VARIANT_MASK 0xc00 +#define FONT_VARIANT_INDEX 11 +#define FONT_VARIANT_SHIFT 4 +#define FONT_VARIANT_MASK 0x30 static inline css_error set_font_variant(css_computed_style *style, uint8_t type) @@ -1742,9 +1382,9 @@ 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 3 -#define FONT_WEIGHT_SHIFT 0 -#define FONT_WEIGHT_MASK 0xf +#define FONT_WEIGHT_INDEX 13 +#define FONT_WEIGHT_SHIFT 28 +#define FONT_WEIGHT_MASK 0xf0000000 static inline css_error set_font_weight(css_computed_style *style, uint8_t type) { @@ -1763,8 +1403,8 @@ static inline css_error set_font_weight(css_computed_style *style, uint8_t type) #undef FONT_WEIGHT_MASK #define HEIGHT_INDEX 4 -#define HEIGHT_SHIFT 4 -#define HEIGHT_MASK 0x7f0 +#define HEIGHT_SHIFT 18 +#define HEIGHT_MASK 0x1fc0000 static inline css_error set_height(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1785,9 +1425,9 @@ static inline css_error set_height(css_computed_style *style, uint8_t type, #undef HEIGHT_SHIFT #undef HEIGHT_MASK -#define JUSTIFY_CONTENT_INDEX 8 -#define JUSTIFY_CONTENT_SHIFT 8 -#define JUSTIFY_CONTENT_MASK 0x700 +#define JUSTIFY_CONTENT_INDEX 9 +#define JUSTIFY_CONTENT_SHIFT 14 +#define JUSTIFY_CONTENT_MASK 0x1c000 static inline css_error set_justify_content(css_computed_style *style, uint8_t type) @@ -1806,9 +1446,9 @@ 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 25 -#define LEFT_MASK 0xfe000000 +#define LEFT_INDEX 5 +#define LEFT_SHIFT 4 +#define LEFT_MASK 0x7f0 static inline css_error set_left(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1829,7 +1469,30 @@ static inline css_error set_left(css_computed_style *style, uint8_t type, #undef LEFT_SHIFT #undef LEFT_MASK -#define LINE_HEIGHT_INDEX 1 +#define LETTER_SPACING_INDEX 7 +#define LETTER_SPACING_SHIFT 11 +#define LETTER_SPACING_MASK 0x3f800 + +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]; + + /* 7bits: uuuuutt : unit | type */ + *bits = (*bits & ~LETTER_SPACING_MASK) | ((((uint32_t)type & 0x3) | ( + unit << 2)) << LETTER_SPACING_SHIFT); + + style->i.letter_spacing = length; + + return CSS_OK; +} +#undef LETTER_SPACING_INDEX +#undef LETTER_SPACING_SHIFT +#undef LETTER_SPACING_MASK + +#define LINE_HEIGHT_INDEX 4 #define LINE_HEIGHT_SHIFT 25 #define LINE_HEIGHT_MASK 0xfe000000 @@ -1852,9 +1515,9 @@ static inline css_error set_line_height(css_computed_style *style, uint8_t #undef LINE_HEIGHT_SHIFT #undef LINE_HEIGHT_MASK -#define LIST_STYLE_IMAGE_INDEX 10 -#define LIST_STYLE_IMAGE_SHIFT 26 -#define LIST_STYLE_IMAGE_MASK 0x4000000 +#define LIST_STYLE_IMAGE_INDEX 14 +#define LIST_STYLE_IMAGE_SHIFT 21 +#define LIST_STYLE_IMAGE_MASK 0x200000 static inline css_error set_list_style_image(css_computed_style *style, uint8_t type, lwc_string *string) @@ -1884,9 +1547,9 @@ 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 9 -#define LIST_STYLE_POSITION_SHIFT 2 -#define LIST_STYLE_POSITION_MASK 0xc +#define LIST_STYLE_POSITION_INDEX 11 +#define LIST_STYLE_POSITION_SHIFT 10 +#define LIST_STYLE_POSITION_MASK 0xc00 static inline css_error set_list_style_position(css_computed_style *style, uint8_t type) @@ -1905,9 +1568,9 @@ static inline css_error set_list_style_position(css_computed_style *style, #undef LIST_STYLE_POSITION_SHIFT #undef LIST_STYLE_POSITION_MASK -#define LIST_STYLE_TYPE_INDEX 6 -#define LIST_STYLE_TYPE_SHIFT 18 -#define LIST_STYLE_TYPE_MASK 0x3c0000 +#define LIST_STYLE_TYPE_INDEX 8 +#define LIST_STYLE_TYPE_SHIFT 0 +#define LIST_STYLE_TYPE_MASK 0xf static inline css_error set_list_style_type(css_computed_style *style, uint8_t type) @@ -1926,7 +1589,7 @@ 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 3 +#define MARGIN_BOTTOM_INDEX 4 #define MARGIN_BOTTOM_SHIFT 4 #define MARGIN_BOTTOM_MASK 0x7f0 @@ -1949,7 +1612,7 @@ 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 1 +#define MARGIN_LEFT_INDEX 6 #define MARGIN_LEFT_SHIFT 4 #define MARGIN_LEFT_MASK 0x7f0 @@ -1972,9 +1635,9 @@ static inline css_error set_margin_left(css_computed_style *style, uint8_t #undef MARGIN_LEFT_SHIFT #undef MARGIN_LEFT_MASK -#define MARGIN_RIGHT_INDEX 2 -#define MARGIN_RIGHT_SHIFT 18 -#define MARGIN_RIGHT_MASK 0x1fc0000 +#define MARGIN_RIGHT_INDEX 7 +#define MARGIN_RIGHT_SHIFT 4 +#define MARGIN_RIGHT_MASK 0x7f0 static inline css_error set_margin_right(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -1995,7 +1658,7 @@ 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 3 +#define MARGIN_TOP_INDEX 5 #define MARGIN_TOP_SHIFT 18 #define MARGIN_TOP_MASK 0x1fc0000 @@ -2018,9 +1681,9 @@ 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 2 -#define MAX_HEIGHT_SHIFT 4 -#define MAX_HEIGHT_MASK 0x7f0 +#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) @@ -2041,7 +1704,7 @@ 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 2 +#define MAX_WIDTH_INDEX 6 #define MAX_WIDTH_SHIFT 25 #define MAX_WIDTH_MASK 0xfe000000 @@ -2065,8 +1728,8 @@ static inline css_error set_max_width(css_computed_style *style, uint8_t type, #undef MAX_WIDTH_MASK #define MIN_HEIGHT_INDEX 3 -#define MIN_HEIGHT_SHIFT 11 -#define MIN_HEIGHT_MASK 0x3f800 +#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) @@ -2087,9 +1750,9 @@ 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 1 -#define MIN_WIDTH_SHIFT 11 -#define MIN_WIDTH_MASK 0x3f800 +#define MIN_WIDTH_INDEX 7 +#define MIN_WIDTH_SHIFT 25 +#define MIN_WIDTH_MASK 0xfe000000 static inline css_error set_min_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2110,9 +1773,9 @@ static inline css_error set_min_width(css_computed_style *style, uint8_t type, #undef MIN_WIDTH_SHIFT #undef MIN_WIDTH_MASK -#define OPACITY_INDEX 10 -#define OPACITY_SHIFT 22 -#define OPACITY_MASK 0x400000 +#define OPACITY_INDEX 14 +#define OPACITY_SHIFT 24 +#define OPACITY_MASK 0x1000000 static inline css_error set_opacity(css_computed_style *style, uint8_t type, css_fixed fixed) @@ -2133,9 +1796,9 @@ static inline css_error set_opacity(css_computed_style *style, uint8_t type, #undef OPACITY_SHIFT #undef OPACITY_MASK -#define ORDER_INDEX 10 -#define ORDER_SHIFT 27 -#define ORDER_MASK 0x8000000 +#define ORDER_INDEX 12 +#define ORDER_SHIFT 0 +#define ORDER_MASK 0x1 static inline css_error set_order(css_computed_style *style, uint8_t type, int32_t integer) @@ -2155,9 +1818,55 @@ static inline css_error set_order(css_computed_style *style, uint8_t type, #undef ORDER_SHIFT #undef ORDER_MASK -#define OUTLINE_STYLE_INDEX 1 -#define OUTLINE_STYLE_SHIFT 0 -#define OUTLINE_STYLE_MASK 0xf +#define ORPHANS_INDEX 14 +#define ORPHANS_SHIFT 20 +#define ORPHANS_MASK 0x100000 + +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]; + + /* 1bit: t : type */ + *bits = (*bits & ~ORPHANS_MASK) | (((uint32_t)type & 0x1) << + ORPHANS_SHIFT); + + style->i.orphans = integer; + + return CSS_OK; +} +#undef ORPHANS_INDEX +#undef ORPHANS_SHIFT +#undef ORPHANS_MASK + +#define OUTLINE_COLOR_INDEX 11 +#define OUTLINE_COLOR_SHIFT 20 +#define OUTLINE_COLOR_MASK 0x300000 + +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]; + + /* 2bits: tt : type */ + *bits = (*bits & ~OUTLINE_COLOR_MASK) | (((uint32_t)type & 0x3) << + OUTLINE_COLOR_SHIFT); + + style->i.outline_color = color; + + return CSS_OK; +} +#undef OUTLINE_COLOR_INDEX +#undef OUTLINE_COLOR_SHIFT +#undef OUTLINE_COLOR_MASK + +#define OUTLINE_STYLE_INDEX 13 +#define OUTLINE_STYLE_SHIFT 24 +#define OUTLINE_STYLE_MASK 0xf000000 static inline css_error set_outline_style(css_computed_style *style, uint8_t type) @@ -2176,9 +1885,32 @@ static inline css_error set_outline_style(css_computed_style *style, uint8_t #undef OUTLINE_STYLE_SHIFT #undef OUTLINE_STYLE_MASK -#define OVERFLOW_X_INDEX 8 -#define OVERFLOW_X_SHIFT 5 -#define OVERFLOW_X_MASK 0xe0 +#define OUTLINE_WIDTH_INDEX 0 +#define OUTLINE_WIDTH_SHIFT 0 +#define OUTLINE_WIDTH_MASK 0xff + +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]; + + /* 8bits: uuuuuttt : unit | type */ + *bits = (*bits & ~OUTLINE_WIDTH_MASK) | ((((uint32_t)type & 0x7) | ( + unit << 3)) << OUTLINE_WIDTH_SHIFT); + + style->i.outline_width = length; + + return CSS_OK; +} +#undef OUTLINE_WIDTH_INDEX +#undef OUTLINE_WIDTH_SHIFT +#undef OUTLINE_WIDTH_MASK + +#define OVERFLOW_X_INDEX 10 +#define OVERFLOW_X_SHIFT 29 +#define OVERFLOW_X_MASK 0xe0000000 static inline css_error set_overflow_x(css_computed_style *style, uint8_t type) { @@ -2196,9 +1928,9 @@ static inline css_error set_overflow_x(css_computed_style *style, uint8_t type) #undef OVERFLOW_X_SHIFT #undef OVERFLOW_X_MASK -#define OVERFLOW_Y_INDEX 8 -#define OVERFLOW_Y_SHIFT 29 -#define OVERFLOW_Y_MASK 0xe0000000 +#define OVERFLOW_Y_INDEX 10 +#define OVERFLOW_Y_SHIFT 20 +#define OVERFLOW_Y_MASK 0x700000 static inline css_error set_overflow_y(css_computed_style *style, uint8_t type) { @@ -2216,9 +1948,9 @@ static inline css_error set_overflow_y(css_computed_style *style, uint8_t type) #undef OVERFLOW_Y_SHIFT #undef OVERFLOW_Y_MASK -#define PADDING_BOTTOM_INDEX 7 -#define PADDING_BOTTOM_SHIFT 20 -#define PADDING_BOTTOM_MASK 0x3f00000 +#define PADDING_BOTTOM_INDEX 8 +#define PADDING_BOTTOM_SHIFT 26 +#define PADDING_BOTTOM_MASK 0xfc000000 static inline css_error set_padding_bottom(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2239,9 +1971,9 @@ 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 7 -#define PADDING_LEFT_SHIFT 26 -#define PADDING_LEFT_MASK 0xfc000000 +#define PADDING_LEFT_INDEX 8 +#define PADDING_LEFT_SHIFT 14 +#define PADDING_LEFT_MASK 0xfc000 static inline css_error set_padding_left(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2262,9 +1994,9 @@ static inline css_error set_padding_left(css_computed_style *style, uint8_t #undef PADDING_LEFT_SHIFT #undef PADDING_LEFT_MASK -#define PADDING_RIGHT_INDEX 7 -#define PADDING_RIGHT_SHIFT 8 -#define PADDING_RIGHT_MASK 0x3f00 +#define PADDING_RIGHT_INDEX 2 +#define PADDING_RIGHT_SHIFT 0 +#define PADDING_RIGHT_MASK 0x3f static inline css_error set_padding_right(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2285,9 +2017,9 @@ 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 7 -#define PADDING_TOP_SHIFT 14 -#define PADDING_TOP_MASK 0xfc000 +#define PADDING_TOP_INDEX 8 +#define PADDING_TOP_SHIFT 20 +#define PADDING_TOP_MASK 0x3f00000 static inline css_error set_padding_top(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2308,9 +2040,72 @@ static inline css_error set_padding_top(css_computed_style *style, uint8_t #undef PADDING_TOP_SHIFT #undef PADDING_TOP_MASK -#define POSITION_INDEX 5 -#define POSITION_SHIFT 0 -#define POSITION_MASK 0x7 +#define PAGE_BREAK_AFTER_INDEX 9 +#define PAGE_BREAK_AFTER_SHIFT 8 +#define PAGE_BREAK_AFTER_MASK 0x700 + +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]; + + /* 3bits: ttt : type */ + *bits = (*bits & ~PAGE_BREAK_AFTER_MASK) | (((uint32_t)type & 0x7) << + PAGE_BREAK_AFTER_SHIFT); + + return CSS_OK; +} +#undef PAGE_BREAK_AFTER_INDEX +#undef PAGE_BREAK_AFTER_SHIFT +#undef PAGE_BREAK_AFTER_MASK + +#define PAGE_BREAK_BEFORE_INDEX 9 +#define PAGE_BREAK_BEFORE_SHIFT 2 +#define PAGE_BREAK_BEFORE_MASK 0x1c + +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]; + + /* 3bits: ttt : type */ + *bits = (*bits & ~PAGE_BREAK_BEFORE_MASK) | (((uint32_t)type & 0x7) << + PAGE_BREAK_BEFORE_SHIFT); + + return CSS_OK; +} +#undef PAGE_BREAK_BEFORE_INDEX +#undef PAGE_BREAK_BEFORE_SHIFT +#undef PAGE_BREAK_BEFORE_MASK + +#define PAGE_BREAK_INSIDE_INDEX 11 +#define PAGE_BREAK_INSIDE_SHIFT 0 +#define PAGE_BREAK_INSIDE_MASK 0x3 + +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]; + + /* 2bits: tt : type */ + *bits = (*bits & ~PAGE_BREAK_INSIDE_MASK) | (((uint32_t)type & 0x3) << + PAGE_BREAK_INSIDE_SHIFT); + + return CSS_OK; +} +#undef PAGE_BREAK_INSIDE_INDEX +#undef PAGE_BREAK_INSIDE_SHIFT +#undef PAGE_BREAK_INSIDE_MASK + +#define POSITION_INDEX 9 +#define POSITION_SHIFT 26 +#define POSITION_MASK 0x1c000000 static inline css_error set_position(css_computed_style *style, uint8_t type) { @@ -2328,9 +2123,9 @@ static inline css_error set_position(css_computed_style *style, uint8_t type) #undef POSITION_SHIFT #undef POSITION_MASK -#define QUOTES_INDEX 10 -#define QUOTES_SHIFT 20 -#define QUOTES_MASK 0x100000 +#define QUOTES_INDEX 13 +#define QUOTES_SHIFT 0 +#define QUOTES_MASK 0x1 static inline css_error set_quotes(css_computed_style *style, uint8_t type, lwc_string **string_arr) @@ -2366,7 +2161,7 @@ static inline css_error set_quotes(css_computed_style *style, uint8_t type, #undef QUOTES_SHIFT #undef QUOTES_MASK -#define RIGHT_INDEX 1 +#define RIGHT_INDEX 7 #define RIGHT_SHIFT 18 #define RIGHT_MASK 0x1fc0000 @@ -2389,9 +2184,9 @@ static inline css_error set_right(css_computed_style *style, uint8_t type, #undef RIGHT_SHIFT #undef RIGHT_MASK -#define TABLE_LAYOUT_INDEX 9 -#define TABLE_LAYOUT_SHIFT 0 -#define TABLE_LAYOUT_MASK 0x3 +#define TABLE_LAYOUT_INDEX 11 +#define TABLE_LAYOUT_SHIFT 18 +#define TABLE_LAYOUT_MASK 0xc0000 static inline css_error set_table_layout(css_computed_style *style, uint8_t type) @@ -2410,9 +2205,9 @@ static inline css_error set_table_layout(css_computed_style *style, uint8_t #undef TABLE_LAYOUT_SHIFT #undef TABLE_LAYOUT_MASK -#define TEXT_ALIGN_INDEX 2 -#define TEXT_ALIGN_SHIFT 0 -#define TEXT_ALIGN_MASK 0xf +#define TEXT_ALIGN_INDEX 13 +#define TEXT_ALIGN_SHIFT 4 +#define TEXT_ALIGN_MASK 0xf0 static inline css_error set_text_align(css_computed_style *style, uint8_t type) { @@ -2430,9 +2225,9 @@ 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 6 -#define TEXT_DECORATION_SHIFT 22 -#define TEXT_DECORATION_MASK 0x7c00000 +#define TEXT_DECORATION_INDEX 8 +#define TEXT_DECORATION_SHIFT 4 +#define TEXT_DECORATION_MASK 0x1f0 static inline css_error set_text_decoration(css_computed_style *style, uint8_t type) @@ -2451,9 +2246,9 @@ 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 7 -#define TEXT_INDENT_SHIFT 2 -#define TEXT_INDENT_MASK 0xfc +#define TEXT_INDENT_INDEX 3 +#define TEXT_INDENT_SHIFT 5 +#define TEXT_INDENT_MASK 0x7e0 static inline css_error set_text_indent(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2474,9 +2269,9 @@ 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 6 -#define TEXT_TRANSFORM_SHIFT 3 -#define TEXT_TRANSFORM_MASK 0x38 +#define TEXT_TRANSFORM_INDEX 10 +#define TEXT_TRANSFORM_SHIFT 23 +#define TEXT_TRANSFORM_MASK 0x3800000 static inline css_error set_text_transform(css_computed_style *style, uint8_t type) @@ -2495,9 +2290,9 @@ static inline css_error set_text_transform(css_computed_style *style, uint8_t #undef TEXT_TRANSFORM_SHIFT #undef TEXT_TRANSFORM_MASK -#define TOP_INDEX 3 -#define TOP_SHIFT 25 -#define TOP_MASK 0xfe000000 +#define TOP_INDEX 1 +#define TOP_SHIFT 0 +#define TOP_MASK 0x7f static inline css_error set_top(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2518,9 +2313,9 @@ static inline css_error set_top(css_computed_style *style, uint8_t type, #undef TOP_SHIFT #undef TOP_MASK -#define UNICODE_BIDI_INDEX 9 -#define UNICODE_BIDI_SHIFT 16 -#define UNICODE_BIDI_MASK 0x30000 +#define UNICODE_BIDI_INDEX 11 +#define UNICODE_BIDI_SHIFT 6 +#define UNICODE_BIDI_MASK 0xc0 static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t type) @@ -2539,9 +2334,9 @@ 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 5 -#define VERTICAL_ALIGN_SHIFT 12 -#define VERTICAL_ALIGN_MASK 0x1ff000 +#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) @@ -2563,8 +2358,8 @@ static inline css_error set_vertical_align(css_computed_style *style, uint8_t #undef VERTICAL_ALIGN_MASK #define VISIBILITY_INDEX 10 -#define VISIBILITY_SHIFT 28 -#define VISIBILITY_MASK 0x30000000 +#define VISIBILITY_SHIFT 18 +#define VISIBILITY_MASK 0xc0000 static inline css_error set_visibility(css_computed_style *style, uint8_t type) { @@ -2582,9 +2377,9 @@ static inline css_error set_visibility(css_computed_style *style, uint8_t type) #undef VISIBILITY_SHIFT #undef VISIBILITY_MASK -#define WHITE_SPACE_INDEX 6 -#define WHITE_SPACE_SHIFT 0 -#define WHITE_SPACE_MASK 0x7 +#define WHITE_SPACE_INDEX 9 +#define WHITE_SPACE_SHIFT 23 +#define WHITE_SPACE_MASK 0x3800000 static inline css_error set_white_space(css_computed_style *style, uint8_t type) { @@ -2602,9 +2397,32 @@ 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 25 +#define WIDOWS_MASK 0x2000000 + +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]; + + /* 1bit: t : type */ + *bits = (*bits & ~WIDOWS_MASK) | (((uint32_t)type & 0x1) << + WIDOWS_SHIFT); + + style->i.widows = integer; + + return CSS_OK; +} +#undef WIDOWS_INDEX +#undef WIDOWS_SHIFT +#undef WIDOWS_MASK + #define WIDTH_INDEX 4 -#define WIDTH_SHIFT 18 -#define WIDTH_MASK 0x1fc0000 +#define WIDTH_SHIFT 11 +#define WIDTH_MASK 0x3f800 static inline css_error set_width(css_computed_style *style, uint8_t type, css_fixed length, css_unit unit) @@ -2625,9 +2443,53 @@ static inline css_error set_width(css_computed_style *style, uint8_t type, #undef WIDTH_SHIFT #undef WIDTH_MASK +#define WORD_SPACING_INDEX 3 +#define WORD_SPACING_SHIFT 11 +#define WORD_SPACING_MASK 0x3f800 + +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]; + + /* 7bits: uuuuutt : unit | type */ + *bits = (*bits & ~WORD_SPACING_MASK) | ((((uint32_t)type & 0x3) | (unit + << 2)) << WORD_SPACING_SHIFT); + + style->i.word_spacing = length; + + return CSS_OK; +} +#undef WORD_SPACING_INDEX +#undef WORD_SPACING_SHIFT +#undef WORD_SPACING_MASK + +#define WRITING_MODE_INDEX 10 +#define WRITING_MODE_SHIFT 6 +#define WRITING_MODE_MASK 0xc0 + +static inline css_error set_writing_mode(css_computed_style *style, uint8_t + type) +{ + uint32_t *bits; + + bits = &style->i.bits[WRITING_MODE_INDEX]; + + /* 2bits: tt : type */ + *bits = (*bits & ~WRITING_MODE_MASK) | (((uint32_t)type & 0x3) << + WRITING_MODE_SHIFT); + + return CSS_OK; +} +#undef WRITING_MODE_INDEX +#undef WRITING_MODE_SHIFT +#undef WRITING_MODE_MASK + #define Z_INDEX_INDEX 10 -#define Z_INDEX_SHIFT 30 -#define Z_INDEX_MASK 0xc0000000 +#define Z_INDEX_SHIFT 4 +#define Z_INDEX_MASK 0x30 static inline css_error set_z_index(css_computed_style *style, uint8_t type, int32_t integer) diff --git a/src/select/computed.c b/src/select/computed.c index 506b079..83bbf10 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -83,121 +83,87 @@ css_error css__computed_style_create(css_computed_style **result) } /** - * Destroy an uncommon computed style section + * Destroy a computed style * * \param style Style to destroy * \return CSS_OK on success, appropriate error otherwise */ -css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon) +css_error css_computed_style_destroy(css_computed_style *style) { - if (uncommon == NULL) + if (style == NULL) return CSS_BADPARM; - if (uncommon->count > 1) { - uncommon->count--; + if (style->count > 1) { + style->count--; return CSS_OK; - } else if (uncommon->count == 1) { - css__arena_remove_uncommon_style(uncommon); + } else if (style->count == 1) { + css__arena_remove_style(style); } - if (uncommon != NULL) { - if (uncommon->counter_increment != NULL) { - css_computed_counter *c; - - for (c = uncommon->counter_increment; - c->name != NULL; c++) { - lwc_string_unref(c->name); - } - - free(uncommon->counter_increment); - } - - if (uncommon->counter_reset != NULL) { - css_computed_counter *c; + if (style->i.aural != NULL) { + free(style->i.aural); + } - for (c = uncommon->counter_reset; - c->name != NULL; c++) { - lwc_string_unref(c->name); - } + if (style->counter_increment != NULL) { + css_computed_counter *c; - free(uncommon->counter_reset); + for (c = style->counter_increment; c->name != NULL; c++) { + lwc_string_unref(c->name); } - if (uncommon->cursor != NULL) { - lwc_string **s; - - for (s = uncommon->cursor; *s != NULL; s++) { - lwc_string_unref(*s); - } - - free(uncommon->cursor); - } + free(style->counter_increment); + } - if (uncommon->content != NULL) { - css_computed_content_item *c; - - for (c = uncommon->content; - c->type != CSS_COMPUTED_CONTENT_NONE; - c++) { - switch (c->type) { - case CSS_COMPUTED_CONTENT_STRING: - lwc_string_unref(c->data.string); - break; - case CSS_COMPUTED_CONTENT_URI: - lwc_string_unref(c->data.uri); - break; - case CSS_COMPUTED_CONTENT_ATTR: - lwc_string_unref(c->data.attr); - break; - case CSS_COMPUTED_CONTENT_COUNTER: - lwc_string_unref(c->data.counter.name); - break; - case CSS_COMPUTED_CONTENT_COUNTERS: - lwc_string_unref(c->data.counters.name); - lwc_string_unref(c->data.counters.sep); - break; - default: - break; - } - } + if (style->counter_reset != NULL) { + css_computed_counter *c; - free(uncommon->content); + for (c = style->counter_reset; c->name != NULL; c++) { + lwc_string_unref(c->name); } - free(uncommon); + free(style->counter_reset); } - return CSS_OK; -} - -/** - * Destroy a computed style - * - * \param style Style to destroy - * \return CSS_OK on success, appropriate error otherwise - */ -css_error css_computed_style_destroy(css_computed_style *style) -{ - if (style == NULL) - return CSS_BADPARM; - - css__computed_uncommon_destroy(style->i.uncommon); + if (style->cursor != NULL) { + lwc_string **s; - if (style->count > 1) { - style->count--; - return CSS_OK; + for (s = style->cursor; *s != NULL; s++) { + lwc_string_unref(*s); + } - } else if (style->count == 1) { - css__arena_remove_style(style); + free(style->cursor); } - if (style->page != NULL) { - free(style->page); - } + if (style->content != NULL) { + css_computed_content_item *c; + + for (c = style->content; + c->type != CSS_COMPUTED_CONTENT_NONE; + c++) { + switch (c->type) { + case CSS_COMPUTED_CONTENT_STRING: + lwc_string_unref(c->data.string); + break; + case CSS_COMPUTED_CONTENT_URI: + lwc_string_unref(c->data.uri); + break; + case CSS_COMPUTED_CONTENT_ATTR: + lwc_string_unref(c->data.attr); + break; + case CSS_COMPUTED_CONTENT_COUNTER: + lwc_string_unref(c->data.counter.name); + break; + case CSS_COMPUTED_CONTENT_COUNTERS: + lwc_string_unref(c->data.counters.name); + lwc_string_unref(c->data.counters.sep); + break; + default: + break; + } + } - if (style->i.aural != NULL) { - free(style->i.aural); + free(style->content); } if (style->font_family != NULL) { @@ -311,15 +277,6 @@ css_error css_computed_style_compose( switch(prop_dispatch[i].group) { case GROUP_NORMAL: break; - case GROUP_UNCOMMON: - if (parent->i.uncommon == NULL && - child->i.uncommon == NULL) - continue; - break; - case GROUP_PAGE: - if (parent->page == NULL && child->page == NULL) - continue; - break; case GROUP_AURAL: if (parent->i.aural == NULL && child->i.aural == NULL) continue; @@ -1292,76 +1249,73 @@ css_error css__compute_absolute_values(const css_computed_style *parent, if (error != CSS_OK) return error; - /* Uncommon properties */ - if (style->i.uncommon != NULL) { - /* Fix up border-spacing */ - error = compute_absolute_length_pair(style, - &ex_size.data.length, - get_border_spacing, - set_border_spacing); - if (error != CSS_OK) - return error; + /* Fix up border-spacing */ + error = compute_absolute_length_pair(style, + &ex_size.data.length, + get_border_spacing, + set_border_spacing); + if (error != CSS_OK) + return error; - /* Fix up clip */ - error = compute_absolute_clip(style, &ex_size.data.length); - if (error != CSS_OK) - return error; + /* Fix up clip */ + error = compute_absolute_clip(style, &ex_size.data.length); + if (error != CSS_OK) + return error; - /* Fix up letter-spacing */ - error = compute_absolute_length(style, - &ex_size.data.length, - get_letter_spacing, - set_letter_spacing); - if (error != CSS_OK) - return error; + /* Fix up letter-spacing */ + error = compute_absolute_length(style, + &ex_size.data.length, + get_letter_spacing, + set_letter_spacing); + if (error != CSS_OK) + return error; - /* Fix up outline-color */ - error = compute_absolute_color(style, - get_outline_color, - set_outline_color); - if (error != CSS_OK) - return error; + /* Fix up outline-color */ + error = compute_absolute_color(style, + get_outline_color, + set_outline_color); + if (error != CSS_OK) + return error; - /* Fix up outline-width */ - error = compute_absolute_border_side_width(style, - &ex_size.data.length, - get_outline_width, - set_outline_width); - if (error != CSS_OK) - return error; + /* Fix up outline-width */ + error = compute_absolute_border_side_width(style, + &ex_size.data.length, + get_outline_width, + set_outline_width); + if (error != CSS_OK) + return error; - /* Fix up word-spacing */ - error = compute_absolute_length(style, - &ex_size.data.length, - get_word_spacing, - set_word_spacing); - if (error != CSS_OK) - return error; + /* Fix up word-spacing */ + error = compute_absolute_length(style, + &ex_size.data.length, + get_word_spacing, + set_word_spacing); + if (error != CSS_OK) + return error; - /* Fix up column-rule-width */ - error = compute_absolute_border_side_width(style, - &ex_size.data.length, - get_column_rule_width, - set_column_rule_width); - if (error != CSS_OK) + /* Fix up column-rule-width */ + error = compute_absolute_border_side_width(style, + &ex_size.data.length, + get_column_rule_width, + set_column_rule_width); + if (error != CSS_OK) return error; - /* Fix up column-width */ - error = compute_absolute_length(style, - &ex_size.data.length, - get_column_width, - set_column_width); - if (error != CSS_OK) + /* Fix up column-width */ + error = compute_absolute_length(style, + &ex_size.data.length, + get_column_width, + set_column_width); + if (error != CSS_OK) return error; - /* Fix up column-gap */ - error = compute_absolute_length(style, - &ex_size.data.length, - get_column_gap, - set_column_gap); - if (error != CSS_OK) - return error; - } + /* Fix up column-gap */ + error = compute_absolute_length(style, + &ex_size.data.length, + get_column_gap, + set_column_gap); + if (error != CSS_OK) + return error; return CSS_OK; } diff --git a/src/select/computed.h b/src/select/computed.h index d59fbe3..c926cec 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -24,10 +24,6 @@ static inline css_computed_style * css__computed_style_ref( if (style == NULL) return NULL; - if (style->i.uncommon != NULL) { - style->i.uncommon->count++; - } - style->count++; return style; } @@ -37,9 +33,6 @@ css_error css__computed_style_create(css_computed_style **result); css_error css__computed_style_initialise(css_computed_style *style, struct css_select_handler *handler, void *pw); - -css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon); - css_error css__compute_absolute_values(const css_computed_style *parent, css_computed_style *style, css_error (*compute_font_size)(void *pw, diff --git a/src/select/overrides.py b/src/select/overrides.py index c8d1a2a..b4d349a 100644 --- a/src/select/overrides.py +++ b/src/select/overrides.py @@ -14,41 +14,36 @@ static inline uint8_t get_clip( const css_computed_style *style, css_computed_clip_rect *rect) { - if (style->i.uncommon != NULL) { - uint32_t bits = style->i.uncommon->i.bits[CLIP_INDEX]; - bits &= CLIP_MASK; - bits >>= CLIP_SHIFT; - - /* - 26bits: tt tttr rrrr bbbb blll llTR BLyy: - units: top | right | bottom | left - opcodes: top | right | bottom | left | type - */ - - if ((bits & 0x3) == CSS_CLIP_RECT) { - rect->left_auto = (bits & 0x4); - rect->bottom_auto = (bits & 0x8); - rect->right_auto = (bits & 0x10); - rect->top_auto = (bits & 0x20); - - rect->top = style->i.uncommon->i.clip_a; - rect->tunit = bits & 0x3e00000 >> 21; - - rect->right = style->i.uncommon->i.clip_b; - rect->runit = bits & 0x1f0000 >> 16; - - rect->bottom = style->i.uncommon->i.clip_c; - rect->bunit = (bits & 0xf800) >> 11; - - rect->left = style->i.uncommon->i.clip_d; - rect->lunit = (bits & 0x7c0) >> 6; - } + uint32_t bits = style->i.bits[CLIP_INDEX]; + bits &= CLIP_MASK; + bits >>= CLIP_SHIFT; + + /* + 26bits: tt tttr rrrr bbbb blll llTR BLyy: + units: top | right | bottom | left + opcodes: top | right | bottom | left | type + */ - return (bits & 0x3); + if ((bits & 0x3) == CSS_CLIP_RECT) { + rect->left_auto = (bits & 0x4); + rect->bottom_auto = (bits & 0x8); + rect->right_auto = (bits & 0x10); + rect->top_auto = (bits & 0x20); + + rect->top = style->i.clip_a; + rect->tunit = bits & 0x3e00000 >> 21; + + rect->right = style->i.clip_b; + rect->runit = bits & 0x1f0000 >> 16; + + rect->bottom = style->i.clip_c; + rect->bunit = (bits & 0xf800) >> 11; + + rect->left = style->i.clip_d; + rect->lunit = (bits & 0x7c0) >> 6; } - /* Initial value */ - return CSS_CLIP_AUTO; + return (bits & 0x3); }''' overrides['set']['clip'] = '''\ @@ -58,9 +53,7 @@ static inline css_error set_clip( { uint32_t *bits; - ENSURE_UNCOMMON; - - bits = &style->i.uncommon->i.bits[CLIP_INDEX]; + bits = &style->i.bits[CLIP_INDEX]; /* 26bits: tt tttr rrrr bbbb blll llTR BLyy: @@ -82,10 +75,10 @@ static inline css_error set_clip( *bits |= (((rect->bunit << 5) | rect->lunit) << (CLIP_SHIFT + 6)); - style->i.uncommon->i.clip_a = rect->top; - style->i.uncommon->i.clip_b = rect->right; - style->i.uncommon->i.clip_c = rect->bottom; - style->i.uncommon->i.clip_d = rect->left; + style->i.clip_a = rect->top; + style->i.clip_b = rect->right; + style->i.clip_c = rect->bottom; + style->i.clip_d = rect->left; } return CSS_OK; @@ -122,11 +115,9 @@ static inline css_error set_content( css_computed_content_item *oldcontent; css_computed_content_item *c; - ENSURE_UNCOMMON; - /* 2bits: type */ - bits = &style->i.uncommon->i.bits[CONTENT_INDEX]; - oldcontent = style->i.uncommon->content; + bits = &style->i.bits[CONTENT_INDEX]; + oldcontent = style->content; *bits = (*bits & ~CONTENT_MASK) | ((type & 0x3) << CONTENT_SHIFT); @@ -158,7 +149,7 @@ static inline css_error set_content( } } - style->i.uncommon->content = content; + style->content = content; /* Free existing array */ if (oldcontent != NULL) { diff --git a/src/select/properties/border_spacing.c b/src/select/properties/border_spacing.c index 147f56f..0077aac 100644 --- a/src/select/properties/border_spacing.c +++ b/src/select/properties/border_spacing.c @@ -71,19 +71,10 @@ css_error css__compose_border_spacing(const css_computed_style *parent, uint8_t type = get_border_spacing(child, &hlength, &hunit, &vlength, &vunit); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_BORDER_SPACING_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_BORDER_SPACING_INHERIT) { - type = get_border_spacing(parent, - &hlength, &hunit, &vlength, &vunit); - } - - return set_border_spacing(result, type, hlength, hunit, - vlength, vunit); + if (type == CSS_BORDER_SPACING_INHERIT) { + type = get_border_spacing(parent, + &hlength, &hunit, &vlength, &vunit); } - return CSS_OK; + return set_border_spacing(result, type, hlength, hunit, vlength, vunit); } - diff --git a/src/select/properties/clip.c b/src/select/properties/clip.c index fe1dd87..2785afb 100644 --- a/src/select/properties/clip.c +++ b/src/select/properties/clip.c @@ -102,17 +102,9 @@ css_error css__compose_clip(const css_computed_style *parent, false, false, false, false }; uint8_t type = get_clip(child, &rect); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_CLIP_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_CLIP_INHERIT) { - type = get_clip(parent, &rect); - } - - return set_clip(result, type, &rect); + if (type == CSS_CLIP_INHERIT) { + type = get_clip(parent, &rect); } - return CSS_OK; + return set_clip(result, type, &rect); } - diff --git a/src/select/properties/column_count.c b/src/select/properties/column_count.c index 7e929b0..efd1243 100644 --- a/src/select/properties/column_count.c +++ b/src/select/properties/column_count.c @@ -59,17 +59,9 @@ css_error css__compose_column_count(const css_computed_style *parent, int32_t count = 0; uint8_t type = get_column_count(child, &count); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COLUMN_COUNT_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COLUMN_COUNT_INHERIT) { - type = get_column_count(parent, &count); - } - - return set_column_count(result, type, count); + if (type == CSS_COLUMN_COUNT_INHERIT) { + type = get_column_count(parent, &count); } - return CSS_OK; + return set_column_count(result, type, count); } - diff --git a/src/select/properties/column_gap.c b/src/select/properties/column_gap.c index 824b3a4..087eb0f 100644 --- a/src/select/properties/column_gap.c +++ b/src/select/properties/column_gap.c @@ -41,17 +41,9 @@ css_error css__compose_column_gap(const css_computed_style *parent, css_unit unit = CSS_UNIT_EM; uint8_t type = get_column_gap(child, &length, &unit); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COLUMN_GAP_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COLUMN_GAP_INHERIT) { - type = get_column_gap(parent, &length, &unit); - } - - return set_column_gap(result, type, length, unit); + if (type == CSS_COLUMN_GAP_INHERIT) { + type = get_column_gap(parent, &length, &unit); } - return CSS_OK; + return set_column_gap(result, type, length, unit); } - diff --git a/src/select/properties/column_width.c b/src/select/properties/column_width.c index b6550ab..e739ade 100644 --- a/src/select/properties/column_width.c +++ b/src/select/properties/column_width.c @@ -41,17 +41,9 @@ css_error css__compose_column_width(const css_computed_style *parent, css_unit unit = CSS_UNIT_EM; uint8_t type = get_column_width(child, &length, &unit); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COLUMN_WIDTH_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COLUMN_WIDTH_INHERIT) { - type = get_column_width(parent, &length, &unit); - } - - return set_column_width(result, type, length, unit); + if (type == CSS_COLUMN_WIDTH_INHERIT) { + type = get_column_width(parent, &length, &unit); } - return CSS_OK; + return set_column_width(result, type, length, unit); } - diff --git a/src/select/properties/content.c b/src/select/properties/content.c index 0506ef3..f75743d 100644 --- a/src/select/properties/content.c +++ b/src/select/properties/content.c @@ -204,43 +204,34 @@ css_error css__compose_content(const css_computed_style *parent, css_computed_style *result) { css_error error; + css_computed_content_item *copy = NULL; const css_computed_content_item *items = NULL; uint8_t type = get_content(child, &items); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_CONTENT_INHERIT || - (child->i.uncommon != NULL && result != child)) { - size_t n_items = 0; - css_computed_content_item *copy = NULL; - - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_CONTENT_INHERIT) { - type = get_content(parent, &items); - } - - if (type == CSS_CONTENT_SET) { - const css_computed_content_item *i; - - for (i = items; i->type != CSS_COMPUTED_CONTENT_NONE; - i++) - n_items++; + if (type == CSS_CONTENT_INHERIT) { + type = get_content(parent, &items); + } - copy = malloc((n_items + 1) * - sizeof(css_computed_content_item)); - if (copy == NULL) - return CSS_NOMEM; + if (type == CSS_CONTENT_SET) { + size_t n_items = 0; + const css_computed_content_item *i; - memcpy(copy, items, (n_items + 1) * - sizeof(css_computed_content_item)); - } + for (i = items; i->type != CSS_COMPUTED_CONTENT_NONE; + i++) + n_items++; - error = set_content(result, type, copy); - if (error != CSS_OK && copy != NULL) - free(copy); + copy = malloc((n_items + 1) * + sizeof(css_computed_content_item)); + if (copy == NULL) + return CSS_NOMEM; - return error; + memcpy(copy, items, (n_items + 1) * + sizeof(css_computed_content_item)); } - return CSS_OK; -} + error = set_content(result, type, copy); + if (error != CSS_OK && copy != NULL) + free(copy); + return error; +} diff --git a/src/select/properties/counter_increment.c b/src/select/properties/counter_increment.c index 9888e0a..1b75c25 100644 --- a/src/select/properties/counter_increment.c +++ b/src/select/properties/counter_increment.c @@ -53,42 +53,33 @@ css_error css__compose_counter_increment(const css_computed_style *parent, css_computed_style *result) { css_error error; + css_computed_counter *copy = NULL; const css_computed_counter *items = NULL; uint8_t type = get_counter_increment(child, &items); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COUNTER_INCREMENT_INHERIT || - (child->i.uncommon != NULL && result != child)) { - size_t n_items = 0; - css_computed_counter *copy = NULL; - - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COUNTER_INCREMENT_INHERIT) { - type = get_counter_increment(parent, &items); - } - - if (type == CSS_COUNTER_INCREMENT_NAMED && items != NULL) { - const css_computed_counter *i; - - for (i = items; i->name != NULL; i++) - n_items++; + if (type == CSS_COUNTER_INCREMENT_INHERIT) { + type = get_counter_increment(parent, &items); + } - copy = malloc((n_items + 1) * - sizeof(css_computed_counter)); - if (copy == NULL) - return CSS_NOMEM; + if (type == CSS_COUNTER_INCREMENT_NAMED && items != NULL) { + size_t n_items = 0; + const css_computed_counter *i; - memcpy(copy, items, (n_items + 1) * - sizeof(css_computed_counter)); - } + for (i = items; i->name != NULL; i++) + n_items++; - error = set_counter_increment(result, type, copy); - if (error != CSS_OK && copy != NULL) - free(copy); + copy = malloc((n_items + 1) * + sizeof(css_computed_counter)); + if (copy == NULL) + return CSS_NOMEM; - return error; + memcpy(copy, items, (n_items + 1) * + sizeof(css_computed_counter)); } - return CSS_OK; -} + error = set_counter_increment(result, type, copy); + if (error != CSS_OK && copy != NULL) + free(copy); + return error; +} diff --git a/src/select/properties/counter_reset.c b/src/select/properties/counter_reset.c index 9d20609..e4ec8bf 100644 --- a/src/select/properties/counter_reset.c +++ b/src/select/properties/counter_reset.c @@ -52,41 +52,33 @@ css_error css__compose_counter_reset(const css_computed_style *parent, css_computed_style *result) { css_error error; + css_computed_counter *copy = NULL; const css_computed_counter *items = NULL; uint8_t type = get_counter_reset(child, &items); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COUNTER_RESET_INHERIT || - (child->i.uncommon != NULL && result != child)) { - size_t n_items = 0; - css_computed_counter *copy = NULL; - - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_COUNTER_RESET_INHERIT) { - type = get_counter_reset(parent, &items); - } - - if (type == CSS_COUNTER_RESET_NAMED && items != NULL) { - const css_computed_counter *i; - - for (i = items; i->name != NULL; i++) - n_items++; + if (type == CSS_COUNTER_RESET_INHERIT) { + type = get_counter_reset(parent, &items); + } - copy = malloc((n_items + 1) * - sizeof(css_computed_counter)); - if (copy == NULL) - return CSS_NOMEM; + if (type == CSS_COUNTER_RESET_NAMED && items != NULL) { + size_t n_items = 0; + const css_computed_counter *i; - memcpy(copy, items, (n_items + 1) * - sizeof(css_computed_counter)); - } + for (i = items; i->name != NULL; i++) + n_items++; - error = set_counter_reset(result, type, copy); - if (error != CSS_OK && copy != NULL) - free(copy); + copy = malloc((n_items + 1) * + sizeof(css_computed_counter)); + if (copy == NULL) + return CSS_NOMEM; - return error; + memcpy(copy, items, (n_items + 1) * + sizeof(css_computed_counter)); } - return CSS_OK; + error = set_counter_reset(result, type, copy); + if (error != CSS_OK && copy != NULL) + free(copy); + + return error; } diff --git a/src/select/properties/cursor.c b/src/select/properties/cursor.c index 6effdb5..c5e50c6 100644 --- a/src/select/properties/cursor.c +++ b/src/select/properties/cursor.c @@ -169,42 +169,33 @@ css_error css__compose_cursor(const css_computed_style *parent, css_computed_style *result) { css_error error; + lwc_string **copy = NULL; lwc_string **urls = NULL; uint8_t type = get_cursor(child, &urls); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_CURSOR_INHERIT || - (child->i.uncommon != NULL && result != child)) { - size_t n_urls = 0; - lwc_string **copy = NULL; - - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_CURSOR_INHERIT) { - type = get_cursor(parent, &urls); - } - - if (urls != NULL) { - lwc_string **i; + if (type == CSS_CURSOR_INHERIT) { + type = get_cursor(parent, &urls); + } - for (i = urls; (*i) != NULL; i++) - n_urls++; + if (urls != NULL) { + lwc_string **i; + size_t n_urls = 0; - copy = malloc((n_urls + 1) * - sizeof(lwc_string *)); - if (copy == NULL) - return CSS_NOMEM; + for (i = urls; (*i) != NULL; i++) + n_urls++; - memcpy(copy, urls, (n_urls + 1) * - sizeof(lwc_string *)); - } - - error = set_cursor(result, type, copy); - if (error != CSS_OK && copy != NULL) - free(copy); + copy = malloc((n_urls + 1) * + sizeof(lwc_string *)); + if (copy == NULL) + return CSS_NOMEM; - return error; + memcpy(copy, urls, (n_urls + 1) * + sizeof(lwc_string *)); } - return CSS_OK; -} + error = set_cursor(result, type, copy); + if (error != CSS_OK && copy != NULL) + free(copy); + return error; +} diff --git a/src/select/properties/letter_spacing.c b/src/select/properties/letter_spacing.c index d799467..27ea04b 100644 --- a/src/select/properties/letter_spacing.c +++ b/src/select/properties/letter_spacing.c @@ -41,17 +41,9 @@ css_error css__compose_letter_spacing(const css_computed_style *parent, css_unit unit = CSS_UNIT_PX; uint8_t type = get_letter_spacing(child, &length, &unit); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_LETTER_SPACING_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_LETTER_SPACING_INHERIT) { - type = get_letter_spacing(parent, &length, &unit); - } - - return set_letter_spacing(result, type, length, unit); + if (type == CSS_LETTER_SPACING_INHERIT) { + type = get_letter_spacing(parent, &length, &unit); } - return CSS_OK; + return set_letter_spacing(result, type, length, unit); } - diff --git a/src/select/properties/outline_color.c b/src/select/properties/outline_color.c index c6c576b..97846ac 100644 --- a/src/select/properties/outline_color.c +++ b/src/select/properties/outline_color.c @@ -65,17 +65,9 @@ css_error css__compose_outline_color(const css_computed_style *parent, css_color color = 0; uint8_t type = get_outline_color(child, &color); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_OUTLINE_COLOR_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_OUTLINE_COLOR_INHERIT) { - type = get_outline_color(parent, &color); - } - - return set_outline_color(result, type, color); + if (type == CSS_OUTLINE_COLOR_INHERIT) { + type = get_outline_color(parent, &color); } - return CSS_OK; + return set_outline_color(result, type, color); } - diff --git a/src/select/properties/outline_width.c b/src/select/properties/outline_width.c index 4d9101c..0289c57 100644 --- a/src/select/properties/outline_width.c +++ b/src/select/properties/outline_width.c @@ -41,17 +41,10 @@ css_error css__compose_outline_width(const css_computed_style *parent, css_unit unit = CSS_UNIT_PX; uint8_t type = get_outline_width(child, &length, &unit); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_OUTLINE_WIDTH_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_OUTLINE_WIDTH_INHERIT) { - type = get_outline_width(parent, &length, &unit); - } - - return set_outline_width(result, type, length, unit); + if (type == CSS_OUTLINE_WIDTH_INHERIT) { + type = get_outline_width(parent, &length, &unit); } - return CSS_OK; + return set_outline_width(result, type, length, unit); } diff --git a/src/select/properties/word_spacing.c b/src/select/properties/word_spacing.c index 4cb9422..eb39b50 100644 --- a/src/select/properties/word_spacing.c +++ b/src/select/properties/word_spacing.c @@ -41,17 +41,9 @@ css_error css__compose_word_spacing(const css_computed_style *parent, css_unit unit = CSS_UNIT_PX; uint8_t type = get_word_spacing(child, &length, &unit); - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_WORD_SPACING_INHERIT || - (child->i.uncommon != NULL && result != child)) { - if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) || - type == CSS_WORD_SPACING_INHERIT) { - type = get_word_spacing(parent, &length, &unit); - } - - return set_word_spacing(result, type, length, unit); + if (type == CSS_WORD_SPACING_INHERIT) { + type = get_word_spacing(parent, &length, &unit); } - return CSS_OK; + return set_word_spacing(result, type, length, unit); } - diff --git a/src/select/select.c b/src/select/select.c index 1b0cadd..6a95b97 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -1826,12 +1826,8 @@ css_error set_initial(css_select_state *state, case GROUP_NORMAL: break; case GROUP_UNCOMMON: - if (state->computed->i.uncommon == NULL) - return CSS_OK; break; case GROUP_PAGE: - if (state->computed->page == NULL) - return CSS_OK; break; case GROUP_AURAL: if (state->computed->i.aural == NULL) diff --git a/src/select/select_config.py b/src/select/select_config.py index a543542..8845814 100644 --- a/src/select/select_config.py +++ b/src/select/select_config.py @@ -110,10 +110,7 @@ style = { 'blank entry.'), ('quotes', 1, 'string_arr', None, None, 'Encode quotes as an array of string objects, terminated with a ' - 'blank entry.') -} - -page = { + 'blank entry.'), # Page group ('page_break_after', 3, None, None, 'CSS_PAGE_BREAK_AFTER_AUTO'), ('page_break_before', 3, None, None, 'CSS_PAGE_BREAK_BEFORE_AUTO'), @@ -121,10 +118,7 @@ page = { ('widows', 1, (('integer', '2'),), None, 'CSS_WIDOWS_SET'), ('orphans', 1, (('integer', '2'),), None, - 'CSS_ORPHANS_SET') -} - -uncommon = { + 'CSS_ORPHANS_SET'), # Uncommon group ('border_spacing', 1, (('length',), ('length',)), 'CSS_BORDER_SPACING_SET', 'CSS_BORDER_SPACING_SET'), @@ -170,7 +164,5 @@ uncommon = { } groups = [ - { 'name': 'uncommon', 'props': uncommon }, - { 'name': 'page', 'props': page }, { 'name': 'style', 'props': style } ] diff --git a/src/select/select_generator.py b/src/select/select_generator.py index 4de99cb..7427a88 100644 --- a/src/select/select_generator.py +++ b/src/select/select_generator.py @@ -512,9 +512,6 @@ class CSSGroup: t.append(self.make_value_declaration(for_commented=True)) t.append() - if self.name is 'style': - t.append('css_computed_page *page;') - t.append('struct css_computed_' + self.name + ' *next;') t.append('uint32_t count;') t.append('uint32_t bin;') |