KHTML
#include <dom_node.h>
Public Types | |
enum | DocumentPosition { DOCUMENT_POSITION_DISCONNECTED = 0x01, DOCUMENT_POSITION_PRECEDING = 0x02, DOCUMENT_POSITION_FOLLOWING = 0x04, DOCUMENT_POSITION_CONTAINS = 0x08, DOCUMENT_POSITION_CONTAINED_BY = 0x10, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20 } |
enum | NodeType { ELEMENT_NODE = 1, ATTRIBUTE_NODE = 2, TEXT_NODE = 3, CDATA_SECTION_NODE = 4, ENTITY_REFERENCE_NODE = 5, ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = 7, COMMENT_NODE = 8, DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = 10, DOCUMENT_FRAGMENT_NODE = 11, NOTATION_NODE = 12, XPATH_NAMESPACE_NODE = 13 } |
Public Member Functions | |
Node () | |
Node (const Node &other) | |
Node (NodeImpl *_impl) | |
virtual | ~Node () |
void | addEventListener (const DOMString &type, EventListener *listener, const bool useCapture) |
Node | appendChild (const Node &newChild) |
void | applyChanges () |
NamedNodeMap | attributes () const |
NodeList | childNodes () const |
Node | cloneNode (bool deep) |
unsigned | compareDocumentPosition (const DOM::Node &other) |
bool | dispatchEvent (const Event &evt) |
quint32 | elementId () const |
Node | firstChild () const |
void | getCursor (int offset, int &_x, int &_y, int &height) |
QRect | getRect () |
NodeImpl * | handle () const |
bool | hasAttributes () |
bool | hasChildNodes () |
unsigned long | index () const |
Node | insertBefore (const Node &newChild, const Node &refChild) |
bool | isNull () const |
bool | isSupported (const DOMString &feature, const DOMString &version) const |
Node | lastChild () const |
DOMString | localName () const |
DOMString | namespaceURI () const |
Node | nextSibling () const |
DOMString | nodeName () const |
unsigned short | nodeType () const |
DOMString | nodeValue () const |
void | normalize () |
bool | operator!= (const Node &other) const |
Node & | operator= (const Node &other) |
bool | operator== (const Node &other) const |
Document | ownerDocument () const |
Node | parentNode () const |
DOMString | prefix () const |
Node | previousSibling () const |
Node | removeChild (const Node &oldChild) |
void | removeEventListener (const DOMString &type, EventListener *listener, bool useCapture) |
Node | replaceChild (const Node &newChild, const Node &oldChild) |
void | setNodeValue (const DOMString &) |
void | setPrefix (const DOMString &prefix) |
void | setTextContent (const DOMString &text) |
DOMString | textContent () const |
QString | toHTML () |
Protected Attributes | |
NodeImpl * | impl |
Detailed Description
The Node
interface is the primary datatype for the entire Document Object Model.
It represents a single node in the document tree. While all objects implementing the Node
interface expose methods for dealing with children, not all objects implementing the Node
interface may have children. For example, Text
nodes may not have children, and adding children to such nodes results in a DOMException
being raised.
The attributes nodeName
, nodeValue
and attributes
are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific nodeType
(e.g., nodeValue
for an Element or attributes
for a Comment), this returns null
. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.
Definition at line 270 of file dom_node.h.
Member Enumeration Documentation
Introduced in DOM Level 3.
These constants represent bitflags returned by the compareDocumentPosition method.
- Since
- 4.2.4
Enumerator | |
---|---|
DOCUMENT_POSITION_DISCONNECTED | |
DOCUMENT_POSITION_PRECEDING | |
DOCUMENT_POSITION_FOLLOWING | |
DOCUMENT_POSITION_CONTAINS | |
DOCUMENT_POSITION_CONTAINED_BY | |
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
Definition at line 875 of file dom_node.h.
enum DOM::Node::NodeType |
An integer indicating which type of node this is.
The values of nodeName
, nodeValue
, and attributes
vary according to the node type as follows:
nodeName | nodeValue | attributes | |
Element | tagName | null | NamedNodeMap |
Attr | name of attribute | value of attribute | null |
Text | #text | content of the text node | null |
CDATASection | #cdata-section | content of the CDATA Section | null |
EntityReference | name of entity referenced | null | null |
Entity | entity name | null | null |
ProcessingInstruction | target | entire content excluding the target | null |
Comment | #comment | content of the comment | null |
Document | #document | null | null |
DocumentType | document type name | null | null |
DocumentFragment | #document-fragment | null | null |
Notation | notation name | null | null |
Definition at line 381 of file dom_node.h.
Constructor & Destructor Documentation
|
inline |
Definition at line 278 of file dom_node.h.
Node::Node | ( | const Node & | other | ) |
Definition at line 133 of file dom_node.cpp.
Node::Node | ( | NodeImpl * | _impl | ) |
Definition at line 139 of file dom_node.cpp.
|
virtual |
Definition at line 165 of file dom_node.cpp.
Member Function Documentation
void Node::addEventListener | ( | const DOMString & | type, |
EventListener * | listener, | ||
const bool | useCapture | ||
) |
Introduced in DOM Level 2 This method is from the EventTarget interface.
This method allows the registration of event listeners on the event target. If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.
If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method. Parameters
- Parameters
-
type The event type for which the user is registering listener The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs. useCapture If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.
Definition at line 346 of file dom_node.cpp.
Adds the node newChild
to the end of the list of children of this node.
If the newChild
is already in the tree, it is first removed.
- Parameters
-
newChild The node to add.
If it is a DocumentFragment
object, the entire contents of the document fragment are moved into the child list of this node
- Returns
- The node added.
- Exceptions
-
DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild
node, or if the node to append is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild
was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
Definition at line 279 of file dom_node.cpp.
void Node::applyChanges | ( | ) |
Definition at line 420 of file dom_node.cpp.
NamedNodeMap Node::attributes | ( | ) | const |
A NamedNodeMap
containing the attributes of this node (if it is an Element
) or null
otherwise.
Definition at line 235 of file dom_node.cpp.
NodeList Node::childNodes | ( | ) | const |
A NodeList
that contains all children of this node.
If there are no children, this is a NodeList
containing no nodes. The content of the returned NodeList
is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the NodeList
accessors; it is not a static snapshot of the content of the node. This is true for every NodeList
, including the ones returned by the getElementsByTagName
method.
Definition at line 205 of file dom_node.cpp.
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
The duplicate node has no parent ( parentNode
returns null
.).
Cloning an Element
copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text
node. Cloning any other type of node simply returns a copy of this node.
- Parameters
-
deep If true
, recursively clone the subtree under the specified node; iffalse
, clone only the node itself (and its attributes, if it is anElement
).
- Returns
- The duplicate node.
Definition at line 301 of file dom_node.cpp.
unsigned Node::compareDocumentPosition | ( | const DOM::Node & | other | ) |
Introduced in DOM Level 3.
This method compares the current node's position with that of 'other' and returns it as a combination of DocumentPosition bitfields. Here DOCUMENT_POSITION_FOLLOWING means that the 'other' is after the current.
The notion of order here is a logical one; for example attributes are viewed as if they were children of an element inserted right before the real children. The method will also assign some total order even if the nodes are not connected.
- Since
- 4.2.4
Definition at line 393 of file dom_node.cpp.
Introduced in DOM Level 2 This method is from the EventTarget interface.
This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.
- Parameters
-
evt Specifies the event type, behavior, and contextual information to be used in processing the event.
- Returns
- The return value of dispatchEvent indicates whether any of the listeners which handled the event called preventDefault. If preventDefault was called the value is false, else the value is true.
- Exceptions
-
EventException UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type was not specified by initializing the event before dispatchEvent was called. Specification of the Event's type as null or an empty string will also trigger this exception.
Definition at line 363 of file dom_node.cpp.
unsigned int Node::elementId | ( | ) | const |
not part of the DOM.
- Returns
- the element id, in case this is an element, 0 otherwise
Definition at line 400 of file dom_node.cpp.
Node Node::firstChild | ( | ) | const |
The first child of this node.
If there is no such node, this returns null
.
Definition at line 211 of file dom_node.cpp.
void Node::getCursor | ( | int | offset, |
int & | _x, | ||
int & | _y, | ||
int & | height | ||
) |
- Deprecated:
- without substitution since 3.2
Definition at line 427 of file dom_node.cpp.
QRect Node::getRect | ( | ) |
not part of the DOM.
- Returns
- the exact coordinates and size of this element.
Definition at line 435 of file dom_node.cpp.
|
inline |
handle to the implementation object
Definition at line 925 of file dom_node.h.
bool Node::hasAttributes | ( | ) |
Returns whether this node (if it is an element) has any attributes.
- Returns
- a boolean. True if this node has any attributes, false otherwise. Introduced in DOM Level 2
Definition at line 289 of file dom_node.cpp.
bool Node::hasChildNodes | ( | ) |
This is a convenience method to allow easy determination of whether a node has any children.
- Returns
true
if the node has any children,false
if the node has no children.
Definition at line 295 of file dom_node.cpp.
unsigned long Node::index | ( | ) | const |
returns the index of a node
Definition at line 406 of file dom_node.cpp.
Inserts the node newChild
before the existing child node refChild
.
If refChild
is null
, insert newChild
at the end of the list of children.
If newChild
is a DocumentFragment
object, all of its children are inserted, in the same order, before refChild
. If the newChild
is already in the tree, it is first removed.
- Parameters
-
newChild The node to insert. refChild The reference node, i.e., the node before which the new node must be inserted.
- Returns
- The node being inserted.
- Exceptions
-
DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild
node, or if the node to insert is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild
was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if refChild
is not a child of this node.
Definition at line 248 of file dom_node.cpp.
|
inline |
tests if this Node is 0.
Useful especially, if casting to a derived class:
Definition at line 920 of file dom_node.h.
Introduced in DOM Level 2.
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
- Parameters
-
feature The name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation. version This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true.
- Returns
- Returns true if the specified feature is supported on this node, false otherwise.
Definition at line 313 of file dom_node.cpp.
Node Node::lastChild | ( | ) | const |
The last child of this node.
If there is no such node, this returns null
.
Definition at line 217 of file dom_node.cpp.
DOMString Node::localName | ( | ) | const |
Introduced in DOM Level 2.
Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
Definition at line 340 of file dom_node.cpp.
DOMString Node::namespaceURI | ( | ) | const |
Introduced in DOM Level 2.
The namespace URI of this node, or null if it is unspecified. This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
Note: Per the Namespaces in XML Specification [Namespaces] an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
Definition at line 319 of file dom_node.cpp.
Node Node::nextSibling | ( | ) | const |
The node immediately following this node.
If there is no such node, this returns null
.
Definition at line 229 of file dom_node.cpp.
DOMString Node::nodeName | ( | ) | const |
The name of this node, depending on its type; see the table above.
Definition at line 170 of file dom_node.cpp.
unsigned short Node::nodeType | ( | ) | const |
A code representing the type of the underlying object, as defined above.
Definition at line 193 of file dom_node.cpp.
DOMString Node::nodeValue | ( | ) | const |
The value of this node, depending on its type; see the table above.
- Exceptions
-
DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString
variable on the implementation platform.
Definition at line 176 of file dom_node.cpp.
void Node::normalize | ( | ) |
Modified in DOM Level 2.
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer] lookups) that depend on a particular document tree structure are to be used.
Note: In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.
Definition at line 307 of file dom_node.cpp.
Definition at line 160 of file dom_node.cpp.
Definition at line 145 of file dom_node.cpp.
Definition at line 155 of file dom_node.cpp.
Document Node::ownerDocument | ( | ) | const |
The Document
object associated with this node.
This is also the Document
object used to create new nodes. When this node is a Document
this is null
.
Definition at line 241 of file dom_node.cpp.
Node Node::parentNode | ( | ) | const |
The parent of this node.
All nodes, except Document
, DocumentFragment
, and Attr
may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null
.
Definition at line 199 of file dom_node.cpp.
DOMString Node::prefix | ( | ) | const |
Introduced in DOM Level 2.
The namespace prefix of this node, or null if it is unspecified. Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable. Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
Definition at line 325 of file dom_node.cpp.
Node Node::previousSibling | ( | ) | const |
The node immediately preceding this node.
If there is no such node, this returns null
.
Definition at line 223 of file dom_node.cpp.
Removes the child node indicated by oldChild
from the list of children, and returns it.
- Parameters
-
oldChild The node being removed.
- Returns
- The node removed.
- Exceptions
-
DOMException NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild
is not a child of this node.
Definition at line 268 of file dom_node.cpp.
void Node::removeEventListener | ( | const DOMString & | type, |
EventListener * | listener, | ||
bool | useCapture | ||
) |
Introduced in DOM Level 2 This method is from the EventTarget interface.
This method allows the removal of event listeners from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions.
EventListeners can never be invoked after being removed.
Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.
- Parameters
-
type Specifies the event type of the EventListener being removed. listener The EventListener parameter indicates the EventListener to be removed. useCapture Specifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.
Definition at line 355 of file dom_node.cpp.
Replaces the child node oldChild
with newChild
in the list of children, and returns the oldChild
node.
If the newChild
is already in the tree, it is first removed.
- Parameters
-
newChild The new node to put in the child list. oldChild The node being replaced in the list.
- Returns
- The node replaced.
- Exceptions
-
DOMException HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild
node, or it the node to put in is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild
was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild
is not a child of this node.
Definition at line 258 of file dom_node.cpp.
void Node::setNodeValue | ( | const DOMString & | _str | ) |
see nodeValue
- Exceptions
-
DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
Definition at line 183 of file dom_node.cpp.
void Node::setPrefix | ( | const DOMString & | prefix | ) |
see prefix
- Exceptions
-
DOMException INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the specified prefix is malformed, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" [Namespaces].
Definition at line 331 of file dom_node.cpp.
void Node::setTextContent | ( | const DOMString & | text | ) |
see textContent()
- Exceptions
-
DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
Definition at line 384 of file dom_node.cpp.
DOMString Node::textContent | ( | ) | const |
Introduced in DOM Level 3.
This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single Text node containing the string this attribute is set to. On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attribute Text.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
Definition at line 378 of file dom_node.cpp.
QString Node::toHTML | ( | ) |
Definition at line 413 of file dom_node.cpp.
Member Data Documentation
|
protected |
Definition at line 948 of file dom_node.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:23 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.