diff options
Diffstat (limited to 'src/select/properties/quotes.c')
-rw-r--r-- | src/select/properties/quotes.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/select/properties/quotes.c b/src/select/properties/quotes.c index 9152f84..57fc48c 100644 --- a/src/select/properties/quotes.c +++ b/src/select/properties/quotes.c @@ -123,43 +123,41 @@ css_error css__initial_quotes(css_select_state *state) return css__set_quotes_from_hint(&hint, state->computed); } -css_error css__compose_quotes(const css_computed_style *parent, - const css_computed_style *child, - css_computed_style *result) +css_error css__copy_quotes( + const css_computed_style *from, + css_computed_style *to) { css_error error; + lwc_string **copy = NULL; lwc_string **quotes = NULL; - uint8_t type = get_quotes(child, "es); - - if (type == CSS_QUOTES_INHERIT || result != child) { - size_t n_quotes = 0; - lwc_string **copy = NULL; - - if (type == CSS_QUOTES_INHERIT) { - type = get_quotes(parent, "es); - } - - if (quotes != NULL) { - lwc_string **i; + uint8_t type = get_quotes(from, "es); - for (i = quotes; (*i) != NULL; i++) - n_quotes++; + if (from == to) { + return CSS_OK; + } - copy = malloc((n_quotes + 1) * sizeof(lwc_string *)); - if (copy == NULL) - return CSS_NOMEM; + error = css__copy_lwc_string_array(false, quotes, ©); + if (error != CSS_OK) { + return CSS_NOMEM; + } - memcpy(copy, quotes, (n_quotes + 1) * - sizeof(lwc_string *)); - } + error = set_quotes(to, type, copy); + if (error != CSS_OK) { + free(copy); + } - error = set_quotes(result, type, copy); - if (error != CSS_OK && copy != NULL) - free(copy); + return error; +} - return error; - } +css_error css__compose_quotes(const css_computed_style *parent, + const css_computed_style *child, + css_computed_style *result) +{ + lwc_string **quotes = NULL; + uint8_t type = get_quotes(child, "es); - return CSS_OK; + return css__copy_quotes( + type == CSS_QUOTES_INHERIT ? parent : child, + result); } |