diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2014-12-29 18:20:48 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2014-12-29 19:06:20 +0000 |
commit | 24207928eb8ba5cc40db4ddd60c60866ec8af684 (patch) | |
tree | 76dc8a7402a6cc4613cef5c2d61c2f5377a8c89e | |
parent | 30833a1ad59bc1f20a4995b23d2794be17227b51 (diff) | |
download | libcss-24207928eb8ba5cc40db4ddd60c60866ec8af684.tar.gz libcss-24207928eb8ba5cc40db4ddd60c60866ec8af684.tar.bz2 |
Add break-before property support.
-rw-r--r-- | include/libcss/computed.h | 3 | ||||
-rw-r--r-- | src/select/computed.c | 5 | ||||
-rw-r--r-- | src/select/properties/break_before.c | 45 | ||||
-rw-r--r-- | src/select/propget.h | 22 | ||||
-rw-r--r-- | src/select/propset.h | 22 |
5 files changed, 62 insertions, 35 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h index 58011e3..d027b4f 100644 --- a/include/libcss/computed.h +++ b/include/libcss/computed.h @@ -335,6 +335,9 @@ uint8_t css_computed_background_position( uint8_t css_computed_break_after( const css_computed_style *style); +uint8_t css_computed_break_before( + const css_computed_style *style); + uint8_t css_computed_column_count( const css_computed_style *style, int32_t *column_count); diff --git a/src/select/computed.c b/src/select/computed.c index ff6da17..20fa082 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -792,6 +792,11 @@ uint8_t css_computed_break_after(const css_computed_style *style) return get_break_after(style); } +uint8_t css_computed_break_before(const css_computed_style *style) +{ + return get_break_before(style); +} + uint8_t css_computed_column_count(const css_computed_style *style, int32_t *column_count) { diff --git a/src/select/properties/break_before.c b/src/select/properties/break_before.c index 73137f4..b8a8d77 100644 --- a/src/select/properties/break_before.c +++ b/src/select/properties/break_before.c @@ -17,56 +17,31 @@ css_error css__cascade_break_before(uint32_t opv, css_style *style, css_select_state *state) { - UNUSED(style); - - if (isInherit(opv) == false) { - switch (getValue(opv)) { - case BREAK_BEFORE_AUTO: - case BREAK_BEFORE_ALWAYS: - case BREAK_BEFORE_AVOID: - case BREAK_BEFORE_LEFT: - case BREAK_BEFORE_RIGHT: - case BREAK_BEFORE_PAGE: - case BREAK_BEFORE_COLUMN: - case BREAK_BEFORE_AVOID_PAGE: - case BREAK_BEFORE_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_before); } css_error css__set_break_before_from_hint(const css_hint *hint, css_computed_style *style) { - UNUSED(hint); - UNUSED(style); - - return CSS_OK; + return set_break_before(style, hint->status); } css_error css__initial_break_before(css_select_state *state) { - UNUSED(state); - - return CSS_OK; + return set_break_before(state->computed, CSS_BREAK_BEFORE_AUTO); } css_error css__compose_break_before(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_before(child); + + if (type == CSS_BREAK_BEFORE_INHERIT) { + type = get_break_before(parent); + } - return CSS_OK; + return set_break_before(result, type); } diff --git a/src/select/propget.h b/src/select/propget.h index 756a7b3..93d96da 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -166,6 +166,28 @@ static inline uint8_t get_break_after( #undef BREAK_AFTER_SHIFT #undef BREAK_AFTER_INDEX +#define BREAK_BEFORE_INDEX 12 +#define BREAK_BEFORE_SHIFT 4 +#define BREAK_BEFORE_MASK (0xf << 4) +static inline uint8_t get_break_before( + const css_computed_style *style) +{ + if (style->uncommon != NULL) { + uint8_t bits = style->uncommon->bits[BREAK_BEFORE_INDEX]; + bits &= BREAK_BEFORE_MASK; + bits >>= BREAK_BEFORE_SHIFT; + + /* 4bits: type */ + return bits; + } + + /* Not inherited; initial value */ + return CSS_BREAK_BEFORE_AUTO; +} +#undef BREAK_BEFORE_MASK +#undef BREAK_BEFORE_SHIFT +#undef BREAK_BEFORE_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 c202ce7..d5db8e0 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -220,6 +220,28 @@ static inline css_error set_break_after( #undef BREAK_AFTER_SHIFT #undef BREAK_AFTER_INDEX +#define BREAK_BEFORE_INDEX 12 +#define BREAK_BEFORE_SHIFT 4 +#define BREAK_BEFORE_MASK (0xf << 4) +static inline css_error set_break_before( + css_computed_style *style, uint8_t type) +{ + uint8_t *bits; + + ENSURE_UNCOMMON; + + bits = &style->uncommon->bits[BREAK_BEFORE_INDEX]; + + /* 4bits: type */ + *bits = (*bits & ~BREAK_BEFORE_MASK) | + ((type & 0xf) << BREAK_BEFORE_SHIFT); + + return CSS_OK; +} +#undef BREAK_BEFORE_MASK +#undef BREAK_BEFORE_SHIFT +#undef BREAK_BEFORE_INDEX + #define WORD_SPACING_INDEX 3 #define WORD_SPACING_SHIFT 2 #define WORD_SPACING_MASK 0xfc |