From: Michael Orlitzky Date: Thu, 12 Oct 2023 18:20:05 +0000 (-0400) Subject: src/svgtiny_css.c: implement parent_node() select handler X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=c4fc5d8fd6c7f1dab195ca4629274086b70e9643;p=libsvgtiny.git src/svgtiny_css.c: implement parent_node() select handler --- diff --git a/src/svgtiny_css.c b/src/svgtiny_css.c index 750fee4..76ee4cc 100644 --- a/src/svgtiny_css.c +++ b/src/svgtiny_css.c @@ -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; +}