From d4cafaf627dd7ceb1a1dfd8292323c4b474ec57c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 6 Dec 2014 13:18:12 +0000 Subject: Add column-span property to computed styles. --- src/select/computed.h | 12 +++++++----- src/select/properties/column_span.c | 29 +++++++++++++++-------------- src/select/propget.h | 21 +++++++++++++++++++++ src/select/propset.h | 25 ++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 20 deletions(-) (limited to 'src/select') diff --git a/src/select/computed.h b/src/select/computed.h index 39904f9..05ea5fa 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -23,12 +23,13 @@ typedef struct css_computed_uncommon { * column_rule_color 2 4 * column_rule_style 4 0 * column_rule_width 3 + 4 4 + * column_span 2 0 * letter_spacing 2 + 4 4 * outline_color 2 4 * outline_width 3 + 4 4 * word_spacing 2 + 4 4 * --- --- - * 75 bits 56 bytes + * 77 bits 56 bytes * * Encode counter_increment and _reset as an array of name, value pairs, * terminated with a blank entry. @@ -52,11 +53,11 @@ typedef struct css_computed_uncommon { * 2 bits sizeof(ptr) * * ___ ___ - * 88 bits 58 + 4sizeof(ptr) bytes + * 90 bits 58 + 4sizeof(ptr) bytes * - * 11 bytes 58 + 4sizeof(ptr) bytes + * 12 bytes 58 + 4sizeof(ptr) bytes * =================== - * 67 + 4sizeof(ptr) bytes + * 68 + 4sizeof(ptr) bytes * * Bit allocations: * @@ -72,8 +73,9 @@ typedef struct css_computed_uncommon { * 9 ccffssss column_count | column-fill | column-rule-style * 10 ggggggcc column-gap | column-rule-color * 11 wwwwwww. column-rule-width + * 12 ss...... column-span */ - uint8_t bits[11]; + uint8_t bits[12]; css_fixed border_spacing[2]; diff --git a/src/select/properties/column_span.c b/src/select/properties/column_span.c index 92048a0..2c870d3 100644 --- a/src/select/properties/column_span.c +++ b/src/select/properties/column_span.c @@ -14,23 +14,27 @@ #include "select/properties/properties.h" #include "select/properties/helpers.h" -css_error css__cascade_column_span(uint32_t opv, css_style *style, +css_error css__cascade_column_span(uint32_t opv, css_style *style, css_select_state *state) { + uint16_t value = CSS_COLUMN_SPAN_INHERIT; + UNUSED(style); if (isInherit(opv) == false) { switch (getValue(opv)) { case COLUMN_SPAN_NONE: + value = CSS_COLUMN_SPAN_NONE; + break; case COLUMN_SPAN_ALL: - /** \todo convert to public values */ + value = CSS_COLUMN_SPAN_ALL; break; } } if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, isInherit(opv))) { - /** \todo set computed elevation */ + return set_column_span(state->computed, value); } return CSS_OK; @@ -39,27 +43,24 @@ css_error css__cascade_column_span(uint32_t opv, css_style *style, css_error css__set_column_span_from_hint(const css_hint *hint, css_computed_style *style) { - UNUSED(hint); - UNUSED(style); - - return CSS_OK; + return set_column_span(style, hint->status); } css_error css__initial_column_span(css_select_state *state) { - UNUSED(state); - - return CSS_OK; + return set_column_span(state->computed, CSS_COLUMN_SPAN_NONE); } css_error css__compose_column_span(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_span(child); - return CSS_OK; + if (type == CSS_COLUMN_SPAN_INHERIT) { + type = get_column_span(parent); + } + + return set_column_span(result, type); } diff --git a/src/select/propget.h b/src/select/propget.h index 423e299..7be323e 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -486,6 +486,27 @@ static inline uint8_t get_column_rule_width( #undef COLUMN_RULE_WIDTH_SHIFT #undef COLUMN_RULE_WIDTH_INDEX +#define COLUMN_SPAN_INDEX 11 +#define COLUMN_SPAN_SHIFT 6 +#define COLUMN_SPAN_MASK 0xc0 +static inline uint8_t get_column_span( + const css_computed_style *style) +{ + if (style->uncommon != NULL) { + uint8_t bits = style->uncommon->bits[COLUMN_SPAN_INDEX]; + bits &= COLUMN_SPAN_MASK; + bits >>= COLUMN_SPAN_SHIFT; + + /* 2bits: type */ + return bits; + } + + return CSS_COLUMN_SPAN_NONE; +} +#undef COLUMN_SPAN_MASK +#undef COLUMN_SPAN_SHIFT +#undef COLUMN_SPAN_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 6dcfbc6..baac10b 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -29,7 +29,8 @@ static const css_computed_uncommon default_uncommon = { (CSS_COLUMN_COUNT_AUTO << 6) | (CSS_COLUMN_FILL_BALANCE << 4) | (CSS_COLUMN_RULE_STYLE_NONE << 0), (CSS_COLUMN_GAP_NORMAL << 2) | (CSS_COLUMN_RULE_COLOR_CURRENT_COLOR), - (CSS_COLUMN_RULE_WIDTH_MEDIUM << 1) + (CSS_COLUMN_RULE_WIDTH_MEDIUM << 1), + (CSS_COLUMN_SPAN_NONE << 6) }, { 0, 0 }, { 0, 0, 0, 0 }, @@ -555,6 +556,28 @@ static inline css_error set_column_rule_width( #undef COLUMN_RULE_WIDTH_SHIFT #undef COLUMN_RULE_WIDTH_INDEX +#define COLUMN_SPAN_INDEX 11 +#define COLUMN_SPAN_SHIFT 6 +#define COLUMN_SPAN_MASK 0xc0 +static inline css_error set_column_span( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits; + + ENSURE_UNCOMMON; + + bits = &style->uncommon->bits[COLUMN_SPAN_INDEX]; + + /* 2bits: tt : type */ + *bits = (*bits & ~COLUMN_SPAN_MASK) | + ((type & 0x3) << COLUMN_SPAN_SHIFT); + + return CSS_OK; +} +#undef COLUMN_SPAN_MASK +#undef COLUMN_SPAN_SHIFT +#undef COLUMN_SPAN_INDEX + #define CONTENT_INDEX 7 #define CONTENT_SHIFT 0 #define CONTENT_MASK 0x3 -- cgit v1.2.3