]> 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, 20 Nov 2023 01:37:04 +0000 (20:37 -0500)
src/svgtiny_css.c

index 750fee48d8b96849d59559394fd044b95b2f0ad1..76ee4ccc60b3adf722bf62d6a8773fcf5caba5cc 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;
+}