diff options
author | Lucas Neves <lcneves@gmail.com> | 2017-08-28 16:49:38 +0000 |
---|---|---|
committer | Lucas Neves <lcneves@gmail.com> | 2017-09-25 21:57:41 -0400 |
commit | 69574fa847973dd6d449c2dd997ae0c86b671ad0 (patch) | |
tree | 1bfa81b3521e42699822cee8a0492829f5619133 | |
parent | ba72b2061e3142a1ea17d51d2020c0cb45d752f7 (diff) | |
download | libcss-69574fa847973dd6d449c2dd997ae0c86b671ad0.tar.gz |
Select: implement getters and setters for Flexbox properties
-rw-r--r-- | src/select/propget.h | 188 | ||||
-rw-r--r-- | src/select/propset.h | 196 |
2 files changed, 384 insertions, 0 deletions
diff --git a/src/select/propget.h b/src/select/propget.h index 6719443..faf7dc0 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -2189,4 +2189,192 @@ static inline uint8_t get_widows( #undef WIDOWS_SHIFT #undef WIDOWS_INDEX +#define ALIGN_CONTENT_INDEX 34 +#define ALIGN_CONTENT_SHIFT 2 +#define ALIGN_CONTENT_MASK 0x1c +static inline uint8_t get_align_content( + const css_computed_style *style) +{ + uint8_t bits = style->i.bits[ALIGN_CONTENT_INDEX]; + bits &= ALIGN_CONTENT_MASK; + bits >>= ALIGN_CONTENT_SHIFT; + + /* 3bits: type */ + return bits; +} +#undef ALIGN_CONTENT_MASK +#undef ALIGN_CONTENT_SHIFT +#undef ALIGN_CONTENT_INDEX + +#define FLEX_WRAP_INDEX 34 +#define FLEX_WRAP_SHIFT 0 +#define FLEX_WRAP_MASK 0x3 +static inline uint8_t get_flex_wrap( + const css_computed_style *style) +{ + uint8_t bits = style->i.bits[FLEX_WRAP_INDEX]; + bits &= FLEX_WRAP_MASK; + bits >>= FLEX_WRAP_SHIFT; + + /* 2bits: type */ + return bits; +} +#undef FLEX_WRAP_MASK +#undef FLEX_WRAP_SHIFT +#undef FLEX_WRAP_INDEX + +#define FLEX_BASIS_INDEX 35 +#define FLEX_BASIS_SHIFT 2 +#define FLEX_BASIS_MASK 0xfc +static inline uint8_t get_flex_basis( + const css_computed_style *style, + css_fixed *length, css_unit *unit) +{ + uint8_t bits = style->i.bits[FLEX_BASIS_INDEX]; + bits &= FLEX_BASIS_MASK; + bits >>= FLEX_BASIS_SHIFT; + + /* 6bits: uuuutt : units | type */ + if ((bits & 0x3) == CSS_FLEX_BASIS_SET) { + *length = style->i.flex_basis; + *unit = bits >> 2; + } + + return (bits & 0x3); +} +#undef FLEX_BASIS_MASK +#undef FLEX_BASIS_SHIFT +#undef FLEX_BASIS_INDEX + +#define FLEX_SHRINK_INDEX 35 +#define FLEX_SHRINK_SHIFT 1 +#define FLEX_SHRINK_MASK 0x2 +static inline uint8_t get_flex_shrink( + const css_computed_style *style, css_fixed *number) +{ + uint8_t bits = style->i.bits[FLEX_SHRINK_INDEX]; + bits &= FLEX_SHRINK_MASK; + bits >>= FLEX_SHRINK_SHIFT; + + /* 1bit: type */ + if ((bits & 0x1) == CSS_FLEX_SHRINK_SET) { + *number = style->i.flex_shrink; + } + + return (bits & 0x1); +} +#undef FLEX_SHRINK_MASK +#undef FLEX_SHRINK_SHIFT +#undef FLEX_SHRINK_INDEX + +#define FLEX_GROW_INDEX 35 +#define FLEX_GROW_SHIFT 0 +#define FLEX_GROW_MASK 0x1 +static inline uint8_t get_flex_grow( + const css_computed_style *style, css_fixed *number) +{ + uint8_t bits = style->i.bits[FLEX_GROW_INDEX]; + bits &= FLEX_GROW_MASK; + bits >>= FLEX_GROW_SHIFT; + + /* 1bit: type */ + if ((bits & 0x1) == CSS_FLEX_GROW_SET) { + *number = style->i.flex_grow; + } + + return (bits & 0x1); +} +#undef FLEX_GROW_MASK +#undef FLEX_GROW_SHIFT +#undef FLEX_GROW_INDEX + +#define FLEX_DIRECTION_INDEX 36 +#define FLEX_DIRECTION_SHIFT 5 +#define FLEX_DIRECTION_MASK 0xe0 +static inline uint8_t get_flex_direction( + const css_computed_style *style) +{ + uint8_t bits = style->i.bits[FLEX_DIRECTION_INDEX]; + bits &= FLEX_DIRECTION_MASK; + bits >>= FLEX_DIRECTION_SHIFT; + + /* 3bits: type */ + return bits; +} +#undef FLEX_DIRECTION_MASK +#undef FLEX_DIRECTION_SHIFT +#undef FLEX_DIRECTION_INDEX + +#define JUSTIFY_CONTENT_INDEX 36 +#define JUSTIFY_CONTENT_SHIFT 2 +#define JUSTIFY_CONTENT_MASK 0x1c +static inline uint8_t get_justify_content( + const css_computed_style *style) +{ + uint8_t bits = style->i.bits[JUSTIFY_CONTENT_INDEX]; + bits &= JUSTIFY_CONTENT_MASK; + bits >>= JUSTIFY_CONTENT_SHIFT; + + /* 3bits: type */ + return bits; +} +#undef JUSTIFY_CONTENT_MASK +#undef JUSTIFY_CONTENT_SHIFT +#undef JUSTIFY_CONTENT_INDEX + +#define ORDER_INDEX 36 +#define ORDER_SHIFT 1 +#define ORDER_MASK 0x2 +static inline uint8_t get_order( + const css_computed_style *style, css_fixed *number) +{ + uint8_t bits = style->i.bits[ORDER_INDEX]; + bits &= ORDER_MASK; + bits >>= ORDER_SHIFT; + + /* 1bit: type */ + if ((bits & 0x1) == CSS_ORDER_SET) { + *number = style->i.order; + } + + return (bits & 0x1); +} +#undef ORDER_MASK +#undef ORDER_SHIFT +#undef ORDER_INDEX + +#define ALIGN_ITEMS_INDEX 37 +#define ALIGN_ITEMS_SHIFT 5 +#define ALIGN_ITEMS_MASK 0xe0 +static inline uint8_t get_align_items( + const css_computed_style *style) +{ + uint8_t bits = style->i.bits[ALIGN_ITEMS_INDEX]; + bits &= ALIGN_ITEMS_MASK; + bits >>= ALIGN_ITEMS_SHIFT; + + /* 3bits: type */ + return bits; +} +#undef ALIGN_ITEMS_MASK +#undef ALIGN_ITEMS_SHIFT +#undef ALIGN_ITEMS_INDEX + +#define ALIGN_SELF_INDEX 37 +#define ALIGN_SELF_SHIFT 2 +#define ALIGN_SELF_MASK 0x1c +static inline uint8_t get_align_self( + const css_computed_style *style) +{ + uint8_t bits = style->i.bits[ALIGN_SELF_INDEX]; + bits &= ALIGN_SELF_MASK; + bits >>= ALIGN_SELF_SHIFT; + + /* 3bits: type */ + return bits; +} +#undef ALIGN_SELF_MASK +#undef ALIGN_SELF_SHIFT +#undef ALIGN_SELF_INDEX + #endif diff --git a/src/select/propset.h b/src/select/propset.h index 3f4038c..b36b519 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -2325,4 +2325,200 @@ static inline css_error set_widows( #undef WIDOWS_SHIFT #undef WIDOWS_MASK +#define ALIGN_CONTENT_INDEX 34 +#define ALIGN_CONTENT_SHIFT 2 +#define ALIGN_CONTENT_MASK 0x1c +static inline css_error set_align_content( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits = &style->i.bits[ALIGN_CONTENT_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~ALIGN_CONTENT_MASK) | + ((type & 0x7) << ALIGN_CONTENT_SHIFT); + + return CSS_OK; +} +#undef ALIGN_CONTENT_MASK +#undef ALIGN_CONTENT_SHIFT +#undef ALIGN_CONTENT_INDEX + +#define FLEX_WRAP_INDEX 34 +#define FLEX_WRAP_SHIFT 0 +#define FLEX_WRAP_MASK 0x3 +static inline css_error set_flex_wrap( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits = &style->i.bits[FLEX_WRAP_INDEX]; + + /* 2bits: type */ + *bits = (*bits & ~FLEX_WRAP_MASK) | + ((type & 0x3) << FLEX_WRAP_SHIFT); + + return CSS_OK; +} +#undef FLEX_WRAP_MASK +#undef FLEX_WRAP_SHIFT +#undef FLEX_WRAP_INDEX + +#define FLEX_BASIS_INDEX 35 +#define FLEX_BASIS_SHIFT 2 +#define FLEX_BASIS_MASK 0xfc +static inline css_error set_flex_basis( + css_computed_style *style, uint8_t type, + css_fixed length, css_unit unit) +{ + uint8_t *bits = &style->i.bits[FLEX_BASIS_INDEX]; + + /* 6bits: uuuutt : units | type */ + *bits = (*bits & ~FLEX_BASIS_MASK) | + (((type & 0x3) | (unit << 2)) << FLEX_BASIS_SHIFT); + + style->i.flex_basis = length; + + return CSS_OK; +} + +#undef FLEX_BASIS_MASK +#undef FLEX_BASIS_SHIFT +#undef FLEX_BASIS_INDEX + +#define FLEX_SHRINK_INDEX 35 +#define FLEX_SHRINK_SHIFT 1 +#define FLEX_SHRINK_MASK 0x2 +static inline css_error set_flex_shrink( + css_computed_style *style, uint8_t type, + css_fixed number) +{ + uint8_t *bits = &style->i.bits[FLEX_SHRINK_INDEX]; + + /* 1bit: type */ + *bits = (*bits & ~FLEX_SHRINK_MASK) | + ((type & 0x1) << FLEX_SHRINK_SHIFT); + + style->i.flex_shrink = number; + + return CSS_OK; +} + +#undef FLEX_SHRINK_MASK +#undef FLEX_SHRINK_SHIFT +#undef FLEX_SHRINK_INDEX + +#define FLEX_GROW_INDEX 35 +#define FLEX_GROW_SHIFT 0 +#define FLEX_GROW_MASK 0x1 +static inline css_error set_flex_grow( + css_computed_style *style, uint8_t type, + css_fixed number) +{ + uint8_t *bits = &style->i.bits[FLEX_GROW_INDEX]; + + /* 1bit: type */ + *bits = (*bits & ~FLEX_GROW_MASK) | + ((type & 0x1) << FLEX_GROW_SHIFT); + + style->i.flex_grow = number; + + return CSS_OK; +} + +#undef FLEX_GROW_MASK +#undef FLEX_GROW_SHIFT +#undef FLEX_GROW_INDEX + +#define FLEX_DIRECTION_INDEX 36 +#define FLEX_DIRECTION_SHIFT 5 +#define FLEX_DIRECTION_MASK 0xe0 +static inline css_error set_flex_direction( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits = &style->i.bits[FLEX_DIRECTION_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~FLEX_DIRECTION_MASK) | + ((type & 0x7) << FLEX_DIRECTION_SHIFT); + + return CSS_OK; +} +#undef FLEX_DIRECTION_MASK +#undef FLEX_DIRECTION_SHIFT +#undef FLEX_DIRECTION_INDEX + +#define JUSTIFY_CONTENT_INDEX 36 +#define JUSTIFY_CONTENT_SHIFT 2 +#define JUSTIFY_CONTENT_MASK 0x1c +static inline css_error set_justify_content( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits = &style->i.bits[JUSTIFY_CONTENT_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~JUSTIFY_CONTENT_MASK) | + ((type & 0x7) << JUSTIFY_CONTENT_SHIFT); + + return CSS_OK; +} +#undef JUSTIFY_CONTENT_MASK +#undef JUSTIFY_CONTENT_SHIFT +#undef JUSTIFY_CONTENT_INDEX + +#define ORDER_INDEX 36 +#define ORDER_SHIFT 1 +#define ORDER_MASK 0x2 +static inline css_error set_order( + css_computed_style *style, uint8_t type, + css_fixed number) +{ + uint8_t *bits = &style->i.bits[ORDER_INDEX]; + + /* 1bit: type */ + *bits = (*bits & ~ORDER_MASK) | + ((type & 0x1) << ORDER_SHIFT); + + style->i.order = number; + + return CSS_OK; +} + +#undef ORDER_MASK +#undef ORDER_SHIFT +#undef ORDER_INDEX + +#define ALIGN_ITEMS_INDEX 37 +#define ALIGN_ITEMS_SHIFT 5 +#define ALIGN_ITEMS_MASK 0xe0 +static inline css_error set_align_items( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits = &style->i.bits[ALIGN_ITEMS_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~ALIGN_ITEMS_MASK) | + ((type & 0x7) << ALIGN_ITEMS_SHIFT); + + return CSS_OK; +} +#undef ALIGN_ITEMS_MASK +#undef ALIGN_ITEMS_SHIFT +#undef ALIGN_ITEMS_INDEX + +#define ALIGN_SELF_INDEX 37 +#define ALIGN_SELF_SHIFT 2 +#define ALIGN_SELF_MASK 0x1c +static inline css_error set_align_self( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits = &style->i.bits[ALIGN_SELF_INDEX]; + + /* 3bits: type */ + *bits = (*bits & ~ALIGN_SELF_MASK) | + ((type & 0x7) << ALIGN_SELF_SHIFT); + + return CSS_OK; +} +#undef ALIGN_SELF_MASK +#undef ALIGN_SELF_SHIFT +#undef ALIGN_SELF_INDEX + #endif |