libdom
Loading...
Searching...
No Matches
Functions
node.c File Reference
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dom/core/attr.h>
#include <dom/core/text.h>
#include <dom/core/document.h>
#include <dom/core/namednodemap.h>
#include <dom/core/nodelist.h>
#include <dom/core/implementation.h>
#include <dom/core/document_type.h>
#include <dom/events/events.h>
#include "core/string.h"
#include "core/namednodemap.h"
#include "core/attr.h"
#include "core/cdatasection.h"
#include "core/comment.h"
#include "core/document.h"
#include "core/document_type.h"
#include "core/doc_fragment.h"
#include "core/element.h"
#include "core/entity_ref.h"
#include "core/node.h"
#include "core/pi.h"
#include "core/text.h"
#include "utils/utils.h"
#include "utils/validate.h"
#include "events/mutation_event.h"

Functions

dom_node_internal_dom_node_create (void)
 
void _dom_node_destroy (struct dom_node_internal *node)
 
dom_exception _dom_node_initialise (dom_node_internal *node, struct dom_document *doc, dom_node_type type, dom_string *name, dom_string *value, dom_string *namespace, dom_string *prefix)
 
void _dom_node_finalise (dom_node_internal *node)
 
dom_exception _dom_node_contains (struct dom_node_internal *node, struct dom_node_internal *other, bool *contains)
 
