From d250b1019c669478cf462b64ca060e7aedb5def1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 6 Nov 2014 12:29:43 +0000 Subject: Implement selection for column-fill property. --- src/select/computed.h | 7 ++++--- src/select/properties/column_fill.c | 27 ++++++++++++++------------- src/select/propget.h | 21 +++++++++++++++++++++ src/select/propset.h | 24 +++++++++++++++++++++++- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/src/select/computed.h b/src/select/computed.h index ff52df3..23b0cb6 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -18,12 +18,13 @@ typedef struct css_computed_uncommon { * border_spacing 1 + 2(4) 2(4) * clip 2 + 4(4) + 4 4(4) * column_count 2 4 + * column_fill 2 0 * letter_spacing 2 + 4 4 * outline_color 2 4 * outline_width 3 + 4 4 * word_spacing 2 + 4 4 * --- --- - * 54 bits 44 bytes + * 56 bits 44 bytes * * Encode counter_increment and _reset as an array of name, value pairs, * terminated with a blank entry. @@ -47,7 +48,7 @@ typedef struct css_computed_uncommon { * 2 bits sizeof(ptr) * * ___ ___ - * 63 bits 44 + 4sizeof(ptr) bytes + * 65 bits 44 + 4sizeof(ptr) bytes * * 8 bytes 44 + 4sizeof(ptr) bytes * =================== @@ -64,7 +65,7 @@ typedef struct css_computed_uncommon { * 6 cccccccc clip * 7 cccccccc clip * 8 ccccccoo clip | content - * 9 cc...... column_count | + * 9 ccff.... column_count | column-fill | */ uint8_t bits[9]; diff --git a/src/select/properties/column_fill.c b/src/select/properties/column_fill.c index 2322c03..9b4f1e0 100644 --- a/src/select/properties/column_fill.c +++ b/src/select/properties/column_fill.c @@ -17,20 +17,24 @@ css_error css__cascade_column_fill(uint32_t opv, css_style *style, css_select_state *state) { + uint16_t value = CSS_COLUMN_FILL_INHERIT; + UNUSED(style); if (isInherit(opv) == false) { switch (getValue(opv)) { case COLUMN_FILL_BALANCE: + value = CSS_COLUMN_FILL_BALANCE; + break; case COLUMN_FILL_AUTO: - /** \todo convert to public values */ + value = CSS_COLUMN_FILL_AUTO; break; } } if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { - /** \todo set computed elevation */ + return set_column_fill(state->computed, value); } return CSS_OK; @@ -39,27 +43,24 @@ css_error css__cascade_column_fill(uint32_t opv, css_style *style, css_error css__set_column_fill_from_hint(const css_hint *hint, css_computed_style *style) { - UNUSED(hint); - UNUSED(style); - - return CSS_OK; + return set_column_fill(style, hint->status); } css_error css__initial_column_fill(css_select_state *state) { - UNUSED(state); - - return CSS_OK; + return set_column_fill(state->computed, CSS_COLUMN_FILL_BALANCE); } css_error css__compose_column_fill(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - UNUSED(parent); - UNUSED(child); - UNUSED(result); + uint8_t type = get_column_fill(child); - return CSS_OK; + if (type == CSS_COLUMN_FILL_INHERIT) { + type = get_column_fill(parent); + } + + return set_column_fill(result, type); } diff --git a/src/select/propget.h b/src/select/propget.h index a9b8edc..7085eba 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -365,6 +365,27 @@ static inline uint8_t get_column_count( #undef COLUMN_COUNT_SHIFT #undef COLUMN_COUNT_INDEX +#define COLUMN_FILL_INDEX 8 +#define COLUMN_FILL_SHIFT 6 +#define COLUMN_FILL_MASK 0x30 +static inline uint8_t get_column_fill( + const css_computed_style *style) +{ + if (style->uncommon != NULL) { + uint8_t bits = style->uncommon->bits[COLUMN_FILL_INDEX]; + bits &= COLUMN_FILL_MASK; + bits >>= COLUMN_FILL_SHIFT; + + /* 2bits: type */ + return bits; + } + + return CSS_COLUMN_FILL_BALANCE; +} +#undef COLUMN_FILL_MASK +#undef COLUMN_FILL_SHIFT +#undef COLUMN_FILL_INDEX + #define CONTENT_INDEX 7 #define CONTENT_SHIFT 0 #define CONTENT_MASK 0x3 diff --git a/src/select/propset.h b/src/select/propset.h index 52d9d8a..23d8076 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -26,7 +26,7 @@ static const css_computed_uncommon default_uncommon = { 0, 0, (CSS_CLIP_AUTO << 2) | CSS_CONTENT_NORMAL, - (CSS_COLUMN_COUNT_AUTO << 6) + (CSS_COLUMN_COUNT_AUTO << 6) | (CSS_COLUMN_FILL_BALANCE << 4) }, { 0, 0 }, { 0, 0, 0, 0 }, @@ -430,6 +430,28 @@ static inline css_error set_column_count( #undef COLUMN_COUNT_SHIFT #undef COLUMN_COUNT_INDEX +#define COLUMN_FILL_INDEX 8 +#define COLUMN_FILL_SHIFT 6 +#define COLUMN_FILL_MASK 0x30 +static inline css_error set_column_fill( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits; + + ENSURE_UNCOMMON; + + bits = &style->uncommon->bits[COLUMN_FILL_INDEX]; + + /* 2bits: tt : type */ + *bits = (*bits & ~COLUMN_FILL_MASK) | + ((type & 0x3) << COLUMN_FILL_SHIFT); + + return CSS_OK; +} +#undef COLUMN_FILL_MASK +#undef COLUMN_FILL_SHIFT +#undef COLUMN_FILL_INDEX + #define CONTENT_INDEX 7 #define CONTENT_SHIFT 0 #define CONTENT_MASK 0x3 -- cgit v1.2.3