23 #include "dom/dom_exception.h"
24 #include "dom/dom_xml.h"
25 #include "dom/dom2_range.h"
26 #include "dom/dom2_events.h"
27 #include "dom/dom2_views.h"
28 #include "dom/dom2_traversal.h"
29 #include "dom/html_document.h"
30 #include "html/html_documentimpl.h"
32 #include "xml/dom_docimpl.h"
33 #include "xml/dom_elementimpl.h"
39 DOMImplementation::DOMImplementation()
44 DOMImplementation::DOMImplementation(
const DOMImplementation &other)
47 if (impl) impl->ref();
50 DOMImplementation::DOMImplementation(DOMImplementationImpl *i)
53 if (impl) impl->ref();
56 DOMImplementation &DOMImplementation::operator = (
const DOMImplementation &other)
58 if ( impl != other.impl ) {
59 if (impl) impl->deref();
61 if (impl) impl->ref();
66 DOMImplementation::~DOMImplementation()
68 if (impl) impl->deref();
76 return impl->hasFeature(feature,version);
86 int exceptioncode = 0;
87 DocumentTypeImpl *r = impl->createDocumentType(qualifiedName, publicId, systemId, exceptioncode);
100 int exceptioncode = 0;
101 DocumentImpl *r = impl->createDocument(namespaceURI, qualifiedName, doctype, exceptioncode );
109 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
111 HTMLDocumentImpl* r = impl->createHTMLDocument( 0 );
115 r->write(TQString::fromLatin1(
"<HTML><HEAD><TITLE>") + title.string() +
116 TQString::fromLatin1(
"</TITLE></HEAD>"));
126 return impl->getInterface(feature);
134 int exceptioncode = 0;
135 CSSStyleSheetImpl *r = impl->createCSSStyleSheet(title.implementation(), media.implementation(),
142 DOMImplementationImpl *DOMImplementation::handle()
const
147 bool DOMImplementation::isNull()
const
158 impl = DOMImplementationImpl::instance()->createDocument();
162 Document::Document(
bool create)
167 impl = DOMImplementationImpl::instance()->createDocument();
180 Document::Document(DocumentImpl *i) : Node(i)
185 Document &Document::operator = (
const Node &other)
187 NodeImpl* ohandle = other.handle();
188 if ( impl != ohandle ) {
189 if (!ohandle || ohandle->nodeType() != DOCUMENT_NODE) {
190 if ( impl ) impl->deref();
193 Node::operator =(other);
199 Document &Document::operator = (
const Document &other)
201 Node::operator =(other);
205 Document::~Document()
212 if (impl)
return ((DocumentImpl *)impl)->doctype();
218 if (impl)
return ((DocumentImpl *)impl)->implementation();
224 if (impl)
return ((DocumentImpl *)impl)->documentElement();
233 int exceptioncode = 0;
234 ElementImpl* r = ((DocumentImpl *)impl)->createElement(tagName, &exceptioncode);
245 int exceptioncode = 0;
246 ElementImpl* r = ((DocumentImpl *)impl)->createElementNS(namespaceURI,qualifiedName, &exceptioncode);
254 if (impl)
return ((DocumentImpl *)impl)->createDocumentFragment();
260 if (impl)
return ((DocumentImpl *)impl)->createTextNode( data.implementation() );
266 if (impl)
return ((DocumentImpl *)impl)->createComment( data.implementation() );
273 if (impl)
return ((DocumentImpl *)impl)->createCDATASection( data.implementation() );
279 if (impl)
return ((DocumentImpl *)impl)->createProcessingInstruction( target, data.implementation() );
285 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
286 if (name.isNull())
throw DOMException(DOMException::NOT_FOUND_ERR);
287 int exceptioncode = 0;
288 AttrImpl* a = impl->getDocument()->createAttribute(name, &exceptioncode);
296 if (!impl)
throw DOMException(DOMException::NOT_FOUND_ERR);
297 if (qualifiedName.isNull())
throw DOMException(DOMException::NAMESPACE_ERR);
298 int exceptioncode = 0;
299 AttrImpl* a = impl->getDocument()->createAttributeNS(namespaceURI, qualifiedName, &exceptioncode);
307 if (impl)
return ((DocumentImpl *)impl)->createEntityReference( name );
313 if(impl)
return ((DocumentImpl *)impl)->getElementById( elementId );
321 if ( tagName ==
"*" )
324 id = impl->getDocument()->getId(NodeImpl::ElementId, tagName.implementation(),
false,
true);
325 return new TagNodeListImpl( impl,
id );
331 return new TagNodeListImpl( impl, namespaceURI, localName );
339 int exceptioncode = 0;
340 NodeImpl *r =
static_cast<DocumentImpl*
>(impl)->
importNode(importedNode.handle(), deep, exceptioncode);
346 bool Document::isHTMLDocument()
const
348 if (impl)
return ((DocumentImpl *)impl)->isHTMLDocument();
354 if (impl)
return ((DocumentImpl *)impl)->createRange();
359 NodeFilter filter,
bool entityReferenceExpansion)
364 int exceptioncode = 0;
365 NodeIteratorImpl *r =
static_cast<DocumentImpl*
>(impl)->
createNodeIterator(root.handle(),
366 whatToShow,filter,entityReferenceExpansion,exceptioncode);
373 bool entityReferenceExpansion)
378 int exceptioncode = 0;
381 root.handle(), whatToShow, filter.handle(), entityReferenceExpansion, exceptioncode);
393 int exceptioncode = 0;
394 EventImpl *r = ((DocumentImpl *)impl)->createEvent(eventType,exceptioncode);
405 return static_cast<DocumentImpl*
>(impl)->
defaultView();
413 return static_cast<DocumentImpl*
>(impl)->
styleSheets();
424 DOMString Document::selectedStylesheetSet()
429 return static_cast<DocumentImpl*
>(impl)->selectedStylesheetSet();
432 void Document::setSelectedStylesheetSet(
const DOMString& s)
435 throw DOMException(DOMException::INVALID_STATE_ERR);
437 static_cast<DocumentImpl*
>(impl)->setSelectedStylesheetSet(s);
445 return static_cast<DocumentImpl*
>(impl)->
view();
453 int exceptioncode = 0;
454 CSSStyleDeclarationImpl *r = ((DocumentImpl *)impl)->getOverrideStyle(static_cast<ElementImpl*>(elt.handle()),pseudoElt.implementation());
465 return static_cast<DocumentImpl*
>( impl )->
async( );
473 static_cast<DocumentImpl*
>( impl )->
setAsync( b );
482 static_cast<DocumentImpl*
>( impl )->
abort( );
490 static_cast<DocumentImpl*
>( impl )->
load( uri );
499 static_cast<DocumentImpl*
>( impl )->
loadXML( source );
506 return static_cast<DocumentImpl*
>( impl )->
designMode();
518 if ( !impl )
return url;
519 return static_cast<DocumentImpl*
>( impl )->
completeURL( url.string() );
527 return static_cast<DocumentImpl*
>(impl)->toString();
538 if (!impl || sheet.isNull())
542 static_cast<DocumentImpl*
>( impl )->
addStyleSheet( sheet.handle(), &exceptioncode );
549 if (!impl || sheet.isNull())
553 static_cast<DocumentImpl*
>( impl )->
removeStyleSheet( sheet.handle(), &exceptioncode );
560 DocumentFragment::DocumentFragment() :
Node()
564 DocumentFragment::DocumentFragment(
const DocumentFragment &other) : Node(other)
568 DocumentFragment &DocumentFragment::operator = (
const Node &other)
570 NodeImpl* ohandle = other.handle();
571 if ( impl != ohandle ) {
572 if (!ohandle || ohandle->nodeType() != DOCUMENT_FRAGMENT_NODE) {
573 if ( impl ) impl->deref();
576 Node::operator =(other);
582 DocumentFragment &DocumentFragment::operator = (
const DocumentFragment &other)
584 Node::operator =(other);
588 DocumentFragment::~DocumentFragment()
592 DocumentFragment::DocumentFragment(DocumentFragmentImpl *i) : Node(i)
598 DocumentType::DocumentType()
603 DocumentType::DocumentType(
const DocumentType &other)
608 DocumentType::DocumentType(DocumentTypeImpl *impl) : Node(impl)
612 DocumentType &DocumentType::operator = (
const Node &other)
614 NodeImpl* ohandle = other.handle();
615 if ( impl != ohandle ) {
616 if (!ohandle || ohandle->nodeType() != DOCUMENT_TYPE_NODE) {
617 if ( impl ) impl->deref();
620 Node::operator =(other);
626 DocumentType &DocumentType::operator = (
const DocumentType &other)
628 Node::operator =(other);
632 DocumentType::~DocumentType()
641 return static_cast<DocumentTypeImpl*
>(impl)->
name();
649 return static_cast<DocumentTypeImpl*
>(impl)->
entities();
657 return static_cast<DocumentTypeImpl*
>(impl)->
notations();
665 return static_cast<DocumentTypeImpl*
>(impl)->
publicId();
673 return static_cast<DocumentTypeImpl*
>(impl)->
systemId();