dom_exception _dom_node_get_node_name (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_get_node_value (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_set_node_value (dom_node_internal *node, dom_string *value)
 
dom_exception _dom_node_get_node_type (dom_node_internal *node, dom_node_type *result)
 
dom_exception _dom_node_get_parent_node (dom_node_internal *node, dom_node_internal **result)
 
dom_exception _dom_node_get_child_nodes (dom_node_internal *node, struct dom_nodelist **result)
 
dom_exception _dom_node_get_first_child (dom_node_internal *node, dom_node_internal **result)
 
dom_exception _dom_node_get_last_child (dom_node_internal *node, dom_node_internal **result)
 
dom_exception _dom_node_get_previous_sibling (dom_node_internal *node, dom_node_internal **result)
 
dom_exception _dom_node_get_next_sibling (dom_node_internal *node, dom_node_internal **result)
 
dom_exception _dom_node_get_attributes (dom_node_internal *node, struct dom_namednodemap **result)
 
dom_exception _dom_node_get_owner_document (dom_node_internal *node, struct dom_document **result)
 
dom_exception _dom_node_insert_before (dom_node_internal *node, dom_node_internal *new_child, dom_node_internal *ref_child, dom_node_internal **result)
 
dom_exception _dom_node_replace_child (dom_node_internal *node, dom_node_internal *new_child, dom_node_internal *old_child, dom_node_internal **result)
 
dom_exception _dom_node_remove_child (dom_node_internal *node, dom_node_internal *old_child, dom_node_internal **result)
 
dom_exception _dom_node_append_child (dom_node_internal *node, dom_node_internal *new_child, dom_node_internal **result)
 
dom_exception _dom_node_has_child_nodes (dom_node_internal *node, bool *result)
 
dom_exception _dom_node_clone_node (dom_node_internal *node, bool deep, dom_node_internal **result)
 
dom_exception _dom_node_normalize (dom_node_internal *node)
 
dom_exception _dom_node_is_supported (dom_node_internal *node, dom_string *feature, dom_string *version, bool *result)
 
dom_exception _dom_node_get_namespace (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_get_prefix (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_set_prefix (dom_node_internal *node, dom_string *prefix)
 
dom_exception _dom_node_get_local_name (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_has_attributes (dom_node_internal *node, bool *result)
 
dom_exception _dom_node_get_base (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_compare_document_position (dom_node_internal *node, dom_node_internal *other, uint16_t *result)
 
dom_exception _dom_node_get_text_content (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_node_set_text_content (dom_node_internal *node, dom_string *content)
 
dom_exception _dom_node_is_same (dom_node_internal *node, dom_node_internal *other, bool *result)
 
dom_exception _dom_node_lookup_prefix (dom_node_internal *node, dom_string *namespace, dom_string **result)
 
dom_exception _dom_node_is_default_namespace (dom_node_internal *node, dom_string *namespace, bool *result)
 
dom_exception _dom_node_lookup_namespace (dom_node_internal *node, dom_string *prefix, dom_string **result)
 
dom_exception _dom_node_is_equal (dom_node_internal *node, dom_node_internal *other, bool *result)
 
dom_exception _dom_node_get_feature (dom_node_internal *node, dom_string *feature, dom_string *version, void **result)
 
dom_exception _dom_node_set_user_data (dom_node_internal *node, dom_string *key, void *data, dom_user_data_handler handler, void **result)
 
dom_exception _dom_node_get_user_data (const dom_node_internal *node, const dom_string *key, void **result)
 
dom_exception _dom_node_copy (dom_node_internal *old, dom_node_internal **copy)
 
dom_exception _dom_node_copy_internal (dom_node_internal *old, dom_node_internal *new)
 
bool _dom_node_readonly (const dom_node_internal *node)
 
dom_exception _dom_merge_adjacent_text (dom_node_internal *p, dom_node_internal *n)
 
dom_exception _dom_node_try_destroy (dom_node_internal *node)
 
void _dom_node_mark_pending (dom_node_internal *node)
 
void _dom_node_remove_pending (dom_node_internal *node)
 
dom_exception _dom_node_add_event_listener (dom_event_target *et, dom_string *type, struct dom_event_listener *listener, bool capture)
 
dom_exception _dom_node_remove_event_listener (dom_event_target *et, dom_string *type, struct dom_event_listener *listener, bool capture)
 
dom_exception _dom_node_add_event_listener_ns (dom_event_target *et, dom_string *namespace, dom_string *type, struct dom_event_listener *listener, bool capture)
 
dom_exception _dom_node_remove_event_listener_ns (dom_event_target *et, dom_string *namespace, dom_string *type, struct dom_event_listener *listener, bool capture)
 
dom_exception _dom_node_dispatch_event (dom_event_target *et, struct dom_event *evt, bool *success)
 
dom_exception _dom_node_dispatch_node_change_event (dom_document *doc, dom_node_internal *node, dom_node_internal *related, dom_mutation_type change, bool *success)
 

Function Documentation

◆ _dom_merge_adjacent_text()

dom_exception _dom_merge_adjacent_text ( dom_node_internal * p,
dom_node_internal * n )

Merge two adjacent text nodes into one text node.

Parameters
pThe first text node
nThe second text node
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ _dom_node_add_event_listener()

dom_exception _dom_node_add_event_listener ( dom_event_target * et,
dom_string * type,
struct dom_event_listener * listener,
bool capture )

◆ _dom_node_add_event_listener_ns()

dom_exception _dom_node_add_event_listener_ns ( dom_event_target * et,
dom_string * namespace,
dom_string * type,
struct dom_event_listener * listener,
bool capture )

◆ _dom_node_append_child()

dom_exception _dom_node_append_child ( dom_node_internal * node,
dom_node_internal * new_child,
dom_node_internal ** result )

Append a child to the end of a node's child list

Parameters
nodeNode to insert into
new_childNode to append
resultPointer to location to receive node being inserted
Returns
DOM_NO_ERR on success, DOM_HIERARCHY_REQUEST_ERR if ::new_child's type is not permitted as a child of ::node, or ::new_child is an ancestor of ::node (or is ::node itself), or ::node is of type Document and a second DocumentType or Element is being inserted, DOM_WRONG_DOCUMENT_ERR if ::new_child was created from a different document than ::node, DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, or ::new_child's parent is readonly.

If ::new_child is a DocumentFragment, all of its children are inserted. If ::new_child is already in the tree, it is first removed.

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_node_clone_node()

dom_exception _dom_node_clone_node ( dom_node_internal * node,
bool deep,
dom_node_internal ** result )

Clone a DOM node

Parameters
nodeThe node to clone
deepTrue to deep-clone the node's sub-tree
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, DOM_NO_MEMORY_ERR on memory exhaustion.

The returned node will already be referenced.

The duplicate node will have no parent and no user data.

If ::node has registered user_data_handlers, then they will be called.

Cloning an Element copies all attributes & their values (including those generated by the XML processor to represent defaulted attributes). It does not copy any child nodes unless it is a deep copy (this includes text contained within the Element, as the text is contained in a child Text node).

Cloning an Attr directly, as opposed to cloning as part of an Element, returns a specified attribute. Cloning an Attr always clones its children, since they represent its value, no matter whether this is a deep clone or not.

Cloning an EntityReference automatically constructs its subtree if a corresponding Entity is available, no matter whether this is a deep clone or not.

Cloning any other type of node simply returns a copy.

Note that cloning an immutable subtree results in a mutable copy, but the children of an EntityReference clone are readonly. In addition, clones of unspecified Attr nodes are specified.

Todo
work out what happens when cloning Document, DocumentType, Entity and Notation nodes.

Note: we adopt a OO paradigm, this clone_node just provide a basic operation of clone. Special clones like Attr/EntitiReference stated above should provide their overload of this interface in their implementation file.

◆ _dom_node_compare_document_position()

dom_exception _dom_node_compare_document_position ( dom_node_internal * node,
dom_node_internal * other,
uint16_t * result )

Compare the positions of two nodes in a DOM tree

Parameters
nodeThe reference node
otherThe node to compare
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, DOM_NOT_SUPPORTED_ERR when the nodes are from different DOM implementations.

The result is a bitfield of dom_document_position values.

We don't support this API now, so this function call should always return DOM_NOT_SUPPORTED_ERR.

◆ _dom_node_contains()

dom_exception _dom_node_contains ( struct dom_node_internal * node,
struct dom_node_internal * other,
bool * contains )

◆ _dom_node_copy()

dom_exception _dom_node_copy ( dom_node_internal * old,
dom_node_internal ** copy )

◆ _dom_node_copy_internal()

dom_exception _dom_node_copy_internal ( dom_node_internal * old,
dom_node_internal * new )

◆ _dom_node_create()

dom_node_internal * _dom_node_create ( void )

◆ _dom_node_destroy()

void _dom_node_destroy ( struct dom_node_internal * node)

Destroy a DOM node

Parameters
nodeThe node to destroy

::node's parent link must be NULL and its reference count must be 0.

::node will be freed.

This function should only be called from dom_node_unref or type-specific destructors (for destroying child nodes). Anything else should not be attempting to destroy nodes – they should simply be unreferencing them (so destruction will occur at the appropriate time).

◆ _dom_node_dispatch_event()

dom_exception _dom_node_dispatch_event ( dom_event_target * et,
struct dom_event * evt,
bool * success )

Dispatch an event into the implementation's event model

Parameters
etThe EventTarget object
evtThe event object
successIndicates whether any of the listeners which handled the event called Event.preventDefault(). If Event.preventDefault() was called the returned value is false, else it is true.
Returns
DOM_NO_ERR on success DOM_DISPATCH_REQUEST_ERR If the event is already in dispatch DOM_UNSPECIFIED_EVENT_TYPE_ERR If the type of the event is Null or empty string. DOM_NOT_SUPPORTED_ERR If the event is not created by Document.createEvent DOM_INVALID_CHARACTER_ERR If the type of this event is not a valid NCName.

◆ _dom_node_dispatch_node_change_event()

dom_exception _dom_node_dispatch_node_change_event ( dom_document * doc,
dom_node_internal * node,
dom_node_internal * related,
dom_mutation_type change,
bool * success )

◆ _dom_node_finalise()

void _dom_node_finalise ( dom_node_internal * node)

Finalise a DOM node

Parameters
nodeThe node to finalise

The contents of ::node will be cleaned up. ::node will not be freed. All children of ::node should have been removed prior to finalisation.

◆ _dom_node_get_attributes()

dom_exception _dom_node_get_attributes ( dom_node_internal * node,
struct dom_namednodemap ** result )

Retrieve a map of attributes associated with a DOM node

Parameters
nodeThe node to retrieve the attributes of
resultPointer to location to receive attribute map
Returns
DOM_NO_ERR.

The returned NamedNodeMap will be referenced. It is the responsibility of the caller to unref the map once it has finished with it.

If ::node is not an Element, then NULL will be returned.

◆ _dom_node_get_base()

dom_exception _dom_node_get_base ( dom_node_internal * node,
dom_string ** result )

Retrieve the base URI of a DOM node

Parameters
nodeThe node to retrieve the base URI of
resultPointer to location to receive base URI
Returns
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.

We don't support this API now, so this function call should always return DOM_NOT_SUPPORTED_ERR.

◆ _dom_node_get_child_nodes()

dom_exception _dom_node_get_child_nodes ( dom_node_internal * node,
struct dom_nodelist ** result )

Retrieve a list of children of a DOM node

Parameters
nodeThe node to retrieve the children of
resultPointer to location to receive child list
Returns
DOM_NO_ERR.

The returned NodeList will be referenced. It is the responsibility of the caller to unref the list once it has finished with it.

◆ _dom_node_get_feature()

dom_exception _dom_node_get_feature ( dom_node_internal * node,
dom_string * feature,
dom_string * version,
void ** result )

Retrieve an object which implements the specialized APIs of the specified feature and version.

Parameters
nodeThe node to query
featureThe requested feature
versionThe version number of the feature
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_node_get_first_child()

dom_exception _dom_node_get_first_child ( dom_node_internal * node,
dom_node_internal ** result )

Retrieve the first child of a DOM node

Parameters
nodeThe node to retrieve the first child of
resultPointer to location to receive node's first child
Returns
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_node_get_last_child()

dom_exception _dom_node_get_last_child ( dom_node_internal * node,
dom_node_internal ** result )

Retrieve the last child of a DOM node

Parameters
nodeThe node to retrieve the last child of
resultPointer to location to receive node's last child
Returns
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_node_get_local_name()

dom_exception _dom_node_get_local_name ( dom_node_internal * node,
dom_string ** result )

Retrieve the local part of a node's qualified name

Parameters
nodeThe node to retrieve the local name of
resultPointer to location to receive local name
Returns
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_node_get_namespace()

dom_exception _dom_node_get_namespace ( dom_node_internal * node,
dom_string ** result )

Retrieve the namespace of a DOM node

Parameters
nodeThe node to retrieve the namespace of
resultPointer to location to receive node's namespace
Returns
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_node_get_next_sibling()

dom_exception _dom_node_get_next_sibling ( dom_node_internal * node,
dom_node_internal ** result )

Retrieve the subsequent sibling of a DOM node

Parameters
nodeThe node to retrieve the subsequent sibling of
resultPointer to location to receive node's subsequent sibling
Returns
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_node_get_node_name()

dom_exception _dom_node_get_node_name ( dom_node_internal * node,
dom_string ** result )

Retrieve the name of a DOM node

Parameters
nodeThe node to retrieve the name of
resultPointer to location to receive node name
Returns
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_node_get_node_type()

dom_exception _dom_node_get_node_type ( dom_node_internal * node,
dom_node_type * result )

Retrieve the type of a DOM node

Parameters
nodeThe node to retrieve the type of
resultPointer to location to receive node type
Returns
DOM_NO_ERR.

◆ _dom_node_get_node_value()

dom_exception _dom_node_get_node_value ( dom_node_internal * node,
dom_string ** result )

Retrieve the value of a DOM node

Parameters
nodeThe node to retrieve the value of
resultPointer to location to receive node value
Returns
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.

DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in this implementation; dom_strings are unbounded.

◆ _dom_node_get_owner_document()

dom_exception _dom_node_get_owner_document ( dom_node_internal * node,
struct dom_document ** result )

Retrieve the owning document of a DOM node

Parameters
nodeThe node to retrieve the owner of
resultPointer to location to receive node's owner
Returns
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_node_get_parent_node()

dom_exception _dom_node_get_parent_node ( dom_node_internal * node,
dom_node_internal ** result )

Retrieve the parent of a DOM node

Parameters
nodeThe node to retrieve the parent of
resultPointer to location to receive node parent
Returns
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_node_get_prefix()

dom_exception _dom_node_get_prefix ( dom_node_internal * node,
dom_string ** result )

Retrieve the prefix of a DOM node

Parameters
nodeThe node to retrieve the prefix of
resultPointer to location to receive node's prefix
Returns
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_node_get_previous_sibling()

dom_exception _dom_node_get_previous_sibling ( dom_node_internal * node,
dom_node_internal ** result )

Retrieve the previous sibling of a DOM node

Parameters
nodeThe node to retrieve the previous sibling of
resultPointer to location to receive node's previous sibling
Returns
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_node_get_text_content()

dom_exception _dom_node_get_text_content ( dom_node_internal * node,
dom_string ** result )

Retrieve the text content of a DOM node

Parameters
nodeThe node to retrieve the text content of
resultPointer to location to receive text content
Returns
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.

If there is no text content in the code, NULL will returned in result.

DOM3Core states that this can raise DOMSTRING_SIZE_ERR. It will not in this implementation; dom_strings are unbounded.

◆ _dom_node_get_user_data()

dom_exception _dom_node_get_user_data ( const dom_node_internal * node,
const dom_string * key,
void ** result )

Retrieves the object associated to a key on this node

Parameters
nodeThe node to retrieve object from
keyThe key to search for
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_node_has_attributes()

dom_exception _dom_node_has_attributes ( dom_node_internal * node,
bool * result )

Determine if a node has any attributes

Parameters
nodeNode to inspect
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_node_has_child_nodes()

dom_exception _dom_node_has_child_nodes ( dom_node_internal * node,
bool * result )

Determine if a node has any children

Parameters
nodeNode to inspect
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_node_initialise()

dom_exception _dom_node_initialise ( dom_node_internal * node,
struct dom_document * doc,
dom_node_type type,
dom_string * name,
dom_string * value,
dom_string * namespace,
dom_string * prefix )

Initialise a DOM node

Parameters
nodeThe node to initialise
docThe document which owns the node
typeThe node type required
nameThe node (local) name, or NULL
valueThe node value, or NULL
namespaceNamespace URI to use for node, or NULL
prefixNamespace prefix to use for node, or NULL
Returns
DOM_NO_ERR on success.

::name, ::value, ::namespace, and ::prefix will have their reference counts increased.

◆ _dom_node_insert_before()

dom_exception _dom_node_insert_before ( dom_node_internal * node,
dom_node_internal * new_child,
dom_node_internal * ref_child,
dom_node_internal ** result )

Insert a child into a node

Parameters
nodeNode to insert into
new_childNode to insert
ref_childNode to insert before, or NULL to insert as last child
resultPointer to location to receive node being inserted
Returns
DOM_NO_ERR on success, DOM_HIERARCHY_REQUEST_ERR if ::new_child's type is not permitted as a child of ::node, or ::new_child is an ancestor of ::node (or is ::node itself), or ::node is of type Document and a second DocumentType or Element is being inserted, DOM_WRONG_DOCUMENT_ERR if ::new_child was created from a different document than ::node, DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, or ::new_child's parent is readonly, DOM_NOT_FOUND_ERR if ::ref_child is not a child of ::node.

If ::new_child is a DocumentFragment, all of its children are inserted. If ::new_child is already in the tree, it is first removed.

Attempting to insert a node before itself is a NOP.

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.

Todo
Is it correct to return DocumentFragments?

◆ _dom_node_is_default_namespace()

dom_exception _dom_node_is_default_namespace ( dom_node_internal * node,
dom_string * namespace,
bool * result )

Determine if the specified namespace is the default namespace

Parameters
nodeThe node to query
namespaceThe namespace URI to test
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_node_is_equal()

dom_exception _dom_node_is_equal ( dom_node_internal * node,
dom_node_internal * other,
bool * result )

Determine if two DOM nodes are equal

Parameters
nodeThe node to compare
otherThe node to compare against
resultPointer to location to receive result
Returns
DOM_NO_ERR.

Two nodes are equal iff:

  • They are of the same type
  • nodeName, localName, namespaceURI, prefix, nodeValue are equal
  • The node attributes are equal
  • The child nodes are equal

Two DocumentType nodes are equal iff:

  • publicId, systemId, internalSubset are equal
  • The node entities are equal
  • The node notations are equal TODO: in document_type, we should override this virtual function TODO: actually handle DocumentType nodes differently

◆ _dom_node_is_same()

dom_exception _dom_node_is_same ( dom_node_internal * node,
dom_node_internal * other,
bool * result )

Determine if two DOM nodes are the same

Parameters
nodeThe node to compare
otherThe node to compare against
resultPointer to location to receive result
Returns
DOM_NO_ERR.

This tests if the two nodes reference the same object.

◆ _dom_node_is_supported()

dom_exception _dom_node_is_supported ( dom_node_internal * node,
dom_string * feature,
dom_string * version,
bool * result )

Test whether the DOM implementation implements a specific feature and that feature is supported by the node.

Parameters
nodeThe node to test
featureThe name of the feature to test
versionThe version number of the feature to test
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_node_lookup_namespace()

dom_exception _dom_node_lookup_namespace ( dom_node_internal * node,
dom_string * prefix,
dom_string ** result )

Lookup the namespace URI associated with the given prefix

Parameters
nodeThe node to start namespace search from
prefixThe prefix to look for, or NULL to find default.
resultPointer to location to receive result
Returns
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_node_lookup_prefix()

dom_exception _dom_node_lookup_prefix ( dom_node_internal * node,
dom_string * namespace,
dom_string ** result )

Lookup the prefix associated with the given namespace URI

Parameters
nodeThe node to start prefix search from
namespaceThe namespace URI
resultPointer to location to receive result
Returns
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_node_mark_pending()

void _dom_node_mark_pending ( dom_node_internal * node)

To add some node to the pending list, when a node is removed from its parent or an attribute is removed from its element

Parameters
nodeThe Node instance

◆ _dom_node_normalize()

dom_exception _dom_node_normalize ( dom_node_internal * node)

Normalize a DOM node

Parameters
nodeThe node to normalize
Returns
DOM_NO_ERR.

Puts all Text nodes in the full depth of the sub-tree beneath ::node, including Attr nodes into "normal" form, where only structure separates Text nodes.

◆ _dom_node_readonly()

bool _dom_node_readonly ( const dom_node_internal * node)

Determine if a node is read only

Parameters
nodeThe node to consider

◆ _dom_node_remove_child()

dom_exception _dom_node_remove_child ( dom_node_internal * node,
dom_node_internal * old_child,
dom_node_internal ** result )

Remove a child from a node

Parameters
nodeNode whose child to replace
old_childChild to remove
resultPointer to location to receive removed node
Returns
DOM_NO_ERR on success, DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly DOM_NOT_FOUND_ERR if ::old_child is not a child of ::node, DOM_NOT_SUPPORTED_ERR if ::node is of type Document and ::new_child is of type DocumentType or 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_node_remove_event_listener()

dom_exception _dom_node_remove_event_listener ( dom_event_target * et,
dom_string * type,
struct dom_event_listener * listener,
bool capture )

◆ _dom_node_remove_event_listener_ns()

dom_exception _dom_node_remove_event_listener_ns ( dom_event_target * et,
dom_string * namespace,
dom_string * type,
struct dom_event_listener * listener,
bool capture )

◆ _dom_node_remove_pending()

void _dom_node_remove_pending ( dom_node_internal * node)

To remove the node from the pending list, this may happen when a node is removed and then appended to another parent

Parameters
nodeThe Node instance

◆ _dom_node_replace_child()

dom_exception _dom_node_replace_child ( dom_node_internal * node,
dom_node_internal * new_child,
dom_node_internal * old_child,
dom_node_internal ** result )

Replace a node's child with a new one

Parameters
nodeNode whose child to replace
new_childReplacement node
old_childChild to replace
resultPointer to location to receive replaced node
Returns
DOM_NO_ERR on success, DOM_HIERARCHY_REQUEST_ERR if ::new_child's type is not permitted as a child of ::node, or ::new_child is an ancestor of ::node (or is ::node itself), or ::node is of type Document and a second DocumentType or Element is being inserted, DOM_WRONG_DOCUMENT_ERR if ::new_child was created from a different document than ::node, DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, or ::new_child's parent is readonly, DOM_NOT_FOUND_ERR if ::old_child is not a child of ::node, DOM_NOT_SUPPORTED_ERR if ::node is of type Document and ::new_child is of type DocumentType or Element.

If ::new_child is a DocumentFragment, ::old_child is replaced by all of ::new_child's children. If ::new_child is already in the tree, it is first removed.

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_node_set_node_value()

dom_exception _dom_node_set_node_value ( dom_node_internal * node,
dom_string * value )

Set the value of a DOM node

Parameters
nodeNode to set the value of
valueNew value for node
Returns
DOM_NO_ERR on success, DOM_NO_MODIFICATION_ALLOWED_ERR if the node is readonly and the value is not defined to be null.

The new value will have its reference count increased, so the caller should unref it after the call (as the caller should have already claimed a reference on the string). The node's existing value will be unrefed.

◆ _dom_node_set_prefix()

dom_exception _dom_node_set_prefix ( dom_node_internal * node,
dom_string * prefix )

Set the prefix of a DOM node

Parameters
nodeThe node to set the prefix of
prefixPointer to prefix string
Returns
DOM_NO_ERR on success, DOM_INVALID_CHARACTER_ERR if the specified prefix contains an illegal character, DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly, DOM_NAMESPACE_ERR if the specified prefix is malformed, if the namespaceURI of ::node is null, if the specified prefix is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", if ::node is an attribute and the specified prefix is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns", or if this node is an attribute and the qualifiedName of ::node is "xmlns".
Todo
validate prefix

◆ _dom_node_set_text_content()

dom_exception _dom_node_set_text_content ( dom_node_internal * node,
dom_string * content )

Set the text content of a DOM node

Parameters
nodeThe node to set the text content of
contentNew text content for node
Returns
DOM_NO_ERR on success, DOM_NO_MODIFICATION_ALLOWED_ERR if ::node is readonly.

Any child nodes ::node may have are removed and replaced with a single Text node containing the new content.

◆ _dom_node_set_user_data()

dom_exception _dom_node_set_user_data ( dom_node_internal * node,
dom_string * key,
void * data,
dom_user_data_handler handler,
void ** result )

Associate an object to a key on this node

Parameters
nodeThe node to insert object into
keyThe key associated with the object
dataThe object to associate with key, or NULL to remove
handlerUser handler function, or NULL if none
resultPointer to location to receive previously associated object
Returns
DOM_NO_ERR.

◆ _dom_node_try_destroy()

dom_exception _dom_node_try_destroy ( dom_node_internal * node)

Try to destroy this node.

Parameters
nodeThe node to destroy

When some node owns this node, (such as an elment owns its attribute nodes) when this node being not owned, the owner should call this function to try to destroy this node.

Note
: Owning a node does not means this node's refcnt is above zero.