23 #include "dom/dom_doc.h"
24 #include "dom/dom_exception.h"
25 #include "dom/dom2_events.h"
26 #include "xml/dom_docimpl.h"
27 #include "xml/dom_elementimpl.h"
28 #include "xml/dom2_eventsimpl.h"
34 NamedNodeMap::NamedNodeMap()
42 if (impl) impl->ref();
45 NamedNodeMap::NamedNodeMap(NamedNodeMapImpl *i)
48 if (impl) impl->ref();
53 if ( impl != other.impl ) {
54 if(impl) impl->deref();
61 NamedNodeMap::~NamedNodeMap()
63 if(impl) impl->deref();
69 NodeImpl::Id nid = impl->mapId(0, name.implementation(),
true);
71 return impl->getNamedItem(nid,
false, name.implementation());
76 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
77 if (!arg.impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
78 int exceptioncode = 0;
79 Node r = impl->setNamedItem(arg.impl,
false,
80 arg.impl->nodeName().implementation(), exceptioncode);
88 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
89 int exceptioncode = 0;
90 Node r = impl->removeNamedItem(impl->mapId(0, name.implementation(),
false),
91 false, name.implementation(), exceptioncode);
100 return impl->item(index);
106 NodeImpl::Id nid = impl->mapId( namespaceURI.implementation(), localName.implementation(),
true );
107 return impl->getNamedItem(nid,
true);
112 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
113 int exceptioncode = 0;
114 Node r = impl->setNamedItem(arg.impl,
true, 0, exceptioncode);
122 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
123 int exceptioncode = 0;
124 NodeImpl::Id nid = impl->mapId( namespaceURI.implementation(), localName.implementation(),
false );
125 Node r = impl->removeNamedItem(nid,
true, 0, exceptioncode);
134 return impl->length();
139 Node::Node(
const Node &other)
142 if(impl) impl->ref();
145 Node::Node( NodeImpl *i )
148 if(impl) impl->ref();
151 Node &Node::operator = (
const Node &other)
153 if(impl != other.impl) {
154 if(impl) impl->deref();
156 if(impl) impl->ref();
161 bool Node::operator == (
const Node &other)
const
163 return (impl == other.impl);
166 bool Node::operator != (
const Node &other)
const
168 return !(impl == other.impl);
173 if(impl) impl->deref();
178 if(impl)
return impl->nodeName();
185 if(impl)
return impl->nodeValue();
191 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
193 int exceptioncode = 0;
194 if(impl) impl->setNodeValue( _str,exceptioncode );
201 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
202 return impl->nodeType();
207 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
208 return impl->parentNode();
214 return impl->childNodes();
219 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
220 return impl->firstChild();
225 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
226 return impl->lastChild();
231 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
232 return impl->previousSibling();
237 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
238 return impl->nextSibling();
243 if (!impl || !impl->isElementNode())
return 0;
244 return static_cast<ElementImpl*
>(impl)->
attributes();
253 if (!impl || impl->getDocument() == impl)
return Document(
false);
255 return impl->getDocument();
260 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
261 int exceptioncode = 0;
262 NodeImpl *r = impl->insertBefore( newChild.impl, refChild.impl, exceptioncode );
265 if (!newChild.impl->closed()) newChild.impl->close();
271 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
272 int exceptioncode = 0;
273 impl->replaceChild( newChild.impl, oldChild.impl, exceptioncode );
276 if (newChild.impl && !newChild.impl->closed()) newChild.impl->close();
283 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
284 int exceptioncode = 0;
285 impl->removeChild( oldChild.impl, exceptioncode );
294 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
295 int exceptioncode = 0;
296 NodeImpl *r = impl->appendChild( newChild.impl, exceptioncode );
299 if (!newChild.impl->closed()) newChild.impl->close();
305 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
306 if (!impl->isElementNode())
return false;
307 ElementImpl* e =
static_cast<ElementImpl*
>(impl);
308 return e->attributes(
true) && e->attributes(
true)->length();
313 if (!impl)
return false;
314 return impl->hasChildNodes();
320 return impl->cloneNode( deep );
333 return (upFeature ==
"HTML" ||
334 upFeature ==
"XML" ||
335 upFeature ==
"CORE");
341 return impl->namespaceURI();
347 return impl->prefix();
352 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
353 int exceptioncode = 0;
354 impl->setPrefix(
prefix,exceptioncode);
362 return impl->localName();
367 const bool useCapture)
371 impl->addEventListener(EventImpl::typeToId(type),listener,useCapture);
379 impl->removeEventListener(EventImpl::typeToId(type),listener,useCapture);
390 int exceptioncode = 0;
391 impl->dispatchEvent(evt.handle(),exceptioncode);
394 return !evt.handle()->defaultPrevented();
398 unsigned int Node::elementId()
const
404 unsigned long Node::index()
const
407 return impl->nodeIndex();
410 TQString Node::toHTML()
412 if (!impl)
return TQString::null;
413 return impl->toString().string();
416 void Node::applyChanges()
419 impl->recalcStyle( NodeImpl::Inherit );
424 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
426 impl->getCaret(offset,
false, _x, _y, dummy, height);
431 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
432 return impl->getRect();
437 if(impl)
return impl->textContent();
443 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
445 int exceptioncode = 0;
446 impl->setTextContent( content, exceptioncode );
458 NodeList::NodeList(
const NodeList &other)
461 if(impl) impl->ref();
464 NodeList::NodeList(
const NodeListImpl *i)
466 impl =
const_cast<NodeListImpl *
>(i);
467 if(impl) impl->ref();
472 if ( impl != other.impl ) {
473 if(impl) impl->deref();
475 if(impl) impl->ref();
480 NodeList::~NodeList()
482 if(impl) impl->deref();
488 return impl->item(index);
494 return impl->length();
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
This class implements the basic string we use in the DOM.
DOMString upper() const
Returns an uppercase version of the string.
The Document interface represents the entire HTML or XML document.
Introduced in DOM Level 2.
Introduced in DOM Level 2.
Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can b...
Node setNamedItem(const Node &arg)
Adds a node using its nodeName attribute.
Node getNamedItem(const DOMString &name) const
Retrieves a node specified by name.
unsigned long length() const
The number of nodes in the map.
Node getNamedItemNS(const DOMString &namespaceURI, const DOMString &localName) const
Introduced in DOM Level 2.
Node setNamedItemNS(const Node &arg)
Introduced in DOM Level 2.
Node removeNamedItemNS(const DOMString &namespaceURI, const DOMString &localName)
Introduced in DOM Level 2.
Node item(unsigned long index) const
Returns the index th item in the map.
Node removeNamedItem(const DOMString &name)
Removes a node specified by name.
The NodeList interface provides the abstraction of an ordered collection of nodes,...
unsigned long length() const
The number of nodes in the list.
Node item(unsigned long index) const
Returns the index th item in the collection.
The Node interface is the primary datatype for the entire Document Object Model.
Node nextSibling() const
The node immediately following this node.
bool isSupported(const DOMString &feature, const DOMString &version) const
Introduced in DOM Level 2.
Node previousSibling() const
The node immediately preceding this node.
Node replaceChild(const Node &newChild, const Node &oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node...
bool dispatchEvent(const Event &evt)
Introduced in DOM Level 2 This method is from the EventTarget interface.
DOMString localName() const
Introduced in DOM Level 2.
Node cloneNode(bool deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
NodeList childNodes() const
A NodeList that contains all children of this node.
void setPrefix(const DOMString &prefix)
see prefix
void setTextContent(const DOMString &content) const
Introduced in DOM Level 3.
bool hasChildNodes()
This is a convenience method to allow easy determination of whether a node has any children.
DOMString namespaceURI() const
Introduced in DOM Level 2.
DOMString nodeValue() const
The value of this node, depending on its type; see the table above.
void removeEventListener(const DOMString &type, EventListener *listener, bool useCapture)
Introduced in DOM Level 2 This method is from the EventTarget interface.
Node parentNode() const
The parent of this node.
Node lastChild() const
The last child of this node.
Node firstChild() const
The first child of this node.
NamedNodeMap attributes() const
A NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise.
Document ownerDocument() const
The Document object associated with this node.
bool hasAttributes()
Returns whether this node (if it is an element) has any attributes.
DOMString textContent() const
Introduced in DOM Level 3.
void normalize()
Modified in DOM Level 2.
TQRect getRect()
not part of the DOM.
Node appendChild(const Node &newChild)
Adds the node newChild to the end of the list of children of this node.
void getCursor(int offset, int &_x, int &_y, int &height) TDE_DEPRECATED
void addEventListener(const DOMString &type, EventListener *listener, const bool useCapture)
Introduced in DOM Level 2 This method is from the EventTarget interface.
void setNodeValue(const DOMString &)
see nodeValue
unsigned short nodeType() const
A code representing the type of the underlying object, as defined above.
Node removeChild(const Node &oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it.
DOMString nodeName() const
The name of this node, depending on its type; see the table above.
DOMString prefix() const
Introduced in DOM Level 2.
Node insertBefore(const Node &newChild, const Node &refChild)
Inserts the node newChild before the existing child node refChild .
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...