From 7c809b74610653dc55276bb6e99459e073d2112c Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 4 Mar 2009 01:24:12 +0000 Subject: Constify. Compose counter-increment and counter-reset. Fix compose_content. svn path=/trunk/libcss/; revision=6692 --- src/select/properties.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/select/properties.c b/src/select/properties.c index 572a151..daf3411 100644 --- a/src/select/properties.c +++ b/src/select/properties.c @@ -1181,7 +1181,7 @@ css_error compose_content(const css_computed_style *parent, copy = result->alloc(NULL, (n_items + 1) * sizeof(css_computed_content_item), result->pw); - if (i == NULL) + if (copy == NULL) return CSS_NOMEM; memcpy(copy, items, (n_items + 1) * @@ -1210,6 +1210,46 @@ css_error initial_counter_increment(css_computed_style *style) return set_counter_increment(style, CSS_COUNTER_INCREMENT_NONE, NULL); } +css_error compose_counter_increment(const css_computed_style *parent, + const css_computed_style *child, + css_computed_style *result) +{ + css_error error; + const css_computed_counter *items = NULL; + + if ((child->uncommon == NULL && parent->uncommon != NULL) || + css_computed_counter_increment(child, &items) == + CSS_COUNTER_INCREMENT_INHERIT) { + uint8_t p = css_computed_counter_increment(parent, &items); + size_t n_items = 0; + css_computed_counter *copy = NULL; + + if (p == CSS_COUNTER_INCREMENT_NAMED && items != NULL) { + const css_computed_counter *i; + + for (i = items; i->name != NULL; i++) + n_items++; + + copy = result->alloc(NULL, (n_items + 1) * + sizeof(css_computed_counter), + result->pw); + if (copy == NULL) + return CSS_NOMEM; + + memcpy(copy, items, (n_items + 1) * + sizeof(css_computed_counter)); + } + + error = set_counter_increment(result, p, copy); + if (error != CSS_OK && copy != NULL) + result->alloc(copy, 0, result->pw); + + return error; + } + + return CSS_OK; +} + css_error cascade_counter_reset(uint32_t opv, css_style *style, css_select_state *state) { @@ -1222,6 +1262,46 @@ css_error initial_counter_reset(css_computed_style *style) return set_counter_reset(style, CSS_COUNTER_RESET_NONE, NULL); } +css_error compose_counter_reset(const css_computed_style *parent, + const css_computed_style *child, + css_computed_style *result) +{ + css_error error; + const css_computed_counter *items = NULL; + + if ((child->uncommon == NULL && parent->uncommon != NULL) || + css_computed_counter_reset(child, &items) == + CSS_COUNTER_RESET_INHERIT) { + uint8_t p = css_computed_counter_reset(parent, &items); + size_t n_items = 0; + css_computed_counter *copy = NULL; + + if (p == CSS_COUNTER_RESET_NAMED && items != NULL) { + const css_computed_counter *i; + + for (i = items; i->name != NULL; i++) + n_items++; + + copy = result->alloc(NULL, (n_items + 1) * + sizeof(css_computed_counter), + result->pw); + if (copy == NULL) + return CSS_NOMEM; + + memcpy(copy, items, (n_items + 1) * + sizeof(css_computed_counter)); + } + + error = set_counter_reset(result, p, copy); + if (error != CSS_OK && copy != NULL) + result->alloc(copy, 0, result->pw); + + return error; + } + + return CSS_OK; +} + css_error cascade_cue_after(uint32_t opv, css_style *style, css_select_state *state) { -- cgit v1.2.3