summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/html/html_element.c67
-rw-r--r--src/html/html_element.h34
2 files changed, 100 insertions, 1 deletions
diff --git a/src/html/html_element.c b/src/html/html_element.c
index 21f3d1e..c2a4899 100644
--- a/src/html/html_element.c
+++ b/src/html/html_element.c
@@ -26,7 +26,7 @@ struct dom_html_element_vtable _dom_html_element_vtable = {
},
DOM_NODE_VTABLE_ELEMENT,
},
- DOM_ELEMENT_VTABLE
+ DOM_ELEMENT_VTABLE_HTML_ELEMENT,
},
DOM_HTML_ELEMENT_VTABLE
};
@@ -142,6 +142,71 @@ SIMPLE_GET_SET(lang,lang)
SIMPLE_GET_SET(dir,dir)
SIMPLE_GET_SET(class_name,class)
+/**
+ * Retrieve a list of descendant elements of an element which match a given
+ * tag name (caselessly)
+ *
+ * \param element The root of the subtree to search
+ * \param name The tag name to match (or "*" for all tags)
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned nodelist will have its reference count increased. It is
+ * the responsibility of the caller to unref the nodelist once it has
+ * finished with it.
+ */
+dom_exception _dom_html_element_get_elements_by_tag_name(
+ struct dom_element *element, dom_string *name,
+ struct dom_nodelist **result)
+{
+ dom_exception err;
+ dom_node_internal *base = (dom_node_internal *) element;
+
+ assert(base->owner != NULL);
+
+ err = _dom_document_get_nodelist(base->owner,
+ DOM_NODELIST_BY_NAME_CASELESS,
+ (struct dom_node_internal *) element, name, NULL,
+ NULL, result);
+
+ return err;
+}
+
+/**
+ * Retrieve a list of descendant elements of an element which match a given
+ * namespace/localname pair, caselessly.
+ *
+ * \param element The root of the subtree to search
+ * \param namespace The namespace URI to match (or "*" for all)
+ * \param localname The local name to match (or "*" for all)
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not support
+ * the feature "XML" and the language exposed
+ * through the Document does not support
+ * Namespaces.
+ *
+ * The returned nodelist will have its reference count increased. It is
+ * the responsibility of the caller to unref the nodelist once it has
+ * finished with it.
+ */
+dom_exception _dom_html_element_get_elements_by_tag_name_ns(
+ struct dom_element *element, dom_string *namespace,
+ dom_string *localname, struct dom_nodelist **result)
+{
+ dom_exception err;
+
+ /** \todo ensure XML feature is supported */
+
+ err = _dom_document_get_nodelist(element->base.owner,
+ DOM_NODELIST_BY_NAMESPACE_CASELESS,
+ (struct dom_node_internal *) element, NULL,
+ namespace, localname,
+ result);
+
+ return err;
+}
+
/*-----------------------------------------------------------------------*/
/* Common functions */
diff --git a/src/html/html_element.h b/src/html/html_element.h
index ebf47ba..2ac4b17 100644
--- a/src/html/html_element.h
+++ b/src/html/html_element.h
@@ -33,11 +33,45 @@ dom_exception _dom_html_element_initialise(struct dom_html_document *doc,
void _dom_html_element_finalise(struct dom_html_element *ele);
+/* Virtual functions */
+dom_exception _dom_html_element_get_elements_by_tag_name(
+ struct dom_element *element, dom_string *name,
+ struct dom_nodelist **result);
+
+dom_exception _dom_html_element_get_elements_by_tag_name_ns(
+ struct dom_element *element, dom_string *namespace,
+ dom_string *localname, struct dom_nodelist **result);
+
+
/* The protected virtual functions */
void _dom_html_element_destroy(dom_node_internal *node);
dom_exception _dom_html_element_copy(dom_node_internal *old,
dom_node_internal **copy);
+#define DOM_ELEMENT_VTABLE_HTML_ELEMENT \
+ _dom_element_get_tag_name, \
+ _dom_element_get_attribute, \
+ _dom_element_set_attribute, \
+ _dom_element_remove_attribute, \
+ _dom_element_get_attribute_node, \
+ _dom_element_set_attribute_node, \
+ _dom_element_remove_attribute_node, \
+ _dom_html_element_get_elements_by_tag_name, \
+ _dom_element_get_attribute_ns, \
+ _dom_element_set_attribute_ns, \
+ _dom_element_remove_attribute_ns, \
+ _dom_element_get_attribute_node_ns, \
+ _dom_element_set_attribute_node_ns, \
+ _dom_html_element_get_elements_by_tag_name_ns, \
+ _dom_element_has_attribute, \
+ _dom_element_has_attribute_ns, \
+ _dom_element_get_schema_type_info, \
+ _dom_element_set_id_attribute, \
+ _dom_element_set_id_attribute_ns, \
+ _dom_element_set_id_attribute_node, \
+ _dom_element_get_classes, \
+ _dom_element_has_class
+
#define DOM_HTML_ELEMENT_PROTECT_VTABLE \
_dom_html_element_destroy, \
_dom_html_element_copy