summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README15
-rw-r--r--src/select/.gitignore2
-rw-r--r--src/select/Makefile1
-rw-r--r--src/select/autogenerated_computed.h328
-rw-r--r--src/select/autogenerated_propget.h2288
-rw-r--r--src/select/autogenerated_propset.h2631
6 files changed, 5259 insertions, 6 deletions
diff --git a/README b/README
index b70bc6a..0f45b87 100644
--- a/README
+++ b/README
@@ -16,7 +16,7 @@ Requirements
+ GNU make or compatible
+ Pkg-config
+ Perl (for the testcases)
- + Python3 (minimum 3.6)
+ + Python3 (minimum 3.6, for generated selection code)
LibCSS also requires the following libraries to be installed:
@@ -28,7 +28,16 @@ Compilation
If necessary, modify the toolchain settings in the Makefile.
Invoke make:
- $ make
+
+ $ make
+
+Regenerating generated selection source code
+--------------------------------------------
+
+ To regenerate the selection sources (computed style data accesses),
+ note this requires python3:
+
+ $ make select_generator
Verification
------------
@@ -36,7 +45,7 @@ Verification
To verify that the parser is working, it is necessary to specify a
different makefile target than that used for normal compilation, thus:
- $ make test
+ $ make test
API documentation
-----------------
diff --git a/src/select/.gitignore b/src/select/.gitignore
index a8bedc3..3901713 100644
--- a/src/select/.gitignore
+++ b/src/select/.gitignore
@@ -1,5 +1,3 @@
-autogenerated_*.c
-autogenerated_*.h
__pycache__
*.pyc
diff --git a/src/select/Makefile b/src/select/Makefile
index 13c3eec..025ad39 100644
--- a/src/select/Makefile
+++ b/src/select/Makefile
@@ -3,6 +3,5 @@ select_generator:
python3 src/select/select_generator.py
DIR_SOURCES := arena.c computed.c dispatch.c hash.c select.c font_face.c
-PRE_TARGETS := select_generator
include $(NSBUILD)/Makefile.subdir
diff --git a/src/select/autogenerated_computed.h b/src/select/autogenerated_computed.h
new file mode 100644
index 0000000..11f4808
--- a/dev/null
+++ b/src/select/autogenerated_computed.h
@@ -0,0 +1,328 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 The NetSurf Project
+ */
+
+
+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 bbbbbbbbbbbccccccccoooooooouuuuu
+ * border_spacing; column_rule_width; outline_width; cursor
+ *
+ * 1 lllllllcccccccooooooowwwwwwwbbbb
+ * letter_spacing; column_gap; column_width; word_spacing; break_after
+ *
+ * 2 ccccccccccccccccccccccccccbbbboo
+ * clip; break_before; column_count
+ *
+ * 3 bbbbccccwwoolluunnmmte..........
+ * break_inside; column_rule_style; writing_mode; column_span;
+ * column_rule_color; outline_color; content; column_fill; 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)
+ * --- --- ---
+ * align_content 3
+ * align_items 3
+ * align_self 3
+ * background_attachment 2
+ * background_color 2 4
+ * background_image 1 sizeof(ptr)
+ * background_position 1 + 10 8
+ * background_repeat 3
+ * border_bottom_color 2 4
+ * border_bottom_style 4
+ * border_bottom_width 3 + 5 4
+ * border_collapse 2
+ * border_left_color 2 4
+ * border_left_style 4
+ * border_left_width 3 + 5 4
+ * border_right_color 2 4
+ * border_right_style 4
+ * border_right_width 3 + 5 4
+ * border_top_color 2 4
+ * border_top_style 4
+ * border_top_width 3 + 5 4
+ * bottom 2 + 5 4
+ * box_sizing 2
+ * caption_side 2
+ * clear 3
+ * color 1 4
+ * direction 2
+ * display 5
+ * empty_cells 2
+ * flex_basis 2 + 5 4
+ * flex_direction 3
+ * flex_grow 1 4
+ * flex_shrink 1 4
+ * flex_wrap 2
+ * float 2
+ * font_size 4 + 5 4
+ * font_style 2
+ * font_variant 2
+ * font_weight 4
+ * height 2 + 5 4
+ * justify_content 3
+ * left 2 + 5 4
+ * line_height 2 + 5 4
+ * list_style_image 1 sizeof(ptr)
+ * list_style_position 2
+ * list_style_type 4
+ * margin_bottom 2 + 5 4
+ * margin_left 2 + 5 4
+ * margin_right 2 + 5 4
+ * margin_top 2 + 5 4
+ * max_height 2 + 5 4
+ * max_width 2 + 5 4
+ * min_height 2 + 5 4
+ * min_width 2 + 5 4
+ * opacity 1 4
+ * order 1 4
+ * outline_style 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
+ * position 3
+ * right 2 + 5 4
+ * table_layout 2
+ * text_align 4
+ * text_decoration 5
+ * text_indent 1 + 5 4
+ * text_transform 3
+ * top 2 + 5 4
+ * unicode_bidi 2
+ * vertical_align 4 + 5 4
+ * visibility 2
+ * white_space 3
+ * width 2 + 5 4
+ * z_index 2 4
+ *
+ * Encode font family as an array of string objects, terminated with a blank
+ * entry.
+ *
+ * font_family 3 sizeof(ptr)
+ *
+ * Encode quotes as an array of string objects, terminated with a blank entry.
+ *
+ * quotes 1 sizeof(ptr)
+ *
+ * --- --- ---
+ * 332 bits 160 + 4sizeof(ptr) bytes
+ * ===================
+ * 202 + 4sizeof(ptr) bytes
+ *
+ * Bit allocations:
+ *
+ * 0 bbbbbbbboooooooorrrrrrrrdddddddd
+ * border_bottom_width; border_left_width; border_top_width; border_right_width
+ *
+ * 1 mmmmmmmaaaaaaawwwwwwwfffffffbbbb
+ * margin_right; max_width; width; flex_basis; border_top_style
+ *
+ * 2 mmmmmmmiiiiiiilllllllhhhhhhhbbbb
+ * margin_bottom; min_width; line_height; height; border_right_style
+ *
+ * 3 lllllllbbbbbbbmmmmmmmiiiiiiissss
+ * left; bottom; max_height; min_height; list_style_type
+ *
+ * 4 rrrrrrrmmmmmmmtttttttaaaaaaaffff
+ * right; margin_top; top; margin_left; font_weight
+ *
+ * 5 bbbbbbbbbbbvvvvvvvvvfffffffffwww
+ * background_position; vertical_align; font_size; white_space
+ *
+ * 6 dddddtttttbbbbooooeeeeuuuuaaafff
+ * display; text_decoration; border_bottom_style; border_left_style;
+ * text_align; outline_style; background_repeat; flex_direction
+ *
+ * 7 ppppppaaaaaaddddddttttttiiiiiibb
+ * padding_top; padding_left; padding_right; text_indent; padding_bottom;
+ * background_color
+ *
+ * 8 tttfffoooaaalllpppccciiijjjvvvdd
+ * text_transform; font_family; overflow_y; align_self; align_items; position;
+ * clear; align_content; justify_content; overflow_x; direction
+ *
+ * 9 ttbbaazzffllvvooFFeeccrrnnuuxxii
+ * table_layout; border_right_color; background_attachment; z_index;
+ * font_style; flex_wrap; visibility; border_top_color; float; empty_cells;
+ * caption_side; border_bottom_color; font_variant; unicode_bidi; box_sizing;
+ * list_style_position
+ *
+ * 10 bbooaclqfrpe....................
+ * border_left_color; border_collapse; background_image; color;
+ * list_style_image; quotes; flex_grow; order; opacity; flex_shrink
+ */
+ uint32_t bits[11];
+
+ css_color background_color;
+ lwc_string *background_image;
+ css_fixed background_position_a;
+ css_fixed background_position_b;
+ css_color border_bottom_color;
+ css_fixed border_bottom_width;
+ css_color border_left_color;
+ css_fixed border_left_width;
+ css_color border_right_color;
+ css_fixed border_right_width;
+ css_color border_top_color;
+ css_fixed border_top_width;
+ css_fixed bottom;
+ css_color color;
+ css_fixed flex_basis;
+ css_fixed flex_grow;
+ css_fixed flex_shrink;
+ css_fixed font_size;
+ css_fixed height;
+ css_fixed left;
+ css_fixed line_height;
+ lwc_string *list_style_image;
+ css_fixed margin_bottom;
+ css_fixed margin_left;
+ css_fixed margin_right;
+ css_fixed margin_top;
+ css_fixed max_height;
+ css_fixed max_width;
+ css_fixed min_height;
+ css_fixed min_width;
+ css_fixed opacity;
+ int32_t order;
+ css_fixed padding_bottom;
+ css_fixed padding_left;
+ css_fixed padding_right;
+ css_fixed padding_top;
+ css_fixed right;
+ css_fixed text_indent;
+ css_fixed top;
+ css_fixed vertical_align;
+ css_fixed width;
+ int32_t z_index;
+
+ css_computed_uncommon *uncommon;
+ void *aural;
+};
+
+struct css_computed_style {
+ struct css_computed_style_i i;
+
+ 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
new file mode 100644
index 0000000..202f7de
--- a/dev/null
+++ b/src/select/autogenerated_propget.h
@@ -0,0 +1,2288 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 The NetSurf Project
+ */
+
+
+#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 1
+#define BREAK_AFTER_SHIFT 0
+#define BREAK_AFTER_MASK 0xf
+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 2
+#define BREAK_BEFORE_SHIFT 2
+#define BREAK_BEFORE_MASK 0x3c
+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 28
+#define BREAK_INSIDE_MASK 0xf0000000
+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 2
+#define COLUMN_COUNT_SHIFT 0
+#define COLUMN_COUNT_MASK 0x3
+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 12
+#define COLUMN_FILL_MASK 0x3000
+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 3
+#define COLUMN_RULE_COLOR_SHIFT 18
+#define COLUMN_RULE_COLOR_MASK 0xc0000
+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 3
+#define COLUMN_RULE_STYLE_SHIFT 24
+#define COLUMN_RULE_STYLE_MASK 0xf000000
+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 13
+#define COLUMN_RULE_WIDTH_MASK 0x1fe000
+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 20
+#define COLUMN_SPAN_MASK 0x300000
+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 11
+#define COLUMN_WIDTH_MASK 0x3f800
+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 14
+#define CONTENT_MASK 0xc000
+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 25
+#define LETTER_SPACING_MASK 0xfe000000
+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 16
+#define OUTLINE_COLOR_MASK 0x30000
+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 5
+#define OUTLINE_WIDTH_MASK 0x1fe0
+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 22
+#define WRITING_MODE_MASK 0xc00000
+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 8
+#define ALIGN_CONTENT_MASK 0x700
+static inline uint8_t get_align_content(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_CONTENT_INDEX];
+ bits &= ALIGN_CONTENT_MASK;
+ bits >>= ALIGN_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef ALIGN_CONTENT_INDEX
+#undef ALIGN_CONTENT_SHIFT
+#undef ALIGN_CONTENT_MASK
+
+#define ALIGN_ITEMS_INDEX 8
+#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];
+ bits &= ALIGN_ITEMS_MASK;
+ bits >>= ALIGN_ITEMS_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef ALIGN_ITEMS_INDEX
+#undef ALIGN_ITEMS_SHIFT
+#undef ALIGN_ITEMS_MASK
+
+#define ALIGN_SELF_INDEX 8
+#define ALIGN_SELF_SHIFT 20
+#define ALIGN_SELF_MASK 0x700000
+static inline uint8_t get_align_self(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[ALIGN_SELF_INDEX];
+ bits &= ALIGN_SELF_MASK;
+ bits >>= ALIGN_SELF_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef ALIGN_SELF_INDEX
+#undef ALIGN_SELF_SHIFT
+#undef ALIGN_SELF_MASK
+
+#define BACKGROUND_ATTACHMENT_INDEX 9
+#define BACKGROUND_ATTACHMENT_SHIFT 26
+#define BACKGROUND_ATTACHMENT_MASK 0xc000000
+static inline uint8_t get_background_attachment(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+ bits &= BACKGROUND_ATTACHMENT_MASK;
+ bits >>= BACKGROUND_ATTACHMENT_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef BACKGROUND_ATTACHMENT_INDEX
+#undef BACKGROUND_ATTACHMENT_SHIFT
+#undef BACKGROUND_ATTACHMENT_MASK
+
+#define BACKGROUND_COLOR_INDEX 7
+#define BACKGROUND_COLOR_SHIFT 0
+#define BACKGROUND_COLOR_MASK 0x3
+static inline uint8_t get_background_color(const css_computed_style *style,
+ css_color *color)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_COLOR_INDEX];
+ bits &= BACKGROUND_COLOR_MASK;
+ bits >>= BACKGROUND_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ *color = style->i.background_color;
+
+ return (bits & 0x3);
+}
+#undef BACKGROUND_COLOR_INDEX
+#undef BACKGROUND_COLOR_SHIFT
+#undef BACKGROUND_COLOR_MASK
+
+#define BACKGROUND_IMAGE_INDEX 10
+#define BACKGROUND_IMAGE_SHIFT 27
+#define BACKGROUND_IMAGE_MASK 0x8000000
+static inline uint8_t get_background_image(const css_computed_style *style,
+ lwc_string **string)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_IMAGE_INDEX];
+ bits &= BACKGROUND_IMAGE_MASK;
+ bits >>= BACKGROUND_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ *string = style->i.background_image;
+
+ return (bits & 0x1);
+}
+#undef BACKGROUND_IMAGE_INDEX
+#undef BACKGROUND_IMAGE_SHIFT
+#undef BACKGROUND_IMAGE_MASK
+
+#define BACKGROUND_POSITION_INDEX 5
+#define BACKGROUND_POSITION_SHIFT 21
+#define BACKGROUND_POSITION_MASK 0xffe00000
+static inline uint8_t get_background_position(const css_computed_style *style,
+ css_fixed *length_a, css_unit *unit_a, css_fixed *length_b,
+ css_unit *unit_b)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_POSITION_INDEX];
+ bits &= BACKGROUND_POSITION_MASK;
+ bits >>= BACKGROUND_POSITION_SHIFT;
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ if ((bits & 0x1) == CSS_BACKGROUND_POSITION_SET) {
+ *length_a = style->i.background_position_a;
+ *length_b = style->i.background_position_b;
+ *unit_a = bits >> 6;
+ *unit_b = (bits & 0x3e) >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef BACKGROUND_POSITION_INDEX
+#undef BACKGROUND_POSITION_SHIFT
+#undef BACKGROUND_POSITION_MASK
+
+#define BACKGROUND_REPEAT_INDEX 6
+#define BACKGROUND_REPEAT_SHIFT 3
+#define BACKGROUND_REPEAT_MASK 0x38
+static inline uint8_t get_background_repeat(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BACKGROUND_REPEAT_INDEX];
+ bits &= BACKGROUND_REPEAT_MASK;
+ bits >>= BACKGROUND_REPEAT_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef BACKGROUND_REPEAT_INDEX
+#undef BACKGROUND_REPEAT_SHIFT
+#undef BACKGROUND_REPEAT_MASK
+
+#define BORDER_BOTTOM_COLOR_INDEX 9
+#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)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+ bits &= BORDER_BOTTOM_COLOR_MASK;
+ bits >>= BORDER_BOTTOM_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ *color = style->i.border_bottom_color;
+
+ return (bits & 0x3);
+}
+#undef BORDER_BOTTOM_COLOR_INDEX
+#undef BORDER_BOTTOM_COLOR_SHIFT
+#undef BORDER_BOTTOM_COLOR_MASK
+
+#define BORDER_BOTTOM_STYLE_INDEX 6
+#define BORDER_BOTTOM_STYLE_SHIFT 18
+#define BORDER_BOTTOM_STYLE_MASK 0x3c0000
+static inline uint8_t get_border_bottom_style(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+ bits &= BORDER_BOTTOM_STYLE_MASK;
+ bits >>= BORDER_BOTTOM_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef BORDER_BOTTOM_STYLE_INDEX
+#undef BORDER_BOTTOM_STYLE_SHIFT
+#undef BORDER_BOTTOM_STYLE_MASK
+
+#define BORDER_BOTTOM_WIDTH_INDEX 0
+#define BORDER_BOTTOM_WIDTH_SHIFT 24
+#define BORDER_BOTTOM_WIDTH_MASK 0xff000000
+static inline uint8_t get_border_bottom_width(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+ bits &= BORDER_BOTTOM_WIDTH_MASK;
+ bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->i.border_bottom_width;
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_BOTTOM_WIDTH_INDEX
+#undef BORDER_BOTTOM_WIDTH_SHIFT
+#undef BORDER_BOTTOM_WIDTH_MASK
+
+#define BORDER_COLLAPSE_INDEX 10
+#define BORDER_COLLAPSE_SHIFT 28
+#define BORDER_COLLAPSE_MASK 0x30000000
+static inline uint8_t get_border_collapse(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_COLLAPSE_INDEX];
+ bits &= BORDER_COLLAPSE_MASK;
+ bits >>= BORDER_COLLAPSE_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef BORDER_COLLAPSE_INDEX
+#undef BORDER_COLLAPSE_SHIFT
+#undef BORDER_COLLAPSE_MASK
+
+#define BORDER_LEFT_COLOR_INDEX 10
+#define BORDER_LEFT_COLOR_SHIFT 30
+#define BORDER_LEFT_COLOR_MASK 0xc0000000
+static inline uint8_t get_border_left_color(const css_computed_style *style,
+ css_color *color)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_COLOR_INDEX];
+ bits &= BORDER_LEFT_COLOR_MASK;
+ bits >>= BORDER_LEFT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ *color = style->i.border_left_color;
+
+ return (bits & 0x3);
+}
+#undef BORDER_LEFT_COLOR_INDEX
+#undef BORDER_LEFT_COLOR_SHIFT
+#undef BORDER_LEFT_COLOR_MASK
+
+#define BORDER_LEFT_STYLE_INDEX 6
+#define BORDER_LEFT_STYLE_SHIFT 14
+#define BORDER_LEFT_STYLE_MASK 0x3c000
+static inline uint8_t get_border_left_style(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_STYLE_INDEX];
+ bits &= BORDER_LEFT_STYLE_MASK;
+ bits >>= BORDER_LEFT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef BORDER_LEFT_STYLE_INDEX
+#undef BORDER_LEFT_STYLE_SHIFT
+#undef BORDER_LEFT_STYLE_MASK
+
+#define BORDER_LEFT_WIDTH_INDEX 0
+#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)
+{
+ uint32_t bits = style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+ bits &= BORDER_LEFT_WIDTH_MASK;
+ bits >>= BORDER_LEFT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->i.border_left_width;
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_LEFT_WIDTH_INDEX
+#undef BORDER_LEFT_WIDTH_SHIFT
+#undef BORDER_LEFT_WIDTH_MASK
+
+#define BORDER_RIGHT_COLOR_INDEX 9
+#define BORDER_RIGHT_COLOR_SHIFT 28
+#define BORDER_RIGHT_COLOR_MASK 0x30000000
+static inline uint8_t get_border_right_color(const css_computed_style *style,
+ css_color *color)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+ bits &= BORDER_RIGHT_COLOR_MASK;
+ bits >>= BORDER_RIGHT_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ *color = style->i.border_right_color;
+
+ return (bits & 0x3);
+}
+#undef BORDER_RIGHT_COLOR_INDEX
+#undef BORDER_RIGHT_COLOR_SHIFT
+#undef BORDER_RIGHT_COLOR_MASK
+
+#define BORDER_RIGHT_STYLE_INDEX 2
+#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];
+ bits &= BORDER_RIGHT_STYLE_MASK;
+ bits >>= BORDER_RIGHT_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef BORDER_RIGHT_STYLE_INDEX
+#undef BORDER_RIGHT_STYLE_SHIFT
+#undef BORDER_RIGHT_STYLE_MASK
+
+#define BORDER_RIGHT_WIDTH_INDEX 0
+#define BORDER_RIGHT_WIDTH_SHIFT 0
+#define BORDER_RIGHT_WIDTH_MASK 0xff
+static inline uint8_t get_border_right_width(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+ bits &= BORDER_RIGHT_WIDTH_MASK;
+ bits >>= BORDER_RIGHT_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->i.border_right_width;
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_RIGHT_WIDTH_INDEX
+#undef BORDER_RIGHT_WIDTH_SHIFT
+#undef BORDER_RIGHT_WIDTH_MASK
+
+#define BORDER_TOP_COLOR_INDEX 9
+#define BORDER_TOP_COLOR_SHIFT 16
+#define BORDER_TOP_COLOR_MASK 0x30000
+static inline uint8_t get_border_top_color(const css_computed_style *style,
+ css_color *color)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_COLOR_INDEX];
+ bits &= BORDER_TOP_COLOR_MASK;
+ bits >>= BORDER_TOP_COLOR_SHIFT;
+
+ /* 2bits: tt : type */
+ *color = style->i.border_top_color;
+
+ return (bits & 0x3);
+}
+#undef BORDER_TOP_COLOR_INDEX
+#undef BORDER_TOP_COLOR_SHIFT
+#undef BORDER_TOP_COLOR_MASK
+
+#define BORDER_TOP_STYLE_INDEX 1
+#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];
+ bits &= BORDER_TOP_STYLE_MASK;
+ bits >>= BORDER_TOP_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef BORDER_TOP_STYLE_INDEX
+#undef BORDER_TOP_STYLE_SHIFT
+#undef BORDER_TOP_STYLE_MASK
+
+#define BORDER_TOP_WIDTH_INDEX 0
+#define BORDER_TOP_WIDTH_SHIFT 8
+#define BORDER_TOP_WIDTH_MASK 0xff00
+static inline uint8_t get_border_top_width(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[BORDER_TOP_WIDTH_INDEX];
+ bits &= BORDER_TOP_WIDTH_MASK;
+ bits >>= BORDER_TOP_WIDTH_SHIFT;
+
+ /* 8bits: uuuuuttt : unit | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->i.border_top_width;
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_TOP_WIDTH_INDEX
+#undef BORDER_TOP_WIDTH_SHIFT
+#undef BORDER_TOP_WIDTH_MASK
+
+#define BOTTOM_INDEX 3
+#define BOTTOM_SHIFT 18
+#define BOTTOM_MASK 0x1fc0000
+static inline uint8_t get_bottom(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[BOTTOM_INDEX];
+ bits &= BOTTOM_MASK;
+ bits >>= BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ *length = style->i.bottom;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+static inline uint8_t get_bottom_bits(
+ const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOTTOM_INDEX];
+ bits &= BOTTOM_MASK;
+ bits >>= BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ return bits;
+}
+#undef BOTTOM_INDEX
+#undef BOTTOM_SHIFT
+#undef BOTTOM_MASK
+
+#define BOX_SIZING_INDEX 9
+#define BOX_SIZING_SHIFT 2
+#define BOX_SIZING_MASK 0xc
+static inline uint8_t get_box_sizing(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef BOX_SIZING_INDEX
+#undef BOX_SIZING_SHIFT
+#undef BOX_SIZING_MASK
+
+#define CAPTION_SIDE_INDEX 9
+#define CAPTION_SIDE_SHIFT 10
+#define CAPTION_SIDE_MASK 0xc00
+static inline uint8_t get_caption_side(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CAPTION_SIDE_INDEX];
+ bits &= CAPTION_SIDE_MASK;
+ bits >>= CAPTION_SIDE_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef CAPTION_SIDE_INDEX
+#undef CAPTION_SIDE_SHIFT
+#undef CAPTION_SIDE_MASK
+
+#define CLEAR_INDEX 8
+#define CLEAR_SHIFT 11
+#define CLEAR_MASK 0x3800
+static inline uint8_t get_clear(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[CLEAR_INDEX];
+ bits &= CLEAR_MASK;
+ bits >>= CLEAR_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef CLEAR_INDEX
+#undef CLEAR_SHIFT
+#undef CLEAR_MASK
+
+#define COLOR_INDEX 10
+#define COLOR_SHIFT 26
+#define COLOR_MASK 0x4000000
+static inline uint8_t get_color(const css_computed_style *style, css_color
+ *color)
+{
+ uint32_t bits = style->i.bits[COLOR_INDEX];
+ bits &= COLOR_MASK;
+ bits >>= COLOR_SHIFT;
+
+ /* 1bit: t : type */
+ *color = style->i.color;
+
+ return (bits & 0x1);
+}
+#undef COLOR_INDEX
+#undef COLOR_SHIFT
+#undef COLOR_MASK
+
+#define DIRECTION_INDEX 8
+#define DIRECTION_SHIFT 0
+#define DIRECTION_MASK 0x3
+static inline uint8_t get_direction(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DIRECTION_INDEX];
+ bits &= DIRECTION_MASK;
+ bits >>= DIRECTION_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef DIRECTION_INDEX
+#undef DIRECTION_SHIFT
+#undef DIRECTION_MASK
+
+#define DISPLAY_INDEX 6
+#define DISPLAY_SHIFT 27
+#define DISPLAY_MASK 0xf8000000
+static inline uint8_t get_display(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[DISPLAY_INDEX];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* 5bits: ttttt : type */
+
+ return (bits & 0x1f);
+}
+#undef DISPLAY_INDEX
+#undef DISPLAY_SHIFT
+#undef DISPLAY_MASK
+
+#define EMPTY_CELLS_INDEX 9
+#define EMPTY_CELLS_SHIFT 12
+#define EMPTY_CELLS_MASK 0x3000
+static inline uint8_t get_empty_cells(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[EMPTY_CELLS_INDEX];
+ bits &= EMPTY_CELLS_MASK;
+ bits >>= EMPTY_CELLS_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef EMPTY_CELLS_INDEX
+#undef EMPTY_CELLS_SHIFT
+#undef EMPTY_CELLS_MASK
+
+#define FLEX_BASIS_INDEX 1
+#define FLEX_BASIS_SHIFT 4
+#define FLEX_BASIS_MASK 0x7f0
+static inline uint8_t get_flex_basis(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[FLEX_BASIS_INDEX];
+ bits &= FLEX_BASIS_MASK;
+ bits >>= FLEX_BASIS_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_FLEX_BASIS_SET) {
+ *length = style->i.flex_basis;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef FLEX_BASIS_INDEX
+#undef FLEX_BASIS_SHIFT
+#undef FLEX_BASIS_MASK
+
+#define FLEX_DIRECTION_INDEX 6
+#define FLEX_DIRECTION_SHIFT 0
+#define FLEX_DIRECTION_MASK 0x7
+static inline uint8_t get_flex_direction(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_DIRECTION_INDEX];
+ bits &= FLEX_DIRECTION_MASK;
+ bits >>= FLEX_DIRECTION_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef FLEX_DIRECTION_INDEX
+#undef FLEX_DIRECTION_SHIFT
+#undef FLEX_DIRECTION_MASK
+
+#define FLEX_GROW_INDEX 10
+#define FLEX_GROW_SHIFT 23
+#define FLEX_GROW_MASK 0x800000
+static inline uint8_t get_flex_grow(const css_computed_style *style, css_fixed
+ *fixed)
+{
+ uint32_t bits = style->i.bits[FLEX_GROW_INDEX];
+ bits &= FLEX_GROW_MASK;
+ bits >>= FLEX_GROW_SHIFT;
+
+ /* 1bit: t : type */
+ if ((bits & 0x1) == CSS_FLEX_GROW_SET) {
+ *fixed = style->i.flex_grow;
+ }
+
+ return (bits & 0x1);
+}
+#undef FLEX_GROW_INDEX
+#undef FLEX_GROW_SHIFT
+#undef FLEX_GROW_MASK
+
+#define FLEX_SHRINK_INDEX 10
+#define FLEX_SHRINK_SHIFT 20
+#define FLEX_SHRINK_MASK 0x100000
+static inline uint8_t get_flex_shrink(const css_computed_style *style,
+ css_fixed *fixed)
+{
+ uint32_t bits = style->i.bits[FLEX_SHRINK_INDEX];
+ bits &= FLEX_SHRINK_MASK;
+ bits >>= FLEX_SHRINK_SHIFT;
+
+ /* 1bit: t : type */
+ if ((bits & 0x1) == CSS_FLEX_SHRINK_SET) {
+ *fixed = style->i.flex_shrink;
+ }
+
+ return (bits & 0x1);
+}
+#undef FLEX_SHRINK_INDEX
+#undef FLEX_SHRINK_SHIFT
+#undef FLEX_SHRINK_MASK
+
+#define FLEX_WRAP_INDEX 9
+#define FLEX_WRAP_SHIFT 20
+#define FLEX_WRAP_MASK 0x300000
+static inline uint8_t get_flex_wrap(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLEX_WRAP_INDEX];
+ bits &= FLEX_WRAP_MASK;
+ bits >>= FLEX_WRAP_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef FLEX_WRAP_INDEX
+#undef FLEX_WRAP_SHIFT
+#undef FLEX_WRAP_MASK
+
+#define FLOAT_INDEX 9
+#define FLOAT_SHIFT 14
+#define FLOAT_MASK 0xc000
+static inline uint8_t get_float(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FLOAT_INDEX];
+ bits &= FLOAT_MASK;
+ bits >>= FLOAT_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef FLOAT_INDEX
+#undef FLOAT_SHIFT
+#undef FLOAT_MASK
+
+#define FONT_FAMILY_INDEX 8
+#define FONT_FAMILY_SHIFT 26
+#define FONT_FAMILY_MASK 0x1c000000
+static inline uint8_t get_font_family(const css_computed_style *style,
+ lwc_string ***string_arr)
+{
+ uint32_t bits = style->i.bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: ttt : type */
+ *string_arr = style->font_family;
+
+ return (bits & 0x7);
+}
+#undef FONT_FAMILY_INDEX
+#undef FONT_FAMILY_SHIFT
+#undef FONT_FAMILY_MASK
+
+#define FONT_SIZE_INDEX 5
+#define FONT_SIZE_SHIFT 3
+#define FONT_SIZE_MASK 0xff8
+static inline uint8_t get_font_size(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[FONT_SIZE_INDEX];
+ bits &= FONT_SIZE_MASK;
+ bits >>= FONT_SIZE_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ if ((bits & 0xf) == CSS_FONT_SIZE_DIMENSION) {
+ *length = style->i.font_size;
+ *unit = bits >> 4;
+ }
+
+ return (bits & 0xf);
+}
+#undef FONT_SIZE_INDEX
+#undef FONT_SIZE_SHIFT
+#undef FONT_SIZE_MASK
+
+#define FONT_STYLE_INDEX 9
+#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];
+ bits &= FONT_STYLE_MASK;
+ bits >>= FONT_STYLE_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef FONT_STYLE_INDEX
+#undef FONT_STYLE_SHIFT
+#undef FONT_STYLE_MASK
+
+#define FONT_VARIANT_INDEX 9
+#define FONT_VARIANT_SHIFT 6
+#define FONT_VARIANT_MASK 0xc0
+static inline uint8_t get_font_variant(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_VARIANT_INDEX];
+ bits &= FONT_VARIANT_MASK;
+ bits >>= FONT_VARIANT_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef FONT_VARIANT_INDEX
+#undef FONT_VARIANT_SHIFT
+#undef FONT_VARIANT_MASK
+
+#define FONT_WEIGHT_INDEX 4
+#define FONT_WEIGHT_SHIFT 0
+#define FONT_WEIGHT_MASK 0xf
+static inline uint8_t get_font_weight(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[FONT_WEIGHT_INDEX];
+ bits &= FONT_WEIGHT_MASK;
+ bits >>= FONT_WEIGHT_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef FONT_WEIGHT_INDEX
+#undef FONT_WEIGHT_SHIFT
+#undef FONT_WEIGHT_MASK
+
+#define HEIGHT_INDEX 2
+#define HEIGHT_SHIFT 4
+#define HEIGHT_MASK 0x7f0
+static inline uint8_t get_height(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[HEIGHT_INDEX];
+ bits &= HEIGHT_MASK;
+ bits >>= HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_HEIGHT_SET) {
+ *length = style->i.height;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef HEIGHT_INDEX
+#undef HEIGHT_SHIFT
+#undef HEIGHT_MASK
+
+#define JUSTIFY_CONTENT_INDEX 8
+#define JUSTIFY_CONTENT_SHIFT 5
+#define JUSTIFY_CONTENT_MASK 0xe0
+static inline uint8_t get_justify_content(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX];
+ bits &= JUSTIFY_CONTENT_MASK;
+ bits >>= JUSTIFY_CONTENT_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef JUSTIFY_CONTENT_INDEX
+#undef JUSTIFY_CONTENT_SHIFT
+#undef JUSTIFY_CONTENT_MASK
+
+#define LEFT_INDEX 3
+#define LEFT_SHIFT 25
+#define LEFT_MASK 0xfe000000
+static inline uint8_t get_left(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[LEFT_INDEX];
+ bits &= LEFT_MASK;
+ bits >>= LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ if ((bits & 0x3) == CSS_LEFT_SET) {
+ *length = style->i.left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+static inline uint8_t get_left_bits(
+ const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LEFT_INDEX];
+ bits &= LEFT_MASK;
+ bits >>= LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ return bits;
+}
+#undef LEFT_INDEX
+#undef LEFT_SHIFT
+#undef LEFT_MASK
+
+#define LINE_HEIGHT_INDEX 2
+#define LINE_HEIGHT_SHIFT 11
+#define LINE_HEIGHT_MASK 0x3f800
+static inline uint8_t get_line_height(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[LINE_HEIGHT_INDEX];
+ bits &= LINE_HEIGHT_MASK;
+ bits >>= LINE_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ if ((bits & 0x3) == CSS_LINE_HEIGHT_NUMBER ||
+ (bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) {
+ *length = style->i.line_height;
+ }
+
+ if ((bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) {
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef LINE_HEIGHT_INDEX
+#undef LINE_HEIGHT_SHIFT
+#undef LINE_HEIGHT_MASK
+
+#define LIST_STYLE_IMAGE_INDEX 10
+#define LIST_STYLE_IMAGE_SHIFT 25
+#define LIST_STYLE_IMAGE_MASK 0x2000000
+static inline uint8_t get_list_style_image(const css_computed_style *style,
+ lwc_string **string)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_IMAGE_INDEX];
+ bits &= LIST_STYLE_IMAGE_MASK;
+ bits >>= LIST_STYLE_IMAGE_SHIFT;
+
+ /* 1bit: t : type */
+ *string = style->i.list_style_image;
+
+ return (bits & 0x1);
+}
+#undef LIST_STYLE_IMAGE_INDEX
+#undef LIST_STYLE_IMAGE_SHIFT
+#undef LIST_STYLE_IMAGE_MASK
+
+#define LIST_STYLE_POSITION_INDEX 9
+#define LIST_STYLE_POSITION_SHIFT 0
+#define LIST_STYLE_POSITION_MASK 0x3
+static inline uint8_t get_list_style_position(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef LIST_STYLE_POSITION_INDEX
+#undef LIST_STYLE_POSITION_SHIFT
+#undef LIST_STYLE_POSITION_MASK
+
+#define LIST_STYLE_TYPE_INDEX 3
+#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];
+ bits &= LIST_STYLE_TYPE_MASK;
+ bits >>= LIST_STYLE_TYPE_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef LIST_STYLE_TYPE_INDEX
+#undef LIST_STYLE_TYPE_SHIFT
+#undef LIST_STYLE_TYPE_MASK
+
+#define MARGIN_BOTTOM_INDEX 2
+#define MARGIN_BOTTOM_SHIFT 25
+#define MARGIN_BOTTOM_MASK 0xfe000000
+static inline uint8_t get_margin_bottom(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MARGIN_BOTTOM_INDEX];
+ bits &= MARGIN_BOTTOM_MASK;
+ bits >>= MARGIN_BOTTOM_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->i.margin_bottom;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_BOTTOM_INDEX
+#undef MARGIN_BOTTOM_SHIFT
+#undef MARGIN_BOTTOM_MASK
+
+#define MARGIN_LEFT_INDEX 4
+#define MARGIN_LEFT_SHIFT 4
+#define MARGIN_LEFT_MASK 0x7f0
+static inline uint8_t get_margin_left(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MARGIN_LEFT_INDEX];
+ bits &= MARGIN_LEFT_MASK;
+ bits >>= MARGIN_LEFT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->i.margin_left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_LEFT_INDEX
+#undef MARGIN_LEFT_SHIFT
+#undef MARGIN_LEFT_MASK
+
+#define MARGIN_RIGHT_INDEX 1
+#define MARGIN_RIGHT_SHIFT 25
+#define MARGIN_RIGHT_MASK 0xfe000000
+static inline uint8_t get_margin_right(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MARGIN_RIGHT_INDEX];
+ bits &= MARGIN_RIGHT_MASK;
+ bits >>= MARGIN_RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->i.margin_right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_RIGHT_INDEX
+#undef MARGIN_RIGHT_SHIFT
+#undef MARGIN_RIGHT_MASK
+
+#define MARGIN_TOP_INDEX 4
+#define MARGIN_TOP_SHIFT 18
+#define MARGIN_TOP_MASK 0x1fc0000
+static inline uint8_t get_margin_top(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MARGIN_TOP_INDEX];
+ bits &= MARGIN_TOP_MASK;
+ bits >>= MARGIN_TOP_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->i.margin_top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_TOP_INDEX
+#undef MARGIN_TOP_SHIFT
+#undef MARGIN_TOP_MASK
+
+#define MAX_HEIGHT_INDEX 3
+#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)
+{
+ uint32_t bits = style->i.bits[MAX_HEIGHT_INDEX];
+ bits &= MAX_HEIGHT_MASK;
+ bits >>= MAX_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MAX_HEIGHT_SET) {
+ *length = style->i.max_height;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MAX_HEIGHT_INDEX
+#undef MAX_HEIGHT_SHIFT
+#undef MAX_HEIGHT_MASK
+
+#define MAX_WIDTH_INDEX 1
+#define MAX_WIDTH_SHIFT 18
+#define MAX_WIDTH_MASK 0x1fc0000
+static inline uint8_t get_max_width(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MAX_WIDTH_INDEX];
+ bits &= MAX_WIDTH_MASK;
+ bits >>= MAX_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MAX_WIDTH_SET) {
+ *length = style->i.max_width;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MAX_WIDTH_INDEX
+#undef MAX_WIDTH_SHIFT
+#undef MAX_WIDTH_MASK
+
+#define MIN_HEIGHT_INDEX 3
+#define MIN_HEIGHT_SHIFT 4
+#define MIN_HEIGHT_MASK 0x7f0
+static inline uint8_t get_min_height(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MIN_HEIGHT_INDEX];
+ bits &= MIN_HEIGHT_MASK;
+ bits >>= MIN_HEIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MIN_HEIGHT_SET) {
+ *length = style->i.min_height;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MIN_HEIGHT_INDEX
+#undef MIN_HEIGHT_SHIFT
+#undef MIN_HEIGHT_MASK
+
+#define MIN_WIDTH_INDEX 2
+#define MIN_WIDTH_SHIFT 18
+#define MIN_WIDTH_MASK 0x1fc0000
+static inline uint8_t get_min_width(const css_computed_style *style, css_fixed
+ *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[MIN_WIDTH_INDEX];
+ bits &= MIN_WIDTH_MASK;
+ bits >>= MIN_WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_MIN_WIDTH_SET) {
+ *length = style->i.min_width;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MIN_WIDTH_INDEX
+#undef MIN_WIDTH_SHIFT
+#undef MIN_WIDTH_MASK
+
+#define OPACITY_INDEX 10
+#define OPACITY_SHIFT 21
+#define OPACITY_MASK 0x200000
+static inline uint8_t get_opacity(const css_computed_style *style, css_fixed
+ *fixed)
+{
+ uint32_t bits = style->i.bits[OPACITY_INDEX];
+ bits &= OPACITY_MASK;
+ bits >>= OPACITY_SHIFT;
+
+ /* 1bit: t : type */
+ if ((bits & 0x1) == CSS_OPACITY_SET) {
+ *fixed = style->i.opacity;
+ }
+
+ return (bits & 0x1);
+}
+#undef OPACITY_INDEX
+#undef OPACITY_SHIFT
+#undef OPACITY_MASK
+
+#define ORDER_INDEX 10
+#define ORDER_SHIFT 22
+#define ORDER_MASK 0x400000
+static inline uint8_t get_order(const css_computed_style *style, int32_t
+ *integer)
+{
+ uint32_t bits = style->i.bits[ORDER_INDEX];
+ bits &= ORDER_MASK;
+ bits >>= ORDER_SHIFT;
+
+ /* 1bit: t : type */
+ if ((bits & 0x1) == CSS_ORDER_SET) {
+ *integer = style->i.order;
+ }
+
+ return (bits & 0x1);
+}
+#undef ORDER_INDEX
+#undef ORDER_SHIFT
+#undef ORDER_MASK
+
+#define OUTLINE_STYLE_INDEX 6
+#define OUTLINE_STYLE_SHIFT 6
+#define OUTLINE_STYLE_MASK 0x3c0
+static inline uint8_t get_outline_style(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OUTLINE_STYLE_INDEX];
+ bits &= OUTLINE_STYLE_MASK;
+ bits >>= OUTLINE_STYLE_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef OUTLINE_STYLE_INDEX
+#undef OUTLINE_STYLE_SHIFT
+#undef OUTLINE_STYLE_MASK
+
+#define OVERFLOW_X_INDEX 8
+#define OVERFLOW_X_SHIFT 2
+#define OVERFLOW_X_MASK 0x1c
+static inline uint8_t get_overflow_x(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_X_INDEX];
+ bits &= OVERFLOW_X_MASK;
+ bits >>= OVERFLOW_X_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef OVERFLOW_X_INDEX
+#undef OVERFLOW_X_SHIFT
+#undef OVERFLOW_X_MASK
+
+#define OVERFLOW_Y_INDEX 8
+#define OVERFLOW_Y_SHIFT 23
+#define OVERFLOW_Y_MASK 0x3800000
+static inline uint8_t get_overflow_y(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[OVERFLOW_Y_INDEX];
+ bits &= OVERFLOW_Y_MASK;
+ bits >>= OVERFLOW_Y_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef OVERFLOW_Y_INDEX
+#undef OVERFLOW_Y_SHIFT
+#undef OVERFLOW_Y_MASK
+
+#define PADDING_BOTTOM_INDEX 7
+#define PADDING_BOTTOM_SHIFT 2
+#define PADDING_BOTTOM_MASK 0xfc
+static inline uint8_t get_padding_bottom(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[PADDING_BOTTOM_INDEX];
+ bits &= PADDING_BOTTOM_MASK;
+ bits >>= PADDING_BOTTOM_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->i.padding_bottom;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_BOTTOM_INDEX
+#undef PADDING_BOTTOM_SHIFT
+#undef PADDING_BOTTOM_MASK
+
+#define PADDING_LEFT_INDEX 7
+#define PADDING_LEFT_SHIFT 20
+#define PADDING_LEFT_MASK 0x3f00000
+static inline uint8_t get_padding_left(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[PADDING_LEFT_INDEX];
+ bits &= PADDING_LEFT_MASK;
+ bits >>= PADDING_LEFT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->i.padding_left;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_LEFT_INDEX
+#undef PADDING_LEFT_SHIFT
+#undef PADDING_LEFT_MASK
+
+#define PADDING_RIGHT_INDEX 7
+#define PADDING_RIGHT_SHIFT 14
+#define PADDING_RIGHT_MASK 0xfc000
+static inline uint8_t get_padding_right(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[PADDING_RIGHT_INDEX];
+ bits &= PADDING_RIGHT_MASK;
+ bits >>= PADDING_RIGHT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->i.padding_right;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_RIGHT_INDEX
+#undef PADDING_RIGHT_SHIFT
+#undef PADDING_RIGHT_MASK
+
+#define PADDING_TOP_INDEX 7
+#define PADDING_TOP_SHIFT 26
+#define PADDING_TOP_MASK 0xfc000000
+static inline uint8_t get_padding_top(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[PADDING_TOP_INDEX];
+ bits &= PADDING_TOP_MASK;
+ bits >>= PADDING_TOP_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->i.padding_top;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_TOP_INDEX
+#undef PADDING_TOP_SHIFT
+#undef PADDING_TOP_MASK
+
+#define POSITION_INDEX 8
+#define POSITION_SHIFT 14
+#define POSITION_MASK 0x1c000
+static inline uint8_t get_position(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[POSITION_INDEX];
+ bits &= POSITION_MASK;
+ bits >>= POSITION_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef POSITION_INDEX
+#undef POSITION_SHIFT
+#undef POSITION_MASK
+
+#define QUOTES_INDEX 10
+#define QUOTES_SHIFT 24
+#define QUOTES_MASK 0x1000000
+static inline uint8_t get_quotes(const css_computed_style *style, lwc_string
+ ***string_arr)
+{
+ uint32_t bits = style->i.bits[QUOTES_INDEX];
+ bits &= QUOTES_MASK;
+ bits >>= QUOTES_SHIFT;
+
+ /* 1bit: t : type */
+ *string_arr = style->quotes;
+
+ return (bits & 0x1);
+}
+#undef QUOTES_INDEX
+#undef QUOTES_SHIFT
+#undef QUOTES_MASK
+
+#define RIGHT_INDEX 4
+#define RIGHT_SHIFT 25
+#define RIGHT_MASK 0xfe000000
+static inline uint8_t get_right(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[RIGHT_INDEX];
+ bits &= RIGHT_MASK;
+ bits >>= RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ *length = style->i.right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+static inline uint8_t get_right_bits(
+ const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[RIGHT_INDEX];
+ bits &= RIGHT_MASK;
+ bits >>= RIGHT_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ return bits;
+}
+#undef RIGHT_INDEX
+#undef RIGHT_SHIFT
+#undef RIGHT_MASK
+
+#define TABLE_LAYOUT_INDEX 9
+#define TABLE_LAYOUT_SHIFT 30
+#define TABLE_LAYOUT_MASK 0xc0000000
+static inline uint8_t get_table_layout(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TABLE_LAYOUT_INDEX];
+ bits &= TABLE_LAYOUT_MASK;
+ bits >>= TABLE_LAYOUT_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef TABLE_LAYOUT_INDEX
+#undef TABLE_LAYOUT_SHIFT
+#undef TABLE_LAYOUT_MASK
+
+#define TEXT_ALIGN_INDEX 6
+#define TEXT_ALIGN_SHIFT 10
+#define TEXT_ALIGN_MASK 0x3c00
+static inline uint8_t get_text_align(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_ALIGN_INDEX];
+ bits &= TEXT_ALIGN_MASK;
+ bits >>= TEXT_ALIGN_SHIFT;
+
+ /* 4bits: tttt : type */
+
+ return (bits & 0xf);
+}
+#undef TEXT_ALIGN_INDEX
+#undef TEXT_ALIGN_SHIFT
+#undef TEXT_ALIGN_MASK
+
+#define TEXT_DECORATION_INDEX 6
+#define TEXT_DECORATION_SHIFT 22
+#define TEXT_DECORATION_MASK 0x7c00000
+static inline uint8_t get_text_decoration(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_DECORATION_INDEX];
+ bits &= TEXT_DECORATION_MASK;
+ bits >>= TEXT_DECORATION_SHIFT;
+
+ /* 5bits: ttttt : type */
+
+ return (bits & 0x1f);
+}
+#undef TEXT_DECORATION_INDEX
+#undef TEXT_DECORATION_SHIFT
+#undef TEXT_DECORATION_MASK
+
+#define TEXT_INDENT_INDEX 7
+#define TEXT_INDENT_SHIFT 8
+#define TEXT_INDENT_MASK 0x3f00
+static inline uint8_t get_text_indent(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[TEXT_INDENT_INDEX];
+ bits &= TEXT_INDENT_MASK;
+ bits >>= TEXT_INDENT_SHIFT;
+
+ /* 6bits: uuuuut : unit | type */
+ if ((bits & 0x1) == CSS_TEXT_INDENT_SET) {
+ *length = style->i.text_indent;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef TEXT_INDENT_INDEX
+#undef TEXT_INDENT_SHIFT
+#undef TEXT_INDENT_MASK
+
+#define TEXT_TRANSFORM_INDEX 8
+#define TEXT_TRANSFORM_SHIFT 29
+#define TEXT_TRANSFORM_MASK 0xe0000000
+static inline uint8_t get_text_transform(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TEXT_TRANSFORM_INDEX];
+ bits &= TEXT_TRANSFORM_MASK;
+ bits >>= TEXT_TRANSFORM_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef TEXT_TRANSFORM_INDEX
+#undef TEXT_TRANSFORM_SHIFT
+#undef TEXT_TRANSFORM_MASK
+
+#define TOP_INDEX 4
+#define TOP_SHIFT 11
+#define TOP_MASK 0x3f800
+static inline uint8_t get_top(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[TOP_INDEX];
+ bits &= TOP_MASK;
+ bits >>= TOP_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ *length = style->i.top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+static inline uint8_t get_top_bits(
+ const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[TOP_INDEX];
+ bits &= TOP_MASK;
+ bits >>= TOP_SHIFT;
+
+ /* 7bits: uuuuutt : units | type */
+ return bits;
+}
+#undef TOP_INDEX
+#undef TOP_SHIFT
+#undef TOP_MASK
+
+#define UNICODE_BIDI_INDEX 9
+#define UNICODE_BIDI_SHIFT 4
+#define UNICODE_BIDI_MASK 0x30
+static inline uint8_t get_unicode_bidi(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[UNICODE_BIDI_INDEX];
+ bits &= UNICODE_BIDI_MASK;
+ bits >>= UNICODE_BIDI_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef UNICODE_BIDI_INDEX
+#undef UNICODE_BIDI_SHIFT
+#undef UNICODE_BIDI_MASK
+
+#define VERTICAL_ALIGN_INDEX 5
+#define VERTICAL_ALIGN_SHIFT 12
+#define VERTICAL_ALIGN_MASK 0x1ff000
+static inline uint8_t get_vertical_align(const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint32_t bits = style->i.bits[VERTICAL_ALIGN_INDEX];
+ bits &= VERTICAL_ALIGN_MASK;
+ bits >>= VERTICAL_ALIGN_SHIFT;
+
+ /* 9bits: uuuuutttt : unit | type */
+ if ((bits & 0xf) == CSS_VERTICAL_ALIGN_SET) {
+ *length = style->i.vertical_align;
+ *unit = bits >> 4;
+ }
+
+ return (bits & 0xf);
+}
+#undef VERTICAL_ALIGN_INDEX
+#undef VERTICAL_ALIGN_SHIFT
+#undef VERTICAL_ALIGN_MASK
+
+#define VISIBILITY_INDEX 9
+#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];
+ bits &= VISIBILITY_MASK;
+ bits >>= VISIBILITY_SHIFT;
+
+ /* 2bits: tt : type */
+
+ return (bits & 0x3);
+}
+#undef VISIBILITY_INDEX
+#undef VISIBILITY_SHIFT
+#undef VISIBILITY_MASK
+
+#define WHITE_SPACE_INDEX 5
+#define WHITE_SPACE_SHIFT 0
+#define WHITE_SPACE_MASK 0x7
+static inline uint8_t get_white_space(const css_computed_style *style)
+{
+ uint32_t bits = style->i.bits[WHITE_SPACE_INDEX];
+ bits &= WHITE_SPACE_MASK;
+ bits >>= WHITE_SPACE_SHIFT;
+
+ /* 3bits: ttt : type */
+
+ return (bits & 0x7);
+}
+#undef WHITE_SPACE_INDEX
+#undef WHITE_SPACE_SHIFT
+#undef WHITE_SPACE_MASK
+
+#define WIDTH_INDEX 1
+#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)
+{
+ uint32_t bits = style->i.bits[WIDTH_INDEX];
+ bits &= WIDTH_MASK;
+ bits >>= WIDTH_SHIFT;
+
+ /* 7bits: uuuuutt : unit | type */
+ if ((bits & 0x3) == CSS_WIDTH_SET) {
+ *length = style->i.width;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef WIDTH_INDEX
+#undef WIDTH_SHIFT
+#undef WIDTH_MASK
+
+#define Z_INDEX_INDEX 9
+#define Z_INDEX_SHIFT 24
+#define Z_INDEX_MASK 0x3000000
+static inline uint8_t get_z_index(const css_computed_style *style, int32_t
+ *integer)
+{
+ uint32_t bits = style->i.bits[Z_INDEX_INDEX];
+ bits &= Z_INDEX_MASK;
+ bits >>= Z_INDEX_SHIFT;
+
+ /* 2bits: tt : type */
+ *integer = style->i.z_index;
+
+ return (bits & 0x3);
+}
+#undef Z_INDEX_INDEX
+#undef Z_INDEX_SHIFT
+#undef Z_INDEX_MASK
diff --git a/src/select/autogenerated_propset.h b/src/select/autogenerated_propset.h
new file mode 100644
index 0000000..41acaa8
--- a/dev/null
+++ b/src/select/autogenerated_propset.h
@@ -0,0 +1,2631 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 The NetSurf Project
+ */
+
+/** 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_COLUMN_RULE_WIDTH_MEDIUM << 13) | (
+ CSS_OUTLINE_WIDTH_MEDIUM << 5) |
+ CSS_CURSOR_AUTO,
+ (CSS_LETTER_SPACING_NORMAL << 25) | (
+ CSS_COLUMN_GAP_NORMAL << 18) | (
+ CSS_COLUMN_WIDTH_AUTO << 11) | (
+ CSS_WORD_SPACING_NORMAL << 4) |
+ CSS_BREAK_AFTER_AUTO,
+ (CSS_CLIP_AUTO << 6) | (CSS_BREAK_BEFORE_AUTO << 2) |
+ CSS_COLUMN_COUNT_AUTO,
+ (CSS_BREAK_INSIDE_AUTO << 28) | (
+ CSS_COLUMN_RULE_STYLE_NONE << 24) | (
+ CSS_WRITING_MODE_HORIZONTAL_TB << 22) |
+ (CSS_COLUMN_SPAN_NONE << 20) | (
+ CSS_COLUMN_RULE_COLOR_CURRENT_COLOR <<
+ 18) | (CSS_OUTLINE_COLOR_INVERT << 16)
+ | (CSS_CONTENT_NORMAL << 14) | (
+ CSS_COLUMN_FILL_BALANCE << 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) | (((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 1
+#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;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->i.uncommon->i.bits[BREAK_AFTER_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~BREAK_AFTER_MASK) | ((type & 0xf) <<
+ BREAK_AFTER_SHIFT);
+
+ return CSS_OK;
+}
+#undef BREAK_AFTER_INDEX
+#undef BREAK_AFTER_SHIFT
+#undef BREAK_AFTER_MASK
+
+#define BREAK_BEFORE_INDEX 2
+#define BREAK_BEFORE_SHIFT 2
+#define BREAK_BEFORE_MASK 0x3c
+
+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) | ((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 28
+#define BREAK_INSIDE_MASK 0xf0000000
+
+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) | ((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 2
+#define COLUMN_COUNT_SHIFT 0
+#define COLUMN_COUNT_MASK 0x3
+
+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) | ((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 12
+#define COLUMN_FILL_MASK 0x3000
+
+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) | ((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) | (((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 3
+#define COLUMN_RULE_COLOR_SHIFT 18
+#define COLUMN_RULE_COLOR_MASK 0xc0000
+
+static inline css_error set_column_rule_color(css_computed_style *style,
+ uint8_t type, css_color color)
+{
+ uint32_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->i.uncommon->i.bits[COLUMN_RULE_COLOR_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~COLUMN_RULE_COLOR_MASK) | ((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 3
+#define COLUMN_RULE_STYLE_SHIFT 24
+#define COLUMN_RULE_STYLE_MASK 0xf000000
+
+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) | ((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 13
+#define COLUMN_RULE_WIDTH_MASK 0x1fe000
+
+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) | (((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 20
+#define COLUMN_SPAN_MASK 0x300000
+
+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) | ((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 11
+#define COLUMN_WIDTH_MASK 0x3f800
+
+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) | (((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 14
+#define CONTENT_MASK 0xc000
+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) | ((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) | ((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) | ((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 25
+#define LETTER_SPACING_MASK 0xfe000000
+
+static inline css_error set_letter_spacing(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ ENSURE_UNCOMMON;
+
+ bits = &style->i.uncommon->i.bits[LETTER_SPACING_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~LETTER_SPACING_MASK) | (((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 16
+#define OUTLINE_COLOR_MASK 0x30000
+
+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) | ((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 5
+#define OUTLINE_WIDTH_MASK 0x1fe0
+
+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) | (((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) | (((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 22
+#define WRITING_MODE_MASK 0xc00000
+
+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) | ((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) | ((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) | ((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) | ((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) | ((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) | ((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 8
+#define ALIGN_CONTENT_MASK 0x700
+
+static inline css_error set_align_content(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[ALIGN_CONTENT_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~ALIGN_CONTENT_MASK) | ((type & 0x7) <<
+ ALIGN_CONTENT_SHIFT);
+
+ return CSS_OK;
+}
+#undef ALIGN_CONTENT_INDEX
+#undef ALIGN_CONTENT_SHIFT
+#undef ALIGN_CONTENT_MASK
+
+#define ALIGN_ITEMS_INDEX 8
+#define ALIGN_ITEMS_SHIFT 17
+#define ALIGN_ITEMS_MASK 0xe0000
+
+static inline css_error set_align_items(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[ALIGN_ITEMS_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~ALIGN_ITEMS_MASK) | ((type & 0x7) <<
+ ALIGN_ITEMS_SHIFT);
+
+ return CSS_OK;
+}
+#undef ALIGN_ITEMS_INDEX
+#undef ALIGN_ITEMS_SHIFT
+#undef ALIGN_ITEMS_MASK
+
+#define ALIGN_SELF_INDEX 8
+#define ALIGN_SELF_SHIFT 20
+#define ALIGN_SELF_MASK 0x700000
+
+static inline css_error set_align_self(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[ALIGN_SELF_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~ALIGN_SELF_MASK) | ((type & 0x7) << ALIGN_SELF_SHIFT);
+
+ return CSS_OK;
+}
+#undef ALIGN_SELF_INDEX
+#undef ALIGN_SELF_SHIFT
+#undef ALIGN_SELF_MASK
+
+#define BACKGROUND_ATTACHMENT_INDEX 9
+#define BACKGROUND_ATTACHMENT_SHIFT 26
+#define BACKGROUND_ATTACHMENT_MASK 0xc000000
+
+static inline css_error set_background_attachment(css_computed_style *style,
+ uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BACKGROUND_ATTACHMENT_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BACKGROUND_ATTACHMENT_MASK) | ((type & 0x3) <<
+ BACKGROUND_ATTACHMENT_SHIFT);
+
+ return CSS_OK;
+}
+#undef BACKGROUND_ATTACHMENT_INDEX
+#undef BACKGROUND_ATTACHMENT_SHIFT
+#undef BACKGROUND_ATTACHMENT_MASK
+
+#define BACKGROUND_COLOR_INDEX 7
+#define BACKGROUND_COLOR_SHIFT 0
+#define BACKGROUND_COLOR_MASK 0x3
+
+static inline css_error set_background_color(css_computed_style *style, uint8_t
+ type, css_color color)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BACKGROUND_COLOR_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BACKGROUND_COLOR_MASK) | ((type & 0x3) <<
+ BACKGROUND_COLOR_SHIFT);
+
+ style->i.background_color = color;
+
+ return CSS_OK;
+}
+#undef BACKGROUND_COLOR_INDEX
+#undef BACKGROUND_COLOR_SHIFT
+#undef BACKGROUND_COLOR_MASK
+
+#define BACKGROUND_IMAGE_INDEX 10
+#define BACKGROUND_IMAGE_SHIFT 27
+#define BACKGROUND_IMAGE_MASK 0x8000000
+
+static inline css_error set_background_image(css_computed_style *style, uint8_t
+ type, lwc_string *string)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BACKGROUND_IMAGE_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~BACKGROUND_IMAGE_MASK) | ((type & 0x1) <<
+ BACKGROUND_IMAGE_SHIFT);
+
+ lwc_string *old_string = style->i.background_image;
+
+ if (string != NULL) {
+ style->i.background_image = lwc_string_ref(string);
+ } else {
+ style->i.background_image = NULL;
+ }
+
+ if (old_string != NULL)
+ lwc_string_unref(old_string);
+
+ return CSS_OK;
+}
+#undef BACKGROUND_IMAGE_INDEX
+#undef BACKGROUND_IMAGE_SHIFT
+#undef BACKGROUND_IMAGE_MASK
+
+#define BACKGROUND_POSITION_INDEX 5
+#define BACKGROUND_POSITION_SHIFT 21
+#define BACKGROUND_POSITION_MASK 0xffe00000
+
+static inline css_error set_background_position(css_computed_style *style,
+ uint8_t type, css_fixed length_a, css_unit unit_a, css_fixed
+ length_b, css_unit unit_b)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BACKGROUND_POSITION_INDEX];
+
+ /* 11bits: aaaaabbbbbt : unit_a | unit_b | type */
+ *bits = (*bits & ~BACKGROUND_POSITION_MASK) | (((type & 0x1) | (unit_b
+ << 1) | (unit_a << 6)) << BACKGROUND_POSITION_SHIFT);
+
+ style->i.background_position_a = length_a;
+
+ style->i.background_position_b = length_b;
+
+ return CSS_OK;
+}
+#undef BACKGROUND_POSITION_INDEX
+#undef BACKGROUND_POSITION_SHIFT
+#undef BACKGROUND_POSITION_MASK
+
+#define BACKGROUND_REPEAT_INDEX 6
+#define BACKGROUND_REPEAT_SHIFT 3
+#define BACKGROUND_REPEAT_MASK 0x38
+
+static inline css_error set_background_repeat(css_computed_style *style,
+ uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BACKGROUND_REPEAT_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~BACKGROUND_REPEAT_MASK) | ((type & 0x7) <<
+ BACKGROUND_REPEAT_SHIFT);
+
+ return CSS_OK;
+}
+#undef BACKGROUND_REPEAT_INDEX
+#undef BACKGROUND_REPEAT_SHIFT
+#undef BACKGROUND_REPEAT_MASK
+
+#define BORDER_BOTTOM_COLOR_INDEX 9
+#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)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_BOTTOM_COLOR_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BORDER_BOTTOM_COLOR_MASK) | ((type & 0x3) <<
+ BORDER_BOTTOM_COLOR_SHIFT);
+
+ style->i.border_bottom_color = color;
+
+ return CSS_OK;
+}
+#undef BORDER_BOTTOM_COLOR_INDEX
+#undef BORDER_BOTTOM_COLOR_SHIFT
+#undef BORDER_BOTTOM_COLOR_MASK
+
+#define BORDER_BOTTOM_STYLE_INDEX 6
+#define BORDER_BOTTOM_STYLE_SHIFT 18
+#define BORDER_BOTTOM_STYLE_MASK 0x3c0000
+
+static inline css_error set_border_bottom_style(css_computed_style *style,
+ uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_BOTTOM_STYLE_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~BORDER_BOTTOM_STYLE_MASK) | ((type & 0xf) <<
+ BORDER_BOTTOM_STYLE_SHIFT);
+
+ return CSS_OK;
+}
+#undef BORDER_BOTTOM_STYLE_INDEX
+#undef BORDER_BOTTOM_STYLE_SHIFT
+#undef BORDER_BOTTOM_STYLE_MASK
+
+#define BORDER_BOTTOM_WIDTH_INDEX 0
+#define BORDER_BOTTOM_WIDTH_SHIFT 24
+#define BORDER_BOTTOM_WIDTH_MASK 0xff000000
+
+static inline css_error set_border_bottom_width(css_computed_style *style,
+ uint8_t type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_BOTTOM_WIDTH_INDEX];
+
+ /* 8bits: uuuuuttt : unit | type */
+ *bits = (*bits & ~BORDER_BOTTOM_WIDTH_MASK) | (((type & 0x7) | (unit <<
+ 3)) << BORDER_BOTTOM_WIDTH_SHIFT);
+
+ style->i.border_bottom_width = length;
+
+ return CSS_OK;
+}
+#undef BORDER_BOTTOM_WIDTH_INDEX
+#undef BORDER_BOTTOM_WIDTH_SHIFT
+#undef BORDER_BOTTOM_WIDTH_MASK
+
+#define BORDER_COLLAPSE_INDEX 10
+#define BORDER_COLLAPSE_SHIFT 28
+#define BORDER_COLLAPSE_MASK 0x30000000
+
+static inline css_error set_border_collapse(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_COLLAPSE_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BORDER_COLLAPSE_MASK) | ((type & 0x3) <<
+ BORDER_COLLAPSE_SHIFT);
+
+ return CSS_OK;
+}
+#undef BORDER_COLLAPSE_INDEX
+#undef BORDER_COLLAPSE_SHIFT
+#undef BORDER_COLLAPSE_MASK
+
+#define BORDER_LEFT_COLOR_INDEX 10
+#define BORDER_LEFT_COLOR_SHIFT 30
+#define BORDER_LEFT_COLOR_MASK 0xc0000000
+
+static inline css_error set_border_left_color(css_computed_style *style,
+ uint8_t type, css_color color)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_LEFT_COLOR_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BORDER_LEFT_COLOR_MASK) | ((type & 0x3) <<
+ BORDER_LEFT_COLOR_SHIFT);
+
+ style->i.border_left_color = color;
+
+ return CSS_OK;
+}
+#undef BORDER_LEFT_COLOR_INDEX
+#undef BORDER_LEFT_COLOR_SHIFT
+#undef BORDER_LEFT_COLOR_MASK
+
+#define BORDER_LEFT_STYLE_INDEX 6
+#define BORDER_LEFT_STYLE_SHIFT 14
+#define BORDER_LEFT_STYLE_MASK 0x3c000
+
+static inline css_error set_border_left_style(css_computed_style *style,
+ uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_LEFT_STYLE_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~BORDER_LEFT_STYLE_MASK) | ((type & 0xf) <<
+ BORDER_LEFT_STYLE_SHIFT);
+
+ return CSS_OK;
+}
+#undef BORDER_LEFT_STYLE_INDEX
+#undef BORDER_LEFT_STYLE_SHIFT
+#undef BORDER_LEFT_STYLE_MASK
+
+#define BORDER_LEFT_WIDTH_INDEX 0
+#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)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_LEFT_WIDTH_INDEX];
+
+ /* 8bits: uuuuuttt : unit | type */
+ *bits = (*bits & ~BORDER_LEFT_WIDTH_MASK) | (((type & 0x7) | (unit <<
+ 3)) << BORDER_LEFT_WIDTH_SHIFT);
+
+ style->i.border_left_width = length;
+
+ return CSS_OK;
+}
+#undef BORDER_LEFT_WIDTH_INDEX
+#undef BORDER_LEFT_WIDTH_SHIFT
+#undef BORDER_LEFT_WIDTH_MASK
+
+#define BORDER_RIGHT_COLOR_INDEX 9
+#define BORDER_RIGHT_COLOR_SHIFT 28
+#define BORDER_RIGHT_COLOR_MASK 0x30000000
+
+static inline css_error set_border_right_color(css_computed_style *style,
+ uint8_t type, css_color color)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_RIGHT_COLOR_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BORDER_RIGHT_COLOR_MASK) | ((type & 0x3) <<
+ BORDER_RIGHT_COLOR_SHIFT);
+
+ style->i.border_right_color = color;
+
+ return CSS_OK;
+}
+#undef BORDER_RIGHT_COLOR_INDEX
+#undef BORDER_RIGHT_COLOR_SHIFT
+#undef BORDER_RIGHT_COLOR_MASK
+
+#define BORDER_RIGHT_STYLE_INDEX 2
+#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)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_RIGHT_STYLE_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~BORDER_RIGHT_STYLE_MASK) | ((type & 0xf) <<
+ BORDER_RIGHT_STYLE_SHIFT);
+
+ return CSS_OK;
+}
+#undef BORDER_RIGHT_STYLE_INDEX
+#undef BORDER_RIGHT_STYLE_SHIFT
+#undef BORDER_RIGHT_STYLE_MASK
+
+#define BORDER_RIGHT_WIDTH_INDEX 0
+#define BORDER_RIGHT_WIDTH_SHIFT 0
+#define BORDER_RIGHT_WIDTH_MASK 0xff
+
+static inline css_error set_border_right_width(css_computed_style *style,
+ uint8_t type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_RIGHT_WIDTH_INDEX];
+
+ /* 8bits: uuuuuttt : unit | type */
+ *bits = (*bits & ~BORDER_RIGHT_WIDTH_MASK) | (((type & 0x7) | (unit <<
+ 3)) << BORDER_RIGHT_WIDTH_SHIFT);
+
+ style->i.border_right_width = length;
+
+ return CSS_OK;
+}
+#undef BORDER_RIGHT_WIDTH_INDEX
+#undef BORDER_RIGHT_WIDTH_SHIFT
+#undef BORDER_RIGHT_WIDTH_MASK
+
+#define BORDER_TOP_COLOR_INDEX 9
+#define BORDER_TOP_COLOR_SHIFT 16
+#define BORDER_TOP_COLOR_MASK 0x30000
+
+static inline css_error set_border_top_color(css_computed_style *style, uint8_t
+ type, css_color color)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_TOP_COLOR_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BORDER_TOP_COLOR_MASK) | ((type & 0x3) <<
+ BORDER_TOP_COLOR_SHIFT);
+
+ style->i.border_top_color = color;
+
+ return CSS_OK;
+}
+#undef BORDER_TOP_COLOR_INDEX
+#undef BORDER_TOP_COLOR_SHIFT
+#undef BORDER_TOP_COLOR_MASK
+
+#define BORDER_TOP_STYLE_INDEX 1
+#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)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_TOP_STYLE_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~BORDER_TOP_STYLE_MASK) | ((type & 0xf) <<
+ BORDER_TOP_STYLE_SHIFT);
+
+ return CSS_OK;
+}
+#undef BORDER_TOP_STYLE_INDEX
+#undef BORDER_TOP_STYLE_SHIFT
+#undef BORDER_TOP_STYLE_MASK
+
+#define BORDER_TOP_WIDTH_INDEX 0
+#define BORDER_TOP_WIDTH_SHIFT 8
+#define BORDER_TOP_WIDTH_MASK 0xff00
+
+static inline css_error set_border_top_width(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BORDER_TOP_WIDTH_INDEX];
+
+ /* 8bits: uuuuuttt : unit | type */
+ *bits = (*bits & ~BORDER_TOP_WIDTH_MASK) | (((type & 0x7) | (unit <<
+ 3)) << BORDER_TOP_WIDTH_SHIFT);
+
+ style->i.border_top_width = length;
+
+ return CSS_OK;
+}
+#undef BORDER_TOP_WIDTH_INDEX
+#undef BORDER_TOP_WIDTH_SHIFT
+#undef BORDER_TOP_WIDTH_MASK
+
+#define BOTTOM_INDEX 3
+#define BOTTOM_SHIFT 18
+#define BOTTOM_MASK 0x1fc0000
+
+static inline css_error set_bottom(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BOTTOM_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~BOTTOM_MASK) | (((type & 0x3) | (unit << 2)) <<
+ BOTTOM_SHIFT);
+
+ style->i.bottom = length;
+
+ return CSS_OK;
+}
+#undef BOTTOM_INDEX
+#undef BOTTOM_SHIFT
+#undef BOTTOM_MASK
+
+#define BOX_SIZING_INDEX 9
+#define BOX_SIZING_SHIFT 2
+#define BOX_SIZING_MASK 0xc
+
+static inline css_error set_box_sizing(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[BOX_SIZING_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~BOX_SIZING_MASK) | ((type & 0x3) << BOX_SIZING_SHIFT);
+
+ return CSS_OK;
+}
+#undef BOX_SIZING_INDEX
+#undef BOX_SIZING_SHIFT
+#undef BOX_SIZING_MASK
+
+#define CAPTION_SIDE_INDEX 9
+#define CAPTION_SIDE_SHIFT 10
+#define CAPTION_SIDE_MASK 0xc00
+
+static inline css_error set_caption_side(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[CAPTION_SIDE_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~CAPTION_SIDE_MASK) | ((type & 0x3) <<
+ CAPTION_SIDE_SHIFT);
+
+ return CSS_OK;
+}
+#undef CAPTION_SIDE_INDEX
+#undef CAPTION_SIDE_SHIFT
+#undef CAPTION_SIDE_MASK
+
+#define CLEAR_INDEX 8
+#define CLEAR_SHIFT 11
+#define CLEAR_MASK 0x3800
+
+static inline css_error set_clear(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[CLEAR_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~CLEAR_MASK) | ((type & 0x7) << CLEAR_SHIFT);
+
+ return CSS_OK;
+}
+#undef CLEAR_INDEX
+#undef CLEAR_SHIFT
+#undef CLEAR_MASK
+
+#define COLOR_INDEX 10
+#define COLOR_SHIFT 26
+#define COLOR_MASK 0x4000000
+
+static inline css_error set_color(css_computed_style *style, uint8_t type,
+ css_color color)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[COLOR_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~COLOR_MASK) | ((type & 0x1) << COLOR_SHIFT);
+
+ style->i.color = color;
+
+ return CSS_OK;
+}
+#undef COLOR_INDEX
+#undef COLOR_SHIFT
+#undef COLOR_MASK
+
+#define DIRECTION_INDEX 8
+#define DIRECTION_SHIFT 0
+#define DIRECTION_MASK 0x3
+
+static inline css_error set_direction(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[DIRECTION_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~DIRECTION_MASK) | ((type & 0x3) << DIRECTION_SHIFT);
+
+ return CSS_OK;
+}
+#undef DIRECTION_INDEX
+#undef DIRECTION_SHIFT
+#undef DIRECTION_MASK
+
+#define DISPLAY_INDEX 6
+#define DISPLAY_SHIFT 27
+#define DISPLAY_MASK 0xf8000000
+
+static inline css_error set_display(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[DISPLAY_INDEX];
+
+ /* 5bits: ttttt : type */
+ *bits = (*bits & ~DISPLAY_MASK) | ((type & 0x1f) << DISPLAY_SHIFT);
+
+ return CSS_OK;
+}
+#undef DISPLAY_INDEX
+#undef DISPLAY_SHIFT
+#undef DISPLAY_MASK
+
+#define EMPTY_CELLS_INDEX 9
+#define EMPTY_CELLS_SHIFT 12
+#define EMPTY_CELLS_MASK 0x3000
+
+static inline css_error set_empty_cells(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[EMPTY_CELLS_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~EMPTY_CELLS_MASK) | ((type & 0x3) <<
+ EMPTY_CELLS_SHIFT);
+
+ return CSS_OK;
+}
+#undef EMPTY_CELLS_INDEX
+#undef EMPTY_CELLS_SHIFT
+#undef EMPTY_CELLS_MASK
+
+#define FLEX_BASIS_INDEX 1
+#define FLEX_BASIS_SHIFT 4
+#define FLEX_BASIS_MASK 0x7f0
+
+static inline css_error set_flex_basis(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FLEX_BASIS_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~FLEX_BASIS_MASK) | (((type & 0x3) | (unit << 2)) <<
+ FLEX_BASIS_SHIFT);
+
+ style->i.flex_basis = length;
+
+ return CSS_OK;
+}
+#undef FLEX_BASIS_INDEX
+#undef FLEX_BASIS_SHIFT
+#undef FLEX_BASIS_MASK
+
+#define FLEX_DIRECTION_INDEX 6
+#define FLEX_DIRECTION_SHIFT 0
+#define FLEX_DIRECTION_MASK 0x7
+
+static inline css_error set_flex_direction(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FLEX_DIRECTION_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~FLEX_DIRECTION_MASK) | ((type & 0x7) <<
+ FLEX_DIRECTION_SHIFT);
+
+ return CSS_OK;
+}
+#undef FLEX_DIRECTION_INDEX
+#undef FLEX_DIRECTION_SHIFT
+#undef FLEX_DIRECTION_MASK
+
+#define FLEX_GROW_INDEX 10
+#define FLEX_GROW_SHIFT 23
+#define FLEX_GROW_MASK 0x800000
+
+static inline css_error set_flex_grow(css_computed_style *style, uint8_t type,
+ css_fixed fixed)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FLEX_GROW_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~FLEX_GROW_MASK) | ((type & 0x1) << FLEX_GROW_SHIFT);
+
+ style->i.flex_grow = fixed;
+
+ return CSS_OK;
+}
+#undef FLEX_GROW_INDEX
+#undef FLEX_GROW_SHIFT
+#undef FLEX_GROW_MASK
+
+#define FLEX_SHRINK_INDEX 10
+#define FLEX_SHRINK_SHIFT 20
+#define FLEX_SHRINK_MASK 0x100000
+
+static inline css_error set_flex_shrink(css_computed_style *style, uint8_t
+ type, css_fixed fixed)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FLEX_SHRINK_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~FLEX_SHRINK_MASK) | ((type & 0x1) <<
+ FLEX_SHRINK_SHIFT);
+
+ style->i.flex_shrink = fixed;
+
+ return CSS_OK;
+}
+#undef FLEX_SHRINK_INDEX
+#undef FLEX_SHRINK_SHIFT
+#undef FLEX_SHRINK_MASK
+
+#define FLEX_WRAP_INDEX 9
+#define FLEX_WRAP_SHIFT 20
+#define FLEX_WRAP_MASK 0x300000
+
+static inline css_error set_flex_wrap(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FLEX_WRAP_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~FLEX_WRAP_MASK) | ((type & 0x3) << FLEX_WRAP_SHIFT);
+
+ return CSS_OK;
+}
+#undef FLEX_WRAP_INDEX
+#undef FLEX_WRAP_SHIFT
+#undef FLEX_WRAP_MASK
+
+#define FLOAT_INDEX 9
+#define FLOAT_SHIFT 14
+#define FLOAT_MASK 0xc000
+
+static inline css_error set_float(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FLOAT_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~FLOAT_MASK) | ((type & 0x3) << FLOAT_SHIFT);
+
+ return CSS_OK;
+}
+#undef FLOAT_INDEX
+#undef FLOAT_SHIFT
+#undef FLOAT_MASK
+
+#define FONT_FAMILY_INDEX 8
+#define FONT_FAMILY_SHIFT 26
+#define FONT_FAMILY_MASK 0x1c000000
+
+static inline css_error set_font_family(css_computed_style *style, uint8_t
+ type, lwc_string **string_arr)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FONT_FAMILY_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~FONT_FAMILY_MASK) | ((type & 0x7) <<
+ FONT_FAMILY_SHIFT);
+
+ lwc_string **old_string_arr = style->font_family;
+ lwc_string **s;
+
+ for (s = string_arr; s != NULL && *s != NULL; s++)
+ *s = lwc_string_ref(*s);
+
+ style->font_family = 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 FONT_FAMILY_INDEX
+#undef FONT_FAMILY_SHIFT
+#undef FONT_FAMILY_MASK
+
+#define FONT_SIZE_INDEX 5
+#define FONT_SIZE_SHIFT 3
+#define FONT_SIZE_MASK 0xff8
+
+static inline css_error set_font_size(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FONT_SIZE_INDEX];
+
+ /* 9bits: uuuuutttt : unit | type */
+ *bits = (*bits & ~FONT_SIZE_MASK) | (((type & 0xf) | (unit << 4)) <<
+ FONT_SIZE_SHIFT);
+
+ style->i.font_size = length;
+
+ return CSS_OK;
+}
+#undef FONT_SIZE_INDEX
+#undef FONT_SIZE_SHIFT
+#undef FONT_SIZE_MASK
+
+#define FONT_STYLE_INDEX 9
+#define FONT_STYLE_SHIFT 22
+#define FONT_STYLE_MASK 0xc00000
+
+static inline css_error set_font_style(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FONT_STYLE_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~FONT_STYLE_MASK) | ((type & 0x3) << FONT_STYLE_SHIFT);
+
+ return CSS_OK;
+}
+#undef FONT_STYLE_INDEX
+#undef FONT_STYLE_SHIFT
+#undef FONT_STYLE_MASK
+
+#define FONT_VARIANT_INDEX 9
+#define FONT_VARIANT_SHIFT 6
+#define FONT_VARIANT_MASK 0xc0
+
+static inline css_error set_font_variant(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FONT_VARIANT_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~FONT_VARIANT_MASK) | ((type & 0x3) <<
+ FONT_VARIANT_SHIFT);
+
+ return CSS_OK;
+}
+#undef FONT_VARIANT_INDEX
+#undef FONT_VARIANT_SHIFT
+#undef FONT_VARIANT_MASK
+
+#define FONT_WEIGHT_INDEX 4
+#define FONT_WEIGHT_SHIFT 0
+#define FONT_WEIGHT_MASK 0xf
+
+static inline css_error set_font_weight(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[FONT_WEIGHT_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~FONT_WEIGHT_MASK) | ((type & 0xf) <<
+ FONT_WEIGHT_SHIFT);
+
+ return CSS_OK;
+}
+#undef FONT_WEIGHT_INDEX
+#undef FONT_WEIGHT_SHIFT
+#undef FONT_WEIGHT_MASK
+
+#define HEIGHT_INDEX 2
+#define HEIGHT_SHIFT 4
+#define HEIGHT_MASK 0x7f0
+
+static inline css_error set_height(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[HEIGHT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~HEIGHT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ HEIGHT_SHIFT);
+
+ style->i.height = length;
+
+ return CSS_OK;
+}
+#undef HEIGHT_INDEX
+#undef HEIGHT_SHIFT
+#undef HEIGHT_MASK
+
+#define JUSTIFY_CONTENT_INDEX 8
+#define JUSTIFY_CONTENT_SHIFT 5
+#define JUSTIFY_CONTENT_MASK 0xe0
+
+static inline css_error set_justify_content(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[JUSTIFY_CONTENT_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~JUSTIFY_CONTENT_MASK) | ((type & 0x7) <<
+ JUSTIFY_CONTENT_SHIFT);
+
+ return CSS_OK;
+}
+#undef JUSTIFY_CONTENT_INDEX
+#undef JUSTIFY_CONTENT_SHIFT
+#undef JUSTIFY_CONTENT_MASK
+
+#define LEFT_INDEX 3
+#define LEFT_SHIFT 25
+#define LEFT_MASK 0xfe000000
+
+static inline css_error set_left(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[LEFT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~LEFT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ LEFT_SHIFT);
+
+ style->i.left = length;
+
+ return CSS_OK;
+}
+#undef LEFT_INDEX
+#undef LEFT_SHIFT
+#undef LEFT_MASK
+
+#define LINE_HEIGHT_INDEX 2
+#define LINE_HEIGHT_SHIFT 11
+#define LINE_HEIGHT_MASK 0x3f800
+
+static inline css_error set_line_height(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[LINE_HEIGHT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~LINE_HEIGHT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ LINE_HEIGHT_SHIFT);
+
+ style->i.line_height = length;
+
+ return CSS_OK;
+}
+#undef LINE_HEIGHT_INDEX
+#undef LINE_HEIGHT_SHIFT
+#undef LINE_HEIGHT_MASK
+
+#define LIST_STYLE_IMAGE_INDEX 10
+#define LIST_STYLE_IMAGE_SHIFT 25
+#define LIST_STYLE_IMAGE_MASK 0x2000000
+
+static inline css_error set_list_style_image(css_computed_style *style, uint8_t
+ type, lwc_string *string)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[LIST_STYLE_IMAGE_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~LIST_STYLE_IMAGE_MASK) | ((type & 0x1) <<
+ LIST_STYLE_IMAGE_SHIFT);
+
+ lwc_string *old_string = style->i.list_style_image;
+
+ if (string != NULL) {
+ style->i.list_style_image = lwc_string_ref(string);
+ } else {
+ style->i.list_style_image = NULL;
+ }
+
+ if (old_string != NULL)
+ lwc_string_unref(old_string);
+
+ return CSS_OK;
+}
+#undef LIST_STYLE_IMAGE_INDEX
+#undef LIST_STYLE_IMAGE_SHIFT
+#undef LIST_STYLE_IMAGE_MASK
+
+#define LIST_STYLE_POSITION_INDEX 9
+#define LIST_STYLE_POSITION_SHIFT 0
+#define LIST_STYLE_POSITION_MASK 0x3
+
+static inline css_error set_list_style_position(css_computed_style *style,
+ uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[LIST_STYLE_POSITION_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~LIST_STYLE_POSITION_MASK) | ((type & 0x3) <<
+ LIST_STYLE_POSITION_SHIFT);
+
+ return CSS_OK;
+}
+#undef LIST_STYLE_POSITION_INDEX
+#undef LIST_STYLE_POSITION_SHIFT
+#undef LIST_STYLE_POSITION_MASK
+
+#define LIST_STYLE_TYPE_INDEX 3
+#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)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[LIST_STYLE_TYPE_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~LIST_STYLE_TYPE_MASK) | ((type & 0xf) <<
+ LIST_STYLE_TYPE_SHIFT);
+
+ return CSS_OK;
+}
+#undef LIST_STYLE_TYPE_INDEX
+#undef LIST_STYLE_TYPE_SHIFT
+#undef LIST_STYLE_TYPE_MASK
+
+#define MARGIN_BOTTOM_INDEX 2
+#define MARGIN_BOTTOM_SHIFT 25
+#define MARGIN_BOTTOM_MASK 0xfe000000
+
+static inline css_error set_margin_bottom(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MARGIN_BOTTOM_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MARGIN_BOTTOM_MASK) | (((type & 0x3) | (unit << 2))
+ << MARGIN_BOTTOM_SHIFT);
+
+ style->i.margin_bottom = length;
+
+ return CSS_OK;
+}
+#undef MARGIN_BOTTOM_INDEX
+#undef MARGIN_BOTTOM_SHIFT
+#undef MARGIN_BOTTOM_MASK
+
+#define MARGIN_LEFT_INDEX 4
+#define MARGIN_LEFT_SHIFT 4
+#define MARGIN_LEFT_MASK 0x7f0
+
+static inline css_error set_margin_left(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MARGIN_LEFT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MARGIN_LEFT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MARGIN_LEFT_SHIFT);
+
+ style->i.margin_left = length;
+
+ return CSS_OK;
+}
+#undef MARGIN_LEFT_INDEX
+#undef MARGIN_LEFT_SHIFT
+#undef MARGIN_LEFT_MASK
+
+#define MARGIN_RIGHT_INDEX 1
+#define MARGIN_RIGHT_SHIFT 25
+#define MARGIN_RIGHT_MASK 0xfe000000
+
+static inline css_error set_margin_right(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MARGIN_RIGHT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MARGIN_RIGHT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MARGIN_RIGHT_SHIFT);
+
+ style->i.margin_right = length;
+
+ return CSS_OK;
+}
+#undef MARGIN_RIGHT_INDEX
+#undef MARGIN_RIGHT_SHIFT
+#undef MARGIN_RIGHT_MASK
+
+#define MARGIN_TOP_INDEX 4
+#define MARGIN_TOP_SHIFT 18
+#define MARGIN_TOP_MASK 0x1fc0000
+
+static inline css_error set_margin_top(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MARGIN_TOP_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MARGIN_TOP_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MARGIN_TOP_SHIFT);
+
+ style->i.margin_top = length;
+
+ return CSS_OK;
+}
+#undef MARGIN_TOP_INDEX
+#undef MARGIN_TOP_SHIFT
+#undef MARGIN_TOP_MASK
+
+#define MAX_HEIGHT_INDEX 3
+#define MAX_HEIGHT_SHIFT 11
+#define MAX_HEIGHT_MASK 0x3f800
+
+static inline css_error set_max_height(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MAX_HEIGHT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MAX_HEIGHT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MAX_HEIGHT_SHIFT);
+
+ style->i.max_height = length;
+
+ return CSS_OK;
+}
+#undef MAX_HEIGHT_INDEX
+#undef MAX_HEIGHT_SHIFT
+#undef MAX_HEIGHT_MASK
+
+#define MAX_WIDTH_INDEX 1
+#define MAX_WIDTH_SHIFT 18
+#define MAX_WIDTH_MASK 0x1fc0000
+
+static inline css_error set_max_width(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MAX_WIDTH_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MAX_WIDTH_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MAX_WIDTH_SHIFT);
+
+ style->i.max_width = length;
+
+ return CSS_OK;
+}
+#undef MAX_WIDTH_INDEX
+#undef MAX_WIDTH_SHIFT
+#undef MAX_WIDTH_MASK
+
+#define MIN_HEIGHT_INDEX 3
+#define MIN_HEIGHT_SHIFT 4
+#define MIN_HEIGHT_MASK 0x7f0
+
+static inline css_error set_min_height(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MIN_HEIGHT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MIN_HEIGHT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MIN_HEIGHT_SHIFT);
+
+ style->i.min_height = length;
+
+ return CSS_OK;
+}
+#undef MIN_HEIGHT_INDEX
+#undef MIN_HEIGHT_SHIFT
+#undef MIN_HEIGHT_MASK
+
+#define MIN_WIDTH_INDEX 2
+#define MIN_WIDTH_SHIFT 18
+#define MIN_WIDTH_MASK 0x1fc0000
+
+static inline css_error set_min_width(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[MIN_WIDTH_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~MIN_WIDTH_MASK) | (((type & 0x3) | (unit << 2)) <<
+ MIN_WIDTH_SHIFT);
+
+ style->i.min_width = length;
+
+ return CSS_OK;
+}
+#undef MIN_WIDTH_INDEX
+#undef MIN_WIDTH_SHIFT
+#undef MIN_WIDTH_MASK
+
+#define OPACITY_INDEX 10
+#define OPACITY_SHIFT 21
+#define OPACITY_MASK 0x200000
+
+static inline css_error set_opacity(css_computed_style *style, uint8_t type,
+ css_fixed fixed)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[OPACITY_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~OPACITY_MASK) | ((type & 0x1) << OPACITY_SHIFT);
+
+ style->i.opacity = fixed;
+
+ return CSS_OK;
+}
+#undef OPACITY_INDEX
+#undef OPACITY_SHIFT
+#undef OPACITY_MASK
+
+#define ORDER_INDEX 10
+#define ORDER_SHIFT 22
+#define ORDER_MASK 0x400000
+
+static inline css_error set_order(css_computed_style *style, uint8_t type,
+ int32_t integer)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[ORDER_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~ORDER_MASK) | ((type & 0x1) << ORDER_SHIFT);
+
+ style->i.order = integer;
+
+ return CSS_OK;
+}
+#undef ORDER_INDEX
+#undef ORDER_SHIFT
+#undef ORDER_MASK
+
+#define OUTLINE_STYLE_INDEX 6
+#define OUTLINE_STYLE_SHIFT 6
+#define OUTLINE_STYLE_MASK 0x3c0
+
+static inline css_error set_outline_style(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[OUTLINE_STYLE_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~OUTLINE_STYLE_MASK) | ((type & 0xf) <<
+ OUTLINE_STYLE_SHIFT);
+
+ return CSS_OK;
+}
+#undef OUTLINE_STYLE_INDEX
+#undef OUTLINE_STYLE_SHIFT
+#undef OUTLINE_STYLE_MASK
+
+#define OVERFLOW_X_INDEX 8
+#define OVERFLOW_X_SHIFT 2
+#define OVERFLOW_X_MASK 0x1c
+
+static inline css_error set_overflow_x(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[OVERFLOW_X_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~OVERFLOW_X_MASK) | ((type & 0x7) << OVERFLOW_X_SHIFT);
+
+ return CSS_OK;
+}
+#undef OVERFLOW_X_INDEX
+#undef OVERFLOW_X_SHIFT
+#undef OVERFLOW_X_MASK
+
+#define OVERFLOW_Y_INDEX 8
+#define OVERFLOW_Y_SHIFT 23
+#define OVERFLOW_Y_MASK 0x3800000
+
+static inline css_error set_overflow_y(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[OVERFLOW_Y_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~OVERFLOW_Y_MASK) | ((type & 0x7) << OVERFLOW_Y_SHIFT);
+
+ return CSS_OK;
+}
+#undef OVERFLOW_Y_INDEX
+#undef OVERFLOW_Y_SHIFT
+#undef OVERFLOW_Y_MASK
+
+#define PADDING_BOTTOM_INDEX 7
+#define PADDING_BOTTOM_SHIFT 2
+#define PADDING_BOTTOM_MASK 0xfc
+
+static inline css_error set_padding_bottom(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[PADDING_BOTTOM_INDEX];
+
+ /* 6bits: uuuuut : unit | type */
+ *bits = (*bits & ~PADDING_BOTTOM_MASK) | (((type & 0x1) | (unit << 1))
+ << PADDING_BOTTOM_SHIFT);
+
+ style->i.padding_bottom = length;
+
+ return CSS_OK;
+}
+#undef PADDING_BOTTOM_INDEX
+#undef PADDING_BOTTOM_SHIFT
+#undef PADDING_BOTTOM_MASK
+
+#define PADDING_LEFT_INDEX 7
+#define PADDING_LEFT_SHIFT 20
+#define PADDING_LEFT_MASK 0x3f00000
+
+static inline css_error set_padding_left(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[PADDING_LEFT_INDEX];
+
+ /* 6bits: uuuuut : unit | type */
+ *bits = (*bits & ~PADDING_LEFT_MASK) | (((type & 0x1) | (unit << 1)) <<
+ PADDING_LEFT_SHIFT);
+
+ style->i.padding_left = length;
+
+ return CSS_OK;
+}
+#undef PADDING_LEFT_INDEX
+#undef PADDING_LEFT_SHIFT
+#undef PADDING_LEFT_MASK
+
+#define PADDING_RIGHT_INDEX 7
+#define PADDING_RIGHT_SHIFT 14
+#define PADDING_RIGHT_MASK 0xfc000
+
+static inline css_error set_padding_right(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[PADDING_RIGHT_INDEX];
+
+ /* 6bits: uuuuut : unit | type */
+ *bits = (*bits & ~PADDING_RIGHT_MASK) | (((type & 0x1) | (unit << 1))
+ << PADDING_RIGHT_SHIFT);
+
+ style->i.padding_right = length;
+
+ return CSS_OK;
+}
+#undef PADDING_RIGHT_INDEX
+#undef PADDING_RIGHT_SHIFT
+#undef PADDING_RIGHT_MASK
+
+#define PADDING_TOP_INDEX 7
+#define PADDING_TOP_SHIFT 26
+#define PADDING_TOP_MASK 0xfc000000
+
+static inline css_error set_padding_top(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[PADDING_TOP_INDEX];
+
+ /* 6bits: uuuuut : unit | type */
+ *bits = (*bits & ~PADDING_TOP_MASK) | (((type & 0x1) | (unit << 1)) <<
+ PADDING_TOP_SHIFT);
+
+ style->i.padding_top = length;
+
+ return CSS_OK;
+}
+#undef PADDING_TOP_INDEX
+#undef PADDING_TOP_SHIFT
+#undef PADDING_TOP_MASK
+
+#define POSITION_INDEX 8
+#define POSITION_SHIFT 14
+#define POSITION_MASK 0x1c000
+
+static inline css_error set_position(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[POSITION_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~POSITION_MASK) | ((type & 0x7) << POSITION_SHIFT);
+
+ return CSS_OK;
+}
+#undef POSITION_INDEX
+#undef POSITION_SHIFT
+#undef POSITION_MASK
+
+#define QUOTES_INDEX 10
+#define QUOTES_SHIFT 24
+#define QUOTES_MASK 0x1000000
+
+static inline css_error set_quotes(css_computed_style *style, uint8_t type,
+ lwc_string **string_arr)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[QUOTES_INDEX];
+
+ /* 1bit: t : type */
+ *bits = (*bits & ~QUOTES_MASK) | ((type & 0x1) << QUOTES_SHIFT);
+
+ lwc_string **old_string_arr = style->quotes;
+ lwc_string **s;
+
+ for (s = string_arr; s != NULL && *s != NULL; s++)
+ *s = lwc_string_ref(*s);
+
+ style->quotes = 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 QUOTES_INDEX
+#undef QUOTES_SHIFT
+#undef QUOTES_MASK
+
+#define RIGHT_INDEX 4
+#define RIGHT_SHIFT 25
+#define RIGHT_MASK 0xfe000000
+
+static inline css_error set_right(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[RIGHT_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~RIGHT_MASK) | (((type & 0x3) | (unit << 2)) <<
+ RIGHT_SHIFT);
+
+ style->i.right = length;
+
+ return CSS_OK;
+}
+#undef RIGHT_INDEX
+#undef RIGHT_SHIFT
+#undef RIGHT_MASK
+
+#define TABLE_LAYOUT_INDEX 9
+#define TABLE_LAYOUT_SHIFT 30
+#define TABLE_LAYOUT_MASK 0xc0000000
+
+static inline css_error set_table_layout(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[TABLE_LAYOUT_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~TABLE_LAYOUT_MASK) | ((type & 0x3) <<
+ TABLE_LAYOUT_SHIFT);
+
+ return CSS_OK;
+}
+#undef TABLE_LAYOUT_INDEX
+#undef TABLE_LAYOUT_SHIFT
+#undef TABLE_LAYOUT_MASK
+
+#define TEXT_ALIGN_INDEX 6
+#define TEXT_ALIGN_SHIFT 10
+#define TEXT_ALIGN_MASK 0x3c00
+
+static inline css_error set_text_align(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[TEXT_ALIGN_INDEX];
+
+ /* 4bits: tttt : type */
+ *bits = (*bits & ~TEXT_ALIGN_MASK) | ((type & 0xf) << TEXT_ALIGN_SHIFT);
+
+ return CSS_OK;
+}
+#undef TEXT_ALIGN_INDEX
+#undef TEXT_ALIGN_SHIFT
+#undef TEXT_ALIGN_MASK
+
+#define TEXT_DECORATION_INDEX 6
+#define TEXT_DECORATION_SHIFT 22
+#define TEXT_DECORATION_MASK 0x7c00000
+
+static inline css_error set_text_decoration(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[TEXT_DECORATION_INDEX];
+
+ /* 5bits: ttttt : type */
+ *bits = (*bits & ~TEXT_DECORATION_MASK) | ((type & 0x1f) <<
+ TEXT_DECORATION_SHIFT);
+
+ return CSS_OK;
+}
+#undef TEXT_DECORATION_INDEX
+#undef TEXT_DECORATION_SHIFT
+#undef TEXT_DECORATION_MASK
+
+#define TEXT_INDENT_INDEX 7
+#define TEXT_INDENT_SHIFT 8
+#define TEXT_INDENT_MASK 0x3f00
+
+static inline css_error set_text_indent(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[TEXT_INDENT_INDEX];
+
+ /* 6bits: uuuuut : unit | type */
+ *bits = (*bits & ~TEXT_INDENT_MASK) | (((type & 0x1) | (unit << 1)) <<
+ TEXT_INDENT_SHIFT);
+
+ style->i.text_indent = length;
+
+ return CSS_OK;
+}
+#undef TEXT_INDENT_INDEX
+#undef TEXT_INDENT_SHIFT
+#undef TEXT_INDENT_MASK
+
+#define TEXT_TRANSFORM_INDEX 8
+#define TEXT_TRANSFORM_SHIFT 29
+#define TEXT_TRANSFORM_MASK 0xe0000000
+
+static inline css_error set_text_transform(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[TEXT_TRANSFORM_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~TEXT_TRANSFORM_MASK) | ((type & 0x7) <<
+ TEXT_TRANSFORM_SHIFT);
+
+ return CSS_OK;
+}
+#undef TEXT_TRANSFORM_INDEX
+#undef TEXT_TRANSFORM_SHIFT
+#undef TEXT_TRANSFORM_MASK
+
+#define TOP_INDEX 4
+#define TOP_SHIFT 11
+#define TOP_MASK 0x3f800
+
+static inline css_error set_top(css_computed_style *style, uint8_t type,
+ css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[TOP_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~TOP_MASK) | (((type & 0x3) | (unit << 2)) <<
+ TOP_SHIFT);
+
+ style->i.top = length;
+
+ return CSS_OK;
+}
+#undef TOP_INDEX
+#undef TOP_SHIFT
+#undef TOP_MASK
+
+#define UNICODE_BIDI_INDEX 9
+#define UNICODE_BIDI_SHIFT 4
+#define UNICODE_BIDI_MASK 0x30
+
+static inline css_error set_unicode_bidi(css_computed_style *style, uint8_t
+ type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[UNICODE_BIDI_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~UNICODE_BIDI_MASK) | ((type & 0x3) <<
+ UNICODE_BIDI_SHIFT);
+
+ return CSS_OK;
+}
+#undef UNICODE_BIDI_INDEX
+#undef UNICODE_BIDI_SHIFT
+#undef UNICODE_BIDI_MASK
+
+#define VERTICAL_ALIGN_INDEX 5
+#define VERTICAL_ALIGN_SHIFT 12
+#define VERTICAL_ALIGN_MASK 0x1ff000
+
+static inline css_error set_vertical_align(css_computed_style *style, uint8_t
+ type, css_fixed length, css_unit unit)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[VERTICAL_ALIGN_INDEX];
+
+ /* 9bits: uuuuutttt : unit | type */
+ *bits = (*bits & ~VERTICAL_ALIGN_MASK) | (((type & 0xf) | (unit << 4))
+ << VERTICAL_ALIGN_SHIFT);
+
+ style->i.vertical_align = length;
+
+ return CSS_OK;
+}
+#undef VERTICAL_ALIGN_INDEX
+#undef VERTICAL_ALIGN_SHIFT
+#undef VERTICAL_ALIGN_MASK
+
+#define VISIBILITY_INDEX 9
+#define VISIBILITY_SHIFT 18
+#define VISIBILITY_MASK 0xc0000
+
+static inline css_error set_visibility(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[VISIBILITY_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~VISIBILITY_MASK) | ((type & 0x3) << VISIBILITY_SHIFT);
+
+ return CSS_OK;
+}
+#undef VISIBILITY_INDEX
+#undef VISIBILITY_SHIFT
+#undef VISIBILITY_MASK
+
+#define WHITE_SPACE_INDEX 5
+#define WHITE_SPACE_SHIFT 0
+#define WHITE_SPACE_MASK 0x7
+
+static inline css_error set_white_space(css_computed_style *style, uint8_t type)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[WHITE_SPACE_INDEX];
+
+ /* 3bits: ttt : type */
+ *bits = (*bits & ~WHITE_SPACE_MASK) | ((type & 0x7) <<
+ WHITE_SPACE_SHIFT);
+
+ return CSS_OK;
+}
+#undef WHITE_SPACE_INDEX
+#undef WHITE_SPACE_SHIFT
+#undef WHITE_SPACE_MASK
+
+#define WIDTH_INDEX 1
+#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)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[WIDTH_INDEX];
+
+ /* 7bits: uuuuutt : unit | type */
+ *bits = (*bits & ~WIDTH_MASK) | (((type & 0x3) | (unit << 2)) <<
+ WIDTH_SHIFT);
+
+ style->i.width = length;
+
+ return CSS_OK;
+}
+#undef WIDTH_INDEX
+#undef WIDTH_SHIFT
+#undef WIDTH_MASK
+
+#define Z_INDEX_INDEX 9
+#define Z_INDEX_SHIFT 24
+#define Z_INDEX_MASK 0x3000000
+
+static inline css_error set_z_index(css_computed_style *style, uint8_t type,
+ int32_t integer)
+{
+ uint32_t *bits;
+
+ bits = &style->i.bits[Z_INDEX_INDEX];
+
+ /* 2bits: tt : type */
+ *bits = (*bits & ~Z_INDEX_MASK) | ((type & 0x3) << Z_INDEX_SHIFT);
+
+ style->i.z_index = integer;
+
+ return CSS_OK;
+}
+#undef Z_INDEX_INDEX
+#undef Z_INDEX_SHIFT
+#undef Z_INDEX_MASK