summaryrefslogtreecommitdiff
path: root/src/select/properties/cursor.c
diff options
context:
space:
mode:
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);
+}