const css_qname *qname, void **sibling);
static css_error parent_node(void *pw, void *node, void **parent);
static css_error sibling_node(void *pw, void *node, void **sibling);
+static css_error node_has_name(void *pw, void *node,
+ const css_qname *qname, bool *match);
/**
return CSS_OK;
}
+
+
+/**
+ * Test the given node for the given name
+ *
+ * This will return true (via the "match" pointer) if the libdom node
+ * has the given name or if that name is the universal selector;
+ * otherwise it returns false. The comparison is case-sensitive. It
+ * corresponds to a rule like "body { ... }" in CSS.
+ *
+ * \param pw Pointer to the current SVG parser state
+ * \param node Libdom SVG node to test
+ * \param qname Name to check for
+ * \param match Pointer to the test result
+ *
+ * \return Always returns CSS_OK
+ */
+css_error node_has_name(void *pw, void *node,
+ const css_qname *qname, bool *match)
+{
+ struct svgtiny_parse_state *state;
+ dom_string *name;
+ dom_exception err;
+
+ /* Start by checking to see if qname is the universal selector */
+ state = (struct svgtiny_parse_state *)pw;
+ if (lwc_string_isequal(qname->name,
+ state->interned_universal, match) == lwc_error_ok) {
+ if (*match) {
+ /* It's the universal selector. In NetSurf, all node
+ * names match the universal selector, and nothing in
+ * the libcss documentation suggests another approach,
+ * so we follow NetSurf here. */
+ return CSS_OK;
+ }
+ }
+
+ err = dom_node_get_node_name((dom_node *)node, &name);
+ if (err != DOM_NO_ERR) {
+ return CSS_OK;
+ }
+
+ /* Unlike with HTML, SVG element names are case-sensitive */
+ *match = dom_string_lwc_isequal(name, qname->name);
+ dom_string_unref(name);
+
+ return CSS_OK;
+}