summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcss/computed.h541
-rw-r--r--src/select/computed.c444
-rw-r--r--src/select/properties.c351
-rw-r--r--src/select/propget.h1724
4 files changed, 2498 insertions, 562 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index df2f5cf..f47b086 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -350,6 +350,13 @@ css_error css_computed_style_compose(const css_computed_style *parent,
* Property accessors below here *
******************************************************************************/
+static inline uint8_t css_computed_font_size(const css_computed_style *style,
+ css_fixed *length, css_unit *unit);
+static inline uint8_t css_computed_line_height(const css_computed_style *style,
+ css_fixed *length, css_unit *unit);
+static inline uint8_t css_computed_position(const css_computed_style *style);
+
+
#define LETTER_SPACING_INDEX 0
#define LETTER_SPACING_SHIFT 2
#define LETTER_SPACING_MASK 0xfc
@@ -367,6 +374,17 @@ static inline uint8_t css_computed_letter_spacing(
if ((bits & 3) == CSS_LETTER_SPACING_SET) {
*length = style->uncommon->letter_spacing;
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size,
+ &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 3);
@@ -421,6 +439,17 @@ static inline uint8_t css_computed_outline_width(
if ((bits & 7) == CSS_OUTLINE_WIDTH_WIDTH) {
*length = style->uncommon->outline_width;
*unit = bits >> 3;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size,
+ &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 7);
@@ -465,6 +494,24 @@ static inline uint8_t css_computed_border_spacing(
*vlength = style->uncommon->border_spacing[1];
*vunit = bits1 & 0xf;
+
+ if (*hunit == CSS_UNIT_EM || *vunit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size,
+ &font_unit);
+
+ if (*hunit == CSS_UNIT_EM) {
+ *hlength = FMUL(*hlength, font_size);
+ *hunit = font_unit;
+ }
+
+ if (*vunit == CSS_UNIT_EM) {
+ *hlength = FMUL(*vunit, font_size);
+ *vunit = font_unit;
+ }
+ }
}
return bits;
@@ -499,6 +546,17 @@ static inline uint8_t css_computed_word_spacing(
if ((bits & 3) == CSS_WORD_SPACING_SET) {
*length = style->uncommon->word_spacing;
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size,
+ &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 3);
@@ -640,6 +698,40 @@ static inline uint8_t css_computed_clip(
rect->left = style->uncommon->clip[3];
rect->lunit = bits1 & 0xf;
+
+ if (rect->tunit == CSS_UNIT_EM ||
+ rect->runit == CSS_UNIT_EM ||
+ rect->bunit == CSS_UNIT_EM ||
+ rect->lunit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size,
+ &font_unit);
+
+ if (rect->tunit == CSS_UNIT_EM) {
+ rect->top = FMUL(rect->top, font_size);
+ rect->tunit = font_unit;
+ }
+
+ if (rect->runit == CSS_UNIT_EM) {
+ rect->right = FMUL(rect->right,
+ font_size);
+ rect->runit = font_unit;
+ }
+
+ if (rect->bunit == CSS_UNIT_EM) {
+ rect->bottom = FMUL(rect->bottom,
+ font_size);
+ rect->bunit = font_unit;
+ }
+
+ if (rect->lunit == CSS_UNIT_EM) {
+ rect->left = FMUL(rect->left,
+ font_size);
+ rect->lunit = font_unit;
+ }
+ }
}
return (bits & 0x3);
@@ -696,6 +788,24 @@ static inline uint8_t css_computed_vertical_align(
if ((bits & 0xf) == CSS_VERTICAL_ALIGN_SET) {
*length = style->vertical_align;
*unit = bits >> 4;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ } else if (*unit == CSS_UNIT_PCT) {
+ css_fixed line_height;
+ css_unit lh_unit;
+
+ css_computed_line_height(style, &line_height, &lh_unit);
+
+ *length = FDIVI(FMUL(*length, line_height), 100);
+ *unit = lh_unit;
+ }
}
return (bits & 0xf);
@@ -742,6 +852,16 @@ static inline uint8_t css_computed_border_top_width(
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
*length = style->border_width[0];
*unit = bits >> 3;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x7);
@@ -765,6 +885,16 @@ static inline uint8_t css_computed_border_right_width(
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
*length = style->border_width[1];
*unit = bits >> 3;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x7);
@@ -788,6 +918,16 @@ static inline uint8_t css_computed_border_bottom_width(
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
*length = style->border_width[2];
*unit = bits >> 3;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x7);
@@ -811,6 +951,16 @@ static inline uint8_t css_computed_border_left_width(
if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
*length = style->border_width[3];
*unit = bits >> 3;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x7);
@@ -902,6 +1052,15 @@ static inline uint8_t css_computed_quotes(
#define TOP_INDEX 6
#define TOP_SHIFT 2
#define TOP_MASK 0xfc
+#define RIGHT_INDEX 7
+#define RIGHT_SHIFT 2
+#define RIGHT_MASK 0xfc
+#define BOTTOM_INDEX 8
+#define BOTTOM_SHIFT 2
+#define BOTTOM_MASK 0xfc
+#define LEFT_INDEX 9
+#define LEFT_SHIFT 2
+#define LEFT_MASK 0xfc
static inline uint8_t css_computed_top(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -910,21 +1069,52 @@ static inline uint8_t css_computed_top(
bits &= TOP_MASK;
bits >>= TOP_SHIFT;
- /* 6bits: uuuutt : units | type */
- if ((bits & 0x3) == CSS_TOP_SET) {
+ /* Fix up, based on computed position */
+ if (css_computed_position(style) == CSS_POSITION_STATIC) {
+ /* Static -> auto */
+ bits = CSS_TOP_AUTO;
+ } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) {
+ /* Relative -> follow $9.4.3 */
+ uint8_t bottom = style->bits[BOTTOM_INDEX];
+ bottom &= BOTTOM_MASK;
+ bottom >>= BOTTOM_SHIFT;
+
+ if ((bits & 0x3) == CSS_TOP_AUTO &&
+ (bottom & 0x3) == CSS_BOTTOM_AUTO) {
+ /* Both auto => 0px */
+ *length = 0;
+ *unit = CSS_UNIT_PX;
+ } else if ((bits & 0x3) == CSS_TOP_AUTO) {
+ /* Top is auto => -bottom */
+ *length = -style->bottom;
+ *unit = bottom >> 2;
+ } else {
+ *length = style->top;
+ *unit = bits >> 2;
+ }
+
+ bits = CSS_TOP_SET;
+ } else if ((bits & 0x3) == CSS_TOP_SET) {
*length = style->top;
*unit = bits >> 2;
}
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
+ }
+
return (bits & 0x3);
}
-#undef TOP_MASK
-#undef TOP_SHIFT
-#undef TOP_INDEX
-#define RIGHT_INDEX 7
-#define RIGHT_SHIFT 2
-#define RIGHT_MASK 0xfc
static inline uint8_t css_computed_right(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -933,21 +1123,54 @@ static inline uint8_t css_computed_right(
bits &= RIGHT_MASK;
bits >>= RIGHT_SHIFT;
- /* 6bits: uuuutt : units | type */
- if ((bits & 0x3) == CSS_RIGHT_SET) {
+ /* Fix up, based on computed position */
+ if (css_computed_position(style) == CSS_POSITION_STATIC) {
+ /* Static -> auto */
+ bits = CSS_RIGHT_AUTO;
+ } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) {
+ /* Relative -> follow $9.4.3 */
+ uint8_t left = style->bits[LEFT_INDEX];
+ left &= LEFT_MASK;
+ left >>= LEFT_SHIFT;
+
+ if ((bits & 0x3) == CSS_RIGHT_AUTO &&
+ (left & 0x3) == CSS_LEFT_AUTO) {
+ /* Both auto => 0px */
+ *length = 0;
+ *unit = CSS_UNIT_PX;
+ } else if ((bits & 0x3) == CSS_RIGHT_AUTO) {
+ /* Right is auto => -left */
+ *length = -style->left;
+ *unit = left >> 2;
+ } else {
+ /** \todo Consider containing block's direction
+ * if overconstrained */
+ *length = style->right;
+ *unit = bits >> 2;
+ }
+
+ bits = CSS_RIGHT_SET;
+ } else if ((bits & 0x3) == CSS_RIGHT_SET) {
*length = style->right;
*unit = bits >> 2;
}
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
+ }
+
return (bits & 0x3);
}
-#undef RIGHT_MASK
-#undef RIGHT_SHIFT
-#undef RIGHT_INDEX
-#define BOTTOM_INDEX 8
-#define BOTTOM_SHIFT 2
-#define BOTTOM_MASK 0xfc
static inline uint8_t css_computed_bottom(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -956,21 +1179,53 @@ static inline uint8_t css_computed_bottom(
bits &= BOTTOM_MASK;
bits >>= BOTTOM_SHIFT;
- /* 6bits: uuuutt : units | type */
- if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ /* Fix up, based on computed position */
+ if (css_computed_position(style) == CSS_POSITION_STATIC) {
+ /* Static -> auto */
+ bits = CSS_BOTTOM_AUTO;
+ } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) {
+ /* Relative -> follow $9.4.3 */
+ uint8_t top = style->bits[TOP_INDEX];
+ top &= TOP_MASK;
+ top >>= TOP_SHIFT;
+
+ if ((bits & 0x3) == CSS_BOTTOM_AUTO &&
+ (top & 0x3) == CSS_TOP_AUTO) {
+ /* Both auto => 0px */
+ *length = 0;
+ *unit = CSS_UNIT_PX;
+ } else if ((bits & 0x3) == CSS_BOTTOM_AUTO ||
+ (top & 0x3) != CSS_TOP_AUTO) {
+ /* Bottom is auto or top is not auto => -top */
+ *length = -style->top;
+ *unit = top >> 2;
+ } else {
+ *length = style->bottom;
+ *unit = bits >> 2;
+ }
+
+ bits = CSS_BOTTOM_SET;
+ } else if ((bits & 0x3) == CSS_BOTTOM_SET) {
*length = style->bottom;
*unit = bits >> 2;
}
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
+ }
+
return (bits & 0x3);
}
-#undef BOTTOM_MASK
-#undef BOTTOM_SHIFT
-#undef BOTTOM_INDEX
-#define LEFT_INDEX 9
-#define LEFT_SHIFT 2
-#define LEFT_MASK 0xfc
static inline uint8_t css_computed_left(
const css_computed_style *style,
css_fixed *length, css_unit *unit)
@@ -979,17 +1234,65 @@ static inline uint8_t css_computed_left(
bits &= LEFT_MASK;
bits >>= LEFT_SHIFT;
- /* 6bits: uuuutt : units | type */
- if ((bits & 0x3) == CSS_LEFT_SET) {
+ /* Fix up, based on computed position */
+ if (css_computed_position(style) == CSS_POSITION_STATIC) {
+ /* Static -> auto */
+ bits = CSS_LEFT_AUTO;
+ } else if (css_computed_position(style) == CSS_POSITION_RELATIVE) {
+ /* Relative -> follow $9.4.3 */
+ uint8_t right = style->bits[RIGHT_INDEX];
+ right &= RIGHT_MASK;
+ right >>= RIGHT_SHIFT;
+
+ if ((bits & 0x3) == CSS_LEFT_AUTO &&
+ (right & 0x3) == CSS_RIGHT_AUTO) {
+ /* Both auto => 0px */
+ *length = 0;
+ *unit = CSS_UNIT_PX;
+ } else if ((bits & 0x3) == CSS_LEFT_AUTO) {
+ /* Left is auto => -right */
+ *length = -style->right;
+ *unit = right >> 2;
+ } else {
+ /** \todo Consider containing block's direction
+ * if overconstrained */
+ *length = style->left;
+ *unit = bits >> 2;
+ }
+
+ bits = CSS_LEFT_SET;
+ } else if ((bits & 0x3) == CSS_LEFT_SET) {
*length = style->left;
*unit = bits >> 2;
}
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
+ }
+
return (bits & 0x3);
}
#undef LEFT_MASK
#undef LEFT_SHIFT
#undef LEFT_INDEX
+#undef BOTTOM_MASK
+#undef BOTTOM_SHIFT
+#undef BOTTOM_INDEX
+#undef RIGHT_MASK
+#undef RIGHT_SHIFT
+#undef RIGHT_INDEX
+#undef TOP_MASK
+#undef TOP_SHIFT
+#undef TOP_INDEX
#define BORDER_TOP_COLOR_INDEX 6
#define BORDER_TOP_COLOR_SHIFT 0
@@ -1086,6 +1389,16 @@ static inline uint8_t css_computed_height(
if ((bits & 0x3) == CSS_HEIGHT_SET) {
*length = style->height;
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1113,6 +1426,20 @@ static inline uint8_t css_computed_line_height(
if ((bits & 0x3) == CSS_LINE_HEIGHT_DIMENSION) {
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM || *unit == CSS_UNIT_PCT) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+
+ if (*unit == CSS_UNIT_PCT)
+ *length = FDIVI(*length, 100);
+
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1176,6 +1503,16 @@ static inline uint8_t css_computed_margin_top(
if ((bits & 0x3) == CSS_MARGIN_SET) {
*length = style->margin[0];
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1199,6 +1536,16 @@ static inline uint8_t css_computed_margin_right(
if ((bits & 0x3) == CSS_MARGIN_SET) {
*length = style->margin[1];
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1222,6 +1569,16 @@ static inline uint8_t css_computed_margin_bottom(
if ((bits & 0x3) == CSS_MARGIN_SET) {
*length = style->margin[2];
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1245,6 +1602,16 @@ static inline uint8_t css_computed_margin_left(
if ((bits & 0x3) == CSS_MARGIN_SET) {
*length = style->margin[3];
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1336,6 +1703,16 @@ static inline uint8_t css_computed_max_height(
if ((bits & 0x3) == CSS_MAX_HEIGHT_SET) {
*length = style->max_height;
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1359,6 +1736,16 @@ static inline uint8_t css_computed_max_width(
if ((bits & 0x3) == CSS_MAX_WIDTH_SET) {
*length = style->max_width;
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1382,6 +1769,16 @@ static inline uint8_t css_computed_width(
if ((bits & 0x3) == CSS_WIDTH_SET) {
*length = style->width;
*unit = bits >> 2;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x3);
@@ -1417,6 +1814,11 @@ static inline uint8_t css_computed_float(
bits &= FLOAT_MASK;
bits >>= FLOAT_SHIFT;
+ /* Fix up as per $9.7:2 */
+ if (css_computed_position(style) == CSS_POSITION_ABSOLUTE ||
+ css_computed_position(style) == CSS_POSITION_FIXED)
+ return CSS_FLOAT_NONE;
+
/* 2bits: type */
return bits;
}
@@ -1456,6 +1858,16 @@ static inline uint8_t css_computed_min_height(
if ((bits & 0x1) == CSS_MIN_HEIGHT_SET) {
*length = style->min_height;
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1479,6 +1891,16 @@ static inline uint8_t css_computed_min_width(
if ((bits & 0x1) == CSS_MIN_WIDTH_SET) {
*length = style->min_width;
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1536,6 +1958,16 @@ static inline uint8_t css_computed_padding_top(
if ((bits & 0x1) == CSS_PADDING_SET) {
*length = style->padding[0];
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1559,6 +1991,16 @@ static inline uint8_t css_computed_padding_right(
if ((bits & 0x1) == CSS_PADDING_SET) {
*length = style->padding[1];
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1582,6 +2024,16 @@ static inline uint8_t css_computed_padding_bottom(
if ((bits & 0x1) == CSS_PADDING_SET) {
*length = style->padding[2];
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1605,6 +2057,16 @@ static inline uint8_t css_computed_padding_left(
if ((bits & 0x1) == CSS_PADDING_SET) {
*length = style->padding[3];
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1696,6 +2158,16 @@ static inline uint8_t css_computed_text_indent(
if ((bits & 0x1) == CSS_TEXT_INDENT_SET) {
*length = style->text_indent;
*unit = bits >> 1;
+
+ if (*unit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ *length = FMUL(*length, font_size);
+ *unit = font_unit;
+ }
}
return (bits & 0x1);
@@ -1748,6 +2220,23 @@ static inline uint8_t css_computed_background_position(
*vlength = style->background_position[1];
*vunit = bits1 & 0xf;
+
+ if (*hunit == CSS_UNIT_EM || *vunit == CSS_UNIT_EM) {
+ css_fixed font_size;
+ css_unit font_unit;
+
+ css_computed_font_size(style, &font_size, &font_unit);
+
+ if (*hunit == CSS_UNIT_EM) {
+ *hlength = FMUL(*hlength, font_size);
+ *hunit = font_unit;
+ }
+
+ if (*vunit == CSS_UNIT_EM) {
+ *hlength = FMUL(*vunit, font_size);
+ *vunit = font_unit;
+ }
+ }
}
return bits;
diff --git a/src/select/computed.c b/src/select/computed.c
index 4e3d219..4b44f56 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -9,70 +9,57 @@
#include "select/computed.h"
#include "select/dispatch.h"
+#include "select/propget.h"
#include "select/propset.h"
#include "utils/utils.h"
static css_error compute_border_colors(css_computed_style *style);
-static css_error compute_float(css_computed_style *style);
static css_error compute_absolute_border_width(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_border_side_width(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
css_error (*set)(css_computed_style *style, uint8_t type,
css_fixed len, css_unit unit));
static css_error compute_absolute_sides(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_clip(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_line_height(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_margins(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_padding(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_vertical_align(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size);
static css_error compute_absolute_length(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
css_error (*set)(css_computed_style *style, uint8_t type,
css_fixed len, css_unit unit));
static css_error compute_absolute_length_auto(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
css_error (*set)(css_computed_style *style, uint8_t type,
css_fixed len, css_unit unit));
static css_error compute_absolute_length_none(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
css_error (*set)(css_computed_style *style, uint8_t type,
css_fixed len, css_unit unit));
static css_error compute_absolute_length_normal(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
css_error (*set)(css_computed_style *style, uint8_t type,
css_fixed len, css_unit unit));
static css_error compute_absolute_length_pair(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len1, css_unit *unit1,
@@ -273,12 +260,12 @@ css_error compute_absolute_values(const css_computed_style *parent,
/* Ensure font-size is absolute */
if (parent != NULL) {
- psize.status = css_computed_font_size(parent,
+ psize.status = get_font_size(parent,
&psize.data.length.value,
&psize.data.length.unit);
}
- size.status = css_computed_font_size(style,
+ size.status = get_font_size(style,
&size.data.length.value,
&size.data.length.unit);
@@ -287,8 +274,9 @@ css_error compute_absolute_values(const css_computed_style *parent,
if (error != CSS_OK)
return error;
- error = set_font_size(style, size.status,
- size.data.length.value, size.data.length.unit);
+ error = set_font_size(style, size.status,
+ size.data.length.value,
+ size.data.length.unit);
if (error != CSS_OK)
return error;
@@ -300,9 +288,14 @@ css_error compute_absolute_values(const css_computed_style *parent,
if (error != CSS_OK)
return error;
+ /* Convert ex size into ems */
+ ex_size.data.length.value = FDIV(ex_size.data.length.value,
+ size.data.length.value);
+ ex_size.data.length.unit = CSS_UNIT_EM;
+
/* Fix up background-position */
- error = compute_absolute_length_pair(style, &size.data.length,
- &ex_size.data.length, css_computed_background_position,
+ error = compute_absolute_length_pair(style, &ex_size.data.length,
+ get_background_position,
set_background_position);
if (error != CSS_OK)
return error;
@@ -313,90 +306,74 @@ css_error compute_absolute_values(const css_computed_style *parent,
return error;
/* Fix up border-{top,right,bottom,left}-width */
- error = compute_absolute_border_width(style, &size.data.length,
- &ex_size.data.length);
+ error = compute_absolute_border_width(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up sides */
- error = compute_absolute_sides(style, &size.data.length,
- &ex_size.data.length);
- if (error != CSS_OK)
- return error;
-
- /* Fix up float */
- error = compute_float(style);
+ error = compute_absolute_sides(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up height */
- error = compute_absolute_length_auto(style, &size.data.length,
- &ex_size.data.length, css_computed_height, set_height);
+ error = compute_absolute_length_auto(style, &ex_size.data.length,
+ get_height, set_height);
if (error != CSS_OK)
return error;
/* Fix up line-height (must be before vertical-align) */
- error = compute_absolute_line_height(style, &size.data.length,
- &ex_size.data.length);
+ error = compute_absolute_line_height(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up margins */
- error = compute_absolute_margins(style, &size.data.length,
- &ex_size.data.length);
+ error = compute_absolute_margins(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up max-height */
- error = compute_absolute_length_none(style, &size.data.length,
- &ex_size.data.length, css_computed_max_height,
- set_max_height);
+ error = compute_absolute_length_none(style, &ex_size.data.length,
+ get_max_height, set_max_height);
if (error != CSS_OK)
return error;
/* Fix up max-width */
- error = compute_absolute_length_none(style, &size.data.length,
- &ex_size.data.length, css_computed_max_width,
- set_max_width);
+ error = compute_absolute_length_none(style, &ex_size.data.length,
+ get_max_width, set_max_width);
if (error != CSS_OK)
return error;
/* Fix up min-height */
- error = compute_absolute_length(style, &size.data.length,
- &ex_size.data.length, css_computed_min_height,
- set_min_height);
+ error = compute_absolute_length(style, &ex_size.data.length,
+ get_min_height, set_min_height);
if (error != CSS_OK)
return error;
/* Fix up min-width */
- error = compute_absolute_length(style, &size.data.length,
- &ex_size.data.length, css_computed_min_width,
- set_min_width);
+ error = compute_absolute_length(style, &ex_size.data.length,
+ get_min_width, set_min_width);
if (error != CSS_OK)
return error;
/* Fix up padding */
- error = compute_absolute_padding(style, &size.data.length,
- &ex_size.data.length);
+ error = compute_absolute_padding(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up text-indent */
- error = compute_absolute_length(style, &size.data.length,
- &ex_size.data.length, css_computed_text_indent,
- set_text_indent);
+ error = compute_absolute_length(style, &ex_size.data.length,
+ get_text_indent, set_text_indent);
if (error != CSS_OK)
return error;
/* Fix up vertical-align */
- error = compute_absolute_vertical_align(style, &size.data.length,
- &ex_size.data.length);
+ error = compute_absolute_vertical_align(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up width */
- error = compute_absolute_length_auto(style, &size.data.length,
- &ex_size.data.length, css_computed_width, set_width);
+ error = compute_absolute_length_auto(style, &ex_size.data.length,
+ get_width, set_width);
if (error != CSS_OK)
return error;
@@ -404,37 +381,38 @@ css_error compute_absolute_values(const css_computed_style *parent,
if (style->uncommon != NULL) {
/* Fix up border-spacing */
error = compute_absolute_length_pair(style,
- &size.data.length, &ex_size.data.length,
- css_computed_border_spacing,
+ &ex_size.data.length,
+ get_border_spacing,
set_border_spacing);
if (error != CSS_OK)
return error;
/* Fix up clip */
- error = compute_absolute_clip(style, &size.data.length,
- &ex_size.data.length);
+ error = compute_absolute_clip(style, &ex_size.data.length);
if (error != CSS_OK)
return error;
/* Fix up letter-spacing */
error = compute_absolute_length_normal(style,
- &size.data.length, &ex_size.data.length,
- css_computed_letter_spacing,
+ &ex_size.data.length,
+ get_letter_spacing,
set_letter_spacing);
if (error != CSS_OK)
return error;
/* Fix up outline-width */
error = compute_absolute_border_side_width(style,
- &size.data.length, &ex_size.data.length,
- css_computed_outline_width, set_outline_width);
+ &ex_size.data.length,
+ get_outline_width,
+ set_outline_width);
if (error != CSS_OK)
return error;
/* Fix up word spacing */
error = compute_absolute_length_normal(style,
- &size.data.length, &ex_size.data.length,
- css_computed_word_spacing, set_word_spacing);
+ &ex_size.data.length,
+ get_word_spacing,
+ set_word_spacing);
if (error != CSS_OK)
return error;
}
@@ -460,32 +438,28 @@ css_error compute_border_colors(css_computed_style *style)
css_computed_color(style, &color);
- if (css_computed_border_top_color(style, &bcol) ==
- CSS_BORDER_COLOR_INITIAL) {
+ if (get_border_top_color(style, &bcol) == CSS_BORDER_COLOR_INITIAL) {
error = set_border_top_color(style,
CSS_BORDER_COLOR_COLOR, color);
if (error != CSS_OK)
return error;
}
- if (css_computed_border_right_color(style, &bcol) ==
- CSS_BORDER_COLOR_INITIAL) {
+ if (get_border_right_color(style, &bcol) == CSS_BORDER_COLOR_INITIAL) {
error = set_border_right_color(style,
CSS_BORDER_COLOR_COLOR, color);
if (error != CSS_OK)
return error;
}
- if (css_computed_border_bottom_color(style, &bcol) ==
- CSS_BORDER_COLOR_INITIAL) {
+ if (get_border_bottom_color(style, &bcol) == CSS_BORDER_COLOR_INITIAL) {
error = set_border_bottom_color(style,
CSS_BORDER_COLOR_COLOR, color);
if (error != CSS_OK)
return error;
}
- if (css_computed_border_left_color(style, &bcol) ==
- CSS_BORDER_COLOR_INITIAL) {
+ if (get_border_left_color(style, &bcol) == CSS_BORDER_COLOR_INITIAL) {
error = set_border_left_color(style,
CSS_BORDER_COLOR_COLOR, color);
if (error != CSS_OK)
@@ -496,61 +470,37 @@ css_error compute_border_colors(css_computed_style *style)
}
/**
- * Compute float, considering position ($9.7)
- *
- * \param style Style to process
- * \return CSS_OK on success
- */
-css_error compute_float(css_computed_style *style)
-{
- uint8_t pos;
- css_error error;
-
- pos = css_computed_position(style);
-
- if (pos == CSS_POSITION_ABSOLUTE || pos == CSS_POSITION_FIXED) /*2*/ {
- error = set_float(style, CSS_FLOAT_NONE);
- if (error != CSS_OK)
- return error;
- }
-
- return CSS_OK;
-}
-
-/**
* Compute absolute border widths
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size in ems
* \return CSS_OK on success
*/
css_error compute_absolute_border_width(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
css_error error;
- error = compute_absolute_border_side_width(style, font_size, ex_size,
- css_computed_border_top_width,
+ error = compute_absolute_border_side_width(style, ex_size,
+ get_border_top_width,
set_border_top_width);
if (error != CSS_OK)
return error;
- error = compute_absolute_border_side_width(style, font_size, ex_size,
- css_computed_border_right_width,
+ error = compute_absolute_border_side_width(style, ex_size,
+ get_border_right_width,
set_border_right_width);
if (error != CSS_OK)
return error;
- error = compute_absolute_border_side_width(style, font_size, ex_size,
- css_computed_border_bottom_width,
+ error = compute_absolute_border_side_width(style, ex_size,
+ get_border_bottom_width,
set_border_bottom_width);
if (error != CSS_OK)
return error;
- error = compute_absolute_border_side_width(style, font_size, ex_size,
- css_computed_border_left_width,
+ error = compute_absolute_border_side_width(style, ex_size,
+ get_border_left_width,
set_border_left_width);
if (error != CSS_OK)
return error;
@@ -562,14 +512,12 @@ css_error compute_absolute_border_width(css_computed_style *style,
* Compute an absolute border side width
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \param get Function to read length
* \param set Function to write length
* \return CSS_OK on success
*/
css_error compute_absolute_border_side_width(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
@@ -592,10 +540,7 @@ css_error compute_absolute_border_side_width(css_computed_style *style,
unit = CSS_UNIT_PX;
}
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
}
@@ -607,55 +552,40 @@ css_error compute_absolute_border_side_width(css_computed_style *style,
* Compute absolute clip
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size in ems
* \return CSS_OK on success
*/
css_error compute_absolute_clip(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX,
CSS_UNIT_PX, CSS_UNIT_PX, false, false, false, false };
css_error error;
- if (css_computed_clip(style, &rect) == CSS_CLIP_RECT) {
+ if (get_clip(style, &rect) == CSS_CLIP_RECT) {
if (rect.top_auto == false) {
- if (rect.tunit == CSS_UNIT_EM) {
- rect.top = FMUL(rect.top, font_size->value);
- rect.tunit = font_size->unit;
- } else if (rect.tunit == CSS_UNIT_EX) {
+ if (rect.tunit == CSS_UNIT_EX) {
rect.top = FMUL(rect.top, ex_size->value);
rect.tunit = ex_size->unit;
}
}
if (rect.right_auto == false) {
- if (rect.runit == CSS_UNIT_EM) {
- rect.right = FMUL(rect.right, font_size->value);
- rect.runit = font_size->unit;
- } else if (rect.runit == CSS_UNIT_EX) {
+ if (rect.runit == CSS_UNIT_EX) {
rect.right = FMUL(rect.right, ex_size->value);
rect.runit = ex_size->unit;
}
}
if (rect.bottom_auto == false) {
- if (rect.bunit == CSS_UNIT_EM) {
- rect.bottom =
- FMUL(rect.bottom, font_size->value);
- rect.bunit = font_size->unit;
- } else if (rect.bunit == CSS_UNIT_EX) {
+ if (rect.bunit == CSS_UNIT_EX) {
rect.bottom = FMUL(rect.bottom, ex_size->value);
rect.bunit = ex_size->unit;
}
}
if (rect.left_auto == false) {
- if (rect.lunit == CSS_UNIT_EM) {
- rect.left = FMUL(rect.left, font_size->value);
- rect.lunit = font_size->unit;
- } else if (rect.lunit == CSS_UNIT_EX) {
+ if (rect.lunit == CSS_UNIT_EX) {
rect.left = FMUL(rect.left, ex_size->value);
rect.lunit = ex_size->unit;
}
@@ -673,12 +603,10 @@ css_error compute_absolute_clip(css_computed_style *style,
* Compute absolute line-height
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \return CSS_OK on success
*/
css_error compute_absolute_line_height(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
css_fixed length = 0;
@@ -686,19 +614,12 @@ css_error compute_absolute_line_height(css_computed_style *style,
uint8_t type;
css_error error;
- type = css_computed_line_height(style, &length, &unit);
+ type = get_line_height(style, &length, &unit);
if (type == CSS_LINE_HEIGHT_DIMENSION) {
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
- } else if (unit == CSS_UNIT_PCT) {
- length = FDIV(FMUL(length, font_size->value),
- INTTOFIX(100));
- unit = font_size->unit;
}
error = set_line_height(style, type, length, unit);
@@ -713,137 +634,34 @@ css_error compute_absolute_line_height(css_computed_style *style,
* Compute the absolute values of {top,right,bottom,left}
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \return CSS_OK on success
*/
css_error compute_absolute_sides(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
- enum css_position pos;
css_error error;
/* Calculate absolute lengths for sides */
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_top, set_top);
+ error = compute_absolute_length_auto(style, ex_size, get_top, set_top);
if (error != CSS_OK)
return error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_right, set_right);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_right, set_right);
if (error != CSS_OK)
return error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_bottom, set_bottom);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_bottom, set_bottom);
if (error != CSS_OK)
return error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_left, set_left);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_left, set_left);
if (error != CSS_OK)
return error;
- /* Now, complete computation based upon computed position */
- pos = css_computed_position(style);
- if (pos == CSS_POSITION_STATIC) {
- /* Static => everything is auto */
- error = set_top(style, CSS_TOP_AUTO, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
-
- error = set_right(style, CSS_RIGHT_AUTO, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
-
- error = set_bottom(style, CSS_BOTTOM_AUTO, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
-
- error = set_left(style, CSS_LEFT_AUTO, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
- } else if (pos == CSS_POSITION_RELATIVE) {
- /* Relative => follow $9.4.3 */
- css_fixed len1 = 0, len2 = 0;
- css_unit unit1 = CSS_UNIT_PX, unit2 = CSS_UNIT_PX;
- uint8_t type1, type2;
-
- /* First, left and right */
- type1 = css_computed_left(style, &len1, &unit1);
- type2 = css_computed_right(style, &len2, &unit2);
-
- if (type1 == CSS_LEFT_AUTO && type2 == CSS_RIGHT_AUTO) {
- /* Both auto => 0px */
- error = set_left(style, CSS_LEFT_SET, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
-
- error = set_right(style, CSS_RIGHT_SET, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
- } else if (type1 == CSS_LEFT_AUTO) {
- /* Left is auto => set to -right */
- error = set_left(style, CSS_LEFT_SET, -len2, unit2);
- if (error != CSS_OK)
- return error;
- } else if (type2 == CSS_RIGHT_AUTO) {
- /* Right is auto => set to -left */
- error = set_right(style, CSS_RIGHT_SET, -len1, unit1);
- if (error != CSS_OK)
- return error;
- } else {
- /** \todo This should be containing block's direction */
- /* Overconstrained => consult direction */
- if (css_computed_direction(style) ==
- CSS_DIRECTION_LTR) {
- /* Right = -left */
- error = set_right(style, CSS_RIGHT_SET,
- -len1, unit1);
- if (error != CSS_OK)
- return error;
- } else {
- /* Left = -right */
- error = set_left(style, CSS_LEFT_SET,
- -len2, unit2);
- if (error != CSS_OK)
- return error;
- }
- }
-
- /* Second, top and bottom */
- type1 = css_computed_top(style, &len1, &unit1);
- type2 = css_computed_bottom(style, &len2, &unit2);
-
- if (type1 == CSS_TOP_AUTO && type2 == CSS_BOTTOM_AUTO) {
- /* Both auto => 0px */
- error = set_top(style, CSS_TOP_SET, 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
-
- error = set_bottom(style, CSS_BOTTOM_SET,
- 0, CSS_UNIT_PX);
- if (error != CSS_OK)
- return error;
- } else if (type1 == CSS_TOP_AUTO) {
- /* Top is auto => set to -bottom */
- error = set_top(style, CSS_TOP_SET, -len2, unit2);
- if (error != CSS_OK)
- return error;
- } else if (type2 == CSS_BOTTOM_AUTO) {
- /* Bottom is auto => set to -top */
- error = set_bottom(style, CSS_BOTTOM_SET, -len1, unit1);
- if (error != CSS_OK)
- return error;
- } else {
- /* Overconstrained => bottom = -top */
- error = set_bottom(style, CSS_BOTTOM_SET, -len1, unit1);
- if (error != CSS_OK)
- return error;
- }
- }
-
return CSS_OK;
}
@@ -851,33 +669,31 @@ css_error compute_absolute_sides(css_computed_style *style,
* Compute absolute margins
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \return CSS_OK on success
*/
css_error compute_absolute_margins(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
css_error error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_margin_top, set_margin_top);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_margin_top, set_margin_top);
if (error != CSS_OK)
return error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_margin_right, set_margin_right);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_margin_right, set_margin_right);
if (error != CSS_OK)
return error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_margin_bottom, set_margin_bottom);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_margin_bottom, set_margin_bottom);
if (error != CSS_OK)
return error;
- error = compute_absolute_length_auto(style, font_size, ex_size,
- css_computed_margin_left, set_margin_left);
+ error = compute_absolute_length_auto(style, ex_size,
+ get_margin_left, set_margin_left);
if (error != CSS_OK)
return error;
@@ -888,33 +704,31 @@ css_error compute_absolute_margins(css_computed_style *style,
* Compute absolute padding
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \return CSS_OK on success
*/
css_error compute_absolute_padding(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
css_error error;
- error = compute_absolute_length(style, font_size, ex_size,
- css_computed_padding_top, set_padding_top);
+ error = compute_absolute_length(style, ex_size,
+ get_padding_top, set_padding_top);
if (error != CSS_OK)
return error;
- error = compute_absolute_length(style, font_size, ex_size,
- css_computed_padding_right, set_padding_right);
+ error = compute_absolute_length(style, ex_size,
+ get_padding_right, set_padding_right);
if (error != CSS_OK)
return error;
- error = compute_absolute_length(style, font_size, ex_size,
- css_computed_padding_bottom, set_padding_bottom);
+ error = compute_absolute_length(style, ex_size,
+ get_padding_bottom, set_padding_bottom);
if (error != CSS_OK)
return error;
- error = compute_absolute_length(style, font_size, ex_size,
- css_computed_padding_left, set_padding_left);
+ error = compute_absolute_length(style, ex_size,
+ get_padding_left, set_padding_left);
if (error != CSS_OK)
return error;
@@ -925,12 +739,10 @@ css_error compute_absolute_padding(css_computed_style *style,
* Compute absolute vertical-align
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \return CSS_OK on success
*/
css_error compute_absolute_vertical_align(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size)
{
css_fixed length = 0;
@@ -938,24 +750,12 @@ css_error compute_absolute_vertical_align(css_computed_style *style,
uint8_t type;
css_error error;
- type = css_computed_vertical_align(style, &length, &unit);
+ type = get_vertical_align(style, &length, &unit);
if (type == CSS_VERTICAL_ALIGN_SET) {
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
- } else if (unit == CSS_UNIT_PCT) {
- css_fixed line_height = 0;
- css_unit lhunit = CSS_UNIT_PX;
-
- /* Relative to line-height */
- css_computed_line_height(style, &line_height, &lhunit);
-
- length = FDIV(FMUL(length, line_height), INTTOFIX(100));
- unit = lhunit;
}
error = set_vertical_align(style, type, length, unit);
@@ -970,14 +770,12 @@ css_error compute_absolute_vertical_align(css_computed_style *style,
* Compute the absolute value of length
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \param get Function to read length
* \param set Function to write length
* \return CSS_OK on success
*/
css_error compute_absolute_length(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
@@ -990,10 +788,7 @@ css_error compute_absolute_length(css_computed_style *style,
type = get(style, &length, &unit);
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
}
@@ -1005,14 +800,12 @@ css_error compute_absolute_length(css_computed_style *style,
* Compute the absolute value of length or auto
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \param get Function to read length
* \param set Function to write length
* \return CSS_OK on success
*/
css_error compute_absolute_length_auto(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
@@ -1025,10 +818,7 @@ css_error compute_absolute_length_auto(css_computed_style *style,
type = get(style, &length, &unit);
if (type != CSS_BOTTOM_AUTO) {
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
}
@@ -1043,14 +833,12 @@ css_error compute_absolute_length_auto(css_computed_style *style,
* Compute the absolute value of length or none
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \param get Function to read length
* \param set Function to write length
* \return CSS_OK on success
*/
css_error compute_absolute_length_none(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
@@ -1063,10 +851,7 @@ css_error compute_absolute_length_none(css_computed_style *style,
type = get(style, &length, &unit);
if (type != CSS_MAX_HEIGHT_NONE) {
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
}
@@ -1081,14 +866,12 @@ css_error compute_absolute_length_none(css_computed_style *style,
* Compute the absolute value of length or normal
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \param get Function to read length
* \param set Function to write length
* \return CSS_OK on success
*/
css_error compute_absolute_length_normal(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len, css_unit *unit),
@@ -1101,10 +884,7 @@ css_error compute_absolute_length_normal(css_computed_style *style,
type = get(style, &length, &unit);
if (type != CSS_LETTER_SPACING_NORMAL) {
- if (unit == CSS_UNIT_EM) {
- length = FMUL(length, font_size->value);
- unit = font_size->unit;
- } else if (unit == CSS_UNIT_EX) {
+ if (unit == CSS_UNIT_EX) {
length = FMUL(length, ex_size->value);
unit = ex_size->unit;
}
@@ -1119,14 +899,12 @@ css_error compute_absolute_length_normal(css_computed_style *style,
* Compute the absolute value of length pair
*
* \param style Style to process
- * \param font_size Absolute font size
- * \param ex_size Absolute ex size
+ * \param ex_size Ex size, in ems
* \param get Function to read length
* \param set Function to write length
* \return CSS_OK on success
*/
css_error compute_absolute_length_pair(css_computed_style *style,
- const css_hint_length *font_size,
const css_hint_length *ex_size,
uint8_t (*get)(const css_computed_style *style,
css_fixed *len1, css_unit *unit1,
@@ -1141,18 +919,12 @@ css_error compute_absolute_length_pair(css_computed_style *style,
type = get(style, &length1, &unit1, &length2, &unit2);
- if (unit1 == CSS_UNIT_EM) {
- length1 = FMUL(length1, font_size->value);
- unit1 = font_size->unit;
- } else if (unit1 == CSS_UNIT_EX) {
+ if (unit1 == CSS_UNIT_EX) {
length1 = FMUL(length1, ex_size->value);
unit1 = ex_size->unit;
}
- if (unit2 == CSS_UNIT_EM) {
- length2 = FMUL(length2, font_size->value);
- unit2 = font_size->unit;
- } else if (unit2 == CSS_UNIT_EX) {
+ if (unit2 == CSS_UNIT_EX) {
length2 = FMUL(length2, ex_size->value);
unit2 = ex_size->unit;
}
diff --git a/src/select/properties.c b/src/select/properties.c
index b62dcb1..02a607f 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -10,6 +10,7 @@
#include "bytecode/bytecode.h"
#include "bytecode/opcodes.h"
#include "select/properties.h"
+#include "select/propget.h"
#include "select/propset.h"
#include "utils/utils.h"
@@ -193,10 +194,10 @@ css_error compose_background_attachment(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_background_attachment(child) ==
+ if (get_background_attachment(child) ==
CSS_BACKGROUND_ATTACHMENT_INHERIT) {
return set_background_attachment(result,
- css_computed_background_attachment(parent));
+ get_background_attachment(parent));
}
return CSS_OK;
@@ -226,9 +227,9 @@ css_error compose_background_color(const css_computed_style *parent,
{
css_color color;
- if (css_computed_background_color(child, &color) ==
+ if (get_background_color(child, &color) ==
CSS_BACKGROUND_COLOR_INHERIT) {
- uint8_t p = css_computed_background_color(parent, &color);
+ uint8_t p = get_background_color(parent, &color);
return set_background_color(result, p, color);
}
@@ -260,9 +261,9 @@ css_error compose_background_image(const css_computed_style *parent,
{
lwc_string *url;
- if (css_computed_background_image(child, &url) ==
+ if (get_background_image(child, &url) ==
CSS_BACKGROUND_IMAGE_INHERIT) {
- uint8_t p = css_computed_background_image(parent, &url);
+ uint8_t p = get_background_image(parent, &url);
return set_background_image(result, p, url);
}
@@ -359,9 +360,9 @@ css_error compose_background_position(const css_computed_style *parent,
css_fixed hlength = 0, vlength = 0;
css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
- if (css_computed_background_position(child, &hlength, &hunit,
+ if (get_background_position(child, &hlength, &hunit,
&vlength, &vunit) == CSS_BACKGROUND_POSITION_INHERIT) {
- uint8_t p = css_computed_background_position(parent,
+ uint8_t p = get_background_position(parent,
&hlength, &hunit, &vlength, &vunit);
return set_background_position(result, p, hlength, hunit,
@@ -420,7 +421,7 @@ css_error compose_background_repeat(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_background_repeat(child) ==
+ if (get_background_repeat(child) ==
CSS_BACKGROUND_REPEAT_INHERIT) {
return set_background_repeat(result,
css_computed_background_repeat(parent));
@@ -470,7 +471,7 @@ css_error compose_border_collapse(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_border_collapse(child) ==
+ if (get_border_collapse(child) ==
CSS_BORDER_COLLAPSE_INHERIT) {
return set_border_collapse(result,
css_computed_border_collapse(parent));
@@ -535,10 +536,10 @@ css_error compose_border_spacing(const css_computed_style *parent,
css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_border_spacing(child,
+ get_border_spacing(child,
&hlength, &hunit, &vlength, &vunit) ==
CSS_BORDER_SPACING_INHERIT) {
- uint8_t p = css_computed_border_spacing(parent,
+ uint8_t p = get_border_spacing(parent,
&hlength, &hunit, &vlength, &vunit);
return set_border_spacing(result, p, hlength, hunit,
@@ -571,9 +572,8 @@ css_error compose_border_top_color(const css_computed_style *parent,
{
css_color color;
- if (css_computed_border_top_color(child, &color) ==
- CSS_BORDER_COLOR_INHERIT) {
- uint8_t p = css_computed_border_top_color(parent, &color);
+ if (get_border_top_color(child, &color) == CSS_BORDER_COLOR_INHERIT) {
+ uint8_t p = get_border_top_color(parent, &color);
return set_border_top_color(result, p, color);
}
@@ -606,9 +606,8 @@ css_error compose_border_right_color(const css_computed_style *parent,
{
css_color color;
- if (css_computed_border_right_color(child, &color) ==
- CSS_BORDER_COLOR_INHERIT) {
- uint8_t p = css_computed_border_right_color(parent, &color);
+ if (get_border_right_color(child, &color) == CSS_BORDER_COLOR_INHERIT) {
+ uint8_t p = get_border_right_color(parent, &color);
return set_border_right_color(result, p, color);
}
@@ -641,9 +640,9 @@ css_error compose_border_bottom_color(const css_computed_style *parent,
{
css_color color;
- if (css_computed_border_bottom_color(child, &color) ==
+ if (get_border_bottom_color(child, &color) ==
CSS_BORDER_COLOR_INHERIT) {
- uint8_t p = css_computed_border_bottom_color(parent, &color);
+ uint8_t p = get_border_bottom_color(parent, &color);
return set_border_bottom_color(result, p, color);
}
@@ -676,9 +675,8 @@ css_error compose_border_left_color(const css_computed_style *parent,
{
css_color color;
- if (css_computed_border_left_color(child, &color) ==
- CSS_BORDER_COLOR_INHERIT) {
- uint8_t p = css_computed_border_left_color(parent, &color);
+ if (get_border_left_color(child, &color) == CSS_BORDER_COLOR_INHERIT) {
+ uint8_t p = get_border_left_color(parent, &color);
return set_border_left_color(result, p, color);
}
@@ -707,10 +705,9 @@ css_error compose_border_top_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_border_top_style(child) ==
- CSS_BORDER_STYLE_INHERIT) {
+ if (get_border_top_style(child) == CSS_BORDER_STYLE_INHERIT) {
return set_border_top_style(result,
- css_computed_border_top_style(parent));
+ get_border_top_style(parent));
}
return CSS_OK;
@@ -737,10 +734,9 @@ css_error compose_border_right_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_border_right_style(child) ==
- CSS_BORDER_STYLE_INHERIT) {
+ if (get_border_right_style(child) == CSS_BORDER_STYLE_INHERIT) {
return set_border_right_style(result,
- css_computed_border_right_style(parent));
+ get_border_right_style(parent));
}
return CSS_OK;
@@ -767,10 +763,9 @@ css_error compose_border_bottom_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_border_bottom_style(child) ==
- CSS_BORDER_STYLE_INHERIT) {
+ if (get_border_bottom_style(child) == CSS_BORDER_STYLE_INHERIT) {
return set_border_bottom_style(result,
- css_computed_border_bottom_style(parent));
+ get_border_bottom_style(parent));
}
return CSS_OK;
@@ -797,10 +792,9 @@ css_error compose_border_left_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_border_left_style(child) ==
- CSS_BORDER_STYLE_INHERIT) {
+ if (get_border_left_style(child) == CSS_BORDER_STYLE_INHERIT) {
return set_border_left_style(result,
- css_computed_border_left_style(parent));
+ get_border_left_style(parent));
}
return CSS_OK;
@@ -832,10 +826,9 @@ css_error compose_border_top_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_border_top_width(child, &length, &unit) ==
+ if (get_border_top_width(child, &length, &unit) ==
CSS_BORDER_WIDTH_INHERIT) {
- uint8_t p = css_computed_border_top_width(parent,
- &length, &unit);
+ uint8_t p = get_border_top_width(parent, &length, &unit);
return set_border_top_width(result, p, length, unit);
}
@@ -869,10 +862,9 @@ css_error compose_border_right_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_border_right_width(child, &length, &unit) ==
+ if (get_border_right_width(child, &length, &unit) ==
CSS_BORDER_WIDTH_INHERIT) {
- uint8_t p = css_computed_border_right_width(parent,
- &length, &unit);
+ uint8_t p = get_border_right_width(parent, &length, &unit);
return set_border_right_width(result, p, length, unit);
}
@@ -906,10 +898,9 @@ css_error compose_border_bottom_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_border_bottom_width(child, &length, &unit) ==
+ if (get_border_bottom_width(child, &length, &unit) ==
CSS_BORDER_WIDTH_INHERIT) {
- uint8_t p = css_computed_border_bottom_width(parent,
- &length, &unit);
+ uint8_t p = get_border_bottom_width(parent, &length, &unit);
return set_border_bottom_width(result, p, length, unit);
}
@@ -943,10 +934,9 @@ css_error compose_border_left_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_border_left_width(child, &length, &unit) ==
+ if (get_border_left_width(child, &length, &unit) ==
CSS_BORDER_WIDTH_INHERIT) {
- uint8_t p = css_computed_border_left_width(parent,
- &length, &unit);
+ uint8_t p = get_border_left_width(parent, &length, &unit);
return set_border_left_width(result, p, length, unit);
}
@@ -979,9 +969,8 @@ css_error compose_bottom(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_bottom(child, &length, &unit) ==
- CSS_BOTTOM_INHERIT) {
- uint8_t p = css_computed_bottom(parent, &length, &unit);
+ if (get_bottom(child, &length, &unit) == CSS_BOTTOM_INHERIT) {
+ uint8_t p = get_bottom(parent, &length, &unit);
return set_bottom(result, p, length, unit);
}
@@ -1030,10 +1019,8 @@ css_error compose_caption_side(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_caption_side(child) ==
- CSS_CAPTION_SIDE_INHERIT) {
- return set_caption_side(result,
- css_computed_caption_side(parent));
+ if (get_caption_side(child) == CSS_CAPTION_SIDE_INHERIT) {
+ return set_caption_side(result, get_caption_side(parent));
}
return CSS_OK;
@@ -1086,8 +1073,8 @@ css_error compose_clear(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_clear(child) == CSS_CLEAR_INHERIT) {
- return set_clear(result, css_computed_clear(parent));
+ if (get_clear(child) == CSS_CLEAR_INHERIT) {
+ return set_clear(result, get_clear(parent));
}
return CSS_OK;
@@ -1180,9 +1167,8 @@ css_error compose_clip(const css_computed_style *parent,
false, false, false, false };
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_clip(child, &rect) ==
- CSS_CLIP_INHERIT) {
- uint8_t p = css_computed_clip(parent, &rect);
+ get_clip(child, &rect) == CSS_CLIP_INHERIT) {
+ uint8_t p = get_clip(parent, &rect);
return set_clip(result, p, &rect);
}
@@ -1234,8 +1220,8 @@ css_error compose_color(const css_computed_style *parent,
{
css_color color;
- if (css_computed_color(child, &color) == CSS_COLOR_INHERIT) {
- uint8_t p = css_computed_color(parent, &color);
+ if (get_color(child, &color) == CSS_COLOR_INHERIT) {
+ uint8_t p = get_color(parent, &color);
return set_color(result, p, color);
}
@@ -1429,9 +1415,8 @@ css_error compose_content(const css_computed_style *parent,
const css_computed_content_item *items = NULL;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_content(child, &items) ==
- CSS_CONTENT_INHERIT) {
- uint8_t p = css_computed_content(parent, &items);
+ get_content(child, &items) == CSS_CONTENT_INHERIT) {
+ uint8_t p = get_content(parent, &items);
size_t n_items = 0;
css_computed_content_item *copy = NULL;
@@ -1514,9 +1499,9 @@ css_error compose_counter_increment(const css_computed_style *parent,
const css_computed_counter *items = NULL;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_counter_increment(child, &items) ==
+ get_counter_increment(child, &items) ==
CSS_COUNTER_INCREMENT_INHERIT) {
- uint8_t p = css_computed_counter_increment(parent, &items);
+ uint8_t p = get_counter_increment(parent, &items);
size_t n_items = 0;
css_computed_counter *copy = NULL;
@@ -1597,9 +1582,9 @@ css_error compose_counter_reset(const css_computed_style *parent,
const css_computed_counter *items = NULL;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_counter_reset(child, &items) ==
+ get_counter_reset(child, &items) ==
CSS_COUNTER_RESET_INHERIT) {
- uint8_t p = css_computed_counter_reset(parent, &items);
+ uint8_t p = get_counter_reset(parent, &items);
size_t n_items = 0;
css_computed_counter *copy = NULL;
@@ -1866,9 +1851,8 @@ css_error compose_cursor(const css_computed_style *parent,
lwc_string **urls = NULL;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_cursor(child, &urls) ==
- CSS_CURSOR_INHERIT) {
- uint8_t p = css_computed_cursor(parent, &urls);
+ get_cursor(child, &urls) == CSS_CURSOR_INHERIT) {
+ uint8_t p = get_cursor(parent, &urls);
size_t n_urls = 0;
lwc_string **copy = NULL;
@@ -1939,8 +1923,8 @@ css_error compose_direction(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_direction(child) == CSS_DIRECTION_INHERIT) {
- return set_direction(result, css_computed_direction(parent));
+ if (get_direction(child) == CSS_DIRECTION_INHERIT) {
+ return set_direction(result, get_direction(parent));
}
return CSS_OK;
@@ -2029,8 +2013,8 @@ css_error compose_display(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_display_static(child) == CSS_DISPLAY_INHERIT) {
- return set_display(result, css_computed_display_static(parent));
+ if (get_display_static(child) == CSS_DISPLAY_INHERIT) {
+ return set_display(result, get_display_static(parent));
}
return CSS_OK;
@@ -2142,9 +2126,8 @@ css_error compose_empty_cells(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_empty_cells(child) == CSS_EMPTY_CELLS_INHERIT) {
- return set_empty_cells(result,
- css_computed_empty_cells(parent));
+ if (get_empty_cells(child) == CSS_EMPTY_CELLS_INHERIT) {
+ return set_empty_cells(result, get_empty_cells(parent));
}
return CSS_OK;
@@ -2194,8 +2177,8 @@ css_error compose_float(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_float(child) == CSS_FLOAT_INHERIT) {
- return set_float(result, css_computed_float(parent));
+ if (get_float(child) == CSS_FLOAT_INHERIT) {
+ return set_float(result, get_float(parent));
}
return CSS_OK;
@@ -2355,8 +2338,8 @@ css_error compose_font_family(const css_computed_style *parent,
css_error error;
lwc_string **urls = NULL;
- if (css_computed_font_family(child, &urls) == CSS_FONT_FAMILY_INHERIT) {
- uint8_t p = css_computed_font_family(parent, &urls);
+ if (get_font_family(child, &urls) == CSS_FONT_FAMILY_INHERIT) {
+ uint8_t p = get_font_family(parent, &urls);
size_t n_urls = 0;
lwc_string **copy = NULL;
@@ -2464,9 +2447,8 @@ css_error compose_font_size(const css_computed_style *parent,
css_fixed size = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_font_size(child, &size, &unit) ==
- CSS_FONT_SIZE_INHERIT) {
- uint8_t p = css_computed_font_size(parent, &size, &unit);
+ if (get_font_size(child, &size, &unit) == CSS_FONT_SIZE_INHERIT) {
+ uint8_t p = get_font_size(parent, &size, &unit);
return set_font_size(result, p, size, unit);
}
@@ -2517,8 +2499,8 @@ css_error compose_font_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_font_style(child) == CSS_FONT_STYLE_INHERIT) {
- return set_font_style(result, css_computed_font_style(parent));
+ if (get_font_style(child) == CSS_FONT_STYLE_INHERIT) {
+ return set_font_style(result, get_font_style(parent));
}
return CSS_OK;
@@ -2565,9 +2547,8 @@ css_error compose_font_variant(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_font_variant(child) == CSS_FONT_VARIANT_INHERIT) {
- return set_font_variant(result,
- css_computed_font_variant(parent));
+ if (get_font_variant(child) == CSS_FONT_VARIANT_INHERIT) {
+ return set_font_variant(result, get_font_variant(parent));
}
return CSS_OK;
@@ -2647,9 +2628,8 @@ css_error compose_font_weight(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_font_weight(child) == CSS_FONT_WEIGHT_INHERIT) {
- return set_font_weight(result,
- css_computed_font_weight(parent));
+ if (get_font_weight(child) == CSS_FONT_WEIGHT_INHERIT) {
+ return set_font_weight(result, get_font_weight(parent));
}
return CSS_OK;
@@ -2680,9 +2660,8 @@ css_error compose_height(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_height(child, &length, &unit) ==
- CSS_HEIGHT_INHERIT) {
- uint8_t p = css_computed_height(parent, &length, &unit);
+ if (get_height(child, &length, &unit) == CSS_HEIGHT_INHERIT) {
+ uint8_t p = get_height(parent, &length, &unit);
return set_height(result, p, length, unit);
}
@@ -2715,9 +2694,8 @@ css_error compose_left(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_left(child, &length, &unit) ==
- CSS_LEFT_INHERIT) {
- uint8_t p = css_computed_left(parent, &length, &unit);
+ if (get_left(child, &length, &unit) == CSS_LEFT_INHERIT) {
+ uint8_t p = get_left(parent, &length, &unit);
return set_left(result, p, length, unit);
}
@@ -2752,9 +2730,9 @@ css_error compose_letter_spacing(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_letter_spacing(child, &length, &unit) ==
+ get_letter_spacing(child, &length, &unit) ==
CSS_LETTER_SPACING_INHERIT) {
- uint8_t p = css_computed_letter_spacing(parent, &length, &unit);
+ uint8_t p = get_letter_spacing(parent, &length, &unit);
return set_letter_spacing(result, p, length, unit);
}
@@ -2819,9 +2797,8 @@ css_error compose_line_height(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_line_height(child, &length, &unit) ==
- CSS_LINE_HEIGHT_INHERIT) {
- uint8_t p = css_computed_line_height(parent, &length, &unit);
+ if (get_line_height(child, &length, &unit) == CSS_LINE_HEIGHT_INHERIT) {
+ uint8_t p = get_line_height(parent, &length, &unit);
return set_line_height(result, p, length, unit);
}
@@ -2853,9 +2830,8 @@ css_error compose_list_style_image(const css_computed_style *parent,
{
lwc_string *url;
- if (css_computed_list_style_image(child, &url) ==
- CSS_LIST_STYLE_IMAGE_INHERIT) {
- uint8_t p = css_computed_list_style_image(parent, &url);
+ if (get_list_style_image(child, &url) == CSS_LIST_STYLE_IMAGE_INHERIT) {
+ uint8_t p = get_list_style_image(parent, &url);
return set_list_style_image(result, p, url);
}
@@ -2905,10 +2881,9 @@ css_error compose_list_style_position(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_list_style_position(child) ==
- CSS_LIST_STYLE_POSITION_INHERIT) {
+ if (get_list_style_position(child) == CSS_LIST_STYLE_POSITION_INHERIT) {
return set_list_style_position(result,
- css_computed_list_style_position(parent));
+ get_list_style_position(parent));
}
return CSS_OK;
@@ -2994,10 +2969,8 @@ css_error compose_list_style_type(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_list_style_type(child) ==
- CSS_LIST_STYLE_TYPE_INHERIT) {
- return set_list_style_type(result,
- css_computed_list_style_type(parent));
+ if (get_list_style_type(child) == CSS_LIST_STYLE_TYPE_INHERIT) {
+ return set_list_style_type(result, get_list_style_type(parent));
}
return CSS_OK;
@@ -3028,9 +3001,8 @@ css_error compose_margin_top(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_margin_top(child, &length, &unit) ==
- CSS_MARGIN_INHERIT) {
- uint8_t p = css_computed_margin_top(parent, &length, &unit);
+ if (get_margin_top(child, &length, &unit) == CSS_MARGIN_INHERIT) {
+ uint8_t p = get_margin_top(parent, &length, &unit);
return set_margin_top(result, p, length, unit);
}
@@ -3063,9 +3035,8 @@ css_error compose_margin_right(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_margin_right(child, &length, &unit) ==
- CSS_MARGIN_INHERIT) {
- uint8_t p = css_computed_margin_right(parent, &length, &unit);
+ if (get_margin_right(child, &length, &unit) == CSS_MARGIN_INHERIT) {
+ uint8_t p = get_margin_right(parent, &length, &unit);
return set_margin_right(result, p, length, unit);
}
@@ -3098,9 +3069,8 @@ css_error compose_margin_bottom(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_margin_bottom(child, &length, &unit) ==
- CSS_MARGIN_INHERIT) {
- uint8_t p = css_computed_margin_bottom(parent, &length, &unit);
+ if (get_margin_bottom(child, &length, &unit) == CSS_MARGIN_INHERIT) {
+ uint8_t p = get_margin_bottom(parent, &length, &unit);
return set_margin_bottom(result, p, length, unit);
}
@@ -3133,9 +3103,8 @@ css_error compose_margin_left(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_margin_left(child, &length, &unit) ==
- CSS_MARGIN_INHERIT) {
- uint8_t p = css_computed_margin_left(parent, &length, &unit);
+ if (get_margin_left(child, &length, &unit) == CSS_MARGIN_INHERIT) {
+ uint8_t p = get_margin_left(parent, &length, &unit);
return set_margin_left(result, p, length, unit);
}
@@ -3169,9 +3138,8 @@ css_error compose_max_height(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_max_height(child, &length, &unit) ==
- CSS_MAX_HEIGHT_INHERIT) {
- uint8_t p = css_computed_max_height(parent, &length, &unit);
+ if (get_max_height(child, &length, &unit) == CSS_MAX_HEIGHT_INHERIT) {
+ uint8_t p = get_max_height(parent, &length, &unit);
return set_max_height(result, p, length, unit);
}
@@ -3204,9 +3172,8 @@ css_error compose_max_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_max_width(child, &length, &unit) ==
- CSS_MAX_WIDTH_INHERIT) {
- uint8_t p = css_computed_max_width(parent, &length, &unit);
+ if (get_max_width(child, &length, &unit) == CSS_MAX_WIDTH_INHERIT) {
+ uint8_t p = get_max_width(parent, &length, &unit);
return set_max_width(result, p, length, unit);
}
@@ -3240,9 +3207,8 @@ css_error compose_min_height(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_min_height(child, &length, &unit) ==
- CSS_MIN_HEIGHT_INHERIT) {
- uint8_t p = css_computed_min_height(parent, &length, &unit);
+ if (get_min_height(child, &length, &unit) == CSS_MIN_HEIGHT_INHERIT) {
+ uint8_t p = get_min_height(parent, &length, &unit);
return set_min_height(result, p, length, unit);
}
@@ -3275,9 +3241,8 @@ css_error compose_min_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_min_width(child, &length, &unit) ==
- CSS_MIN_WIDTH_INHERIT) {
- uint8_t p = css_computed_min_width(parent, &length, &unit);
+ if (get_min_width(child, &length, &unit) == CSS_MIN_WIDTH_INHERIT) {
+ uint8_t p = get_min_width(parent, &length, &unit);
return set_min_width(result, p, length, unit);
}
@@ -3364,9 +3329,9 @@ css_error compose_outline_color(const css_computed_style *parent,
css_color color = 0;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_outline_color(child, &color) ==
+ get_outline_color(child, &color) ==
CSS_OUTLINE_COLOR_INHERIT) {
- uint8_t p = css_computed_outline_color(parent, &color);
+ uint8_t p = get_outline_color(parent, &color);
return set_outline_color(result, p, color);
}
@@ -3395,9 +3360,8 @@ css_error compose_outline_style(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_outline_style(child) == CSS_OUTLINE_STYLE_INHERIT) {
- return set_outline_style(result,
- css_computed_outline_style(parent));
+ if (get_outline_style(child) == CSS_OUTLINE_STYLE_INHERIT) {
+ return set_outline_style(result, get_outline_style(parent));
}
return CSS_OK;
@@ -3430,9 +3394,9 @@ css_error compose_outline_width(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_outline_width(child, &length, &unit) ==
+ get_outline_width(child, &length, &unit) ==
CSS_OUTLINE_WIDTH_INHERIT) {
- uint8_t p = css_computed_outline_width(parent, &length, &unit);
+ uint8_t p = get_outline_width(parent, &length, &unit);
return set_outline_width(result, p, length, unit);
}
@@ -3487,8 +3451,8 @@ css_error compose_overflow(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_overflow(child) == CSS_OVERFLOW_INHERIT) {
- return set_overflow(result, css_computed_overflow(parent));
+ if (get_overflow(child) == CSS_OVERFLOW_INHERIT) {
+ return set_overflow(result, get_overflow(parent));
}
return CSS_OK;
@@ -3519,9 +3483,8 @@ css_error compose_padding_top(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_padding_top(child, &length, &unit) ==
- CSS_PADDING_INHERIT) {
- uint8_t p = css_computed_padding_top(parent, &length, &unit);
+ if (get_padding_top(child, &length, &unit) == CSS_PADDING_INHERIT) {
+ uint8_t p = get_padding_top(parent, &length, &unit);
return set_padding_top(result, p, length, unit);
}
@@ -3555,9 +3518,8 @@ css_error compose_padding_right(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_padding_right(child, &length, &unit) ==
- CSS_PADDING_INHERIT) {
- uint8_t p = css_computed_padding_right(parent, &length, &unit);
+ if (get_padding_right(child, &length, &unit) == CSS_PADDING_INHERIT) {
+ uint8_t p = get_padding_right(parent, &length, &unit);
return set_padding_right(result, p, length, unit);
}
@@ -3591,9 +3553,8 @@ css_error compose_padding_bottom(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_padding_bottom(child, &length, &unit) ==
- CSS_PADDING_INHERIT) {
- uint8_t p = css_computed_padding_bottom(parent, &length, &unit);
+ if (get_padding_bottom(child, &length, &unit) == CSS_PADDING_INHERIT) {
+ uint8_t p = get_padding_bottom(parent, &length, &unit);
return set_padding_bottom(result, p, length, unit);
}
@@ -3626,9 +3587,8 @@ css_error compose_padding_left(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_padding_left(child, &length, &unit) ==
- CSS_PADDING_INHERIT) {
- uint8_t p = css_computed_padding_left(parent, &length, &unit);
+ if (get_padding_left(child, &length, &unit) == CSS_PADDING_INHERIT) {
+ uint8_t p = get_padding_left(parent, &length, &unit);
return set_padding_left(result, p, length, unit);
}
@@ -4027,8 +3987,8 @@ css_error compose_position(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_position(child) == CSS_POSITION_INHERIT) {
- return set_position(result, css_computed_position(parent));
+ if (get_position(child) == CSS_POSITION_INHERIT) {
+ return set_position(result, get_position(parent));
}
return CSS_OK;
@@ -4158,8 +4118,8 @@ css_error compose_quotes(const css_computed_style *parent,
css_error error;
lwc_string **quotes = NULL;
- if (css_computed_quotes(child, &quotes) == CSS_QUOTES_INHERIT) {
- uint8_t p = css_computed_quotes(parent, &quotes);
+ if (get_quotes(child, &quotes) == CSS_QUOTES_INHERIT) {
+ uint8_t p = get_quotes(parent, &quotes);
size_t n_quotes = 0;
lwc_string **copy = NULL;
@@ -4248,9 +4208,8 @@ css_error compose_right(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_right(child, &length, &unit) ==
- CSS_RIGHT_INHERIT) {
- uint8_t p = css_computed_right(parent, &length, &unit);
+ if (get_right(child, &length, &unit) == CSS_RIGHT_INHERIT) {
+ uint8_t p = get_right(parent, &length, &unit);
return set_right(result, p, length, unit);
}
@@ -4603,9 +4562,8 @@ css_error compose_table_layout(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_table_layout(child) == CSS_TABLE_LAYOUT_INHERIT) {
- return set_table_layout(result,
- css_computed_table_layout(parent));
+ if (get_table_layout(child) == CSS_TABLE_LAYOUT_INHERIT) {
+ return set_table_layout(result, get_table_layout(parent));
}
return CSS_OK;
@@ -4658,8 +4616,8 @@ css_error compose_text_align(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_text_align(child) == CSS_TEXT_ALIGN_INHERIT) {
- return set_text_align(result, css_computed_text_align(parent));
+ if (get_text_align(child) == CSS_TEXT_ALIGN_INHERIT) {
+ return set_text_align(result, get_text_align(parent));
}
return CSS_OK;
@@ -4712,10 +4670,8 @@ css_error compose_text_decoration(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_text_decoration(child) ==
- CSS_TEXT_DECORATION_INHERIT) {
- return set_text_decoration(result,
- css_computed_text_decoration(parent));
+ if (get_text_decoration(child) == CSS_TEXT_DECORATION_INHERIT) {
+ return set_text_decoration(result, get_text_decoration(parent));
}
return CSS_OK;
@@ -4747,9 +4703,8 @@ css_error compose_text_indent(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_text_indent(child, &length, &unit) ==
- CSS_TEXT_INDENT_INHERIT) {
- uint8_t p = css_computed_text_indent(parent, &length, &unit);
+ if (get_text_indent(child, &length, &unit) == CSS_TEXT_INDENT_INHERIT) {
+ uint8_t p = get_text_indent(parent, &length, &unit);
return set_text_indent(result, p, length, unit);
}
@@ -4804,9 +4759,8 @@ css_error compose_text_transform(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_text_transform(child) == CSS_TEXT_TRANSFORM_INHERIT) {
- return set_text_transform(result,
- css_computed_text_transform(parent));
+ if (get_text_transform(child) == CSS_TEXT_TRANSFORM_INHERIT) {
+ return set_text_transform(result, get_text_transform(parent));
}
return CSS_OK;
@@ -4837,9 +4791,8 @@ css_error compose_top(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_top(child, &length, &unit) ==
- CSS_TOP_INHERIT) {
- uint8_t p = css_computed_top(parent, &length, &unit);
+ if (get_top(child, &length, &unit) == CSS_TOP_INHERIT) {
+ uint8_t p = get_top(parent, &length, &unit);
return set_top(result, p, length, unit);
}
@@ -4891,9 +4844,8 @@ css_error compose_unicode_bidi(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_unicode_bidi(child) == CSS_UNICODE_BIDI_INHERIT) {
- return set_unicode_bidi(result,
- css_computed_unicode_bidi(parent));
+ if (get_unicode_bidi(child) == CSS_UNICODE_BIDI_INHERIT) {
+ return set_unicode_bidi(result, get_unicode_bidi(parent));
}
return CSS_OK;
@@ -4973,9 +4925,9 @@ css_error compose_vertical_align(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_vertical_align(child, &length, &unit) ==
+ if (get_vertical_align(child, &length, &unit) ==
CSS_VERTICAL_ALIGN_INHERIT) {
- uint8_t p = css_computed_vertical_align(parent, &length, &unit);
+ uint8_t p = get_vertical_align(parent, &length, &unit);
return set_vertical_align(result, p, length, unit);
}
@@ -5027,8 +4979,8 @@ css_error compose_visibility(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_visibility(child) == CSS_VISIBILITY_INHERIT) {
- return set_visibility(result, css_computed_visibility(parent));
+ if (get_visibility(child) == CSS_VISIBILITY_INHERIT) {
+ return set_visibility(result, get_visibility(parent));
}
return CSS_OK;
@@ -5275,9 +5227,8 @@ css_error compose_white_space(const css_computed_style *parent,
const css_computed_style *child,
css_computed_style *result)
{
- if (css_computed_white_space(child) == CSS_WHITE_SPACE_INHERIT) {
- return set_white_space(result,
- css_computed_white_space(parent));
+ if (get_white_space(child) == CSS_WHITE_SPACE_INHERIT) {
+ return set_white_space(result, get_white_space(parent));
}
return CSS_OK;
@@ -5342,8 +5293,8 @@ css_error compose_width(const css_computed_style *parent,
css_fixed length = 0;
css_unit unit = CSS_UNIT_PX;
- if (css_computed_width(child, &length, &unit) == CSS_WIDTH_INHERIT) {
- uint8_t p = css_computed_width(parent, &length, &unit);
+ if (get_width(child, &length, &unit) == CSS_WIDTH_INHERIT) {
+ uint8_t p = get_width(parent, &length, &unit);
return set_width(result, p, length, unit);
}
@@ -5378,9 +5329,9 @@ css_error compose_word_spacing(const css_computed_style *parent,
css_unit unit = CSS_UNIT_PX;
if ((child->uncommon == NULL && parent->uncommon != NULL) ||
- css_computed_word_spacing(child, &length, &unit) ==
+ get_word_spacing(child, &length, &unit) ==
CSS_WORD_SPACING_INHERIT) {
- uint8_t p = css_computed_word_spacing(parent, &length, &unit);
+ uint8_t p = get_word_spacing(parent, &length, &unit);
return set_word_spacing(result, p, length, unit);
}
@@ -5433,8 +5384,8 @@ css_error compose_z_index(const css_computed_style *parent,
{
int32_t index = 0;
- if (css_computed_z_index(child, &index) == CSS_Z_INDEX_INHERIT) {
- uint8_t p = css_computed_z_index(parent, &index);
+ if (get_z_index(child, &index) == CSS_Z_INDEX_INHERIT) {
+ uint8_t p = get_z_index(parent, &index);
return set_z_index(result, p, index);
}
diff --git a/src/select/propget.h b/src/select/propget.h
new file mode 100644
index 0000000..23c7cdf
--- /dev/null
+++ b/src/select/propget.h
@@ -0,0 +1,1724 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#ifndef css_select_propget_h_
+#define css_select_propget_h_
+
+#include <libcss/computed.h>
+
+/* Important: keep this file in sync with computed.h */
+/** \todo Is there a better way to ensure this happens? */
+
+#define LETTER_SPACING_INDEX 0
+#define LETTER_SPACING_SHIFT 2
+#define LETTER_SPACING_MASK 0xfc
+static inline uint8_t get_letter_spacing(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[LETTER_SPACING_INDEX];
+ bits &= LETTER_SPACING_MASK;
+ bits >>= LETTER_SPACING_SHIFT;
+
+ /* 6bits: uuuutt : unit | type */
+
+ if ((bits & 3) == CSS_LETTER_SPACING_SET) {
+ *length = style->uncommon->letter_spacing;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 3);
+ }
+
+ return CSS_LETTER_SPACING_NORMAL;
+}
+#undef LETTER_SPACING_MASK
+#undef LETTER_SPACING_SHIFT
+#undef LETTER_SPACING_INDEX
+
+#define OUTLINE_COLOR_INDEX 0
+#define OUTLINE_COLOR_SHIFT 0
+#define OUTLINE_COLOR_MASK 0x3
+static inline uint8_t get_outline_color(
+ const css_computed_style *style, css_color *color)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[OUTLINE_COLOR_INDEX];
+ bits &= OUTLINE_COLOR_MASK;
+ bits >>= 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;
+}
+#undef OUTLINE_COLOR_MASK
+#undef OUTLINE_COLOR_SHIFT
+#undef OUTLINE_COLOR_INDEX
+
+#define OUTLINE_WIDTH_INDEX 1
+#define OUTLINE_WIDTH_SHIFT 1
+#define OUTLINE_WIDTH_MASK 0xfe
+static inline uint8_t get_outline_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[OUTLINE_WIDTH_INDEX];
+ bits &= OUTLINE_WIDTH_MASK;
+ bits >>= OUTLINE_WIDTH_SHIFT;
+
+ /* 7bits: uuuuttt : unit | type */
+
+ if ((bits & 7) == CSS_OUTLINE_WIDTH_WIDTH) {
+ *length = style->uncommon->outline_width;
+ *unit = bits >> 3;
+ }
+
+ return (bits & 7);
+ }
+
+ *length = INTTOFIX(2);
+ *unit = CSS_UNIT_PX;
+
+ return CSS_OUTLINE_WIDTH_WIDTH;
+}
+#undef OUTLINE_WIDTH_MASK
+#undef OUTLINE_WIDTH_SHIFT
+#undef OUTLINE_WIDTH_INDEX
+
+#define BORDER_SPACING_INDEX 1
+#define BORDER_SPACING_SHIFT 0
+#define BORDER_SPACING_MASK 0x1
+#define BORDER_SPACING_INDEX1 2
+#define BORDER_SPACING_SHIFT1 0
+#define BORDER_SPACING_MASK1 0xff
+static inline uint8_t get_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[BORDER_SPACING_INDEX];
+ bits &= BORDER_SPACING_MASK;
+ bits >>= BORDER_SPACING_SHIFT;
+
+ /* 1 bit: type */
+ if (bits == CSS_BORDER_SPACING_SET) {
+ uint8_t bits1 =
+ style->uncommon->bits[BORDER_SPACING_INDEX1];
+ bits1 &= BORDER_SPACING_MASK1;
+ bits1 >>= BORDER_SPACING_SHIFT1;
+
+ /* 8bits: hhhhvvvv : hunit | vunit */
+
+ *hlength = style->uncommon->border_spacing[0];
+ *hunit = bits1 >> 4;
+
+ *vlength = style->uncommon->border_spacing[1];
+ *vunit = bits1 & 0xf;
+ }
+
+ return bits;
+ } else {
+ *hlength = *vlength = 0;
+ *hunit = *vunit = CSS_UNIT_PX;
+ }
+
+ return CSS_BORDER_SPACING_SET;
+}
+#undef BORDER_SPACING_MASK1
+#undef BORDER_SPACING_SHIFT1
+#undef BORDER_SPACING_INDEX1
+#undef BORDER_SPACING_MASK
+#undef BORDER_SPACING_SHIFT
+#undef BORDER_SPACING_INDEX
+
+#define WORD_SPACING_INDEX 3
+#define WORD_SPACING_SHIFT 2
+#define WORD_SPACING_MASK 0xfc
+static inline uint8_t get_word_spacing(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[WORD_SPACING_INDEX];
+ bits &= WORD_SPACING_MASK;
+ bits >>= WORD_SPACING_SHIFT;
+
+ /* 6bits: uuuutt : unit | type */
+
+ if ((bits & 3) == CSS_WORD_SPACING_SET) {
+ *length = style->uncommon->word_spacing;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 3);
+ }
+
+ return CSS_WORD_SPACING_NORMAL;
+}
+#undef WORD_SPACING_MASK
+#undef WORD_SPACING_SHIFT
+#undef WORD_SPACING_INDEX
+
+#define COUNTER_INCREMENT_INDEX 3
+#define COUNTER_INCREMENT_SHIFT 1
+#define COUNTER_INCREMENT_MASK 0x2
+static inline uint8_t get_counter_increment(
+ const css_computed_style *style,
+ const css_computed_counter **counters)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[COUNTER_INCREMENT_INDEX];
+ bits &= COUNTER_INCREMENT_MASK;
+ bits >>= COUNTER_INCREMENT_SHIFT;
+
+ /* 1bit: type */
+ *counters = style->uncommon->counter_increment;
+
+ return bits;
+ }
+
+ return CSS_COUNTER_INCREMENT_NONE;
+}
+#undef COUNTER_INCREMENT_MASK
+#undef COUNTER_INCREMENT_SHIFT
+#undef COUNTER_INCREMENT_INDEX
+
+#define COUNTER_RESET_INDEX 3
+#define COUNTER_RESET_SHIFT 0
+#define COUNTER_RESET_MASK 0x1
+static inline uint8_t get_counter_reset(
+ const css_computed_style *style,
+ const css_computed_counter **counters)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[COUNTER_RESET_INDEX];
+ bits &= COUNTER_RESET_MASK;
+ bits >>= COUNTER_RESET_SHIFT;
+
+ /* 1bit: type */
+ *counters = style->uncommon->counter_reset;
+
+ return bits;
+ }
+
+ return CSS_COUNTER_RESET_NONE;
+}
+#undef COUNTER_RESET_MASK
+#undef COUNTER_RESET_SHIFT
+#undef COUNTER_RESET_INDEX
+
+#define CURSOR_INDEX 4
+#define CURSOR_SHIFT 3
+#define CURSOR_MASK 0xf8
+static inline uint8_t get_cursor(
+ const css_computed_style *style,
+ lwc_string ***urls)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[CURSOR_INDEX];
+ bits &= CURSOR_MASK;
+ bits >>= CURSOR_SHIFT;
+
+ /* 5bits: type */
+ *urls = style->uncommon->cursor;
+
+ return bits;
+ }
+
+ return CSS_CURSOR_AUTO;
+}
+#undef CURSOR_MASK
+#undef CURSOR_SHIFT
+#undef CURSOR_INDEX
+
+#define CLIP_INDEX 7
+#define CLIP_SHIFT 2
+#define CLIP_MASK 0xfc
+#define CLIP_INDEX1 5
+#define CLIP_SHIFT1 0
+#define CLIP_MASK1 0xff
+#define CLIP_INDEX2 6
+#define CLIP_SHIFT2 0
+#define CLIP_MASK2 0xff
+static inline uint8_t get_clip(
+ const css_computed_style *style,
+ css_computed_clip_rect *rect)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[CLIP_INDEX];
+ bits &= CLIP_MASK;
+ bits >>= 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[CLIP_INDEX1];
+ bits1 &= CLIP_MASK1;
+ bits1 >>= CLIP_SHIFT1;
+ } else {
+ bits1 = 0;
+ }
+
+ rect->top = style->uncommon->clip[0];
+ rect->tunit = bits1 >> 4;
+
+ rect->right = style->uncommon->clip[1];
+ rect->runit = bits1 & 0xf;
+
+ if (rect->bottom_auto == false ||
+ rect->left_auto == false) {
+ /* 8bits: bbbbllll : bottom | left */
+ bits1 = style->uncommon->bits[CLIP_INDEX2];
+ bits1 &= CLIP_MASK2;
+ bits1 >>= CLIP_SHIFT2;
+ } else {
+ bits1 = 0;
+ }
+
+ rect->bottom = style->uncommon->clip[2];
+ rect->bunit = bits1 >> 4;
+
+ rect->left = style->uncommon->clip[3];
+ rect->lunit = bits1 & 0xf;
+ }
+
+ return (bits & 0x3);
+ }
+
+ return CSS_CLIP_AUTO;
+}
+#undef CLIP_MASK2
+#undef CLIP_SHIFT2
+#undef CLIP_INDEX2
+#undef CLIP_MASK1
+#undef CLIP_SHIFT1
+#undef CLIP_INDEX1
+#undef CLIP_MASK
+#undef CLIP_SHIFT
+#undef CLIP_INDEX
+
+#define CONTENT_INDEX 7
+#define CONTENT_SHIFT 0
+#define CONTENT_MASK 0x3
+static inline uint8_t get_content(
+ const css_computed_style *style,
+ const css_computed_content_item **content)
+{
+ if (style->uncommon != NULL) {
+ uint8_t bits = style->uncommon->bits[CONTENT_INDEX];
+ bits &= CONTENT_MASK;
+ bits >>= CONTENT_SHIFT;
+
+ /* 2bits: type */
+ *content = style->uncommon->content;
+
+ return bits;
+ }
+
+ return CSS_CONTENT_NORMAL;
+}
+#undef CONTENT_MASK
+#undef CONTENT_SHIFT
+#undef CONTENT_INDEX
+
+#define VERTICAL_ALIGN_INDEX 0
+#define VERTICAL_ALIGN_SHIFT 0
+#define VERTICAL_ALIGN_MASK 0xff
+static inline uint8_t get_vertical_align(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[VERTICAL_ALIGN_INDEX];
+ bits &= VERTICAL_ALIGN_MASK;
+ bits >>= VERTICAL_ALIGN_SHIFT;
+
+ /* 8bits: uuuutttt : units | type */
+ if ((bits & 0xf) == CSS_VERTICAL_ALIGN_SET) {
+ *length = style->vertical_align;
+ *unit = bits >> 4;
+ }
+
+ return (bits & 0xf);
+}
+#undef VERTICAL_ALIGN_MASK
+#undef VERTICAL_ALIGN_SHIFT
+#undef VERTICAL_ALIGN_INDEX
+
+#define FONT_SIZE_INDEX 1
+#define FONT_SIZE_SHIFT 0
+#define FONT_SIZE_MASK 0xff
+static inline uint8_t get_font_size(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[FONT_SIZE_INDEX];
+ bits &= FONT_SIZE_MASK;
+ bits >>= FONT_SIZE_SHIFT;
+
+ /* 8bits: uuuutttt : units | type */
+ if ((bits & 0xf) == CSS_FONT_SIZE_DIMENSION) {
+ *length = style->font_size;
+ *unit = bits >> 4;
+ }
+
+ return (bits & 0xf);
+}
+#undef FONT_SIZE_MASK
+#undef FONT_SIZE_SHIFT
+#undef FONT_SIZE_INDEX
+
+#define BORDER_TOP_WIDTH_INDEX 2
+#define BORDER_TOP_WIDTH_SHIFT 1
+#define BORDER_TOP_WIDTH_MASK 0xfe
+static inline uint8_t get_border_top_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[BORDER_TOP_WIDTH_INDEX];
+ bits &= BORDER_TOP_WIDTH_MASK;
+ bits >>= BORDER_TOP_WIDTH_SHIFT;
+
+ /* 7bits: uuuuttt : units | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->border_width[0];
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_TOP_WIDTH_MASK
+#undef BORDER_TOP_WIDTH_SHIFT
+#undef BORDER_TOP_WIDTH_INDEX
+
+#define BORDER_RIGHT_WIDTH_INDEX 3
+#define BORDER_RIGHT_WIDTH_SHIFT 1
+#define BORDER_RIGHT_WIDTH_MASK 0xfe
+static inline uint8_t get_border_right_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[BORDER_RIGHT_WIDTH_INDEX];
+ bits &= BORDER_RIGHT_WIDTH_MASK;
+ bits >>= BORDER_RIGHT_WIDTH_SHIFT;
+
+ /* 7bits: uuuuttt : units | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->border_width[1];
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_RIGHT_WIDTH_MASK
+#undef BORDER_RIGHT_WIDTH_SHIFT
+#undef BORDER_RIGHT_WIDTH_INDEX
+
+#define BORDER_BOTTOM_WIDTH_INDEX 4
+#define BORDER_BOTTOM_WIDTH_SHIFT 1
+#define BORDER_BOTTOM_WIDTH_MASK 0xfe
+static inline uint8_t get_border_bottom_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[BORDER_BOTTOM_WIDTH_INDEX];
+ bits &= BORDER_BOTTOM_WIDTH_MASK;
+ bits >>= BORDER_BOTTOM_WIDTH_SHIFT;
+
+ /* 7bits: uuuuttt : units | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->border_width[2];
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_BOTTOM_WIDTH_MASK
+#undef BORDER_BOTTOM_WIDTH_SHIFT
+#undef BORDER_BOTTOM_WIDTH_INDEX
+
+#define BORDER_LEFT_WIDTH_INDEX 5
+#define BORDER_LEFT_WIDTH_SHIFT 1
+#define BORDER_LEFT_WIDTH_MASK 0xfe
+static inline uint8_t get_border_left_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[BORDER_LEFT_WIDTH_INDEX];
+ bits &= BORDER_LEFT_WIDTH_MASK;
+ bits >>= BORDER_LEFT_WIDTH_SHIFT;
+
+ /* 7bits: uuuuttt : units | type */
+ if ((bits & 0x7) == CSS_BORDER_WIDTH_WIDTH) {
+ *length = style->border_width[3];
+ *unit = bits >> 3;
+ }
+
+ return (bits & 0x7);
+}
+#undef BORDER_LEFT_WIDTH_MASK
+#undef BORDER_LEFT_WIDTH_SHIFT
+#undef BORDER_LEFT_WIDTH_INDEX
+
+#define BACKGROUND_IMAGE_INDEX 2
+#define BACKGROUND_IMAGE_SHIFT 0
+#define BACKGROUND_IMAGE_MASK 0x1
+static inline uint8_t get_background_image(
+ const css_computed_style *style,
+ lwc_string **url)
+{
+ uint8_t bits = style->bits[BACKGROUND_IMAGE_INDEX];
+ bits &= BACKGROUND_IMAGE_MASK;
+ bits >>= BACKGROUND_IMAGE_SHIFT;
+
+ /* 1bit: type */
+ *url = style->background_image;
+
+ return bits;
+}
+#undef BACKGROUND_IMAGE_MASK
+#undef BACKGROUND_IMAGE_SHIFT
+#undef BACKGROUND_IMAGE_INDEX
+
+#define COLOR_INDEX 3
+#define COLOR_SHIFT 0
+#define COLOR_MASK 0x1
+static inline uint8_t get_color(
+ const css_computed_style *style,
+ css_color *color)
+{
+ uint8_t bits = style->bits[COLOR_INDEX];
+ bits &= COLOR_MASK;
+ bits >>= COLOR_SHIFT;
+
+ /* 1bit: type */
+ *color = style->color;
+
+ return bits;
+}
+#undef COLOR_MASK
+#undef COLOR_SHIFT
+#undef COLOR_INDEX
+
+#define LIST_STYLE_IMAGE_INDEX 4
+#define LIST_STYLE_IMAGE_SHIFT 0
+#define LIST_STYLE_IMAGE_MASK 0x1
+static inline uint8_t get_list_style_image(
+ const css_computed_style *style,
+ lwc_string **url)
+{
+ uint8_t bits = style->bits[LIST_STYLE_IMAGE_INDEX];
+ bits &= LIST_STYLE_IMAGE_MASK;
+ bits >>= LIST_STYLE_IMAGE_SHIFT;
+
+ /* 1bit: type */
+ *url = style->list_style_image;
+
+ return bits;
+}
+#undef LIST_STYLE_IMAGE_MASK
+#undef LIST_STYLE_IMAGE_SHIFT
+#undef LIST_STYLE_IMAGE_INDEX
+
+#define QUOTES_INDEX 5
+#define QUOTES_SHIFT 0
+#define QUOTES_MASK 0x1
+static inline uint8_t get_quotes(
+ const css_computed_style *style,
+ lwc_string ***quotes)
+{
+ uint8_t bits = style->bits[QUOTES_INDEX];
+ bits &= QUOTES_MASK;
+ bits >>= QUOTES_SHIFT;
+
+ /* 1bit: type */
+ *quotes = style->quotes;
+
+ return bits;
+}
+#undef QUOTES_MASK
+#undef QUOTES_SHIFT
+#undef QUOTES_INDEX
+
+#define TOP_INDEX 6
+#define TOP_SHIFT 2
+#define TOP_MASK 0xfc
+static inline uint8_t get_top(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[TOP_INDEX];
+ bits &= TOP_MASK;
+ bits >>= TOP_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_TOP_SET) {
+ *length = style->top;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef TOP_MASK
+#undef TOP_SHIFT
+#undef TOP_INDEX
+
+#define RIGHT_INDEX 7
+#define RIGHT_SHIFT 2
+#define RIGHT_MASK 0xfc
+static inline uint8_t get_right(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[RIGHT_INDEX];
+ bits &= RIGHT_MASK;
+ bits >>= RIGHT_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_RIGHT_SET) {
+ *length = style->right;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef RIGHT_MASK
+#undef RIGHT_SHIFT
+#undef RIGHT_INDEX
+
+#define BOTTOM_INDEX 8
+#define BOTTOM_SHIFT 2
+#define BOTTOM_MASK 0xfc
+static inline uint8_t get_bottom(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[BOTTOM_INDEX];
+ bits &= BOTTOM_MASK;
+ bits >>= BOTTOM_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_BOTTOM_SET) {
+ *length = style->bottom;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef BOTTOM_MASK
+#undef BOTTOM_SHIFT
+#undef BOTTOM_INDEX
+
+#define LEFT_INDEX 9
+#define LEFT_SHIFT 2
+#define LEFT_MASK 0xfc
+static inline uint8_t get_left(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[LEFT_INDEX];
+ bits &= LEFT_MASK;
+ bits >>= LEFT_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_LEFT_SET) {
+ *length = style->left;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef LEFT_MASK
+#undef LEFT_SHIFT
+#undef LEFT_INDEX
+
+#define BORDER_TOP_COLOR_INDEX 6
+#define BORDER_TOP_COLOR_SHIFT 0
+#define BORDER_TOP_COLOR_MASK 0x3
+static inline uint8_t get_border_top_color(
+ const css_computed_style *style,
+ css_color *color)
+{
+ uint8_t bits = style->bits[BORDER_TOP_COLOR_INDEX];
+ bits &= BORDER_TOP_COLOR_MASK;
+ bits >>= BORDER_TOP_COLOR_SHIFT;
+
+ /* 2bits: type */
+ *color = style->border_color[0];
+
+ return bits;
+}
+#undef BORDER_TOP_COLOR_MASK
+#undef BORDER_TOP_COLOR_SHIFT
+#undef BORDER_TOP_COLOR_INDEX
+
+#define BORDER_RIGHT_COLOR_INDEX 7
+#define BORDER_RIGHT_COLOR_SHIFT 0
+#define BORDER_RIGHT_COLOR_MASK 0x3
+static inline uint8_t get_border_right_color(
+ const css_computed_style *style,
+ css_color *color)
+{
+ uint8_t bits = style->bits[BORDER_RIGHT_COLOR_INDEX];
+ bits &= BORDER_RIGHT_COLOR_MASK;
+ bits >>= BORDER_RIGHT_COLOR_SHIFT;
+
+ /* 2bits: type */
+ *color = style->border_color[1];
+
+ return bits;
+}
+#undef BORDER_RIGHT_COLOR_MASK
+#undef BORDER_RIGHT_COLOR_SHIFT
+#undef BORDER_RIGHT_COLOR_INDEX
+
+#define BORDER_BOTTOM_COLOR_INDEX 8
+#define BORDER_BOTTOM_COLOR_SHIFT 0
+#define BORDER_BOTTOM_COLOR_MASK 0x3
+static inline uint8_t get_border_bottom_color(
+ const css_computed_style *style,
+ css_color *color)
+{
+ uint8_t bits = style->bits[BORDER_BOTTOM_COLOR_INDEX];
+ bits &= BORDER_BOTTOM_COLOR_MASK;
+ bits >>= BORDER_BOTTOM_COLOR_SHIFT;
+
+ /* 2bits: type */
+ *color = style->border_color[2];
+
+ return bits;
+}
+#undef BORDER_BOTTOM_COLOR_MASK
+#undef BORDER_BOTTOM_COLOR_SHIFT
+#undef BORDER_BOTTOM_COLOR_INDEX
+
+#define BORDER_LEFT_COLOR_INDEX 9
+#define BORDER_LEFT_COLOR_SHIFT 0
+#define BORDER_LEFT_COLOR_MASK 0x3
+static inline uint8_t get_border_left_color(
+ const css_computed_style *style,
+ css_color *color)
+{
+ uint8_t bits = style->bits[BORDER_LEFT_COLOR_INDEX];
+ bits &= BORDER_LEFT_COLOR_MASK;
+ bits >>= BORDER_LEFT_COLOR_SHIFT;
+
+ /* 2bits: type */
+ *color = style->border_color[3];
+
+ return bits;
+}
+#undef BORDER_LEFT_COLOR_MASK
+#undef BORDER_LEFT_COLOR_SHIFT
+#undef BORDER_LEFT_COLOR_INDEX
+
+#define HEIGHT_INDEX 10
+#define HEIGHT_SHIFT 2
+#define HEIGHT_MASK 0xfc
+static inline uint8_t get_height(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[HEIGHT_INDEX];
+ bits &= HEIGHT_MASK;
+ bits >>= HEIGHT_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_HEIGHT_SET) {
+ *length = style->height;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef HEIGHT_MASK
+#undef HEIGHT_SHIFT
+#undef HEIGHT_INDEX
+
+#define LINE_HEIGHT_INDEX 11
+#define LINE_HEIGHT_SHIFT 2
+#define LINE_HEIGHT_MASK 0xfc
+static inline uint8_t get_line_height(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[LINE_HEIGHT_INDEX];
+ bits &= LINE_HEIGHT_MASK;
+ bits >>= 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 = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef LINE_HEIGHT_MASK
+#undef LINE_HEIGHT_SHIFT
+#undef LINE_HEIGHT_INDEX
+
+#define BACKGROUND_COLOR_INDEX 10
+#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)
+{
+ uint8_t bits = style->bits[BACKGROUND_COLOR_INDEX];
+ bits &= BACKGROUND_COLOR_MASK;
+ bits >>= BACKGROUND_COLOR_SHIFT;
+
+ /* 2bits: type */
+ *color = style->background_color;
+
+ return bits;
+}
+#undef BACKGROUND_COLOR_MASK
+#undef BACKGROUND_COLOR_SHIFT
+#undef BACKGROUND_COLOR_INDEX
+
+#define Z_INDEX_INDEX 11
+#define Z_INDEX_SHIFT 0
+#define Z_INDEX_MASK 0x3
+static inline uint8_t get_z_index(
+ const css_computed_style *style,
+ int32_t *z_index)
+{
+ uint8_t bits = style->bits[Z_INDEX_INDEX];
+ bits &= Z_INDEX_MASK;
+ bits >>= Z_INDEX_SHIFT;
+
+ /* 2bits: type */
+ *z_index = style->z_index;
+
+ return bits;
+}
+#undef Z_INDEX_MASK
+#undef Z_INDEX_SHIFT
+#undef Z_INDEX_INDEX
+
+#define MARGIN_TOP_INDEX 12
+#define MARGIN_TOP_SHIFT 2
+#define MARGIN_TOP_MASK 0xfc
+static inline uint8_t get_margin_top(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MARGIN_TOP_INDEX];
+ bits &= MARGIN_TOP_MASK;
+ bits >>= MARGIN_TOP_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->margin[0];
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_TOP_MASK
+#undef MARGIN_TOP_SHIFT
+#undef MARGIN_TOP_INDEX
+
+#define MARGIN_RIGHT_INDEX 13
+#define MARGIN_RIGHT_SHIFT 2
+#define MARGIN_RIGHT_MASK 0xfc
+static inline uint8_t get_margin_right(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MARGIN_RIGHT_INDEX];
+ bits &= MARGIN_RIGHT_MASK;
+ bits >>= MARGIN_RIGHT_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->margin[1];
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_RIGHT_MASK
+#undef MARGIN_RIGHT_SHIFT
+#undef MARGIN_RIGHT_INDEX
+
+#define MARGIN_BOTTOM_INDEX 14
+#define MARGIN_BOTTOM_SHIFT 2
+#define MARGIN_BOTTOM_MASK 0xfc
+static inline uint8_t get_margin_bottom(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MARGIN_BOTTOM_INDEX];
+ bits &= MARGIN_BOTTOM_MASK;
+ bits >>= MARGIN_BOTTOM_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->margin[2];
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_BOTTOM_MASK
+#undef MARGIN_BOTTOM_SHIFT
+#undef MARGIN_BOTTOM_INDEX
+
+#define MARGIN_LEFT_INDEX 15
+#define MARGIN_LEFT_SHIFT 2
+#define MARGIN_LEFT_MASK 0xfc
+static inline uint8_t get_margin_left(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MARGIN_LEFT_INDEX];
+ bits &= MARGIN_LEFT_MASK;
+ bits >>= MARGIN_LEFT_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MARGIN_SET) {
+ *length = style->margin[3];
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MARGIN_LEFT_MASK
+#undef MARGIN_LEFT_SHIFT
+#undef MARGIN_LEFT_INDEX
+
+#define BACKGROUND_ATTACHMENT_INDEX 12
+#define BACKGROUND_ATTACHMENT_SHIFT 0
+#define BACKGROUND_ATTACHMENT_MASK 0x3
+static inline uint8_t get_background_attachment(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[BACKGROUND_ATTACHMENT_INDEX];
+ bits &= BACKGROUND_ATTACHMENT_MASK;
+ bits >>= BACKGROUND_ATTACHMENT_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef BACKGROUND_ATTACHMENT_MASK
+#undef BACKGROUND_ATTACHMENT_SHIFT
+#undef BACKGROUND_ATTACHMENT_INDEX
+
+#define BORDER_COLLAPSE_INDEX 13
+#define BORDER_COLLAPSE_SHIFT 0
+#define BORDER_COLLAPSE_MASK 0x3
+static inline uint8_t get_border_collapse(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[BORDER_COLLAPSE_INDEX];
+ bits &= BORDER_COLLAPSE_MASK;
+ bits >>= BORDER_COLLAPSE_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef BORDER_COLLAPSE_MASK
+#undef BORDER_COLLAPSE_SHIFT
+#undef BORDER_COLLAPSE_INDEX
+
+#define CAPTION_SIDE_INDEX 14
+#define CAPTION_SIDE_SHIFT 0
+#define CAPTION_SIDE_MASK 0x3
+static inline uint8_t get_caption_side(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[CAPTION_SIDE_INDEX];
+ bits &= CAPTION_SIDE_MASK;
+ bits >>= CAPTION_SIDE_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef CAPTION_SIDE_MASK
+#undef CAPTION_SIDE_SHIFT
+#undef CAPTION_SIDE_INDEX
+
+#define DIRECTION_INDEX 15
+#define DIRECTION_SHIFT 0
+#define DIRECTION_MASK 0x3
+static inline uint8_t get_direction(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[DIRECTION_INDEX];
+ bits &= DIRECTION_MASK;
+ bits >>= DIRECTION_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef DIRECTION_MASK
+#undef DIRECTION_SHIFT
+#undef DIRECTION_INDEX
+
+#define MAX_HEIGHT_INDEX 16
+#define MAX_HEIGHT_SHIFT 2
+#define MAX_HEIGHT_MASK 0xfc
+static inline uint8_t get_max_height(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MAX_HEIGHT_INDEX];
+ bits &= MAX_HEIGHT_MASK;
+ bits >>= MAX_HEIGHT_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MAX_HEIGHT_SET) {
+ *length = style->max_height;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MAX_HEIGHT_MASK
+#undef MAX_HEIGHT_SHIFT
+#undef MAX_HEIGHT_INDEX
+
+#define MAX_WIDTH_INDEX 17
+#define MAX_WIDTH_SHIFT 2
+#define MAX_WIDTH_MASK 0xfc
+static inline uint8_t get_max_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MAX_WIDTH_INDEX];
+ bits &= MAX_WIDTH_MASK;
+ bits >>= MAX_WIDTH_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_MAX_WIDTH_SET) {
+ *length = style->max_width;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef MAX_WIDTH_MASK
+#undef MAX_WIDTH_SHIFT
+#undef MAX_WIDTH_INDEX
+
+#define WIDTH_INDEX 18
+#define WIDTH_SHIFT 2
+#define WIDTH_MASK 0xfc
+static inline uint8_t get_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[WIDTH_INDEX];
+ bits &= WIDTH_MASK;
+ bits >>= WIDTH_SHIFT;
+
+ /* 6bits: uuuutt : units | type */
+ if ((bits & 0x3) == CSS_WIDTH_SET) {
+ *length = style->width;
+ *unit = bits >> 2;
+ }
+
+ return (bits & 0x3);
+}
+#undef WIDTH_MASK
+#undef WIDTH_SHIFT
+#undef WIDTH_INDEX
+
+#define EMPTY_CELLS_INDEX 16
+#define EMPTY_CELLS_SHIFT 0
+#define EMPTY_CELLS_MASK 0x3
+static inline uint8_t get_empty_cells(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[EMPTY_CELLS_INDEX];
+ bits &= EMPTY_CELLS_MASK;
+ bits >>= EMPTY_CELLS_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef EMPTY_CELLS_MASK
+#undef EMPTY_CELLS_SHIFT
+#undef EMPTY_CELLS_INDEX
+
+#define FLOAT_INDEX 17
+#define FLOAT_SHIFT 0
+#define FLOAT_MASK 0x3
+static inline uint8_t get_float(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[FLOAT_INDEX];
+ bits &= FLOAT_MASK;
+ bits >>= FLOAT_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef FLOAT_MASK
+#undef FLOAT_SHIFT
+#undef FLOAT_INDEX
+
+#define FONT_STYLE_INDEX 18
+#define FONT_STYLE_SHIFT 0
+#define FONT_STYLE_MASK 0x3
+static inline uint8_t get_font_style(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[FONT_STYLE_INDEX];
+ bits &= FONT_STYLE_MASK;
+ bits >>= FONT_STYLE_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef FONT_STYLE_MASK
+#undef FONT_STYLE_SHIFT
+#undef FONT_STYLE_INDEX
+
+#define MIN_HEIGHT_INDEX 19
+#define MIN_HEIGHT_SHIFT 3
+#define MIN_HEIGHT_MASK 0xf8
+static inline uint8_t get_min_height(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MIN_HEIGHT_INDEX];
+ bits &= MIN_HEIGHT_MASK;
+ bits >>= MIN_HEIGHT_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_MIN_HEIGHT_SET) {
+ *length = style->min_height;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef MIN_HEIGHT_MASK
+#undef MIN_HEIGHT_SHIFT
+#undef MIN_HEIGHT_INDEX
+
+#define MIN_WIDTH_INDEX 20
+#define MIN_WIDTH_SHIFT 3
+#define MIN_WIDTH_MASK 0xf8
+static inline uint8_t get_min_width(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[MIN_WIDTH_INDEX];
+ bits &= MIN_WIDTH_MASK;
+ bits >>= MIN_WIDTH_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_MIN_WIDTH_SET) {
+ *length = style->min_width;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef MIN_WIDTH_MASK
+#undef MIN_WIDTH_SHIFT
+#undef MIN_WIDTH_INDEX
+
+#define BACKGROUND_REPEAT_INDEX 19
+#define BACKGROUND_REPEAT_SHIFT 0
+#define BACKGROUND_REPEAT_MASK 0x7
+static inline uint8_t get_background_repeat(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[BACKGROUND_REPEAT_INDEX];
+ bits &= BACKGROUND_REPEAT_MASK;
+ bits >>= BACKGROUND_REPEAT_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef BACKGROUND_REPEAT_MASK
+#undef BACKGROUND_REPEAT_SHIFT
+#undef BACKGROUND_REPEAT_INDEX
+
+#define CLEAR_INDEX 20
+#define CLEAR_SHIFT 0
+#define CLEAR_MASK 0x7
+static inline uint8_t get_clear(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[CLEAR_INDEX];
+ bits &= CLEAR_MASK;
+ bits >>= CLEAR_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef CLEAR_MASK
+#undef CLEAR_SHIFT
+#undef CLEAR_INDEX
+
+#define PADDING_TOP_INDEX 21
+#define PADDING_TOP_SHIFT 3
+#define PADDING_TOP_MASK 0xf8
+static inline uint8_t get_padding_top(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[PADDING_TOP_INDEX];
+ bits &= PADDING_TOP_MASK;
+ bits >>= PADDING_TOP_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->padding[0];
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_TOP_MASK
+#undef PADDING_TOP_SHIFT
+#undef PADDING_TOP_INDEX
+
+#define PADDING_RIGHT_INDEX 22
+#define PADDING_RIGHT_SHIFT 3
+#define PADDING_RIGHT_MASK 0xf8
+static inline uint8_t get_padding_right(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[PADDING_RIGHT_INDEX];
+ bits &= PADDING_RIGHT_MASK;
+ bits >>= PADDING_RIGHT_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->padding[1];
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_RIGHT_MASK
+#undef PADDING_RIGHT_SHIFT
+#undef PADDING_RIGHT_INDEX
+
+#define PADDING_BOTTOM_INDEX 23
+#define PADDING_BOTTOM_SHIFT 3
+#define PADDING_BOTTOM_MASK 0xf8
+static inline uint8_t get_padding_bottom(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[PADDING_BOTTOM_INDEX];
+ bits &= PADDING_BOTTOM_MASK;
+ bits >>= PADDING_BOTTOM_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->padding[2];
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_BOTTOM_MASK
+#undef PADDING_BOTTOM_SHIFT
+#undef PADDING_BOTTOM_INDEX
+
+#define PADDING_LEFT_INDEX 24
+#define PADDING_LEFT_SHIFT 3
+#define PADDING_LEFT_MASK 0xf8
+static inline uint8_t get_padding_left(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[PADDING_LEFT_INDEX];
+ bits &= PADDING_LEFT_MASK;
+ bits >>= PADDING_LEFT_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_PADDING_SET) {
+ *length = style->padding[3];
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef PADDING_LEFT_MASK
+#undef PADDING_LEFT_SHIFT
+#undef PADDING_LEFT_INDEX
+
+#define OVERFLOW_INDEX 21
+#define OVERFLOW_SHIFT 0
+#define OVERFLOW_MASK 0x7
+static inline uint8_t get_overflow(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[OVERFLOW_INDEX];
+ bits &= OVERFLOW_MASK;
+ bits >>= OVERFLOW_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef OVERFLOW_MASK
+#undef OVERFLOW_SHIFT
+#undef OVERFLOW_INDEX
+
+#define POSITION_INDEX 22
+#define POSITION_SHIFT 0
+#define POSITION_MASK 0x7
+static inline uint8_t get_position(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[POSITION_INDEX];
+ bits &= POSITION_MASK;
+ bits >>= POSITION_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef POSITION_MASK
+#undef POSITION_SHIFT
+#undef POSITION_INDEX
+
+#define TEXT_ALIGN_INDEX 23
+#define TEXT_ALIGN_SHIFT 0
+#define TEXT_ALIGN_MASK 0x7
+static inline uint8_t get_text_align(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[TEXT_ALIGN_INDEX];
+ bits &= TEXT_ALIGN_MASK;
+ bits >>= TEXT_ALIGN_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef TEXT_ALIGN_MASK
+#undef TEXT_ALIGN_SHIFT
+#undef TEXT_ALIGN_INDEX
+
+#define TEXT_TRANSFORM_INDEX 24
+#define TEXT_TRANSFORM_SHIFT 0
+#define TEXT_TRANSFORM_MASK 0x7
+static inline uint8_t get_text_transform(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[TEXT_TRANSFORM_INDEX];
+ bits &= TEXT_TRANSFORM_MASK;
+ bits >>= TEXT_TRANSFORM_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef TEXT_TRANSFORM_MASK
+#undef TEXT_TRANSFORM_SHIFT
+#undef TEXT_TRANSFORM_INDEX
+
+#define TEXT_INDENT_INDEX 25
+#define TEXT_INDENT_SHIFT 3
+#define TEXT_INDENT_MASK 0xf8
+static inline uint8_t get_text_indent(
+ const css_computed_style *style,
+ css_fixed *length, css_unit *unit)
+{
+ uint8_t bits = style->bits[TEXT_INDENT_INDEX];
+ bits &= TEXT_INDENT_MASK;
+ bits >>= TEXT_INDENT_SHIFT;
+
+ /* 5bits: uuuut : units | type */
+ if ((bits & 0x1) == CSS_TEXT_INDENT_SET) {
+ *length = style->text_indent;
+ *unit = bits >> 1;
+ }
+
+ return (bits & 0x1);
+}
+#undef TEXT_INDENT_MASK
+#undef TEXT_INDENT_SHIFT
+#undef TEXT_INDENT_INDEX
+
+#define WHITE_SPACE_INDEX 25
+#define WHITE_SPACE_SHIFT 0
+#define WHITE_SPACE_MASK 0x7
+static inline uint8_t get_white_space(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[WHITE_SPACE_INDEX];
+ bits &= WHITE_SPACE_MASK;
+ bits >>= WHITE_SPACE_SHIFT;
+
+ /* 3bits: type */
+ return bits;
+}
+#undef WHITE_SPACE_MASK
+#undef WHITE_SPACE_SHIFT
+#undef WHITE_SPACE_INDEX
+
+#define BACKGROUND_POSITION_INDEX 27
+#define BACKGROUND_POSITION_SHIFT 7
+#define BACKGROUND_POSITION_MASK 0x80
+#define BACKGROUND_POSITION_INDEX1 26
+#define BACKGROUND_POSITION_SHIFT1 0
+#define BACKGROUND_POSITION_MASK1 0xff
+static inline uint8_t get_background_position(
+ const css_computed_style *style,
+ css_fixed *hlength, css_unit *hunit,
+ css_fixed *vlength, css_unit *vunit)
+{
+ uint8_t bits = style->bits[BACKGROUND_POSITION_INDEX];
+ bits &= BACKGROUND_POSITION_MASK;
+ bits >>= BACKGROUND_POSITION_SHIFT;
+
+ /* 1bit: type */
+ if (bits == CSS_BACKGROUND_POSITION_SET) {
+ uint8_t bits1 = style->bits[BACKGROUND_POSITION_INDEX1];
+ bits1 &= BACKGROUND_POSITION_MASK1;
+ bits1 >>= BACKGROUND_POSITION_SHIFT1;
+
+ /* 8bits: hhhhvvvv : hunit | vunit */
+ *hlength = style->background_position[0];
+ *hunit = bits1 >> 4;
+
+ *vlength = style->background_position[1];
+ *vunit = bits1 & 0xf;
+ }
+
+ return bits;
+}
+#undef BACKGROUND_POSITION_MASK1
+#undef BACKGROUND_POSITION_SHIFT1
+#undef BACKGROUND_POSITION_INDEX1
+#undef BACKGROUND_POSITION_MASK
+#undef BACKGROUND_POSITION_SHIFT
+#undef BACKGROUND_POSITION_INDEX
+
+#define DISPLAY_INDEX 27
+#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];
+ bits &= DISPLAY_MASK;
+ bits >>= DISPLAY_SHIFT;
+
+ /* 5bits: type */
+ return bits;
+}
+
+#undef DISPLAY_MASK
+#undef DISPLAY_SHIFT
+#undef DISPLAY_INDEX
+
+#define FONT_VARIANT_INDEX 27
+#define FONT_VARIANT_SHIFT 0
+#define FONT_VARIANT_MASK 0x3
+static inline uint8_t get_font_variant(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[FONT_VARIANT_INDEX];
+ bits &= FONT_VARIANT_MASK;
+ bits >>= FONT_VARIANT_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef FONT_VARIANT_MASK
+#undef FONT_VARIANT_SHIFT
+#undef FONT_VARIANT_INDEX
+
+#define TEXT_DECORATION_INDEX 28
+#define TEXT_DECORATION_SHIFT 3
+#define TEXT_DECORATION_MASK 0xf8
+static inline uint8_t get_text_decoration(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[TEXT_DECORATION_INDEX];
+ bits &= TEXT_DECORATION_MASK;
+ bits >>= TEXT_DECORATION_SHIFT;
+
+ /* 5bits: type */
+ return bits;
+}
+#undef TEXT_DECORATION_MASK
+#undef TEXT_DECORATION_SHIFT
+#undef TEXT_DECORATION_INDEX
+
+#define FONT_FAMILY_INDEX 28
+#define FONT_FAMILY_SHIFT 0
+#define FONT_FAMILY_MASK 0x7
+static inline uint8_t get_font_family(
+ const css_computed_style *style,
+ lwc_string ***names)
+{
+ uint8_t bits = style->bits[FONT_FAMILY_INDEX];
+ bits &= FONT_FAMILY_MASK;
+ bits >>= FONT_FAMILY_SHIFT;
+
+ /* 3bits: type */
+ *names = style->font_family;
+
+ return bits;
+}
+#undef FONT_FAMILY_MASK
+#undef FONT_FAMILY_SHIFT
+#undef FONT_FAMILY_INDEX
+
+#define BORDER_TOP_STYLE_INDEX 29
+#define BORDER_TOP_STYLE_SHIFT 4
+#define BORDER_TOP_STYLE_MASK 0xf0
+static inline uint8_t get_border_top_style(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[BORDER_TOP_STYLE_INDEX];
+ bits &= BORDER_TOP_STYLE_MASK;
+ bits >>= BORDER_TOP_STYLE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef BORDER_TOP_STYLE_MASK
+#undef BORDER_TOP_STYLE_SHIFT
+#undef BORDER_TOP_STYLE_INDEX
+
+#define BORDER_RIGHT_STYLE_INDEX 29
+#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)
+{
+ uint8_t bits = style->bits[BORDER_RIGHT_STYLE_INDEX];
+ bits &= BORDER_RIGHT_STYLE_MASK;
+ bits >>= BORDER_RIGHT_STYLE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef BORDER_RIGHT_STYLE_MASK
+#undef BORDER_RIGHT_STYLE_SHIFT
+#undef BORDER_RIGHT_STYLE_INDEX
+
+#define BORDER_BOTTOM_STYLE_INDEX 30
+#define BORDER_BOTTOM_STYLE_SHIFT 4
+#define BORDER_BOTTOM_STYLE_MASK 0xf0
+static inline uint8_t get_border_bottom_style(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[BORDER_BOTTOM_STYLE_INDEX];
+ bits &= BORDER_BOTTOM_STYLE_MASK;
+ bits >>= BORDER_BOTTOM_STYLE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef BORDER_BOTTOM_STYLE_MASK
+#undef BORDER_BOTTOM_STYLE_SHIFT
+#undef BORDER_BOTTOM_STYLE_INDEX
+
+#define BORDER_LEFT_STYLE_INDEX 30
+#define BORDER_LEFT_STYLE_SHIFT 0
+#define BORDER_LEFT_STYLE_MASK 0xf
+static inline uint8_t get_border_left_style(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[BORDER_LEFT_STYLE_INDEX];
+ bits &= BORDER_LEFT_STYLE_MASK;
+ bits >>= BORDER_LEFT_STYLE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef BORDER_LEFT_STYLE_MASK
+#undef BORDER_LEFT_STYLE_SHIFT
+#undef BORDER_LEFT_STYLE_INDEX
+
+#define FONT_WEIGHT_INDEX 31
+#define FONT_WEIGHT_SHIFT 4
+#define FONT_WEIGHT_MASK 0xf0
+static inline uint8_t get_font_weight(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[FONT_WEIGHT_INDEX];
+ bits &= FONT_WEIGHT_MASK;
+ bits >>= FONT_WEIGHT_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef FONT_WEIGHT_MASK
+#undef FONT_WEIGHT_SHIFT
+#undef FONT_WEIGHT_INDEX
+
+#define LIST_STYLE_TYPE_INDEX 31
+#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)
+{
+ uint8_t bits = style->bits[LIST_STYLE_TYPE_INDEX];
+ bits &= LIST_STYLE_TYPE_MASK;
+ bits >>= LIST_STYLE_TYPE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef LIST_STYLE_TYPE_MASK
+#undef LIST_STYLE_TYPE_SHIFT
+#undef LIST_STYLE_TYPE_INDEX
+
+#define OUTLINE_STYLE_INDEX 32
+#define OUTLINE_STYLE_SHIFT 4
+#define OUTLINE_STYLE_MASK 0xf0
+static inline uint8_t get_outline_style(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[OUTLINE_STYLE_INDEX];
+ bits &= OUTLINE_STYLE_MASK;
+ bits >>= OUTLINE_STYLE_SHIFT;
+
+ /* 4bits: type */
+ return bits;
+}
+#undef OUTLINE_STYLE_MASK
+#undef OUTLINE_STYLE_SHIFT
+#undef OUTLINE_STYLE_INDEX
+
+#define TABLE_LAYOUT_INDEX 32
+#define TABLE_LAYOUT_SHIFT 2
+#define TABLE_LAYOUT_MASK 0xc
+static inline uint8_t get_table_layout(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[TABLE_LAYOUT_INDEX];
+ bits &= TABLE_LAYOUT_MASK;
+ bits >>= TABLE_LAYOUT_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef TABLE_LAYOUT_MASK
+#undef TABLE_LAYOUT_SHIFT
+#undef TABLE_LAYOUT_INDEX
+
+#define UNICODE_BIDI_INDEX 32
+#define UNICODE_BIDI_SHIFT 0
+#define UNICODE_BIDI_MASK 0x3
+static inline uint8_t get_unicode_bidi(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[UNICODE_BIDI_INDEX];
+ bits &= UNICODE_BIDI_MASK;
+ bits >>= UNICODE_BIDI_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef UNICODE_BIDI_MASK
+#undef UNICODE_BIDI_SHIFT
+#undef UNICODE_BIDI_INDEX
+
+#define VISIBILITY_INDEX 33
+#define VISIBILITY_SHIFT 6
+#define VISIBILITY_MASK 0xc0
+static inline uint8_t get_visibility(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[VISIBILITY_INDEX];
+ bits &= VISIBILITY_MASK;
+ bits >>= VISIBILITY_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef VISIBILITY_MASK
+#undef VISIBILITY_SHIFT
+#undef VISIBILITY_INDEX
+
+#define LIST_STYLE_POSITION_INDEX 33
+#define LIST_STYLE_POSITION_SHIFT 4
+#define LIST_STYLE_POSITION_MASK 0x30
+static inline uint8_t get_list_style_position(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->bits[LIST_STYLE_POSITION_INDEX];
+ bits &= LIST_STYLE_POSITION_MASK;
+ bits >>= LIST_STYLE_POSITION_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef LIST_STYLE_POSITION_MASK
+#undef LIST_STYLE_POSITION_SHIFT
+#undef LIST_STYLE_POSITION_INDEX
+
+#endif