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