From 4729e025decd4d92ceeeb40659decf6183594ac6 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 29 Dec 2014 18:21:21 +0000 Subject: Add break-inside property support. --- src/select/computed.c | 5 +++++ src/select/properties/break_inside.c | 40 +++++++++--------------------------- src/select/propget.h | 22 ++++++++++++++++++++ src/select/propset.h | 22 ++++++++++++++++++++ 4 files changed, 59 insertions(+), 30 deletions(-) (limited to 'src/select') diff --git a/src/select/computed.c b/src/select/computed.c index 20fa082..a33b6a2 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -797,6 +797,11 @@ uint8_t css_computed_break_before(const css_computed_style *style) return get_break_before(style); } +uint8_t css_computed_break_inside(const css_computed_style *style) +{ + return get_break_inside(style); +} + uint8_t css_computed_column_count(const css_computed_style *style, int32_t *column_count) { diff --git a/src/select/properties/break_inside.c b/src/select/properties/break_inside.c index 82cf09c..58931b3 100644 --- a/src/select/properties/break_inside.c +++ b/src/select/properties/break_inside.c @@ -17,51 +17,31 @@ css_error css__cascade_break_inside(uint32_t opv, css_style *style, css_select_state *state) { - UNUSED(style); - - if (isInherit(opv) == false) { - switch (getValue(opv)) { - case BREAK_INSIDE_AUTO: - case BREAK_INSIDE_AVOID: - case BREAK_INSIDE_AVOID_PAGE: - case BREAK_INSIDE_AVOID_COLUMN: - /** \todo convert to public values */ - break; - } - } - - if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, - isInherit(opv))) { - /** \todo set computed elevation */ - } - - return CSS_OK; + return css__cascade_break_after_before_inside(opv, style, state, + set_break_inside); } css_error css__set_break_inside_from_hint(const css_hint *hint, css_computed_style *style) { - UNUSED(hint); - UNUSED(style); - - return CSS_OK; + return set_break_inside(style, hint->status); } css_error css__initial_break_inside(css_select_state *state) { - UNUSED(state); - - return CSS_OK; + return set_break_inside(state->computed, CSS_BREAK_INSIDE_AUTO); } css_error css__compose_break_inside(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - UNUSED(parent); - UNUSED(child); - UNUSED(result); + uint8_t type = get_break_inside(child); + + if (type == CSS_BREAK_INSIDE_INHERIT) { + type = get_break_inside(parent); + } - return CSS_OK; + return set_break_inside(result, type); } diff --git a/src/select/propget.h b/src/select/propget.h index 93d96da..45c773f 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -188,6 +188,28 @@ static inline uint8_t get_break_before( #undef BREAK_BEFORE_SHIFT #undef BREAK_BEFORE_INDEX +#define BREAK_INSIDE_INDEX 13 +#define BREAK_INSIDE_SHIFT 4 +#define BREAK_INSIDE_MASK (0xf << 4) +static inline uint8_t get_break_inside( + const css_computed_style *style) +{ + if (style->uncommon != NULL) { + uint8_t bits = style->uncommon->bits[BREAK_INSIDE_INDEX]; + bits &= BREAK_INSIDE_MASK; + bits >>= BREAK_INSIDE_SHIFT; + + /* 4bits: type */ + return bits; + } + + /* Not inherited; initial value */ + return CSS_BREAK_INSIDE_AUTO; +} +#undef BREAK_INSIDE_MASK +#undef BREAK_INSIDE_SHIFT +#undef BREAK_INSIDE_INDEX + #define WORD_SPACING_INDEX 3 #define WORD_SPACING_SHIFT 2 #define WORD_SPACING_MASK 0xfc diff --git a/src/select/propset.h b/src/select/propset.h index d5db8e0..d3d6fb1 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -242,6 +242,28 @@ static inline css_error set_break_before( #undef BREAK_BEFORE_SHIFT #undef BREAK_BEFORE_INDEX +#define BREAK_INSIDE_INDEX 13 +#define BREAK_INSIDE_SHIFT 4 +#define BREAK_INSIDE_MASK (0xf << 4) +static inline css_error set_break_inside( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits; + + ENSURE_UNCOMMON; + + bits = &style->uncommon->bits[BREAK_INSIDE_INDEX]; + + /* 4bits: type */ + *bits = (*bits & ~BREAK_INSIDE_MASK) | + ((type & 0xf) << BREAK_INSIDE_SHIFT); + + return CSS_OK; +} +#undef BREAK_INSIDE_MASK +#undef BREAK_INSIDE_SHIFT +#undef BREAK_INSIDE_INDEX + #define WORD_SPACING_INDEX 3 #define WORD_SPACING_SHIFT 2 #define WORD_SPACING_MASK 0xfc -- cgit v1.2.3