]> 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, 20 Nov 2023 16:42:26 +0000 (11:42 -0500)
src/svgtiny_css.c

index e2af9a41d6a6402f04d56e73286aee096ff6c775..6d345a753dacf4764cb3353ce983a1a8e651241c 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);
 
 
 /**
@@ -554,3 +556,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;
+}