const css_qname *qname, bool *match);
static css_error node_has_class(void *pw, void *node,
lwc_string *name, bool *match);
+static css_error node_has_id(void *pw, void *node,
+ lwc_string *name, bool *match);
/**
dom_element_has_class((dom_node *)node, name, match);
return CSS_OK;
}
+
+
+/**
+ * Test the given node for the given id
+ *
+ * This will return true (via the "match" pointer) if the libdom node
+ * has the given id. The comparison is case-sensitive. It corresponds
+ * to node#id in CSS.
+ *
+ * \param pw Pointer to the current SVG parser state
+ * \param node Libdom SVG node to test
+ * \param name Id to check for
+ * \param match Pointer to the test result
+ *
+ * \return Always returns CSS_OK
+ */
+css_error node_has_id(void *pw, void *node,
+ lwc_string *name, bool *match)
+{
+ dom_string *attr;
+ dom_exception err;
+ struct svgtiny_parse_state *state;
+
+ attr = NULL; /* a priori the "id" attribute may not exist */
+ *match = false; /* default to no match */
+
+ state = (struct svgtiny_parse_state *)pw;
+ err = dom_element_get_attribute((dom_node *)node,
+ state->interned_id, &attr);
+ if (err != DOM_NO_ERR || attr == NULL) {
+ return CSS_OK;
+ }
+
+ *match = dom_string_lwc_isequal(attr, name);
+ dom_string_unref(attr);
+
+ return CSS_OK;
+}