]> gitweb.michael.orlitzky.com - libsvgtiny.git/commitdiff
src/svgtiny_css.c: implement get_libcss_node_data() select handler
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 17 Oct 2023 14:36:08 +0000 (10:36 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 9 Jun 2025 01:13:06 +0000 (21:13 -0400)
src/svgtiny_css.c

index cb24bfc6f41913a85baf70e2dc836d9bbe3c3199..21551a0dae8714f320f4bdb07f4d30656154a6c8 100644 (file)
@@ -61,6 +61,8 @@ 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);
 
 
 /**
@@ -1823,3 +1825,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;
+}