X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fsvgtiny_css.c;h=ce31ef2763a83d43ff2e6ece8fd938e9a6125456;hb=c94da068c1d10b9de282396355565ec7214d4fa3;hp=687a113b6e346e02c392707c4ffc049980b1bf62;hpb=055fe696680e65f48eaff2bb0149c7ea1e174192;p=libsvgtiny.git diff --git a/src/svgtiny_css.c b/src/svgtiny_css.c index 687a113..ce31ef2 100644 --- a/src/svgtiny_css.c +++ b/src/svgtiny_css.c @@ -47,6 +47,7 @@ static css_error node_count_siblings(void *pw, void *node, bool same_name, bool after, int32_t *count); static css_error node_is_empty(void *pw, void *node, bool *is_empty); static css_error node_is_link(void *pw, void *node, bool *is_link); +static css_error node_is_visited(void *pw, void *node, bool *is_visited); static css_error node_is_hover(void *pw, void *node, bool *is_hover); static css_error node_is_active(void *pw, void *node, bool *is_active); static css_error node_is_focus(void *pw, void *node, bool *is_focus); @@ -58,6 +59,8 @@ static css_error node_is_lang(void *pw, void *node, lwc_string *lang, bool *is_lang); static css_error ua_default_for_property(void *pw, uint32_t property, css_hint *hint); +static css_error set_libcss_node_data(void *pw, void *node, + void *libcss_node_data); /** @@ -1514,6 +1517,26 @@ css_error node_is_link(void *pw, void *node, bool *is_link) return CSS_OK; } +/** + * Check if the given node is a link that has been visited already + * + * This check always fails because the SVG DOM does not have the + * necessary information (it's a UI property). + * + * \param pw Pointer to the current SVG parser state; unused + * \param node Libdom SVG node to check; unused + * \param is_visited Pointer to the boolean return value + * + * \return Always returns CSS_OK + */ +css_error node_is_visited(void *pw, void *node, bool *is_visited) +{ + UNUSED(pw); + UNUSED(node); + *is_visited = false; + return CSS_OK; +} + /** * Check if the given node is being "hovered" over @@ -1766,3 +1789,39 @@ css_error ua_default_for_property(void *pw, uint32_t property, UNUSED(hint); return CSS_INVALID; } + + +/** + * Store libcss data on a node + * + * This is part of the libcss select handler API that we need to + * implement. It is essentially a thin dom_node_set_user_data() + * wrapper. + * + * \param pw Pointer to the current SVG parser state + * \param node Libdom SVG node on which to store the data + * \param libcss_node_data Pointer to the data to store + * + * \return Always returns CSS_OK + */ +css_error set_libcss_node_data(void *pw, void *node, + void *libcss_node_data) +{ + struct svgtiny_parse_state *state; + void *old_data; + + /* A unique "userdata key" (a string) is used to identify this + * data. The fourth parameter (NULL) is a "user handler + * function." We will eventually have one, but for now we set + * it to NULL to avoid a circular reference mess that would + * break the build temporarily. */ + state = (struct svgtiny_parse_state *)pw; + dom_node_set_user_data((dom_node *)node, + state->interned_userdata_key, + libcss_node_data, + NULL, + &old_data); + + /* dom_node_set_user_data() always returns DOM_NO_ERR */ + return CSS_OK; +}