]> gitweb.michael.orlitzky.com - libsvgtiny.git/commitdiff
src/svgtiny_css.c: implement node_has_class() select handler
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 12 Oct 2023 22:18:30 +0000 (18:18 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 9 Jun 2025 01:13:06 +0000 (21:13 -0400)
src/svgtiny_css.c

index 39340b6935d49016fe11901804a4eef3b8446f94..937484023eceea228395e58945354c5e8dc58ab4 100644 (file)
@@ -17,6 +17,8 @@ static css_error parent_node(void *pw, void *node, void **parent);
 static css_error sibling_node(void *pw, void *node, void **sibling);
 static css_error node_has_name(void *pw, void *node,
                const css_qname *qname, bool *match);
+static css_error node_has_class(void *pw, void *node,
+               lwc_string *name, bool *match);
 
 
 /**
@@ -552,3 +554,27 @@ css_error node_has_name(void *pw, void *node,
 
        return CSS_OK;
 }
+
+
+/**
+ * Test the given node for the given class
+ *
+ * This will return true (via the "match" pointer) if the libdom node
+ * has the given class. The comparison is case-sensitive. It
+ * corresponds to node.class in CSS.
+ *
+ * \param pw       Pointer to the current SVG parser state
+ * \param node     Libdom SVG node to test
+ * \param name     Class name to check for
+ * \param match    Pointer to the test result
+ *
+ * \return Always returns CSS_OK
+ */
+css_error node_has_class(void *pw, void *node,
+               lwc_string *name, bool *match)
+{
+       UNUSED(pw);
+       /* libdom implements this for us and apparently it cannot fail */
+       dom_element_has_class((dom_node *)node, name, match);
+       return CSS_OK;
+}