summaryrefslogtreecommitdiff
path: root/src/select/properties/quotes.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-08-27 13:00:57 +0100
committerMichael Drake <mdrake.unique@gmail.com>2022-08-29 13:49:20 +0100
commit8d4c3080202d5c9cb1ffe0b67448c0392c53028b (patch)
tree990847a2b6afd4e8ea56dc7a5290a13436917d7c /src/select/properties/quotes.c
parent9a4646ccb841105404f153cfc5f76cfe3d61b35f (diff)
downloadlibcss-8d4c3080202d5c9cb1ffe0b67448c0392c53028b.tar.gz
Select: Properties: Implement copy handler for complex properties
Diffstat (limited to 'src/select/properties/quotes.c')
-rw-r--r--src/select/properties/quotes.c56
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, &quotes);
-
- 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, &quotes);
- }
-
- if (quotes != NULL) {
- lwc_string **i;
+ uint8_t type = get_quotes(from, &quotes);
- 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, &copy);
+ 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, &quotes);
- return CSS_OK;
+ return css__copy_quotes(
+ type == CSS_QUOTES_INHERIT ? parent : child,
+ result);
}