Author: jmb
Date: Wed Jul 11 03:23:16 2007
New Revision: 3400
URL:
http://source.netsurf-browser.org?rev=3400&view=rev
Log:
Add Element.
Fix Attr's get_schema_type_info to have the right name.
Added:
trunk/dom/include/dom/core/element.h
trunk/dom/src/core/element.c
Modified:
trunk/dom/include/dom/core/attr.h
trunk/dom/src/core/Makefile
trunk/dom/src/core/attr.c
Modified: trunk/dom/include/dom/core/attr.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/core/attr.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/attr.h (original)
+++ trunk/dom/include/dom/core/attr.h Wed Jul 11 03:23:16 2007
@@ -27,7 +27,7 @@
struct dom_string *value);
dom_exception dom_attr_get_owner(struct dom_attr *attr,
struct dom_element **result);
-dom_exception dom_attr_get_type_info(struct dom_attr *attr,
+dom_exception dom_attr_get_schema_type_info(struct dom_attr *attr,
struct dom_type_info **result);
dom_exception dom_attr_is_id(struct dom_attr *attr, bool *result);
Added: trunk/dom/include/dom/core/element.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/core/element.h?re...
==============================================================================
--- trunk/dom/include/dom/core/element.h (added)
+++ trunk/dom/include/dom/core/element.h Wed Jul 11 03:23:16 2007
@@ -1,0 +1,78 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ *
http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_core_element_h_
+#define dom_core_element_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_attr;
+struct dom_element;
+struct dom_nodelist;
+struct dom_string;
+struct dom_type_info;
+
+dom_exception dom_element_get_tag_name(struct dom_element *element,
+ struct dom_string **name);
+
+dom_exception dom_element_get_attribute(struct dom_element *element,
+ struct dom_string *name, struct dom_string **value);
+dom_exception dom_element_set_attribute(struct dom_element *element,
+ struct dom_string *name, struct dom_string *value);
+dom_exception dom_element_remove_attribute(struct dom_element *element,
+ struct dom_string *name);
+
+dom_exception dom_element_get_attribute_node(struct dom_element *element,
+ struct dom_string *name, struct dom_attr **result);
+dom_exception dom_element_set_attribute_node(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result);
+dom_exception dom_element_remove_attribute_node(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result);
+
+dom_exception dom_element_get_elements_by_tag_name(
+ struct dom_element *element, struct dom_string *name,
+ struct dom_nodelist **result);
+
+dom_exception dom_element_get_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ struct dom_string **value);
+dom_exception dom_element_set_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_string *value);
+dom_exception dom_element_remove_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname);
+
+dom_exception dom_element_get_attribute_node_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ struct dom_attr **result);
+dom_exception dom_element_set_attribute_node_ns(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result);
+
+dom_exception dom_element_get_elements_by_tag_name_ns(
+ struct dom_element *element, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_nodelist **result);
+
+dom_exception dom_element_has_attribute(struct dom_element *element,
+ struct dom_string *name, bool *result);
+dom_exception dom_element_has_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ bool *result);
+
+dom_exception dom_element_get_schema_type_info(struct dom_element *element,
+ struct dom_type_info **result);
+
+dom_exception dom_element_set_id_attribute(struct dom_element *element,
+ struct dom_string *name, bool is_id);
+dom_exception dom_element_set_id_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ bool is_id);
+dom_exception dom_element_set_id_attribute_node(struct dom_element *element,
+ struct dom_attr *id_attr, bool is_id);
+
+#endif
Modified: trunk/dom/src/core/Makefile
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/Makefile?rev=3400&am...
==============================================================================
--- trunk/dom/src/core/Makefile (original)
+++ trunk/dom/src/core/Makefile Wed Jul 11 03:23:16 2007
@@ -22,7 +22,8 @@
CFLAGS += -I$(CURDIR)
# Objects
-OBJS = attr characterdata document namednodemap node nodelist string text
+OBJS = attr characterdata document element namednodemap node nodelist \
+ string text
.PHONY: clean debug distclean export release setup test
Modified: trunk/dom/src/core/attr.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/attr.c?rev=3400&...
==============================================================================
--- trunk/dom/src/core/attr.c (original)
+++ trunk/dom/src/core/attr.c Wed Jul 11 03:23:16 2007
@@ -135,7 +135,7 @@
* The returned type info will have its reference count increased. The caller
* should unref it once it has finished with it.
*/
-dom_exception dom_attr_get_type_info(struct dom_attr *attr,
+dom_exception dom_attr_get_schema_type_info(struct dom_attr *attr,
struct dom_type_info **result)
{
UNUSED(attr);
Added: trunk/dom/src/core/element.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/element.c?rev=3400&a...
==============================================================================
--- trunk/dom/src/core/element.c (added)
+++ trunk/dom/src/core/element.c Wed Jul 11 03:23:16 2007
@@ -1,0 +1,513 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ *
http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <dom/core/element.h>
+
+#include "core/node.h"
+#include "utils/utils.h"
+
+/**
+ * DOM element node
+ */
+struct dom_element {
+ struct dom_node base; /**< Base node */
+
+ struct dom_type_info *schema_type_info; /**< Type information */
+};
+
+/**
+ * Retrieve an element's tag name
+ *
+ * \param element The element to retrieve the name from
+ * \param name Pointer to location to receive name
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_tag_name(struct dom_element *element,
+ struct dom_string **name)
+{
+ UNUSED(element);
+ UNUSED(name);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute from an element by name
+ *
+ * \param element The element to retrieve attribute from
+ * \param name The attribute's name
+ * \param value Pointer to location to receive attribute's value
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute(struct dom_element *element,
+ struct dom_string *name, struct dom_string **value)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute on an element by name
+ *
+ * \param element The element to set attribute on
+ * \param name The attribute's name
+ * \param value The attribute's value
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::name is invalid,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly.
+ */
+dom_exception dom_element_set_attribute(struct dom_element *element,
+ struct dom_string *name, struct dom_string *value)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove an attribute from an element by name
+ *
+ * \param element The element to remove attribute from
+ * \param name The name of the attribute to remove
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly.
+ */
+dom_exception dom_element_remove_attribute(struct dom_element *element,
+ struct dom_string *name)
+{
+ UNUSED(element);
+ UNUSED(name);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute node from an element by name
+ *
+ * \param element The element to retrieve attribute node from
+ * \param name The attribute's name
+ * \param result Pointer to location to receive attribute node
+ * \return DOM_NO_ERR.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute_node(struct dom_element *element,
+ struct dom_string *name, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute node on an element, replacing existing node, if present
+ *
+ * \param element The element to add a node to
+ * \param attr The attribute node to add
+ * \param result Pointer to location to recieve previous node
+ * \return DOM_NO_ERR on success,
+ * DOM_WRONG_DOCUMENT_ERR if ::attr does not belong to the
+ * same document as ::element,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_INUSE_ATTRIBUTE_ERR if ::attr is already an attribute
+ * of another Element node.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_set_attribute_node(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove an attribute node from an element by name
+ *
+ * \param element The element to remove attribute node from
+ * \param attr The attribute node to remove
+ * \param result Pointer to location to receive attribute node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if ::attr is not an attribute of
+ * ::element.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_remove_attribute_node(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a list of descendant elements of an element which match a given
+ * tag name
+ *
+ * \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_element_get_elements_by_tag_name(
+ struct dom_element *element, struct dom_string *name,
+ struct dom_nodelist **result)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute from an element by namespace/localname
+ *
+ * \param element The element to retrieve attribute from
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \param value Pointer to location to receive attribute's value
+ * \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 string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ struct dom_string **value)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute on an element by namespace/qualified name
+ *
+ * \param element The element to set attribute on
+ * \param namespace The attribute's namespace URI
+ * \param qname The attribute's qualified name
+ * \param value The attribute's value
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::qname is invalid,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NAMESPACE_ERR if ::qname is malformed, or
+ * ::qname has a prefix and
+ * ::namespace is null, or ::qname
+ * has a prefix "xml" and
+ * ::namespace is not
+ *
"http://www.w3.org/XML/1998/namespace",
+ * or ::qname has a prefix "xmlns"
+ * and ::namespace is not
+ * "http://www.w3.org/2000/xmlns",
+ * or ::namespace is
+ * "http://www.w3.org/2000/xmlns"
+ * and ::qname is not prefixed
+ * "xmlns",
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not
+ * support the feature "XML" and the
+ * language exposed through the
+ * Document does not support
+ * Namespaces.
+ */
+dom_exception dom_element_set_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_string *value)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(qname);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove an attribute from an element by namespace/localname
+ *
+ * \param element The element to remove attribute from
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not
+ * support the feature "XML" and the
+ * language exposed through the
+ * Document does not support
+ * Namespaces.
+ */
+dom_exception dom_element_remove_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute node from an element by namespace/localname
+ *
+ * \param element The element to retrieve attribute from
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \param result Pointer to location to receive attribute node
+ * \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 node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute_node_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute node on an element, replacing existing node, if present
+ *
+ * \param element The element to add a node to
+ * \param attr The attribute node to add
+ * \param result Pointer to location to recieve previous node
+ * \return DOM_NO_ERR on success,
+ * DOM_WRONG_DOCUMENT_ERR if ::attr does not belong to the
+ * same document as ::element,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_INUSE_ATTRIBUTE_ERR if ::attr is already an attribute
+ * of another Element node.
+ * 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 node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_set_attribute_node_ns(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a list of descendant elements of an element which match a given
+ * namespace/localname pair.
+ *
+ * \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_element_get_elements_by_tag_name_ns(
+ struct dom_element *element, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_nodelist **result)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if an element possesses and attribute with the given name
+ *
+ * \param element The element to query
+ * \param name The attribute name to look for
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_element_has_attribute(struct dom_element *element,
+ struct dom_string *name, bool *result)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if an element possesses and attribute with the given
+ * namespace/localname pair.
+ *
+ * \param element The element to query
+ * \param namespace The attribute namespace URI to look for
+ * \param localname The attribute local name to look for
+ * \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.
+ */
+dom_exception dom_element_has_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ bool *result)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the type information associated with an element
+ *
+ * \param element The element to retrieve type information from
+ * \param result Pointer to location to receive type information
+ * \return DOM_NO_ERR.
+ *
+ * The returned typeinfo will have its reference count increased. It is
+ * the responsibility of the caller to unref the typeinfo once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_schema_type_info(struct dom_element *element,
+ struct dom_type_info **result)
+{
+ UNUSED(element);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * (Un)declare an attribute as being an element's ID by name
+ *
+ * \param element The element containing the attribute
+ * \param name The attribute's name
+ * \param is_id Whether the attribute is an ID
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if the specified node is not an
+ * attribute of ::element.
+ */
+dom_exception dom_element_set_id_attribute(struct dom_element *element,
+ struct dom_string *name, bool is_id)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(is_id);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * (Un)declare an attribute as being an element's ID by namespace/localname
+ *
+ * \param element The element containing the attribute
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \param is_id Whether the attribute is an ID
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if the specified node is not an
+ * attribute of ::element.
+ */
+dom_exception dom_element_set_id_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ bool is_id)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(is_id);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * (Un)declare an attribute node as being an element's ID
+ *
+ * \param element The element containing the attribute
+ * \param id_attr The attribute node
+ * \param is_id Whether the attribute is an ID
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if the specified node is not an
+ * attribute of ::element.
+ */
+dom_exception dom_element_set_id_attribute_node(struct dom_element *element,
+ struct dom_attr *id_attr, bool is_id)
+{
+ UNUSED(element);
+ UNUSED(id_attr);
+ UNUSED(is_id);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+