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

index 21b5cdffc38e8cdac95ef0fec9ddc28340758ee6..b1790d34f3b89472706d2c3ab202f90e6533cb7f 100644 (file)
@@ -13,6 +13,7 @@ static css_error named_sibling_node(void *pw, void *node,
                const css_qname *qname, void **sibling);
 static css_error named_generic_sibling_node(void *pw, void *node,
                const css_qname *qname, void **sibling);
+static css_error parent_node(void *pw, void *node, void **parent);
 
 
 /**
@@ -409,3 +410,26 @@ css_error named_generic_sibling_node(void *pw, void *node,
 
        return CSS_OK;
 }
+
+
+/**
+ * Return a pointer to the given node's parent
+ *
+ * \param pw      Pointer to the current SVG parser state
+ * \param node    Libdom SVG node
+ * \param parent  Address at which to store the node's parent pointer
+ *
+ * \return Always returns CSS_OK
+ */
+css_error parent_node(void *pw, void *node, void **parent)
+{
+       UNUSED(pw);
+       /* Libdom basically implements this for us */
+       dom_element_parent_node(node, (struct dom_element **)parent);
+
+       /* See the comment in named_parent_node() for why we decrement
+        * this reference counter here. */
+       dom_node_unref(*parent);
+
+       return CSS_OK;
+}