From a3737b84a9ab76421cca972139b2ec5a6572ab72 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 10 Jan 2014 15:21:06 +0000 Subject: Various changes for orphans and widows properties: + Keep as int internally, rather than css_fixed. + Fix get_widows to return widows instead of orphans. + Remove duplicate implementations in css_computed_ getters. --- src/select/computed.c | 50 ++++------------------------------------- src/select/computed.h | 4 ++-- src/select/properties/orphans.c | 6 ++--- src/select/properties/windows.c | 6 ++--- src/select/propget.h | 12 +++++----- src/select/propset.h | 8 +++---- 6 files changed, 22 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/select/computed.c b/src/select/computed.c index 135fa07..6f0d979 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -1003,59 +1003,17 @@ uint8_t css_computed_page_break_inside(const css_computed_style *style) return get_page_break_inside(style); } -#define CSS_ORPHANS_INDEX 1 -#define CSS_ORPHANS_SHIFT 0 -#define CSS_ORPHANS_MASK 0x1 -uint8_t css_computed_orphans( - const css_computed_style *style, +uint8_t css_computed_orphans(const css_computed_style *style, int32_t *orphans) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_ORPHANS_INDEX]; - bits &= CSS_ORPHANS_MASK; - bits >>= CSS_ORPHANS_SHIFT; - - *orphans = FIXTOINT(style->page->orphans);; - - /* 1bit: type */ - return bits; - } - - /* Use initial value */ - *orphans = 2; - - return CSS_ORPHANS_SET; + return get_orphans(style, orphans); } -#undef CSS_ORPHANS_MASK -#undef CSS_ORPHANS_SHIFT -#undef CSS_ORPHANS_INDEX -#define CSS_WIDOWS_INDEX 1 -#define CSS_WIDOWS_SHIFT 1 -#define CSS_WIDOWS_MASK 0x2 -uint8_t css_computed_widows( - const css_computed_style *style, +uint8_t css_computed_widows(const css_computed_style *style, int32_t *widows) { - if (style->page != NULL) { - uint8_t bits = style->page->bits[CSS_WIDOWS_INDEX]; - bits &= CSS_WIDOWS_MASK; - bits >>= CSS_WIDOWS_SHIFT; - - *widows = FIXTOINT(style->page->widows); - - /* 1bit: type */ - return bits; - } - - /* Use initial value */ - *widows = 2; - - return CSS_WIDOWS_SET; + return get_widows(style, widows); } -#undef CSS_WIDOWS_MASK -#undef CSS_WIDOWS_SHIFT -#undef CSS_WIDOWS_INDEX /****************************************************************************** diff --git a/src/select/computed.h b/src/select/computed.h index 1f2cded..58964af 100644 --- a/src/select/computed.h +++ b/src/select/computed.h @@ -95,8 +95,8 @@ typedef struct css_computed_page { */ uint8_t bits[2]; - css_fixed widows; - css_fixed orphans; + int32_t widows; + int32_t orphans; } css_computed_page; struct css_computed_style { diff --git a/src/select/properties/orphans.c b/src/select/properties/orphans.c index 265c6f5..d5c4937 100644 --- a/src/select/properties/orphans.c +++ b/src/select/properties/orphans.c @@ -23,19 +23,19 @@ css_error css__cascade_orphans(uint32_t opv, css_style *style, css_error css__set_orphans_from_hint(const css_hint *hint, css_computed_style *style) { - return set_orphans(style, hint->status, hint->data.fixed); + return set_orphans(style, hint->status, hint->data.integer); } css_error css__initial_orphans(css_select_state *state) { - return set_orphans(state->computed, CSS_ORPHANS_SET, INTTOFIX(2)); + return set_orphans(state->computed, CSS_ORPHANS_SET, 2); } css_error css__compose_orphans(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - css_fixed count = 0; + int32_t count = 0; uint8_t type = get_orphans(child, &count); if (type == CSS_ORPHANS_INHERIT) { diff --git a/src/select/properties/windows.c b/src/select/properties/windows.c index 3f568cb..916966a 100644 --- a/src/select/properties/windows.c +++ b/src/select/properties/windows.c @@ -23,19 +23,19 @@ css_error css__cascade_widows(uint32_t opv, css_style *style, css_error css__set_widows_from_hint(const css_hint *hint, css_computed_style *style) { - return set_widows(style, hint->status, hint->data.fixed); + return set_widows(style, hint->status, hint->data.integer); } css_error css__initial_widows(css_select_state *state) { - return set_widows(state->computed, CSS_WIDOWS_SET, INTTOFIX(2)); + return set_widows(state->computed, CSS_WIDOWS_SET, 2); } css_error css__compose_widows(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { - css_fixed count = 0; + int32_t count = 0; uint8_t type = get_widows(child, &count); if (type == CSS_WIDOWS_INHERIT) { diff --git a/src/select/propget.h b/src/select/propget.h index 15fef05..0f32e8c 100644 --- a/src/select/propget.h +++ b/src/select/propget.h @@ -1832,20 +1832,20 @@ static inline uint8_t get_page_break_inside( #define ORPHANS_MASK 0x1 static inline uint8_t get_orphans( const css_computed_style *style, - css_fixed *count) + int32_t *orphans) { if (style->page != NULL) { uint8_t bits = style->page->bits[ORPHANS_INDEX]; bits &= ORPHANS_MASK; bits >>= ORPHANS_SHIFT; - *count = style->page->orphans; + *orphans = style->page->orphans; /* 1bit: type */ return bits; } - *count = INTTOFIX(2); + *orphans = 2; return CSS_ORPHANS_SET; } #undef ORPHANS_MASK @@ -1857,20 +1857,20 @@ static inline uint8_t get_orphans( #define WIDOWS_MASK 0x2 static inline uint8_t get_widows( const css_computed_style *style, - css_fixed *count) + int32_t *widows) { if (style->page != NULL) { uint8_t bits = style->page->bits[WIDOWS_INDEX]; bits &= WIDOWS_MASK; bits >>= WIDOWS_SHIFT; - *count = style->page->orphans; + *widows = style->page->widows; /* 1bit: type */ return bits; } - *count = INTTOFIX(2); + *widows = 2; return CSS_WIDOWS_SET; } #undef WIDOWS_MASK diff --git a/src/select/propset.h b/src/select/propset.h index 5af7e8b..4aa15af 100644 --- a/src/select/propset.h +++ b/src/select/propset.h @@ -1952,12 +1952,12 @@ static inline css_error set_page_break_inside( #define ORPHANS_SHIFT 0 #define ORPHANS_MASK 0x1 static inline css_error set_orphans( - css_computed_style *style, uint8_t type, css_fixed count) + css_computed_style *style, uint8_t type, int32_t count) { uint8_t *bits; if (style->page == NULL) { - if (type == CSS_ORPHANS_SET && count == INTTOFIX(2)) { + if (type == CSS_ORPHANS_SET && count == 2) { return CSS_OK; } } @@ -1981,12 +1981,12 @@ static inline css_error set_orphans( #define WIDOWS_SHIFT 1 #define WIDOWS_MASK 0x2 static inline css_error set_widows( - css_computed_style *style, uint8_t type, css_fixed count) + css_computed_style *style, uint8_t type, int32_t count) { uint8_t *bits; if (style->page == NULL) { - if (type == CSS_WIDOWS_SET && count == INTTOFIX(2)) { + if (type == CSS_WIDOWS_SET && count == 2) { return CSS_OK; } } -- cgit v1.2.3