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