From c4fc5d8fd6c7f1dab195ca4629274086b70e9643 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 12 Oct 2023 14:20:05 -0400 Subject: [PATCH] src/svgtiny_css.c: implement parent_node() select handler --- src/svgtiny_css.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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; +} -- 2.44.2