diff options
-rw-r--r-- | src/select/computed.c | 1912 | ||||
-rw-r--r-- | src/select/computed.h | 4 | ||||
-rw-r--r-- | src/select/properties/Makefile | 2 | ||||
-rw-r--r-- | src/select/properties/display.c | 4 | ||||
-rw-r--r-- | src/select/properties/orphans.c | 6 | ||||
-rw-r--r-- | src/select/properties/widows.c (renamed from src/select/properties/windows.c) | 6 | ||||
-rw-r--r-- | src/select/propget.h | 95 | ||||
-rw-r--r-- | src/select/propset.h | 8 |
8 files changed, 337 insertions, 1700 deletions
diff --git a/src/select/computed.c b/src/select/computed.c index ce46a16..cb3bab9 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -353,1984 +353,620 @@ css_error css_computed_style_compose(const css_computed_style *parent, ******************************************************************************/ -#define CSS_LETTER_SPACING_INDEX 0 -#define CSS_LETTER_SPACING_SHIFT 2 -#define CSS_LETTER_SPACING_MASK 0xfc -uint8_t css_computed_letter_spacing( - const css_computed_style *style, +uint8_t css_computed_letter_spacing(const css_computed_style *style, css_fixed *length, css_unit *unit) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_LETTER_SPACING_INDEX]; - bits &= CSS_LETTER_SPACING_MASK; - bits >>= CSS_LETTER_SPACING_SHIFT; - - /* 6bits: uuuutt : unit | type */ - - if ((bits & 3) == CSS_LETTER_SPACING_SET) { - *length = style->uncommon->letter_spacing; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 3); - } - - return CSS_LETTER_SPACING_NORMAL; + return get_letter_spacing(style, length, unit); } -#undef CSS_LETTER_SPACING_MASK -#undef CSS_LETTER_SPACING_SHIFT -#undef CSS_LETTER_SPACING_INDEX -#define CSS_OUTLINE_COLOR_INDEX 0 -#define CSS_OUTLINE_COLOR_SHIFT 0 -#define CSS_OUTLINE_COLOR_MASK 0x3 -uint8_t css_computed_outline_color( - const css_computed_style *style, css_color *color) +uint8_t css_computed_outline_color(const css_computed_style *style, + css_color *color) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_OUTLINE_COLOR_INDEX]; - bits &= CSS_OUTLINE_COLOR_MASK; - bits >>= CSS_OUTLINE_COLOR_SHIFT; - - /* 2bits: tt : type */ - - if ((bits & 3) == CSS_OUTLINE_COLOR_COLOR) { - *color = style->uncommon->outline_color; - } - - return (bits & 3); - } - - return CSS_OUTLINE_COLOR_INVERT; + return get_outline_color(style, color); } -#undef CSS_OUTLINE_COLOR_MASK -#undef CSS_OUTLINE_COLOR_SHIFT -#undef CSS_OUTLINE_COLOR_INDEX -#define CSS_OUTLINE_WIDTH_INDEX 1 -#define CSS_OUTLINE_WIDTH_SHIFT 1 -#define CSS_OUTLINE_WIDTH_MASK 0xfe -uint8_t css_computed_outline_width( - const css_computed_style *style, +uint8_t css_computed_outline_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_OUTLINE_WIDTH_INDEX]; - bits &= CSS_OUTLINE_WIDTH_MASK; - bits >>= CSS_OUTLINE_WIDTH_SHIFT; - - /* 7bits: uuuuttt : unit | type */ - - if ((bits & 7) == CSS_OUTLINE_WIDTH_WIDTH) { - *length = style->uncommon->outline_width; - *unit = (css_unit) (bits >> 3); - } - - return (bits & 7); - } - - *length = INTTOFIX(2); - *unit = CSS_UNIT_PX; - - return CSS_OUTLINE_WIDTH_WIDTH; + return get_outline_width(style, length, unit); } -#undef CSS_OUTLINE_WIDTH_MASK -#undef CSS_OUTLINE_WIDTH_SHIFT -#undef CSS_OUTLINE_WIDTH_INDEX -#define CSS_BORDER_SPACING_INDEX 1 -#define CSS_BORDER_SPACING_SHIFT 0 -#define CSS_BORDER_SPACING_MASK 0x1 -#define CSS_BORDER_SPACING_INDEX1 2 -#define CSS_BORDER_SPACING_SHIFT1 0 -#define CSS_BORDER_SPACING_MASK1 0xff -uint8_t css_computed_border_spacing( - const css_computed_style *style, +uint8_t css_computed_border_spacing(const css_computed_style *style, css_fixed *hlength, css_unit *hunit, css_fixed *vlength, css_unit *vunit) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_BORDER_SPACING_INDEX]; - bits &= CSS_BORDER_SPACING_MASK; - bits >>= CSS_BORDER_SPACING_SHIFT; - - /* 1 bit: type */ - if (bits == CSS_BORDER_SPACING_SET) { - uint8_t bits1 = - style->uncommon->bits[CSS_BORDER_SPACING_INDEX1]; - bits1 &= CSS_BORDER_SPACING_MASK1; - bits1 >>= CSS_BORDER_SPACING_SHIFT1; - - /* 8bits: hhhhvvvv : hunit | vunit */ - - *hlength = style->uncommon->border_spacing[0]; - *hunit = (css_unit) (bits1 >> 4); - - *vlength = style->uncommon->border_spacing[1]; - *vunit = (css_unit) (bits1 & 0xf); - } - - return bits; - } else { - *hlength = *vlength = 0; - *hunit = *vunit = CSS_UNIT_PX; - } - - return CSS_BORDER_SPACING_SET; + return get_border_spacing(style, hlength, hunit, vlength, vunit); } -#undef CSS_BORDER_SPACING_MASK1 -#undef CSS_BORDER_SPACING_SHIFT1 -#undef CSS_BORDER_SPACING_INDEX1 -#undef CSS_BORDER_SPACING_MASK -#undef CSS_BORDER_SPACING_SHIFT -#undef CSS_BORDER_SPACING_INDEX -#define CSS_WORD_SPACING_INDEX 3 -#define CSS_WORD_SPACING_SHIFT 2 -#define CSS_WORD_SPACING_MASK 0xfc -uint8_t css_computed_word_spacing( - const css_computed_style *style, +uint8_t css_computed_word_spacing(const css_computed_style *style, css_fixed *length, css_unit *unit) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_WORD_SPACING_INDEX]; - bits &= CSS_WORD_SPACING_MASK; - bits >>= CSS_WORD_SPACING_SHIFT; - - /* 6bits: uuuutt : unit | type */ - - if ((bits & 3) == CSS_WORD_SPACING_SET) { - *length = style->uncommon->word_spacing; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 3); - } - - return CSS_WORD_SPACING_NORMAL; + return get_word_spacing(style, length, unit); } -#undef CSS_WORD_SPACING_MASK -#undef CSS_WORD_SPACING_SHIFT -#undef CSS_WORD_SPACING_INDEX -#define CSS_WRITING_MODE_INDEX 4 -#define CSS_WRITING_MODE_SHIFT 1 -#define CSS_WRITING_MODE_MASK 0x6 -uint8_t css_computed_writing_mode( - const css_computed_style *style) +uint8_t css_computed_writing_mode(const css_computed_style *style) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_WRITING_MODE_INDEX]; - bits &= CSS_WRITING_MODE_MASK; - bits >>= CSS_WRITING_MODE_SHIFT; - - /* 2bits: type */ - return bits; - } - - return CSS_WRITING_MODE_HORIZONTAL_TB; + return get_writing_mode(style); } -#undef CSS_WRITING_MODE_MASK -#undef CSS_WRITING_MODE_SHIFT -#undef CSS_WRITING_MODE_INDEX -#define CSS_COUNTER_INCREMENT_INDEX 3 -#define CSS_COUNTER_INCREMENT_SHIFT 1 -#define CSS_COUNTER_INCREMENT_MASK 0x2 -uint8_t css_computed_counter_increment( - const css_computed_style *style, +uint8_t css_computed_counter_increment(const css_computed_style *style, const css_computed_counter **counters) { - if (style->uncommon != NULL) { - uint8_t bits = - style->uncommon->bits[CSS_COUNTER_INCREMENT_INDEX]; - bits &= CSS_COUNTER_INCREMENT_MASK; - bits >>= CSS_COUNTER_INCREMENT_SHIFT; - - /* 1bit: type */ - *counters = style->uncommon->counter_increment; - - return bits; - } - - return CSS_COUNTER_INCREMENT_NONE; + return get_counter_increment(style, counters); } -#undef CSS_COUNTER_INCREMENT_MASK -#undef CSS_COUNTER_INCREMENT_SHIFT -#undef CSS_COUNTER_INCREMENT_INDEX -#define CSS_COUNTER_RESET_INDEX 3 -#define CSS_COUNTER_RESET_SHIFT 0 -#define CSS_COUNTER_RESET_MASK 0x1 -uint8_t css_computed_counter_reset( - const css_computed_style *style, +uint8_t css_computed_counter_reset(const css_computed_style *style, const css_computed_counter **counters) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_COUNTER_RESET_INDEX]; - bits &= CSS_COUNTER_RESET_MASK; - bits >>= CSS_COUNTER_RESET_SHIFT; - - /* 1bit: type */ - *counters = style->uncommon->counter_reset; - - return bits; - } - - return CSS_COUNTER_RESET_NONE; + return get_counter_reset(style, counters); } -#undef CSS_COUNTER_RESET_MASK -#undef CSS_COUNTER_RESET_SHIFT -#undef CSS_COUNTER_RESET_INDEX -#define CSS_CURSOR_INDEX 4 -#define CSS_CURSOR_SHIFT 3 -#define CSS_CURSOR_MASK 0xf8 -uint8_t css_computed_cursor( - const css_computed_style *style, +uint8_t css_computed_cursor(const css_computed_style *style, lwc_string ***urls) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_CURSOR_INDEX]; - bits &= CSS_CURSOR_MASK; - bits >>= CSS_CURSOR_SHIFT; - - /* 5bits: type */ - *urls = style->uncommon->cursor; - - return bits; - } + return get_cursor(style, urls); +} - return CSS_CURSOR_AUTO; -} -#undef CSS_CURSOR_MASK -#undef CSS_CURSOR_SHIFT -#undef CSS_CURSOR_INDEX - -#define CSS_CLIP_INDEX 7 -#define CSS_CLIP_SHIFT 2 -#define CSS_CLIP_MASK 0xfc -#define CSS_CLIP_INDEX1 5 -#define CSS_CLIP_SHIFT1 0 -#define CSS_CLIP_MASK1 0xff -#define CSS_CLIP_INDEX2 6 -#define CSS_CLIP_SHIFT2 0 -#define CSS_CLIP_MASK2 0xff -uint8_t css_computed_clip( - const css_computed_style *style, +uint8_t css_computed_clip(const css_computed_style *style, css_computed_clip_rect *rect) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_CLIP_INDEX]; - bits &= CSS_CLIP_MASK; - bits >>= CSS_CLIP_SHIFT; - - /* 6bits: trblyy : top | right | bottom | left | type */ - if ((bits & 0x3) == CSS_CLIP_RECT) { - uint8_t bits1; - - rect->left_auto = (bits & 0x4); - rect->bottom_auto = (bits & 0x8); - rect->right_auto = (bits & 0x10); - rect->top_auto = (bits & 0x20); - - if (rect->top_auto == false || - rect->right_auto == false) { - /* 8bits: ttttrrrr : top | right */ - bits1 = style->uncommon->bits[CSS_CLIP_INDEX1]; - bits1 &= CSS_CLIP_MASK1; - bits1 >>= CSS_CLIP_SHIFT1; - } else { - bits1 = 0; - } - - rect->top = style->uncommon->clip[0]; - rect->tunit = (css_unit) (bits1 >> 4); - - rect->right = style->uncommon->clip[1]; - rect->runit = (css_unit) (bits1 & 0xf); - - if (rect->bottom_auto == false || - rect->left_auto == false) { - /* 8bits: bbbbllll : bottom | left */ - bits1 = style->uncommon->bits[CSS_CLIP_INDEX2]; - bits1 &= CSS_CLIP_MASK2; - bits1 >>= CSS_CLIP_SHIFT2; - } else { - bits1 = 0; - } - - rect->bottom = style->uncommon->clip[2]; - rect->bunit = (css_unit) (bits1 >> 4); - - rect->left = style->uncommon->clip[3]; - rect->lunit = (css_unit) (bits1 & 0xf); - } - - return (bits & 0x3); - } + return get_clip(style, rect); +} - return CSS_CLIP_AUTO; -} -#undef CSS_CLIP_MASK2 -#undef CSS_CLIP_SHIFT2 -#undef CSS_CLIP_INDEX2 -#undef CSS_CLIP_MASK1 -#undef CSS_CLIP_SHIFT1 -#undef CSS_CLIP_INDEX1 -#undef CSS_CLIP_MASK -#undef CSS_CLIP_SHIFT -#undef CSS_CLIP_INDEX - -#define CSS_CONTENT_INDEX 7 -#define CSS_CONTENT_SHIFT 0 -#define CSS_CONTENT_MASK 0x3 -uint8_t css_computed_content( - const css_computed_style *style, +uint8_t css_computed_content(const css_computed_style *style, const css_computed_content_item **content) { - if (style->uncommon != NULL) { - uint8_t bits = style->uncommon->bits[CSS_CONTENT_INDEX]; - bits &= CSS_CONTENT_MASK; - bits >>= CSS_CONTENT_SHIFT; - - /* 2bits: type */ - *content = style->uncommon->content; - - return bits; - } - - return CSS_CONTENT_NORMAL; + return get_content(style, content); } -#undef CSS_CONTENT_MASK -#undef CSS_CONTENT_SHIFT -#undef CSS_CONTENT_INDEX -#define CSS_VERTICAL_ALIGN_INDEX 0 -#define CSS_VERTICAL_ALIGN_SHIFT 0 -#define CSS_VERTICAL_ALIGN_MASK 0xff -uint8_t css_computed_vertical_align( - const css_computed_style *style, +uint8_t css_computed_vertical_align(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_VERTICAL_ALIGN_INDEX]; - bits &= CSS_VERTICAL_ALIGN_MASK; - bits >>= CSS_VERTICAL_ALIGN_SHIFT; - - /* 8bits: uuuutttt : units | type */ - if ((bits & 0xf) == CSS_VERTICAL_ALIGN_SET) { - *length = style->vertical_align; - *unit = (css_unit) (bits >> 4); - } - - return (bits & 0xf); + return get_vertical_align(style, length, unit); } -#undef CSS_VERTICAL_ALIGN_MASK -#undef CSS_VERTICAL_ALIGN_SHIFT -#undef CSS_VERTICAL_ALIGN_INDEX -#define CSS_FONT_SIZE_INDEX 1 -#define CSS_FONT_SIZE_SHIFT 0 -#define CSS_FONT_SIZE_MASK 0xff -uint8_t css_computed_font_size( - const css_computed_style *style, +uint8_t css_computed_font_size(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_FONT_SIZE_INDEX]; - bits &= CSS_FONT_SIZE_MASK; - bits >>= CSS_FONT_SIZE_SHIFT; - - /* 8bits: uuuutttt : units | type */ - if ((bits & 0xf) == CSS_FONT_SIZE_DIMENSION) { - *length = style->font_size; - *unit = (css_unit) (bits >> 4); - } - - return (bits & 0xf); + return get_font_size(style, length, unit); } -#undef CSS_FONT_SIZE_MASK -#undef CSS_FONT_SIZE_SHIFT -#undef CSS_FONT_SIZE_INDEX -#define CSS_BORDER_TOP_WIDTH_INDEX 2 -#define CSS_BORDER_TOP_WIDTH_SHIFT 1 -#define CSS_BORDER_TOP_WIDTH_MASK 0xfe -uint8_t css_computed_border_top_width( - const css_computed_style *style, +uint8_t css_computed_border_top_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_BORDER_TOP_WIDTH_INDEX]; - bits &= CSS_BORDER_TOP_WIDTH_MASK; - bits >>= CSS_BORDER_TOP_WIDTH_SHIFT; - - /* 7bits: uuuuttt : units | type */ - if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) { - *length = style->border_width[0]; - *unit = (css_unit) (bits >> 3); - } - - return (bits & 0x7); + return get_border_top_width(style, length, unit); } -#undef CSS_BORDER_TOP_WIDTH_MASK -#undef CSS_BORDER_TOP_WIDTH_SHIFT -#undef CSS_BORDER_TOP_WIDTH_INDEX -#define CSS_BORDER_RIGHT_WIDTH_INDEX 3 -#define CSS_BORDER_RIGHT_WIDTH_SHIFT 1 -#define CSS_BORDER_RIGHT_WIDTH_MASK 0xfe -uint8_t css_computed_border_right_width( - const css_computed_style *style, +uint8_t css_computed_border_right_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_BORDER_RIGHT_WIDTH_INDEX]; - bits &= CSS_BORDER_RIGHT_WIDTH_MASK; - bits >>= CSS_BORDER_RIGHT_WIDTH_SHIFT; - - /* 7bits: uuuuttt : units | type */ - if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) { - *length = style->border_width[1]; - *unit = (css_unit) (bits >> 3); - } - - return (bits & 0x7); + return get_border_right_width(style, length, unit); } -#undef CSS_BORDER_RIGHT_WIDTH_MASK -#undef CSS_BORDER_RIGHT_WIDTH_SHIFT -#undef CSS_BORDER_RIGHT_WIDTH_INDEX -#define CSS_BORDER_BOTTOM_WIDTH_INDEX 4 -#define CSS_BORDER_BOTTOM_WIDTH_SHIFT 1 -#define CSS_BORDER_BOTTOM_WIDTH_MASK 0xfe -uint8_t css_computed_border_bottom_width( - const css_computed_style *style, +uint8_t css_computed_border_bottom_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_BORDER_BOTTOM_WIDTH_INDEX]; - bits &= CSS_BORDER_BOTTOM_WIDTH_MASK; - bits >>= CSS_BORDER_BOTTOM_WIDTH_SHIFT; - - /* 7bits: uuuuttt : units | type */ - if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) { - *length = style->border_width[2]; - *unit = (css_unit) (bits >> 3); - } - - return (bits & 0x7); + return get_border_bottom_width(style, length, unit); } -#undef CSS_BORDER_BOTTOM_WIDTH_MASK -#undef CSS_BORDER_BOTTOM_WIDTH_SHIFT -#undef CSS_BORDER_BOTTOM_WIDTH_INDEX -#define CSS_BORDER_LEFT_WIDTH_INDEX 5 -#define CSS_BORDER_LEFT_WIDTH_SHIFT 1 -#define CSS_BORDER_LEFT_WIDTH_MASK 0xfe -uint8_t css_computed_border_left_width( - const css_computed_style *style, +uint8_t css_computed_border_left_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_BORDER_LEFT_WIDTH_INDEX]; - bits &= CSS_BORDER_LEFT_WIDTH_MASK; - bits >>= CSS_BORDER_LEFT_WIDTH_SHIFT; - - /* 7bits: uuuuttt : units | type */ - if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) { - *length = style->border_width[3]; - *unit = (css_unit) (bits >> 3); - } - - return (bits & 0x7); + return get_border_left_width(style, length, unit); } -#undef CSS_BORDER_LEFT_WIDTH_MASK -#undef CSS_BORDER_LEFT_WIDTH_SHIFT -#undef CSS_BORDER_LEFT_WIDTH_INDEX -#define CSS_BACKGROUND_IMAGE_INDEX 2 -#define CSS_BACKGROUND_IMAGE_SHIFT 0 -#define CSS_BACKGROUND_IMAGE_MASK 0x1 -uint8_t css_computed_background_image( - const css_computed_style *style, +uint8_t css_computed_background_image(const css_computed_style *style, lwc_string **url) { - uint8_t bits = style->bits[CSS_BACKGROUND_IMAGE_INDEX]; - bits &= CSS_BACKGROUND_IMAGE_MASK; - bits >>= CSS_BACKGROUND_IMAGE_SHIFT; - - /* 1bit: type */ - *url = style->background_image; - - return bits; + return get_background_image(style, url); } -#undef CSS_BACKGROUND_IMAGE_MASK -#undef CSS_BACKGROUND_IMAGE_SHIFT -#undef CSS_BACKGROUND_IMAGE_INDEX -#define CSS_COLOR_INDEX 3 -#define CSS_COLOR_SHIFT 0 -#define CSS_COLOR_MASK 0x1 -uint8_t css_computed_color( - const css_computed_style *style, +uint8_t css_computed_color(const css_computed_style *style, css_color *color) { - uint8_t bits = style->bits[CSS_COLOR_INDEX]; - bits &= CSS_COLOR_MASK; - bits >>= CSS_COLOR_SHIFT; - - /* 1bit: type */ - *color = style->color; - - return bits; + return get_color(style, color); } -#undef CSS_COLOR_MASK -#undef CSS_COLOR_SHIFT -#undef CSS_COLOR_INDEX -#define CSS_LIST_STYLE_IMAGE_INDEX 4 -#define CSS_LIST_STYLE_IMAGE_SHIFT 0 -#define CSS_LIST_STYLE_IMAGE_MASK 0x1 -uint8_t css_computed_list_style_image( - const css_computed_style *style, +uint8_t css_computed_list_style_image(const css_computed_style *style, lwc_string **url) { - uint8_t bits = style->bits[CSS_LIST_STYLE_IMAGE_INDEX]; - bits &= CSS_LIST_STYLE_IMAGE_MASK; - bits >>= CSS_LIST_STYLE_IMAGE_SHIFT; - - /* 1bit: type */ - *url = style->list_style_image; - - return bits; + return get_list_style_image(style, url); } -#undef CSS_LIST_STYLE_IMAGE_MASK -#undef CSS_LIST_STYLE_IMAGE_SHIFT -#undef CSS_LIST_STYLE_IMAGE_INDEX -#define CSS_QUOTES_INDEX 5 -#define CSS_QUOTES_SHIFT 0 -#define CSS_QUOTES_MASK 0x1 -uint8_t css_computed_quotes( - const css_computed_style *style, +uint8_t css_computed_quotes(const css_computed_style *style, lwc_string ***quotes) { - uint8_t bits = style->bits[CSS_QUOTES_INDEX]; - bits &= CSS_QUOTES_MASK; - bits >>= CSS_QUOTES_SHIFT; - - /* 1bit: type */ - *quotes = style->quotes; - - return bits; -} -#undef CSS_QUOTES_MASK -#undef CSS_QUOTES_SHIFT -#undef CSS_QUOTES_INDEX - -#define CSS_TOP_INDEX 6 -#define CSS_TOP_SHIFT 2 -#define CSS_TOP_MASK 0xfc -#define CSS_RIGHT_INDEX 7 -#define CSS_RIGHT_SHIFT 2 -#define CSS_RIGHT_MASK 0xfc -#define CSS_BOTTOM_INDEX 8 -#define CSS_BOTTOM_SHIFT 2 -#define CSS_BOTTOM_MASK 0xfc -#define CSS_LEFT_INDEX 9 -#define CSS_LEFT_SHIFT 2 -#define CSS_LEFT_MASK 0xfc -uint8_t css_computed_top( - const css_computed_style *style, + return get_quotes(style, quotes); +} + +uint8_t css_computed_top(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_TOP_INDEX]; - bits &= CSS_TOP_MASK; - bits >>= CSS_TOP_SHIFT; + uint8_t position = css_computed_position(style); + uint8_t top = get_top(style, length, unit); /* Fix up, based on computed position */ - if (css_computed_position(style) == CSS_POSITION_STATIC) { + if (position == CSS_POSITION_STATIC) { /* Static -> auto */ - bits = CSS_TOP_AUTO; - } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) { + top = CSS_TOP_AUTO; + } else if (position == CSS_POSITION_RELATIVE) { /* Relative -> follow $9.4.3 */ - uint8_t bottom = style->bits[CSS_BOTTOM_INDEX]; - bottom &= CSS_BOTTOM_MASK; - bottom >>= CSS_BOTTOM_SHIFT; + uint8_t bottom = get_bottom_bits(style); - if ((bits & 0x3) == CSS_TOP_AUTO && - (bottom & 0x3) == CSS_BOTTOM_AUTO) { + if (top == CSS_TOP_AUTO && (bottom & 0x3) == CSS_BOTTOM_AUTO) { /* Both auto => 0px */ *length = 0; *unit = CSS_UNIT_PX; - } else if ((bits & 0x3) == CSS_TOP_AUTO) { + } else if (top == CSS_TOP_AUTO) { /* Top is auto => -bottom */ *length = -style->bottom; *unit = (css_unit) (bottom >> 2); - } else { - *length = style->top; - *unit = (css_unit) (bits >> 2); } - bits = CSS_TOP_SET; - } else if ((bits & 0x3) == CSS_TOP_SET) { - *length = style->top; - *unit = (css_unit) (bits >> 2); + top = CSS_TOP_SET; } - /* 6bits: uuuutt : units | type */ - return (bits & 0x3); + return top; } -uint8_t css_computed_right( - const css_computed_style *style, +uint8_t css_computed_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_RIGHT_INDEX]; - bits &= CSS_RIGHT_MASK; - bits >>= CSS_RIGHT_SHIFT; + uint8_t position = css_computed_position(style); + uint8_t right = get_right(style, length, unit); /* Fix up, based on computed position */ - if (css_computed_position(style) == CSS_POSITION_STATIC) { + if (position == CSS_POSITION_STATIC) { /* Static -> auto */ - bits = CSS_RIGHT_AUTO; - } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) { + right = CSS_RIGHT_AUTO; + } else if (position == CSS_POSITION_RELATIVE) { /* Relative -> follow $9.4.3 */ - uint8_t left = style->bits[CSS_LEFT_INDEX]; - left &= CSS_LEFT_MASK; - left >>= CSS_LEFT_SHIFT; + uint8_t left = get_left_bits(style); - if ((bits & 0x3) == CSS_RIGHT_AUTO && - (left & 0x3) == CSS_LEFT_AUTO) { + if (right == CSS_RIGHT_AUTO && (left & 0x3) == CSS_LEFT_AUTO) { /* Both auto => 0px */ *length = 0; *unit = CSS_UNIT_PX; - } else if ((bits & 0x3) == CSS_RIGHT_AUTO) { + } else if (right == CSS_RIGHT_AUTO) { /* Right is auto => -left */ *length = -style->left; *unit = (css_unit) (left >> 2); } else { /** \todo Consider containing block's direction * if overconstrained */ - *length = style->right; - *unit = (css_unit) (bits >> 2); } - bits = CSS_RIGHT_SET; - } else if ((bits & 0x3) == CSS_RIGHT_SET) { - *length = style->right; - *unit = (css_unit) (bits >> 2); + right = CSS_RIGHT_SET; } - /* 6bits: uuuutt : units | type */ - return (bits & 0x3); + return right; } -uint8_t css_computed_bottom( - const css_computed_style *style, +uint8_t css_computed_bottom(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_BOTTOM_INDEX]; - bits &= CSS_BOTTOM_MASK; - bits >>= CSS_BOTTOM_SHIFT; + uint8_t position = css_computed_position(style); + uint8_t bottom = get_bottom(style, length, unit); /* Fix up, based on computed position */ - if (css_computed_position(style) == CSS_POSITION_STATIC) { + if (position == CSS_POSITION_STATIC) { /* Static -> auto */ - bits = CSS_BOTTOM_AUTO; - } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) { + bottom = CSS_BOTTOM_AUTO; + } else if (position == CSS_POSITION_RELATIVE) { /* Relative -> follow $9.4.3 */ - uint8_t top = style->bits[CSS_TOP_INDEX]; - top &= CSS_TOP_MASK; - top >>= CSS_TOP_SHIFT; + uint8_t top = get_top_bits(style); - if ((bits & 0x3) == CSS_BOTTOM_AUTO && - (top & 0x3) == CSS_TOP_AUTO) { + if (bottom == CSS_BOTTOM_AUTO && (top & 0x3) == CSS_TOP_AUTO) { /* Both auto => 0px */ *length = 0; *unit = CSS_UNIT_PX; - } else if ((bits & 0x3) == CSS_BOTTOM_AUTO || + } else if (bottom == CSS_BOTTOM_AUTO || (top & 0x3) != CSS_TOP_AUTO) { /* Bottom is auto or top is not auto => -top */ *length = -style->top; *unit = (css_unit) (top >> 2); - } else { - *length = style->bottom; - *unit = (css_unit) (bits >> 2); } - bits = CSS_BOTTOM_SET; - } else if ((bits & 0x3) == CSS_BOTTOM_SET) { - *length = style->bottom; - *unit = (css_unit) (bits >> 2); + bottom = CSS_BOTTOM_SET; } - /* 6bits: uuuutt : units | type */ - return (bits & 0x3); + return bottom; } -uint8_t css_computed_left( - const css_computed_style *style, +uint8_t css_computed_left(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_LEFT_INDEX]; - bits &= CSS_LEFT_MASK; - bits >>= CSS_LEFT_SHIFT; + uint8_t position = css_computed_position(style); + uint8_t left = get_left(style, length, unit); /* Fix up, based on computed position */ - if (css_computed_position(style) == CSS_POSITION_STATIC) { + if (position == CSS_POSITION_STATIC) { /* Static -> auto */ - bits = CSS_LEFT_AUTO; - } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) { + left = CSS_LEFT_AUTO; + } else if (position == CSS_POSITION_RELATIVE) { /* Relative -> follow $9.4.3 */ - uint8_t right = style->bits[CSS_RIGHT_INDEX]; - right &= CSS_RIGHT_MASK; - right >>= CSS_RIGHT_SHIFT; + uint8_t right = get_right_bits(style); - if ((bits & 0x3) == CSS_LEFT_AUTO && - (right & 0x3) == CSS_RIGHT_AUTO) { + if (left == CSS_LEFT_AUTO && (right & 0x3) == CSS_RIGHT_AUTO) { /* Both auto => 0px */ *length = 0; *unit = CSS_UNIT_PX; - } else if ((bits & 0x3) == CSS_LEFT_AUTO) { + } else if (left == CSS_LEFT_AUTO) { /* Left is auto => -right */ *length = -style->right; *unit = (css_unit) (right >> 2); } else { /** \todo Consider containing block's direction * if overconstrained */ - *length = style->left; - *unit = (css_unit) (bits >> 2); } - bits = CSS_LEFT_SET; - } else if ((bits & 0x3) == CSS_LEFT_SET) { - *length = style->left; - *unit = (css_unit) (bits >> 2); + left = CSS_LEFT_SET; } - /* 6bits: uuuutt : units | type */ - return (bits & 0x3); -} -#undef CSS_LEFT_MASK -#undef CSS_LEFT_SHIFT -#undef CSS_LEFT_INDEX -#undef CSS_BOTTOM_MASK -#undef CSS_BOTTOM_SHIFT -#undef CSS_BOTTOM_INDEX -#undef CSS_RIGHT_MASK -#undef CSS_RIGHT_SHIFT -#undef CSS_RIGHT_INDEX -#undef CSS_TOP_MASK -#undef CSS_TOP_SHIFT -#undef CSS_TOP_INDEX - -#define CSS_BORDER_TOP_COLOR_INDEX 6 -#define CSS_BORDER_TOP_COLOR_SHIFT 0 -#define CSS_BORDER_TOP_COLOR_MASK 0x3 -uint8_t css_computed_border_top_color( - const css_computed_style *style, + return left; +} + +uint8_t css_computed_border_top_color(const css_computed_style *style, css_color *color) { - uint8_t bits = style->bits[CSS_BORDER_TOP_COLOR_INDEX]; - bits &= CSS_BORDER_TOP_COLOR_MASK; - bits >>= CSS_BORDER_TOP_COLOR_SHIFT; - - /* 2bits: type */ - *color = style->border_color[0]; - - return bits; + return get_border_top_color(style, color); } -#undef CSS_BORDER_TOP_COLOR_MASK -#undef CSS_BORDER_TOP_COLOR_SHIFT -#undef CSS_BORDER_TOP_COLOR_INDEX -#define CSS_BORDER_RIGHT_COLOR_INDEX 7 -#define CSS_BORDER_RIGHT_COLOR_SHIFT 0 -#define CSS_BORDER_RIGHT_COLOR_MASK 0x3 -uint8_t css_computed_border_right_color( - const css_computed_style *style, +uint8_t css_computed_border_right_color(const css_computed_style *style, css_color *color) { - uint8_t bits = style->bits[CSS_BORDER_RIGHT_COLOR_INDEX]; - bits &= CSS_BORDER_RIGHT_COLOR_MASK; - bits >>= CSS_BORDER_RIGHT_COLOR_SHIFT; - - /* 2bits: type */ - *color = style->border_color[1]; - - return bits; + return get_border_right_color(style, color); } -#undef CSS_BORDER_RIGHT_COLOR_MASK -#undef CSS_BORDER_RIGHT_COLOR_SHIFT -#undef CSS_BORDER_RIGHT_COLOR_INDEX -#define CSS_BORDER_BOTTOM_COLOR_INDEX 8 -#define CSS_BORDER_BOTTOM_COLOR_SHIFT 0 -#define CSS_BORDER_BOTTOM_COLOR_MASK 0x3 -uint8_t css_computed_border_bottom_color( - const css_computed_style *style, +uint8_t css_computed_border_bottom_color(const css_computed_style *style, css_color *color) { - uint8_t bits = style->bits[CSS_BORDER_BOTTOM_COLOR_INDEX]; - bits &= CSS_BORDER_BOTTOM_COLOR_MASK; - bits >>= CSS_BORDER_BOTTOM_COLOR_SHIFT; - - /* 2bits: type */ - *color = style->border_color[2]; - - return bits; + return get_border_bottom_color(style, color); } -#undef CSS_BORDER_BOTTOM_COLOR_MASK -#undef CSS_BORDER_BOTTOM_COLOR_SHIFT -#undef CSS_BORDER_BOTTOM_COLOR_INDEX -#define CSS_BORDER_LEFT_COLOR_INDEX 9 -#define CSS_BORDER_LEFT_COLOR_SHIFT 0 -#define CSS_BORDER_LEFT_COLOR_MASK 0x3 -uint8_t css_computed_border_left_color( - const css_computed_style *style, +uint8_t css_computed_border_left_color(const css_computed_style *style, css_color *color) { - uint8_t bits = style->bits[CSS_BORDER_LEFT_COLOR_INDEX]; - bits &= CSS_BORDER_LEFT_COLOR_MASK; - bits >>= CSS_BORDER_LEFT_COLOR_SHIFT; - - /* 2bits: type */ - *color = style->border_color[3]; - - return bits; + return get_border_left_color(style, color); } -#undef CSS_BORDER_LEFT_COLOR_MASK -#undef CSS_BORDER_LEFT_COLOR_SHIFT -#undef CSS_BORDER_LEFT_COLOR_INDEX -#define CSS_HEIGHT_INDEX 10 -#define CSS_HEIGHT_SHIFT 2 -#define CSS_HEIGHT_MASK 0xfc -uint8_t css_computed_height( - const css_computed_style *style, +uint8_t css_computed_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_HEIGHT_INDEX]; - bits &= CSS_HEIGHT_MASK; - bits >>= CSS_HEIGHT_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_HEIGHT_SET) { - *length = style->height; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_height(style, length, unit); } -#undef CSS_HEIGHT_MASK -#undef CSS_HEIGHT_SHIFT -#undef CSS_HEIGHT_INDEX -#define CSS_LINE_HEIGHT_INDEX 11 -#define CSS_LINE_HEIGHT_SHIFT 2 -#define CSS_LINE_HEIGHT_MASK 0xfc -uint8_t css_computed_line_height( - const css_computed_style *style, +uint8_t css_computed_line_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_LINE_HEIGHT_INDEX]; - bits &= CSS_LINE_HEIGHT_MASK; - bits >>= CSS_LINE_HEIGHT_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_LINE_HEIGHT_NUMBER || - (bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) { - *length = style->line_height; - } - - if ((bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) { - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_line_height(style, length, unit); } -#undef CSS_LINE_HEIGHT_MASK -#undef CSS_LINE_HEIGHT_SHIFT -#undef CSS_LINE_HEIGHT_INDEX -#define CSS_BACKGROUND_COLOR_INDEX 10 -#define CSS_BACKGROUND_COLOR_SHIFT 0 -#define CSS_BACKGROUND_COLOR_MASK 0x3 -uint8_t css_computed_background_color( - const css_computed_style *style, +uint8_t css_computed_background_color(const css_computed_style *style, css_color *color) { - uint8_t bits = style->bits[CSS_BACKGROUND_COLOR_INDEX]; - bits &= CSS_BACKGROUND_COLOR_MASK; - bits >>= CSS_BACKGROUND_COLOR_SHIFT; - - /* 2bits: type */ - *color = style->background_color; - - return bits; + return get_background_color(style, color); } -#undef CSS_BACKGROUND_COLOR_MASK -#undef CSS_BACKGROUND_COLOR_SHIFT -#undef CSS_BACKGROUND_COLOR_INDEX -#define CSS_Z_INDEX_INDEX 11 -#define CSS_Z_INDEX_SHIFT 0 -#define CSS_Z_INDEX_MASK 0x3 -uint8_t css_computed_z_index( - const css_computed_style *style, +uint8_t css_computed_z_index(const css_computed_style *style, int32_t *z_index) { - uint8_t bits = style->bits[CSS_Z_INDEX_INDEX]; - bits &= CSS_Z_INDEX_MASK; - bits >>= CSS_Z_INDEX_SHIFT; - - /* 2bits: type */ - *z_index = style->z_index; - - return bits; + return get_z_index(style, z_index); } -#undef CSS_Z_INDEX_MASK -#undef CSS_Z_INDEX_SHIFT -#undef CSS_Z_INDEX_INDEX -#define CSS_MARGIN_TOP_INDEX 12 -#define CSS_MARGIN_TOP_SHIFT 2 -#define CSS_MARGIN_TOP_MASK 0xfc -uint8_t css_computed_margin_top( - const css_computed_style *style, +uint8_t css_computed_margin_top(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MARGIN_TOP_INDEX]; - bits &= CSS_MARGIN_TOP_MASK; - bits >>= CSS_MARGIN_TOP_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_MARGIN_SET) { - *length = style->margin[0]; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_margin_top(style, length, unit); } -#undef CSS_MARGIN_TOP_MASK -#undef CSS_MARGIN_TOP_SHIFT -#undef CSS_MARGIN_TOP_INDEX -#define CSS_MARGIN_RIGHT_INDEX 13 -#define CSS_MARGIN_RIGHT_SHIFT 2 -#define CSS_MARGIN_RIGHT_MASK 0xfc -uint8_t css_computed_margin_right( - const css_computed_style *style, +uint8_t css_computed_margin_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MARGIN_RIGHT_INDEX]; - bits &= CSS_MARGIN_RIGHT_MASK; - bits >>= CSS_MARGIN_RIGHT_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_MARGIN_SET) { - *length = style->margin[1]; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_margin_right(style, length, unit); } -#undef CSS_MARGIN_RIGHT_MASK -#undef CSS_MARGIN_RIGHT_SHIFT -#undef CSS_MARGIN_RIGHT_INDEX -#define CSS_MARGIN_BOTTOM_INDEX 14 -#define CSS_MARGIN_BOTTOM_SHIFT 2 -#define CSS_MARGIN_BOTTOM_MASK 0xfc -uint8_t css_computed_margin_bottom( - const css_computed_style *style, +uint8_t css_computed_margin_bottom(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MARGIN_BOTTOM_INDEX]; - bits &= CSS_MARGIN_BOTTOM_MASK; - bits >>= CSS_MARGIN_BOTTOM_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_MARGIN_SET) { - *length = style->margin[2]; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_margin_bottom(style, length, unit); } -#undef CSS_MARGIN_BOTTOM_MASK -#undef CSS_MARGIN_BOTTOM_SHIFT -#undef CSS_MARGIN_BOTTOM_INDEX -#define CSS_MARGIN_LEFT_INDEX 15 -#define CSS_MARGIN_LEFT_SHIFT 2 -#define CSS_MARGIN_LEFT_MASK 0xfc -uint8_t css_computed_margin_left( - const css_computed_style *style, +uint8_t css_computed_margin_left(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MARGIN_LEFT_INDEX]; - bits &= CSS_MARGIN_LEFT_MASK; - bits >>= CSS_MARGIN_LEFT_SHIFT; + return get_margin_left(style, length, unit); +} - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_MARGIN_SET) { - *length = style->margin[3]; - *unit = (css_unit) (bits >> 2); - } +uint8_t css_computed_background_attachment(const css_computed_style *style) +{ + return get_background_attachment(style); +} - return (bits & 0x3); -} -#undef CSS_MARGIN_LEFT_MASK -#undef CSS_MARGIN_LEFT_SHIFT -#undef CSS_MARGIN_LEFT_INDEX - -#define CSS_BACKGROUND_ATTACHMENT_INDEX 12 -#define CSS_BACKGROUND_ATTACHMENT_SHIFT 0 -#define CSS_BACKGROUND_ATTACHMENT_MASK 0x3 -uint8_t css_computed_background_attachment( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_BACKGROUND_ATTACHMENT_INDEX]; - bits &= CSS_BACKGROUND_ATTACHMENT_MASK; - bits >>= CSS_BACKGROUND_ATTACHMENT_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_BACKGROUND_ATTACHMENT_MASK -#undef CSS_BACKGROUND_ATTACHMENT_SHIFT -#undef CSS_BACKGROUND_ATTACHMENT_INDEX - -#define CSS_BORDER_COLLAPSE_INDEX 13 -#define CSS_BORDER_COLLAPSE_SHIFT 0 -#define CSS_BORDER_COLLAPSE_MASK 0x3 -uint8_t css_computed_border_collapse( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_BORDER_COLLAPSE_INDEX]; - bits &= CSS_BORDER_COLLAPSE_MASK; - bits >>= CSS_BORDER_COLLAPSE_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_BORDER_COLLAPSE_MASK -#undef CSS_BORDER_COLLAPSE_SHIFT -#undef CSS_BORDER_COLLAPSE_INDEX - -#define CSS_CAPTION_SIDE_INDEX 14 -#define CSS_CAPTION_SIDE_SHIFT 0 -#define CSS_CAPTION_SIDE_MASK 0x3 -uint8_t css_computed_caption_side( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_CAPTION_SIDE_INDEX]; - bits &= CSS_CAPTION_SIDE_MASK; - bits >>= CSS_CAPTION_SIDE_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_CAPTION_SIDE_MASK -#undef CSS_CAPTION_SIDE_SHIFT -#undef CSS_CAPTION_SIDE_INDEX - -#define CSS_DIRECTION_INDEX 15 -#define CSS_DIRECTION_SHIFT 0 -#define CSS_DIRECTION_MASK 0x3 -uint8_t css_computed_direction( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_DIRECTION_INDEX]; - bits &= CSS_DIRECTION_MASK; - bits >>= CSS_DIRECTION_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_DIRECTION_MASK -#undef CSS_DIRECTION_SHIFT -#undef CSS_DIRECTION_INDEX - -#define CSS_MAX_HEIGHT_INDEX 16 -#define CSS_MAX_HEIGHT_SHIFT 2 -#define CSS_MAX_HEIGHT_MASK 0xfc -uint8_t css_computed_max_height( - const css_computed_style *style, - css_fixed *length, css_unit *unit) +uint8_t css_computed_border_collapse(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_MAX_HEIGHT_INDEX]; - bits &= CSS_MAX_HEIGHT_MASK; - bits >>= CSS_MAX_HEIGHT_SHIFT; + return get_border_collapse(style); +} - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_MAX_HEIGHT_SET) { - *length = style->max_height; - *unit = (css_unit) (bits >> 2); - } +uint8_t css_computed_caption_side(const css_computed_style *style) +{ + return get_caption_side(style); +} - return (bits & 0x3); +uint8_t css_computed_direction(const css_computed_style *style) +{ + return get_direction(style); } -#undef CSS_MAX_HEIGHT_MASK -#undef CSS_MAX_HEIGHT_SHIFT -#undef CSS_MAX_HEIGHT_INDEX -#define CSS_MAX_WIDTH_INDEX 17 -#define CSS_MAX_WIDTH_SHIFT 2 -#define CSS_MAX_WIDTH_MASK 0xfc -uint8_t css_computed_max_width( - const css_computed_style *style, +uint8_t css_computed_max_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MAX_WIDTH_INDEX]; - bits &= CSS_MAX_WIDTH_MASK; - bits >>= CSS_MAX_WIDTH_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_MAX_WIDTH_SET) { - *length = style->max_width; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_max_height(style, length, unit); } -#undef CSS_MAX_WIDTH_MASK -#undef CSS_MAX_WIDTH_SHIFT -#undef CSS_MAX_WIDTH_INDEX -#define CSS_WIDTH_INDEX 18 -#define CSS_WIDTH_SHIFT 2 -#define CSS_WIDTH_MASK 0xfc -uint8_t css_computed_width( - const css_computed_style *style, +uint8_t css_computed_max_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_WIDTH_INDEX]; - bits &= CSS_WIDTH_MASK; - bits >>= CSS_WIDTH_SHIFT; - - /* 6bits: uuuutt : units | type */ - if ((bits & 0x3) == CSS_WIDTH_SET) { - *length = style->width; - *unit = (css_unit) (bits >> 2); - } - - return (bits & 0x3); + return get_max_width(style, length, unit); } -#undef CSS_WIDTH_MASK -#undef CSS_WIDTH_SHIFT -#undef CSS_WIDTH_INDEX -#define CSS_EMPTY_CELLS_INDEX 16 -#define CSS_EMPTY_CELLS_SHIFT 0 -#define CSS_EMPTY_CELLS_MASK 0x3 -uint8_t css_computed_empty_cells( - const css_computed_style *style) +uint8_t css_computed_width(const css_computed_style *style, + css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_EMPTY_CELLS_INDEX]; - bits &= CSS_EMPTY_CELLS_MASK; - bits >>= CSS_EMPTY_CELLS_SHIFT; + return get_width(style, length, unit); +} - /* 2bits: type */ - return bits; +uint8_t css_computed_empty_cells(const css_computed_style *style) +{ + return get_empty_cells(style); } -#undef CSS_EMPTY_CELLS_MASK -#undef CSS_EMPTY_CELLS_SHIFT -#undef CSS_EMPTY_CELLS_INDEX -#define CSS_FLOAT_INDEX 17 -#define CSS_FLOAT_SHIFT 0 -#define CSS_FLOAT_MASK 0x3 -uint8_t css_computed_float( - const css_computed_style *style) +uint8_t css_computed_float(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_FLOAT_INDEX]; - bits &= CSS_FLOAT_MASK; - bits >>= CSS_FLOAT_SHIFT; + uint8_t position = css_computed_position(style); + uint8_t value = get_float(style); /* Fix up as per $9.7:2 */ - if (css_computed_position(style) == CSS_POSITION_ABSOLUTE || - css_computed_position(style) == CSS_POSITION_FIXED) + if (position == CSS_POSITION_ABSOLUTE || + position == CSS_POSITION_FIXED) return CSS_FLOAT_NONE; - /* 2bits: type */ - return bits; + return value; } -#undef CSS_FLOAT_MASK -#undef CSS_FLOAT_SHIFT -#undef CSS_FLOAT_INDEX -#define CSS_FONT_STYLE_INDEX 18 -#define CSS_FONT_STYLE_SHIFT 0 -#define CSS_FONT_STYLE_MASK 0x3 -uint8_t css_computed_font_style( - const css_computed_style *style) +uint8_t css_computed_font_style(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_FONT_STYLE_INDEX]; - bits &= CSS_FONT_STYLE_MASK; - bits >>= CSS_FONT_STYLE_SHIFT; - - /* 2bits: type */ - return bits; + return get_font_style(style); } -#undef CSS_FONT_STYLE_MASK -#undef CSS_FONT_STYLE_SHIFT -#undef CSS_FONT_STYLE_INDEX -#define CSS_MIN_HEIGHT_INDEX 19 -#define CSS_MIN_HEIGHT_SHIFT 3 -#define CSS_MIN_HEIGHT_MASK 0xf8 -uint8_t css_computed_min_height( - const css_computed_style *style, +uint8_t css_computed_min_height(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MIN_HEIGHT_INDEX]; - bits &= CSS_MIN_HEIGHT_MASK; - bits >>= CSS_MIN_HEIGHT_SHIFT; - - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_MIN_HEIGHT_SET) { - *length = style->min_height; - *unit = (css_unit) (bits >> 1); - } - - return (bits & 0x1); + return get_min_height(style, length, unit); } -#undef CSS_MIN_HEIGHT_MASK -#undef CSS_MIN_HEIGHT_SHIFT -#undef CSS_MIN_HEIGHT_INDEX -#define CSS_MIN_WIDTH_INDEX 20 -#define CSS_MIN_WIDTH_SHIFT 3 -#define CSS_MIN_WIDTH_MASK 0xf8 -uint8_t css_computed_min_width( - const css_computed_style *style, +uint8_t css_computed_min_width(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_MIN_WIDTH_INDEX]; - bits &= CSS_MIN_WIDTH_MASK; - bits >>= CSS_MIN_WIDTH_SHIFT; - - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_MIN_WIDTH_SET) { - *length = style->min_width; - *unit = (css_unit) (bits >> 1); - } - - return (bits & 0x1); + return get_min_width(style, length, unit); } -#undef CSS_MIN_WIDTH_MASK -#undef CSS_MIN_WIDTH_SHIFT -#undef CSS_MIN_WIDTH_INDEX -#define CSS_BACKGROUND_REPEAT_INDEX 19 -#define CSS_BACKGROUND_REPEAT_SHIFT 0 -#define CSS_BACKGROUND_REPEAT_MASK 0x7 -uint8_t css_computed_background_repeat( - const css_computed_style *style) +uint8_t css_computed_background_repeat(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_BACKGROUND_REPEAT_INDEX]; - bits &= CSS_BACKGROUND_REPEAT_MASK; - bits >>= CSS_BACKGROUND_REPEAT_SHIFT; - - /* 3bits: type */ - return bits; + return get_background_repeat(style); } -#undef CSS_BACKGROUND_REPEAT_MASK -#undef CSS_BACKGROUND_REPEAT_SHIFT -#undef CSS_BACKGROUND_REPEAT_INDEX -#define CSS_CLEAR_INDEX 20 -#define CSS_CLEAR_SHIFT 0 -#define CSS_CLEAR_MASK 0x7 -uint8_t css_computed_clear( - const css_computed_style *style) +uint8_t css_computed_clear(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_CLEAR_INDEX]; - bits &= CSS_CLEAR_MASK; - bits >>= CSS_CLEAR_SHIFT; - - /* 3bits: type */ - return bits; + return get_clear(style); } -#undef CSS_CLEAR_MASK -#undef CSS_CLEAR_SHIFT -#undef CSS_CLEAR_INDEX -#define CSS_PADDING_TOP_INDEX 21 -#define CSS_PADDING_TOP_SHIFT 3 -#define CSS_PADDING_TOP_MASK 0xf8 -uint8_t css_computed_padding_top( - const css_computed_style *style, +uint8_t css_computed_padding_top(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_PADDING_TOP_INDEX]; - bits &= CSS_PADDING_TOP_MASK; - bits >>= CSS_PADDING_TOP_SHIFT; - - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_PADDING_SET) { - *length = style->padding[0]; - *unit = (css_unit) (bits >> 1); - } - - return (bits & 0x1); + return get_padding_top(style, length, unit); } -#undef CSS_PADDING_TOP_MASK -#undef CSS_PADDING_TOP_SHIFT -#undef CSS_PADDING_TOP_INDEX -#define CSS_PADDING_RIGHT_INDEX 22 -#define CSS_PADDING_RIGHT_SHIFT 3 -#define CSS_PADDING_RIGHT_MASK 0xf8 -uint8_t css_computed_padding_right( - const css_computed_style *style, +uint8_t css_computed_padding_right(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_PADDING_RIGHT_INDEX]; - bits &= CSS_PADDING_RIGHT_MASK; - bits >>= CSS_PADDING_RIGHT_SHIFT; - - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_PADDING_SET) { - *length = style->padding[1]; - *unit = (css_unit) (bits >> 1); - } - - return (bits & 0x1); + return get_padding_right(style, length, unit); } -#undef CSS_PADDING_RIGHT_MASK -#undef CSS_PADDING_RIGHT_SHIFT -#undef CSS_PADDING_RIGHT_INDEX -#define CSS_PADDING_BOTTOM_INDEX 23 -#define CSS_PADDING_BOTTOM_SHIFT 3 -#define CSS_PADDING_BOTTOM_MASK 0xf8 -uint8_t css_computed_padding_bottom( - const css_computed_style *style, +uint8_t css_computed_padding_bottom(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_PADDING_BOTTOM_INDEX]; - bits &= CSS_PADDING_BOTTOM_MASK; - bits >>= CSS_PADDING_BOTTOM_SHIFT; - - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_PADDING_SET) { - *length = style->padding[2]; - *unit = (css_unit) (bits >> 1); - } - - return (bits & 0x1); + return get_padding_bottom(style, length, unit); } -#undef CSS_PADDING_BOTTOM_MASK -#undef CSS_PADDING_BOTTOM_SHIFT -#undef CSS_PADDING_BOTTOM_INDEX -#define CSS_PADDING_LEFT_INDEX 24 -#define CSS_PADDING_LEFT_SHIFT 3 -#define CSS_PADDING_LEFT_MASK 0xf8 -uint8_t css_computed_padding_left( - const css_computed_style *style, +uint8_t css_computed_padding_left(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_PADDING_LEFT_INDEX]; - bits &= CSS_PADDING_LEFT_MASK; - bits >>= CSS_PADDING_LEFT_SHIFT; - - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_PADDING_SET) { - *length = style->padding[3]; - *unit = (css_unit) (bits >> 1); - } - - return (bits & 0x1); + return get_padding_left(style, length, unit); } -#undef CSS_PADDING_LEFT_MASK -#undef CSS_PADDING_LEFT_SHIFT -#undef CSS_PADDING_LEFT_INDEX -#define CSS_OVERFLOW_INDEX 21 -#define CSS_OVERFLOW_SHIFT 0 -#define CSS_OVERFLOW_MASK 0x7 -uint8_t css_computed_overflow( - const css_computed_style *style) +uint8_t css_computed_overflow(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_OVERFLOW_INDEX]; - bits &= CSS_OVERFLOW_MASK; - bits >>= CSS_OVERFLOW_SHIFT; - - /* 3bits: type */ - return bits; + return get_overflow(style); } -#undef CSS_OVERFLOW_MASK -#undef CSS_OVERFLOW_SHIFT -#undef CSS_OVERFLOW_INDEX -#define CSS_POSITION_INDEX 22 -#define CSS_POSITION_SHIFT 0 -#define CSS_POSITION_MASK 0x7 -uint8_t css_computed_position( - const css_computed_style *style) +uint8_t css_computed_position(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_POSITION_INDEX]; - bits &= CSS_POSITION_MASK; - bits >>= CSS_POSITION_SHIFT; - - /* 3bits: type */ - return bits; + return get_position(style); } -#undef CSS_POSITION_MASK -#undef CSS_POSITION_SHIFT -#undef CSS_POSITION_INDEX -#define CSS_OPACITY_INDEX 23 -#define CSS_OPACITY_SHIFT 2 -#define CSS_OPACITY_MASK 0x04 -uint8_t css_computed_opacity( - const css_computed_style *style, +uint8_t css_computed_opacity(const css_computed_style *style, css_fixed *opacity) { - uint8_t bits = style->bits[CSS_OPACITY_INDEX]; - bits &= CSS_OPACITY_MASK; - bits >>= CSS_OPACITY_SHIFT; - - /* 1bit: t : type */ - if ((bits & 0x1) == CSS_OPACITY_SET) { - *opacity = style->opacity; - } - - return (bits & 0x1); + return get_opacity(style, opacity); } -#undef CSS_OPACITY_MASK -#undef CSS_OPACITY_SHIFT -#undef CSS_OPACITY_INDEX -#define CSS_TEXT_TRANSFORM_INDEX 24 -#define CSS_TEXT_TRANSFORM_SHIFT 0 -#define CSS_TEXT_TRANSFORM_MASK 0x7 -uint8_t css_computed_text_transform( - const css_computed_style *style) +uint8_t css_computed_text_transform(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_TEXT_TRANSFORM_INDEX]; - bits &= CSS_TEXT_TRANSFORM_MASK; - bits >>= CSS_TEXT_TRANSFORM_SHIFT; - - /* 3bits: type */ - return bits; + return get_text_transform(style); } -#undef CSS_TEXT_TRANSFORM_MASK -#undef CSS_TEXT_TRANSFORM_SHIFT -#undef CSS_TEXT_TRANSFORM_INDEX -#define CSS_TEXT_INDENT_INDEX 25 -#define CSS_TEXT_INDENT_SHIFT 3 -#define CSS_TEXT_INDENT_MASK 0xf8 -uint8_t css_computed_text_indent( - const css_computed_style *style, +uint8_t css_computed_text_indent(const css_computed_style *style, css_fixed *length, css_unit *unit) { - uint8_t bits = style->bits[CSS_TEXT_INDENT_INDEX]; - bits &= CSS_TEXT_INDENT_MASK; - bits >>= CSS_TEXT_INDENT_SHIFT; + return get_text_indent(style, length, unit); +} - /* 5bits: uuuut : units | type */ - if ((bits & 0x1) == CSS_TEXT_INDENT_SET) { - *length = style->text_indent; - *unit = (css_unit) (bits >> 1); - } +uint8_t css_computed_white_space(const css_computed_style *style) +{ + return get_white_space(style); +} - return (bits & 0x1); -} -#undef CSS_TEXT_INDENT_MASK -#undef CSS_TEXT_INDENT_SHIFT -#undef CSS_TEXT_INDENT_INDEX - -#define CSS_WHITE_SPACE_INDEX 25 -#define CSS_WHITE_SPACE_SHIFT 0 -#define CSS_WHITE_SPACE_MASK 0x7 -uint8_t css_computed_white_space( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_WHITE_SPACE_INDEX]; - bits &= CSS_WHITE_SPACE_MASK; - bits >>= CSS_WHITE_SPACE_SHIFT; - - /* 3bits: type */ - return bits; -} -#undef CSS_WHITE_SPACE_MASK -#undef CSS_WHITE_SPACE_SHIFT -#undef CSS_WHITE_SPACE_INDEX - -#define CSS_BACKGROUND_POSITION_INDEX 27 -#define CSS_BACKGROUND_POSITION_SHIFT 7 -#define CSS_BACKGROUND_POSITION_MASK 0x80 -#define CSS_BACKGROUND_POSITION_INDEX1 26 -#define CSS_BACKGROUND_POSITION_SHIFT1 0 -#define CSS_BACKGROUND_POSITION_MASK1 0xff -uint8_t css_computed_background_position( - const css_computed_style *style, +uint8_t css_computed_background_position(const css_computed_style *style, css_fixed *hlength, css_unit *hunit, css_fixed *vlength, css_unit *vunit) { - uint8_t bits = style->bits[CSS_BACKGROUND_POSITION_INDEX]; - bits &= CSS_BACKGROUND_POSITION_MASK; - bits >>= CSS_BACKGROUND_POSITION_SHIFT; - - /* 1bit: type */ - if (bits == CSS_BACKGROUND_POSITION_SET) { - uint8_t bits1 = style->bits[CSS_BACKGROUND_POSITION_INDEX1]; - bits1 &= CSS_BACKGROUND_POSITION_MASK1; - bits1 >>= CSS_BACKGROUND_POSITION_SHIFT1; - - /* 8bits: hhhhvvvv : hunit | vunit */ - *hlength = style->background_position[0]; - *hunit = (css_unit) (bits1 >> 4); - - *vlength = style->background_position[1]; - *vunit = (css_unit) (bits1 & 0xf); - } - - return bits; + return get_background_position(style, hlength, hunit, vlength, vunit); } -#undef CSS_BACKGROUND_POSITION_MASK1 -#undef CSS_BACKGROUND_POSITION_SHIFT1 -#undef CSS_BACKGROUND_POSITION_INDEX1 -#undef CSS_BACKGROUND_POSITION_MASK -#undef CSS_BACKGROUND_POSITION_SHIFT -#undef CSS_BACKGROUND_POSITION_INDEX -#define CSS_DISPLAY_INDEX 27 -#define CSS_DISPLAY_SHIFT 2 -#define CSS_DISPLAY_MASK 0x7c -uint8_t css_computed_display( - const css_computed_style *style, bool root) +uint8_t css_computed_display(const css_computed_style *style, + bool root) { - uint8_t position; - uint8_t bits = style->bits[CSS_DISPLAY_INDEX]; - bits &= CSS_DISPLAY_MASK; - bits >>= CSS_DISPLAY_SHIFT; + uint8_t position = css_computed_position(style); + uint8_t display = get_display(style); /* Return computed display as per $9.7 */ - position = css_computed_position(style); - /* 5bits: type */ - if (bits == CSS_DISPLAY_NONE) - return bits; /* 1. */ + if (display == CSS_DISPLAY_NONE) + return display; /* 1. */ if ((position == CSS_POSITION_ABSOLUTE || position == CSS_POSITION_FIXED) /* 2. */ || css_computed_float(style) != CSS_FLOAT_NONE /* 3. */ || root /* 4. */) { - if (bits == CSS_DISPLAY_INLINE_TABLE) { + if (display == CSS_DISPLAY_INLINE_TABLE) { return CSS_DISPLAY_TABLE; - } else if (bits == CSS_DISPLAY_INLINE || - bits == CSS_DISPLAY_RUN_IN || - bits == CSS_DISPLAY_TABLE_ROW_GROUP || - bits == CSS_DISPLAY_TABLE_COLUMN || - bits == CSS_DISPLAY_TABLE_COLUMN_GROUP || - bits == CSS_DISPLAY_TABLE_HEADER_GROUP || - bits == CSS_DISPLAY_TABLE_FOOTER_GROUP || - bits == CSS_DISPLAY_TABLE_ROW || - bits == CSS_DISPLAY_TABLE_CELL || - bits == CSS_DISPLAY_TABLE_CAPTION || - bits == CSS_DISPLAY_INLINE_BLOCK) { + } else if (display == CSS_DISPLAY_INLINE || + display == CSS_DISPLAY_RUN_IN || + display == CSS_DISPLAY_TABLE_ROW_GROUP || + display == CSS_DISPLAY_TABLE_COLUMN || + display == CSS_DISPLAY_TABLE_COLUMN_GROUP || + display == CSS_DISPLAY_TABLE_HEADER_GROUP || + display == CSS_DISPLAY_TABLE_FOOTER_GROUP || + display == CSS_DISPLAY_TABLE_ROW || + display == CSS_DISPLAY_TABLE_CELL || + display == CSS_DISPLAY_TABLE_CAPTION || + display == CSS_DISPLAY_INLINE_BLOCK) { return CSS_DISPLAY_BLOCK; } } /* 5. */ - return bits; + return display; } -uint8_t css_computed_display_static( - const css_computed_style *style) +uint8_t css_computed_display_static(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_DISPLAY_INDEX]; - bits &= CSS_DISPLAY_MASK; - bits >>= CSS_DISPLAY_SHIFT; - - /* 5bits: type */ - return bits; + return get_display(style); } -#undef CSS_DISPLAY_MASK -#undef CSS_DISPLAY_SHIFT -#undef CSS_DISPLAY_INDEX - -#define CSS_FONT_VARIANT_INDEX 27 -#define CSS_FONT_VARIANT_SHIFT 0 -#define CSS_FONT_VARIANT_MASK 0x3 -uint8_t css_computed_font_variant( - const css_computed_style *style) +uint8_t css_computed_font_variant(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_FONT_VARIANT_INDEX]; - bits &= CSS_FONT_VARIANT_MASK; - bits >>= CSS_FONT_VARIANT_SHIFT; - - /* 2bits: type */ - return bits; + return get_font_variant(style); } -#undef CSS_FONT_VARIANT_MASK -#undef CSS_FONT_VARIANT_SHIFT -#undef CSS_FONT_VARIANT_INDEX -#define CSS_TEXT_DECORATION_INDEX 28 -#define CSS_TEXT_DECORATION_SHIFT 3 -#define CSS_TEXT_DECORATION_MASK 0xf8 -uint8_t css_computed_text_decoration( - const css_computed_style *style) +uint8_t css_computed_text_decoration(const css_computed_style *style) { - uint8_t bits = style->bits[CSS_TEXT_DECORATION_INDEX]; - bits &= CSS_TEXT_DECORATION_MASK; - bits >>= CSS_TEXT_DECORATION_SHIFT; - - /* 5bits: type */ - return bits; + return get_text_decoration(style); } -#undef CSS_TEXT_DECORATION_MASK -#undef CSS_TEXT_DECORATION_SHIFT -#undef CSS_TEXT_DECORATION_INDEX -#define CSS_FONT_FAMILY_INDEX 28 -#define CSS_FONT_FAMILY_SHIFT 0 -#define CSS_FONT_FAMILY_MASK 0x7 -uint8_t css_computed_font_family( - const css_computed_style *style, +uint8_t css_computed_font_family(const css_computed_style *style, lwc_string ***names) { - uint8_t bits = style->bits[CSS_FONT_FAMILY_INDEX]; - bits &= CSS_FONT_FAMILY_MASK; - bits >>= CSS_FONT_FAMILY_SHIFT; + return get_font_family(style, names); +} - /* 3bits: type */ - *names = style->font_family; - - return bits; +uint8_t css_computed_border_top_style(const css_computed_style *style) +{ + return get_border_top_style(style); } -#undef CSS_FONT_FAMILY_MASK -#undef CSS_FONT_FAMILY_SHIFT -#undef CSS_FONT_FAMILY_INDEX -#define CSS_BORDER_TOP_STYLE_INDEX 29 -#define CSS_BORDER_TOP_STYLE_SHIFT 4 -#define CSS_BORDER_TOP_STYLE_MASK 0xf0 -uint8_t css_computed_border_top_style( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_BORDER_TOP_STYLE_INDEX]; - bits &= CSS_BORDER_TOP_STYLE_MASK; - bits >>= CSS_BORDER_TOP_STYLE_SHIFT; - - /* 4bits: type */ - return bits; +uint8_t css_computed_border_right_style(const css_computed_style *style) +{ + return get_border_right_style(style); } -#undef CSS_BORDER_TOP_STYLE_MASK -#undef CSS_BORDER_TOP_STYLE_SHIFT -#undef CSS_BORDER_TOP_STYLE_INDEX -#define CSS_BORDER_RIGHT_STYLE_INDEX 29 -#define CSS_BORDER_RIGHT_STYLE_SHIFT 0 -#define CSS_BORDER_RIGHT_STYLE_MASK 0xf -uint8_t css_computed_border_right_style( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_BORDER_RIGHT_STYLE_INDEX]; - bits &= CSS_BORDER_RIGHT_STYLE_MASK; - bits >>= CSS_BORDER_RIGHT_STYLE_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_BORDER_RIGHT_STYLE_MASK -#undef CSS_BORDER_RIGHT_STYLE_SHIFT -#undef CSS_BORDER_RIGHT_STYLE_INDEX - -#define CSS_BORDER_BOTTOM_STYLE_INDEX 30 -#define CSS_BORDER_BOTTOM_STYLE_SHIFT 4 -#define CSS_BORDER_BOTTOM_STYLE_MASK 0xf0 -uint8_t css_computed_border_bottom_style( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_BORDER_BOTTOM_STYLE_INDEX]; - bits &= CSS_BORDER_BOTTOM_STYLE_MASK; - bits >>= CSS_BORDER_BOTTOM_STYLE_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_BORDER_BOTTOM_STYLE_MASK -#undef CSS_BORDER_BOTTOM_STYLE_SHIFT -#undef CSS_BORDER_BOTTOM_STYLE_INDEX - -#define CSS_BORDER_LEFT_STYLE_INDEX 30 -#define CSS_BORDER_LEFT_STYLE_SHIFT 0 -#define CSS_BORDER_LEFT_STYLE_MASK 0xf -uint8_t css_computed_border_left_style( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_BORDER_LEFT_STYLE_INDEX]; - bits &= CSS_BORDER_LEFT_STYLE_MASK; - bits >>= CSS_BORDER_LEFT_STYLE_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_BORDER_LEFT_STYLE_MASK -#undef CSS_BORDER_LEFT_STYLE_SHIFT -#undef CSS_BORDER_LEFT_STYLE_INDEX - -#define CSS_FONT_WEIGHT_INDEX 31 -#define CSS_FONT_WEIGHT_SHIFT 4 -#define CSS_FONT_WEIGHT_MASK 0xf0 -uint8_t css_computed_font_weight( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_FONT_WEIGHT_INDEX]; - bits &= CSS_FONT_WEIGHT_MASK; - bits >>= CSS_FONT_WEIGHT_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_FONT_WEIGHT_MASK -#undef CSS_FONT_WEIGHT_SHIFT -#undef CSS_FONT_WEIGHT_INDEX - -#define CSS_LIST_STYLE_TYPE_INDEX 31 -#define CSS_LIST_STYLE_TYPE_SHIFT 0 -#define CSS_LIST_STYLE_TYPE_MASK 0xf -uint8_t css_computed_list_style_type( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_LIST_STYLE_TYPE_INDEX]; - bits &= CSS_LIST_STYLE_TYPE_MASK; - bits >>= CSS_LIST_STYLE_TYPE_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_LIST_STYLE_TYPE_MASK -#undef CSS_LIST_STYLE_TYPE_SHIFT -#undef CSS_LIST_STYLE_TYPE_INDEX - -#define CSS_OUTLINE_STYLE_INDEX 32 -#define CSS_OUTLINE_STYLE_SHIFT 4 -#define CSS_OUTLINE_STYLE_MASK 0xf0 -uint8_t css_computed_outline_style( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_OUTLINE_STYLE_INDEX]; - bits &= CSS_OUTLINE_STYLE_MASK; - bits >>= CSS_OUTLINE_STYLE_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_OUTLINE_STYLE_MASK -#undef CSS_OUTLINE_STYLE_SHIFT -#undef CSS_OUTLINE_STYLE_INDEX - -#define CSS_TABLE_LAYOUT_INDEX 32 -#define CSS_TABLE_LAYOUT_SHIFT 2 -#define CSS_TABLE_LAYOUT_MASK 0xc -uint8_t css_computed_table_layout( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_TABLE_LAYOUT_INDEX]; - bits &= CSS_TABLE_LAYOUT_MASK; - bits >>= CSS_TABLE_LAYOUT_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_TABLE_LAYOUT_MASK -#undef CSS_TABLE_LAYOUT_SHIFT -#undef CSS_TABLE_LAYOUT_INDEX - -#define CSS_UNICODE_BIDI_INDEX 32 -#define CSS_UNICODE_BIDI_SHIFT 0 -#define CSS_UNICODE_BIDI_MASK 0x3 -uint8_t css_computed_unicode_bidi( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_UNICODE_BIDI_INDEX]; - bits &= CSS_UNICODE_BIDI_MASK; - bits >>= CSS_UNICODE_BIDI_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_UNICODE_BIDI_MASK -#undef CSS_UNICODE_BIDI_SHIFT -#undef CSS_UNICODE_BIDI_INDEX - -#define CSS_VISIBILITY_INDEX 33 -#define CSS_VISIBILITY_SHIFT 6 -#define CSS_VISIBILITY_MASK 0xc0 -uint8_t css_computed_visibility( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_VISIBILITY_INDEX]; - bits &= CSS_VISIBILITY_MASK; - bits >>= CSS_VISIBILITY_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_VISIBILITY_MASK -#undef CSS_VISIBILITY_SHIFT -#undef CSS_VISIBILITY_INDEX - -#define CSS_LIST_STYLE_POSITION_INDEX 33 -#define CSS_LIST_STYLE_POSITION_SHIFT 4 -#define CSS_LIST_STYLE_POSITION_MASK 0x30 -uint8_t css_computed_list_style_position( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_LIST_STYLE_POSITION_INDEX]; - bits &= CSS_LIST_STYLE_POSITION_MASK; - bits >>= CSS_LIST_STYLE_POSITION_SHIFT; - - /* 2bits: type */ - return bits; -} -#undef CSS_LIST_STYLE_POSITION_MASK -#undef CSS_LIST_STYLE_POSITION_SHIFT -#undef CSS_LIST_STYLE_POSITION_INDEX - -#define CSS_TEXT_ALIGN_INDEX 33 -#define CSS_TEXT_ALIGN_SHIFT 0 -#define CSS_TEXT_ALIGN_MASK 0xf -uint8_t css_computed_text_align( - const css_computed_style *style) -{ - uint8_t bits = style->bits[CSS_TEXT_ALIGN_INDEX]; - bits &= CSS_TEXT_ALIGN_MASK; - bits >>= CSS_TEXT_ALIGN_SHIFT; - - /* 4bits: type */ - return bits; -} -#undef CSS_TEXT_ALIGN_MASK -#undef CSS_TEXT_ALIGN_SHIFT -#undef CSS_TEXT_ALIGN_INDEX - -#define CSS_PAGE_BREAK_AFTER_INDEX 0 -#define CSS_PAGE_BREAK_AFTER_SHIFT 0 -#define CSS_PAGE_BREAK_AFTER_MASK 0x7 -uint8_t css_computed_page_break_after( - const css_computed_style *style) +uint8_t css_computed_border_bottom_style(const css_computed_style *style) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_PAGE_BREAK_AFTER_INDEX]; - bits &= CSS_PAGE_BREAK_AFTER_MASK; - bits >>= CSS_PAGE_BREAK_AFTER_SHIFT; - - /* 3bits: type */ - return bits; - } - - return CSS_PAGE_BREAK_AFTER_AUTO; + return get_border_bottom_style(style); } -#undef CSS_PAGE_BREAK_AFTER_MASK -#undef CSS_PAGE_BREAK_AFTER_SHIFT -#undef CSS_PAGE_BREAK_AFTER_INDEX - -#define CSS_PAGE_BREAK_BEFORE_INDEX 0 -#define CSS_PAGE_BREAK_BEFORE_SHIFT 3 -#define CSS_PAGE_BREAK_BEFORE_MASK 0x38 -uint8_t css_computed_page_break_before( - const css_computed_style *style) + +uint8_t css_computed_border_left_style(const css_computed_style *style) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_PAGE_BREAK_BEFORE_INDEX]; - bits &= CSS_PAGE_BREAK_BEFORE_MASK; - bits >>= CSS_PAGE_BREAK_BEFORE_SHIFT; - - /* 3bits: type */ - return bits; - } - - return CSS_PAGE_BREAK_BEFORE_AUTO; + return get_border_left_style(style); } -#undef CSS_PAGE_BREAK_BEFORE_MASK -#undef CSS_PAGE_BREAK_BEFORE_SHIFT -#undef CSS_PAGE_BREAK_BEFORE_INDEX - -#define CSS_PAGE_BREAK_INSIDE_INDEX 0 -#define CSS_PAGE_BREAK_INSIDE_SHIFT 6 -#define CSS_PAGE_BREAK_INSIDE_MASK 0xc0 -uint8_t css_computed_page_break_inside( - const css_computed_style *style) + +uint8_t css_computed_font_weight(const css_computed_style *style) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_PAGE_BREAK_INSIDE_INDEX]; - bits &= CSS_PAGE_BREAK_INSIDE_MASK; - bits >>= CSS_PAGE_BREAK_INSIDE_SHIFT; - - /* 2bits: type */ - return bits; - } - - return CSS_PAGE_BREAK_INSIDE_AUTO; + return get_font_weight(style); } -#undef CSS_PAGE_BREAK_INSIDE_MASK -#undef CSS_PAGE_BREAK_INSIDE_SHIFT -#undef CSS_PAGE_BREAK_INSIDE_INDEX -#define CSS_ORPHANS_INDEX 1 -#define CSS_ORPHANS_SHIFT 0 -#define CSS_ORPHANS_MASK 0x1 -uint8_t css_computed_orphans( - const css_computed_style *style, - int32_t *orphans) +uint8_t css_computed_list_style_type(const css_computed_style *style) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_ORPHANS_INDEX]; - bits &= CSS_ORPHANS_MASK; - bits >>= CSS_ORPHANS_SHIFT; + return get_list_style_type(style); +} - *orphans = FIXTOINT(style->page->orphans);; +uint8_t css_computed_outline_style(const css_computed_style *style) +{ + return get_outline_style(style); +} - /* 1bit: type */ - return bits; - } +uint8_t css_computed_table_layout(const css_computed_style *style) +{ + return get_table_layout(style); +} - /* Use initial value */ - *orphans = 2; +uint8_t css_computed_unicode_bidi(const css_computed_style *style) +{ + return get_unicode_bidi(style); +} - return CSS_ORPHANS_SET; +uint8_t css_computed_visibility(const css_computed_style *style) +{ + return get_visibility(style); } -#undef CSS_ORPHANS_MASK -#undef CSS_ORPHANS_SHIFT -#undef CSS_ORPHANS_INDEX -#define CSS_WIDOWS_INDEX 1 -#define CSS_WIDOWS_SHIFT 1 -#define CSS_WIDOWS_MASK 0x2 -uint8_t css_computed_widows( - const css_computed_style *style, - int32_t *widows) +uint8_t css_computed_list_style_position(const css_computed_style *style) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_WIDOWS_INDEX]; - bits &= CSS_WIDOWS_MASK; - bits >>= CSS_WIDOWS_SHIFT; + return get_list_style_position(style); +} - *widows = FIXTOINT(style->page->widows); +uint8_t css_computed_text_align(const css_computed_style *style) +{ + return get_text_align(style); +} - /* 1bit: type */ - return bits; - } +uint8_t css_computed_page_break_after(const css_computed_style *style) +{ + return get_page_break_after(style); +} + +uint8_t css_computed_page_break_before(const css_computed_style *style) +{ + return get_page_break_before(style); +} + +uint8_t css_computed_page_break_inside(const css_computed_style *style) +{ + return get_page_break_inside(style); +} - /* Use initial value */ - *widows = 2; +uint8_t css_computed_orphans(const css_computed_style *style, + int32_t *orphans) +{ + return get_orphans(style, orphans); +} - return CSS_WIDOWS_SET; +uint8_t css_computed_widows(const css_computed_style *style, + int32_t *widows) +{ + return get_widows(style, widows); } -#undef CSS_WIDOWS_MASK -#undef CSS_WIDOWS_SHIFT -#undef CSS_WIDOWS_INDEX /****************************************************************************** diff --git a/src/select/computed.h b/src/select/computed.h index bfa0f52..0248920 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -95,8 +95,8 @@ typedef struct css_computed_page { */ uint8_t bits[2]; - css_fixed widows; - css_fixed orphans; + int32_t widows; + int32_t orphans; } css_computed_page; struct css_computed_style { diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile index eacc240..8905695 100644 --- a/src/select/properties/Makefile +++ b/src/select/properties/Makefile @@ -107,8 +107,8 @@ visibility.c \ voice_family.c \ volume.c \ white_space.c \ +widows.c \ width.c \ -windows.c \ word_spacing.c \ writing_mode.c \ z_index.c diff --git a/src/select/properties/display.c b/src/select/properties/display.c index 02f5e1e..e5e7711 100644 --- a/src/select/properties/display.c +++ b/src/select/properties/display.c @@ -97,10 +97,10 @@ css_error css__compose_display(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - uint8_t type = get_display_static(child); + uint8_t type = get_display(child); if (type == CSS_DISPLAY_INHERIT) { - type = get_display_static(parent); + type = get_display(parent); } return set_display(result, type); diff --git a/src/select/properties/orphans.c b/src/select/properties/orphans.c index 265c6f5..d5c4937 100644 --- a/src/select/properties/orphans.c +++ b/src/select/properties/orphans.c @@ -23,19 +23,19 @@ css_error css__cascade_orphans(uint32_t opv, css_style *style, css_error css__set_orphans_from_hint(const css_hint *hint, css_computed_style *style) { - return set_orphans(style, hint->status, hint->data.fixed); + return set_orphans(style, hint->status, hint->data.integer); } css_error css__initial_orphans(css_select_state *state) { - return set_orphans(state->computed, CSS_ORPHANS_SET, INTTOFIX(2)); + return set_orphans(state->computed, CSS_ORPHANS_SET, 2); } css_error css__compose_orphans(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - css_fixed count = 0; + int32_t count = 0; uint8_t type = get_orphans(child, &count); if (type == CSS_ORPHANS_INHERIT) { diff --git a/src/select/properties/windows.c b/src/select/properties/widows.c index 3f568cb..916966a 100644 --- a/src/select/properties/windows.c +++ b/src/select/properties/widows.c @@ -23,19 +23,19 @@ css_error css__cascade_widows(uint32_t opv, css_style *style, css_error css__set_widows_from_hint(const css_hint *hint, css_computed_style *style) { - return set_widows(style, hint->status, hint->data.fixed); + return set_widows(style, hint->status, hint->data.integer); } css_error css__initial_widows(css_select_state *state) { - return set_widows(state->computed, CSS_WIDOWS_SET, INTTOFIX(2)); + return set_widows(state->computed, CSS_WIDOWS_SET, 2); } css_error css__compose_widows(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - css_fixed count = 0; + int32_t count = 0; uint8_t type = get_widows(child, &count); if (type == CSS_WIDOWS_INHERIT) { diff --git a/src/select/propget.h b/src/select/propget.h index 16b8fc2..7fff136 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -184,6 +184,8 @@ static inline uint8_t get_writing_mode( uint8_t bits = style->uncommon->bits[WRITING_MODE_INDEX]; bits &= WRITING_MODE_MASK; bits >>= WRITING_MODE_SHIFT; + + /* 2bits: type */ return bits; } @@ -601,6 +603,16 @@ static inline uint8_t get_top( return (bits & 0x3); } +static inline uint8_t get_top_bits( + const css_computed_style *style) +{ + uint8_t bits = style->bits[TOP_INDEX]; + bits &= TOP_MASK; + bits >>= TOP_SHIFT; + + /* 6bits: uuuutt : units | type */ + return bits; +} #undef TOP_MASK #undef TOP_SHIFT #undef TOP_INDEX @@ -624,6 +636,16 @@ static inline uint8_t get_right( return (bits & 0x3); } +static inline uint8_t get_right_bits( + const css_computed_style *style) +{ + uint8_t bits = style->bits[RIGHT_INDEX]; + bits &= RIGHT_MASK; + bits >>= RIGHT_SHIFT; + + /* 6bits: uuuutt : units | type */ + return bits; +} #undef RIGHT_MASK #undef RIGHT_SHIFT #undef RIGHT_INDEX @@ -647,6 +669,16 @@ static inline uint8_t get_bottom( return (bits & 0x3); } +static inline uint8_t get_bottom_bits( + const css_computed_style *style) +{ + uint8_t bits = style->bits[BOTTOM_INDEX]; + bits &= BOTTOM_MASK; + bits >>= BOTTOM_SHIFT; + + /* 6bits: uuuutt : units | type */ + return bits; +} #undef BOTTOM_MASK #undef BOTTOM_SHIFT #undef BOTTOM_INDEX @@ -670,6 +702,16 @@ static inline uint8_t get_left( return (bits & 0x3); } +static inline uint8_t get_left_bits( + const css_computed_style *style) +{ + uint8_t bits = style->bits[LEFT_INDEX]; + bits &= LEFT_MASK; + bits >>= LEFT_SHIFT; + + /* 6bits: uuuutt : units | type */ + return bits; +} #undef LEFT_MASK #undef LEFT_SHIFT #undef LEFT_INDEX @@ -1451,46 +1493,6 @@ static inline uint8_t get_background_position( #define DISPLAY_SHIFT 2 #define DISPLAY_MASK 0x7c static inline uint8_t get_display( - const css_computed_style *style, bool root) -{ - uint8_t position; - uint8_t bits = style->bits[DISPLAY_INDEX]; - bits &= DISPLAY_MASK; - bits >>= DISPLAY_SHIFT; - - /* Return computed display as per $9.7 */ - position = css_computed_position(style); - - /* 5bits: type */ - if (bits == CSS_DISPLAY_NONE) - return bits; /* 1. */ - - if ((position == CSS_POSITION_ABSOLUTE || - position == CSS_POSITION_FIXED) /* 2. */ || - css_computed_float(style) != CSS_FLOAT_NONE /* 3. */ || - root /* 4. */) { - if (bits == CSS_DISPLAY_INLINE_TABLE) { - return CSS_DISPLAY_TABLE; - } else if (bits == CSS_DISPLAY_INLINE || - bits == CSS_DISPLAY_RUN_IN || - bits == CSS_DISPLAY_TABLE_ROW_GROUP || - bits == CSS_DISPLAY_TABLE_COLUMN || - bits == CSS_DISPLAY_TABLE_COLUMN_GROUP || - bits == CSS_DISPLAY_TABLE_HEADER_GROUP || - bits == CSS_DISPLAY_TABLE_FOOTER_GROUP || - bits == CSS_DISPLAY_TABLE_ROW || - bits == CSS_DISPLAY_TABLE_CELL || - bits == CSS_DISPLAY_TABLE_CAPTION || - bits == CSS_DISPLAY_INLINE_BLOCK) { - return CSS_DISPLAY_BLOCK; - } - } - - /* 5. */ - return bits; -} - -static inline uint8_t get_display_static( const css_computed_style *style) { uint8_t bits = style->bits[DISPLAY_INDEX]; @@ -1500,7 +1502,6 @@ static inline uint8_t get_display_static( /* 5bits: type */ return bits; } - #undef DISPLAY_MASK #undef DISPLAY_SHIFT #undef DISPLAY_INDEX @@ -1831,20 +1832,20 @@ static inline uint8_t get_page_break_inside( #define ORPHANS_MASK 0x1 static inline uint8_t get_orphans( const css_computed_style *style, - css_fixed *count) + int32_t *orphans) { if (style->page != NULL) { uint8_t bits = style->page->bits[ORPHANS_INDEX]; bits &= ORPHANS_MASK; bits >>= ORPHANS_SHIFT; - *count = style->page->orphans; + *orphans = style->page->orphans; /* 1bit: type */ return bits; } - *count = INTTOFIX(2); + *orphans = 2; return CSS_ORPHANS_SET; } #undef ORPHANS_MASK @@ -1856,20 +1857,20 @@ static inline uint8_t get_orphans( #define WIDOWS_MASK 0x2 static inline uint8_t get_widows( const css_computed_style *style, - css_fixed *count) + int32_t *widows) { if (style->page != NULL) { uint8_t bits = style->page->bits[WIDOWS_INDEX]; bits &= WIDOWS_MASK; bits >>= WIDOWS_SHIFT; - *count = style->page->orphans; + *widows = style->page->widows; /* 1bit: type */ return bits; } - *count = INTTOFIX(2); + *widows = 2; return CSS_WIDOWS_SET; } #undef WIDOWS_MASK diff --git a/src/select/propset.h b/src/select/propset.h index 5af7e8b..4aa15af 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -1952,12 +1952,12 @@ static inline css_error set_page_break_inside( #define ORPHANS_SHIFT 0 #define ORPHANS_MASK 0x1 static inline css_error set_orphans( - css_computed_style *style, uint8_t type, css_fixed count) + css_computed_style *style, uint8_t type, int32_t count) { uint8_t *bits; if (style->page == NULL) { - if (type == CSS_ORPHANS_SET && count == INTTOFIX(2)) { + if (type == CSS_ORPHANS_SET && count == 2) { return CSS_OK; } } @@ -1981,12 +1981,12 @@ static inline css_error set_orphans( #define WIDOWS_SHIFT 1 #define WIDOWS_MASK 0x2 static inline css_error set_widows( - css_computed_style *style, uint8_t type, css_fixed count) + css_computed_style *style, uint8_t type, int32_t count) { uint8_t *bits; if (style->page == NULL) { - if (type == CSS_WIDOWS_SET && count == INTTOFIX(2)) { + if (type == CSS_WIDOWS_SET && count == 2) { return CSS_OK; } } |