html_document.cpp
00001
00023
00024
00025 #include "html_document.h"
00026 #include "css/csshelper.h"
00027 #include "dom/html_misc.h"
00028 #include "xml/dom_textimpl.h"
00029 #include "html/html_documentimpl.h"
00030 #include "html/html_miscimpl.h"
00031 #include "misc/htmlhashes.h"
00032
00033 using namespace DOM;
00034
00035 HTMLDocument::HTMLDocument() : Document(false)
00036 {
00037 impl = DOMImplementationImpl::instance()->createHTMLDocument();
00038 impl->ref();
00039
00040 }
00041
00042 HTMLDocument::HTMLDocument(KHTMLView *parent)
00043 : Document(false)
00044 {
00045 impl = DOMImplementationImpl::instance()->createHTMLDocument(parent);
00046 impl->ref();
00047 }
00048
00049 HTMLDocument::HTMLDocument(const HTMLDocument &other) : Document(other)
00050 {
00051 }
00052
00053 HTMLDocument::HTMLDocument(HTMLDocumentImpl *impl) : Document(impl)
00054 {
00055 }
00056
00057 HTMLDocument &HTMLDocument::operator = (const Node &other)
00058 {
00059 if(other.nodeType() != DOCUMENT_NODE) {
00060 if ( impl ) impl->deref();
00061 impl = 0;
00062 } else {
00063 DocumentImpl *d = static_cast<DocumentImpl *>(other.handle());
00064 if(!d->isHTMLDocument()) {
00065 if ( impl ) impl->deref();
00066 impl = 0;
00067 } else {
00068 Node::operator =(other);
00069 }
00070 }
00071 return *this;
00072 }
00073
00074 HTMLDocument &HTMLDocument::operator = (const HTMLDocument &other)
00075 {
00076 Document::operator =(other);
00077 return *this;
00078 }
00079
00080 HTMLDocument::~HTMLDocument()
00081 {
00082 }
00083
00084 DOMString HTMLDocument::title() const
00085 {
00086 if(!impl) return DOMString();
00087 return static_cast<HTMLDocumentImpl *>(impl)->title();
00088 }
00089
00090 void HTMLDocument::setTitle( const DOMString &value )
00091 {
00092 if (impl)
00093 static_cast<HTMLDocumentImpl *>(impl)->setTitle(value);
00094 }
00095
00096 DOMString HTMLDocument::referrer() const
00097 {
00098 if(!impl) return DOMString();
00099 return ((HTMLDocumentImpl *)impl)->referrer();
00100 }
00101
00102 DOMString HTMLDocument::completeURL(const DOMString& str) const
00103 {
00104 if(!impl) return str;
00105 DOMString parsed = khtml::parseURL(str);
00106 return ((HTMLDocumentImpl *)impl)->completeURL(parsed.string());
00107 }
00108
00109 DOMString HTMLDocument::domain() const
00110 {
00111 if(!impl) return DOMString();
00112 return ((HTMLDocumentImpl *)impl)->domain();
00113 }
00114
00115 DOMString HTMLDocument::lastModified() const
00116 {
00117 if(!impl) return DOMString();
00118 return ((HTMLDocumentImpl *)impl)->lastModified();
00119 }
00120
00121 DOMString HTMLDocument::URL() const
00122 {
00123 if(!impl) return DOMString();
00124 return ((HTMLDocumentImpl *)impl)->URL();
00125 }
00126
00127 HTMLElement HTMLDocument::body() const
00128 {
00129 if(!impl) return 0;
00130 return ((HTMLDocumentImpl *)impl)->body();
00131 }
00132
00133 void HTMLDocument::setBody(const HTMLElement &_body)
00134 {
00135 if (!impl) return;
00136 ((HTMLDocumentImpl *)impl)->setBody(static_cast<HTMLElementImpl *>(_body.handle()));
00137 return;
00138 }
00139
00140 HTMLCollection HTMLDocument::images() const
00141 {
00142 if(!impl) return HTMLCollection();
00143 return HTMLCollection(impl, HTMLCollectionImpl::DOC_IMAGES);
00144 }
00145
00146 HTMLCollection HTMLDocument::applets() const
00147 {
00148 if(!impl) return HTMLCollection();
00149 return HTMLCollection(impl, HTMLCollectionImpl::DOC_APPLETS);
00150 }
00151
00152 HTMLCollection HTMLDocument::links() const
00153 {
00154 if(!impl) return HTMLCollection();
00155 return HTMLCollection(impl, HTMLCollectionImpl::DOC_LINKS);
00156 }
00157
00158 HTMLCollection HTMLDocument::forms() const
00159 {
00160 if(!impl) return HTMLCollection();
00161 return HTMLCollection(impl, HTMLCollectionImpl::DOC_FORMS);
00162 }
00163
00164 HTMLCollection HTMLDocument::anchors() const
00165 {
00166 if(!impl) return HTMLCollection();
00167 return HTMLCollection(impl, HTMLCollectionImpl::DOC_ANCHORS);
00168 }
00169
00170 HTMLCollection HTMLDocument::all() const
00171 {
00172 if(!impl) return HTMLCollection();
00173 return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL);
00174 }
00175
00176 DOMString HTMLDocument::cookie() const
00177 {
00178 if (!impl) return DOMString();
00179 return ((HTMLDocumentImpl *)impl)->cookie();
00180 }
00181
00182 void HTMLDocument::setCookie( const DOMString & value )
00183 {
00184 if (impl)
00185 ((HTMLDocumentImpl *)impl)->setCookie(value);
00186
00187 }
00188
00189 void HTMLDocument::open( )
00190 {
00191 if(impl)
00192 ((HTMLDocumentImpl *)impl)->open( );
00193 }
00194
00195 void HTMLDocument::close( )
00196 {
00197 if(impl)
00198 ((HTMLDocumentImpl *)impl)->close( );
00199 }
00200
00201 void HTMLDocument::write( const DOMString &text )
00202 {
00203 if(impl)
00204 ((HTMLDocumentImpl *)impl)->write( text );
00205 }
00206
00207 void HTMLDocument::writeln( const DOMString &text )
00208 {
00209 if(impl)
00210 ((HTMLDocumentImpl *)impl)->writeln( text );
00211 }
00212
00213 NodeList HTMLDocument::getElementsByName( const DOMString &elementName )
00214 {
00215 if(!impl) return 0;
00216 return new NameNodeListImpl(impl, elementName);
00217 }
00218
This file is part of the documentation for kdelibs Version 3.1.4.