X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fsvgtiny_css.c;h=f01c3b40df17ca066611aec5a3458c8d6d104bd2;hb=2d9df164155af9c43959aa5fb0f7465454b33839;hp=ce31ef2763a83d43ff2e6ece8fd938e9a6125456;hpb=c94da068c1d10b9de282396355565ec7214d4fa3;p=libsvgtiny.git diff --git a/src/svgtiny_css.c b/src/svgtiny_css.c index ce31ef2..f01c3b4 100644 --- a/src/svgtiny_css.c +++ b/src/svgtiny_css.c @@ -57,10 +57,14 @@ static css_error node_is_checked(void *pw, void *node, bool *is_checked); static css_error node_is_target(void *pw, void *node, bool *is_target); static css_error node_is_lang(void *pw, void *node, lwc_string *lang, bool *is_lang); +static css_error node_presentational_hint(void *pw, void *node, + uint32_t *nhints, css_hint **hints); 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); +static css_error get_libcss_node_data(void *pw, void *node, + void **libcss_node_data); /** @@ -1769,6 +1773,31 @@ static css_error node_is_lang(void *pw, void *node, } +/** + * Return presentational hints for the given node + * + * Unless an SVG is being rendered from within an HTML document, + * there are no presentational hints. We always return an empty + * array (no hints). + * + * \param pw Pointer to the current SVG parser state; unused + * \param node Libdom SVG node whose hints we want; unused + * \param nhints How many hints are returned (return by reference) + * \param hints Array of css_hint structures (return by reference) + * + * \return Always returns CSS_OK + */ +css_error node_presentational_hint(void *pw, void *node, + uint32_t *nhints, css_hint **hints) +{ + UNUSED(pw); + UNUSED(node); + *nhints = 0; + *hints = NULL; + return CSS_OK; +} + + /** * User-agent defaults for CSS properties * @@ -1825,3 +1854,33 @@ css_error set_libcss_node_data(void *pw, void *node, /* dom_node_set_user_data() always returns DOM_NO_ERR */ return CSS_OK; } + + +/** + * Retrieve libcss data from a node + * + * This is part of the libcss select handler API that we need to + * implement. It is essentially a thin dom_node_get_user_data() + * wrapper. + * + * \param pw Pointer to the current SVG parser state + * \param node Libdom SVG node from which to get the data + * \param libcss_node_data Address at which to store a pointer to the data + * + * \return Always returns CSS_OK + */ +css_error get_libcss_node_data(void *pw, void *node, + void **libcss_node_data) +{ + struct svgtiny_parse_state *state; + + /* A unique "userdata key" (a string) is used to identify this + * data. */ + state = (struct svgtiny_parse_state *)pw; + dom_node_get_user_data((dom_node *)node, + state->interned_userdata_key, + libcss_node_data); + + /* dom_node_get_user_data() always returns DOM_NO_ERR */ + return CSS_OK; +}