summaryrefslogtreecommitdiff
path: root/src/select/properties/counter_reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/select/properties/counter_reset.c')
-rw-r--r--src/select/properties/counter_reset.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/select/properties/counter_reset.c b/src/select/properties/counter_reset.c
index 9d20609..e4ec8bf 100644
--- a/src/select/properties/counter_reset.c
+++ b/src/select/properties/counter_reset.c
@@ -52,41 +52,33 @@ css_error css__compose_counter_reset(const css_computed_style *parent,
css_computed_style *result)
{
css_error error;
+ css_computed_counter *copy = NULL;
const css_computed_counter *items = NULL;
uint8_t type = get_counter_reset(child, &items);
- if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
- type == CSS_COUNTER_RESET_INHERIT ||
- (child->i.uncommon != NULL && result != child)) {
- size_t n_items = 0;
- css_computed_counter *copy = NULL;
-
- if ((child->i.uncommon == NULL && parent->i.uncommon != NULL) ||
- type == CSS_COUNTER_RESET_INHERIT) {
- type = get_counter_reset(parent, &items);
- }
-
- if (type == CSS_COUNTER_RESET_NAMED && items != NULL) {
- const css_computed_counter *i;
-
- for (i = items; i->name != NULL; i++)
- n_items++;
+ if (type == CSS_COUNTER_RESET_INHERIT) {
+ type = get_counter_reset(parent, &items);
+ }
- copy = malloc((n_items + 1) *
- sizeof(css_computed_counter));
- if (copy == NULL)
- return CSS_NOMEM;
+ if (type == CSS_COUNTER_RESET_NAMED && items != NULL) {
+ size_t n_items = 0;
+ const css_computed_counter *i;
- memcpy(copy, items, (n_items + 1) *
- sizeof(css_computed_counter));
- }
+ for (i = items; i->name != NULL; i++)
+ n_items++;
- error = set_counter_reset(result, type, copy);
- if (error != CSS_OK && copy != NULL)
- free(copy);
+ copy = malloc((n_items + 1) *
+ sizeof(css_computed_counter));
+ if (copy == NULL)
+ return CSS_NOMEM;
- return error;
+ memcpy(copy, items, (n_items + 1) *
+ sizeof(css_computed_counter));
}
- return CSS_OK;
+ error = set_counter_reset(result, type, copy);
+ if (error != CSS_OK && copy != NULL)
+ free(copy);
+
+ return error;
}