summaryrefslogtreecommitdiff
path: root/src/select/properties/cursor.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/cursor.c
parent9a4646ccb841105404f153cfc5f76cfe3d61b35f (diff)
downloadlibcss-8d4c3080202d5c9cb1ffe0b67448c0392c53028b.tar.gz
libcss-8d4c3080202d5c9cb1ffe0b67448c0392c53028b.tar.bz2
Select: Properties: Implement copy handler for complex properties
Diffstat (limited to 'src/select/properties/cursor.c')
-rw-r--r--src/select/properties/cursor.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/select/properties/cursor.c b/src/select/properties/cursor.c
index 7b1e39b..09955c6 100644
--- a/src/select/properties/cursor.c
+++ b/src/select/properties/cursor.c
@@ -164,38 +164,40 @@ css_error css__initial_cursor(css_select_state *state)
return set_cursor(state->computed, CSS_CURSOR_AUTO, NULL);
}
-css_error css__compose_cursor(const css_computed_style *parent,
- const css_computed_style *child,
- css_computed_style *result)
+css_error css__copy_cursor(
+ const css_computed_style *from,
+ css_computed_style *to)
{
css_error error;
lwc_string **copy = NULL;
- lwc_string **urls = NULL;
- uint8_t type = get_cursor(child, &urls);
+ lwc_string **cursor = NULL;
+ uint8_t type = get_cursor(from, &cursor);
- if (type == CSS_CURSOR_INHERIT) {
- type = get_cursor(parent, &urls);
+ if (from == to) {
+ return CSS_OK;
}
- if (urls != NULL) {
- lwc_string **i;
- size_t n_urls = 0;
-
- for (i = urls; (*i) != NULL; i++)
- n_urls++;
-
- copy = malloc((n_urls + 1) *
- sizeof(lwc_string *));
- if (copy == NULL)
- return CSS_NOMEM;
-
- memcpy(copy, urls, (n_urls + 1) *
- sizeof(lwc_string *));
+ error = css__copy_lwc_string_array(false, cursor, &copy);
+ if (error != CSS_OK) {
+ return CSS_NOMEM;
}
- error = set_cursor(result, type, copy);
- if (error != CSS_OK && copy != NULL)
+ error = set_cursor(to, type, copy);
+ if (error != CSS_OK) {
free(copy);
+ }
return error;
}
+
+css_error css__compose_cursor(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ lwc_string **cursor = NULL;
+ uint8_t type = get_cursor(child, &cursor);
+
+ return css__copy_cursor(
+ type == CSS_CURSOR_INHERIT ? parent : child,
+ result);
+}