diff options
Diffstat (limited to 'include/libcss')
-rw-r--r-- | include/libcss/computed.h | 31 | ||||
-rw-r--r-- | include/libcss/fpmath.h | 13 | ||||
-rw-r--r-- | include/libcss/properties.h | 31 | ||||
-rw-r--r-- | include/libcss/types.h | 6 |
4 files changed, 68 insertions, 13 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h index 30e369b..c048e64 100644 --- a/include/libcss/computed.h +++ b/include/libcss/computed.h @@ -279,8 +279,29 @@ uint8_t css_computed_max_width( const css_computed_style *style, css_fixed *length, css_unit *unit); -uint8_t css_computed_width( +/** + * Get the width property value in device pixels. + * + * \note If available_px is set to a negative number (invalid) then, + * if the computation would have required a valid available + * width, it will return CSS_WIDTH_AUTO. + * + * This will resolve `calc()` expressions to used values. + * + * \param[in] style A computed style. + * \param[in] unit_ctx Unit conversion context. + * \param[in] available_px The available width in pixels. + * \param[out] px_out Returns width in pixels if and only if the + * call returns CSS_WIDTH_SET. + * \return CSS_WIDTH_SET or CSS_WIDTH_AUTO. + */ +uint8_t css_computed_width_px( const css_computed_style *style, + const css_unit_ctx *unit_ctx, + int available_px, + int *px_out); + +uint8_t css_computed_width(const css_computed_style *style, css_fixed *length, css_unit *unit); uint8_t css_computed_empty_cells( @@ -338,6 +359,14 @@ uint8_t css_computed_opacity( const css_computed_style *style, css_fixed *opacity); +uint8_t css_computed_fill_opacity( + const css_computed_style *style, + css_fixed *fill_opacity); + +uint8_t css_computed_stroke_opacity( + const css_computed_style *style, + css_fixed *stroke_opacity); + uint8_t css_computed_text_transform( const css_computed_style *style); diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h index bed5ee6..a080fc1 100644 --- a/include/libcss/fpmath.h +++ b/include/libcss/fpmath.h @@ -99,10 +99,12 @@ css_float_to_fixed(const float a) { float xx = a * (float) (1 << CSS_RADIX_POINT); if (xx < INT_MIN) - xx = INT_MIN; + return INT_MIN; - if (xx > INT_MAX) - xx = INT_MAX; + /* Conversion from int to float changes value from + * 2147483647 to 2147483648, so we use >= instead of >. */ + if (xx >= (float)INT_MAX) + return INT_MAX; return (css_fixed) xx; } @@ -128,6 +130,8 @@ css_float_to_fixed(const float a) { /* truncate a fixed point value */ #define TRUNCATEFIX(a) (a & ~((1 << CSS_RADIX_POINT)- 1 )) +/* get fractional component of a fixed point value */ +#define FIXFRAC(a) (a & ((1 << CSS_RADIX_POINT)- 1 )) /* Useful values */ #define F_PI_2 0x00000648 /* 1.5708 (PI/2) */ @@ -151,6 +155,9 @@ css_float_to_fixed(const float a) { #define F_300 0x0004b000 /* 300 */ #define F_400 0x00064000 /* 400 */ +/* Fixed point percentage `p` of integer `i`, to an integer */ +#define FPCT_OF_INT_TOINT(p, i) (FIXTOINT(FDIV((p * i), F_100))) + #ifdef __cplusplus } #endif diff --git a/include/libcss/properties.h b/include/libcss/properties.h index ae00551..cb1f0ff 100644 --- a/include/libcss/properties.h +++ b/include/libcss/properties.h @@ -138,6 +138,8 @@ enum css_properties_e { CSS_PROP_FLEX_WRAP = 0x079, CSS_PROP_JUSTIFY_CONTENT = 0x07a, CSS_PROP_ORDER = 0x07b, + CSS_PROP_FILL_OPACITY = 0x07c, + CSS_PROP_STROKE_OPACITY = 0x07d, CSS_N_PROPERTIES }; @@ -163,12 +165,12 @@ enum css_align_items_e { }; enum css_align_self_e { - CSS_ALIGN_SELF_INHERIT = 0x0, - CSS_ALIGN_SELF_STRETCH = 0x1, - CSS_ALIGN_SELF_FLEX_START = 0x2, - CSS_ALIGN_SELF_FLEX_END = 0x3, - CSS_ALIGN_SELF_CENTER = 0x4, - CSS_ALIGN_SELF_BASELINE = 0x5, + CSS_ALIGN_SELF_INHERIT = CSS_ALIGN_ITEMS_INHERIT, + CSS_ALIGN_SELF_STRETCH = CSS_ALIGN_ITEMS_STRETCH, + CSS_ALIGN_SELF_FLEX_START = CSS_ALIGN_ITEMS_FLEX_START, + CSS_ALIGN_SELF_FLEX_END = CSS_ALIGN_ITEMS_FLEX_END, + CSS_ALIGN_SELF_CENTER = CSS_ALIGN_ITEMS_CENTER, + CSS_ALIGN_SELF_BASELINE = CSS_ALIGN_ITEMS_BASELINE, CSS_ALIGN_SELF_AUTO = 0x6 }; @@ -440,7 +442,9 @@ enum css_display_e { CSS_DISPLAY_TABLE_CAPTION = 0x0f, CSS_DISPLAY_NONE = 0x10, CSS_DISPLAY_FLEX = 0x11, - CSS_DISPLAY_INLINE_FLEX = 0x12 + CSS_DISPLAY_INLINE_FLEX = 0x12, + CSS_DISPLAY_GRID = 0x13, + CSS_DISPLAY_INLINE_GRID = 0x14 }; enum css_empty_cells_e { @@ -449,6 +453,11 @@ enum css_empty_cells_e { CSS_EMPTY_CELLS_HIDE = 0x2 }; +enum css_fill_opacity_e { + CSS_FILL_OPACITY_INHERIT = 0x0, + CSS_FILL_OPACITY_SET = 0x1 +}; + enum css_flex_basis_e { CSS_FLEX_BASIS_INHERIT = 0x0, CSS_FLEX_BASIS_SET = 0x1, @@ -761,7 +770,8 @@ enum css_position_e { CSS_POSITION_STATIC = 0x1, CSS_POSITION_RELATIVE = 0x2, CSS_POSITION_ABSOLUTE = 0x3, - CSS_POSITION_FIXED = 0x4 + CSS_POSITION_FIXED = 0x4, + CSS_POSITION_STICKY = 0x5 }; enum css_quotes_e { @@ -777,6 +787,11 @@ enum css_right_e { CSS_RIGHT_AUTO = 0x2 }; +enum css_stroke_opacity_e { + CSS_STROKE_OPACITY_INHERIT = 0x0, + CSS_STROKE_OPACITY_SET = 0x1 +}; + enum css_table_layout_e { CSS_TABLE_LAYOUT_INHERIT = 0x0, CSS_TABLE_LAYOUT_AUTO = 0x1, diff --git a/include/libcss/types.h b/include/libcss/types.h index 2b0dfb7..c0b19da 100644 --- a/include/libcss/types.h +++ b/include/libcss/types.h @@ -109,7 +109,9 @@ typedef enum css_unit { CSS_UNIT_S = 0x1a, CSS_UNIT_HZ = 0x1b, - CSS_UNIT_KHZ = 0x1c + CSS_UNIT_KHZ = 0x1c, + + CSS_UNIT_CALC = 0x1d /**< Un-resolved calc() */ } css_unit; /** @@ -223,6 +225,8 @@ typedef struct css_media { css_fixed monochrome; /* monochrome bpp (0 for colour) */ css_fixed inverted_colors; /** boolean: {0|1} */ + lwc_string *prefers_color_scheme; /* "light", "dark" */ + /* Interaction media features */ css_media_pointer pointer; css_media_pointer any_pointer; |