diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-03-04 01:24:12 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-03-04 01:24:12 +0000 |
commit | 7c809b74610653dc55276bb6e99459e073d2112c (patch) | |
tree | 189487a527dfb07ac96c66ccdeacbd40b8a6f3af | |
parent | ccb0737a07d5f97e917d37252123b1293ab242fe (diff) | |
download | libcss-7c809b74610653dc55276bb6e99459e073d2112c.tar.gz libcss-7c809b74610653dc55276bb6e99459e073d2112c.tar.bz2 |
Constify.
Compose counter-increment and counter-reset.
Fix compose_content.
svn path=/trunk/libcss/; revision=6692
-rw-r--r-- | include/libcss/computed.h | 4 | ||||
-rw-r--r-- | src/select/properties.c | 82 |
2 files changed, 83 insertions, 3 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h index 0d4f5f0..c0cbdfe 100644 --- a/include/libcss/computed.h +++ b/include/libcss/computed.h @@ -501,7 +501,7 @@ static inline uint8_t css_computed_word_spacing( #define COUNTER_INCREMENT_MASK 0x2 static inline uint8_t css_computed_counter_increment( const css_computed_style *style, - css_computed_counter **counters) + const css_computed_counter **counters) { if (style->uncommon != NULL) { uint8_t bits = style->uncommon->bits[COUNTER_INCREMENT_INDEX]; @@ -525,7 +525,7 @@ static inline uint8_t css_computed_counter_increment( #define COUNTER_RESET_MASK 0x1 static inline uint8_t css_computed_counter_reset( const css_computed_style *style, - css_computed_counter **counters) + const css_computed_counter **counters) { if (style->uncommon != NULL) { uint8_t bits = style->uncommon->bits[COUNTER_RESET_INDEX]; 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) { |