2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 // --------------------------------------------------------------------------
24 #include "html_document.h"
25 #include "css/csshelper.h"
26 #include "dom/html_misc.h"
27 #include "dom/dom_exception.h"
28 #include "xml/dom_textimpl.h"
29 #include "html/html_documentimpl.h"
30 #include "html/html_miscimpl.h"
31 #include "misc/htmlhashes.h"
35 HTMLDocument::HTMLDocument() : Document(false) // create the impl here
37 impl
= DOMImplementationImpl::instance()->createHTMLDocument();
42 HTMLDocument::HTMLDocument(KHTMLView
*parent
)
43 : Document(false) // create the impl here
45 impl
= DOMImplementationImpl::instance()->createHTMLDocument(parent
);
49 HTMLDocument::HTMLDocument(const HTMLDocument
&other
) : Document(other
)
53 HTMLDocument::HTMLDocument(HTMLDocumentImpl
*impl
) : Document(impl
)
57 HTMLDocument
&HTMLDocument::operator = (const Node
&other
)
59 if(other
.nodeType() != DOCUMENT_NODE
) {
60 if ( impl
) impl
->deref();
63 DocumentImpl
*d
= static_cast<DocumentImpl
*>(other
.handle());
64 if(!d
->isHTMLDocument()) {
65 if ( impl
) impl
->deref();
68 Node::operator =(other
);
74 HTMLDocument
&HTMLDocument::operator = (const HTMLDocument
&other
)
76 Document::operator =(other
);
80 HTMLDocument::~HTMLDocument()
84 DOMString
HTMLDocument::title() const
86 if(!impl
) return DOMString();
87 return static_cast<HTMLDocumentImpl
*>(impl
)->title();
90 void HTMLDocument::setTitle( const DOMString
&value
)
93 static_cast<HTMLDocumentImpl
*>(impl
)->setTitle(value
);
96 DOMString
HTMLDocument::referrer() const
98 if(!impl
) return DOMString();
99 return ((HTMLDocumentImpl
*)impl
)->referrer();
102 DOMString
HTMLDocument::completeURL(const DOMString
& str
) const
104 if(!impl
) return str
;
105 DOMString parsed
= khtml::parseURL(str
);
106 return ((HTMLDocumentImpl
*)impl
)->completeURL(parsed
.string());
109 DOMString
HTMLDocument::domain() const
111 if(!impl
) return DOMString();
112 return ((HTMLDocumentImpl
*)impl
)->domain();
115 DOMString
HTMLDocument::lastModified() const
117 if(!impl
) return DOMString();
118 return ((HTMLDocumentImpl
*)impl
)->lastModified();
121 DOMString
HTMLDocument::URL() const
123 if(!impl
) return DOMString();
124 return ((HTMLDocumentImpl
*)impl
)->URL().url();
127 HTMLElement
HTMLDocument::body() const
130 return ((HTMLDocumentImpl
*)impl
)->body();
133 void HTMLDocument::setBody(const HTMLElement
&_body
)
136 int exceptioncode
= 0;
137 ((HTMLDocumentImpl
*)impl
)->setBody(static_cast<HTMLElementImpl
*>(_body
.handle()), exceptioncode
);
139 throw DOMException( exceptioncode
);
143 HTMLCollection
HTMLDocument::images() const
145 if(!impl
) return HTMLCollection();
146 return ((HTMLDocumentImpl
*)impl
)->images();
149 HTMLCollection
HTMLDocument::applets() const
151 if(!impl
) return HTMLCollection();
152 return ((HTMLDocumentImpl
*)impl
)->applets();
155 HTMLCollection
HTMLDocument::scripts() const
157 if(!impl
) return HTMLCollection();
158 return ((HTMLDocumentImpl
*)impl
)->scripts();
161 HTMLCollection
HTMLDocument::links() const
163 if(!impl
) return HTMLCollection();
164 return ((HTMLDocumentImpl
*)impl
)->links();
167 HTMLCollection
HTMLDocument::forms() const
169 if(!impl
) return HTMLCollection();
170 return ((HTMLDocumentImpl
*)impl
)->forms();
173 HTMLCollection
HTMLDocument::layers() const
175 if(!impl
) return HTMLCollection();
176 return ((HTMLDocumentImpl
*)impl
)->layers();
179 HTMLCollection
HTMLDocument::anchors() const
181 if(!impl
) return HTMLCollection();
182 return ((HTMLDocumentImpl
*)impl
)->anchors();
185 HTMLCollection
HTMLDocument::all() const
187 if(!impl
) return HTMLCollection();
188 return ((HTMLDocumentImpl
*)impl
)->all();
191 DOMString
HTMLDocument::cookie() const
193 if (!impl
) return DOMString();
194 return ((HTMLDocumentImpl
*)impl
)->cookie();
197 void HTMLDocument::setCookie( const DOMString
& value
)
200 ((HTMLDocumentImpl
*)impl
)->setCookie(value
);
204 void HTMLDocument::open( )
207 ((HTMLDocumentImpl
*)impl
)->open( );
210 void HTMLDocument::close( )
213 ((HTMLDocumentImpl
*)impl
)->close( );
216 void HTMLDocument::write( const DOMString
&text
)
219 ((HTMLDocumentImpl
*)impl
)->write( text
);
222 void HTMLDocument::writeln( const DOMString
&text
)
225 ((HTMLDocumentImpl
*)impl
)->writeln( text
);
228 NodeList
HTMLDocument::getElementsByName( const DOMString
&elementName
)
231 return ((HTMLDocumentImpl
*)impl
)->getElementsByName(elementName
);