2 * This file is part of the DOM implementation for KDE.
4 * (C) 1999 Lars Knoll (knoll@kde.org)
5 * Copyright (C) 2003 Apple Computer, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 // --------------------------------------------------------------------------
25 #include "html_document.h"
27 #include "dom/html_misc.h"
28 #include "xml/dom_textimpl.h"
29 #include "html/html_documentimpl.h"
30 #include "html/html_miscimpl.h"
31 #include "misc/htmlhashes.h"
32 #include "dom/html_image.h"
33 #include "dom/html_form.h"
34 #include "html/html_imageimpl.h"
35 #include "html/html_formimpl.h"
36 #include "dom/dom_exception.h"
40 HTMLDocument::HTMLDocument() : Document(false) // create the impl here
42 impl = DOMImplementationImpl::instance()->createHTMLDocument();
47 HTMLDocument::HTMLDocument(KHTMLView *parent)
48 : Document(false) // create the impl here
50 impl = DOMImplementationImpl::instance()->createHTMLDocument(parent);
54 HTMLDocument::HTMLDocument(const HTMLDocument &other) : Document(other)
58 HTMLDocument::HTMLDocument(HTMLDocumentImpl *impl) : Document(impl)
62 HTMLDocument &HTMLDocument::operator = (const Node &other)
64 if(other.nodeType() != DOCUMENT_NODE) {
65 if ( impl ) impl->deref();
68 DocumentImpl *d = static_cast<DocumentImpl *>(other.handle());
69 if(!d->isHTMLDocument()) {
70 if ( impl ) impl->deref();
73 Node::operator =(other);
79 HTMLDocument &HTMLDocument::operator = (const HTMLDocument &other)
81 Document::operator =(other);
85 HTMLDocument::~HTMLDocument()
89 DOMString HTMLDocument::title() const
91 if(!impl) return DOMString();
92 return static_cast<HTMLDocumentImpl *>(impl)->title();
95 void HTMLDocument::setTitle( const DOMString &v )
99 ((HTMLDocumentImpl *)impl)->setTitle(v);
105 DOMString HTMLDocument::referrer() const
107 if(!impl) return DOMString();
108 return ((HTMLDocumentImpl *)impl)->referrer();
111 DOMString HTMLDocument::completeURL(const DOMString& str) const
113 if(!impl) return str;
114 return ((HTMLDocumentImpl *)impl)->completeURL(str.string());
117 DOMString HTMLDocument::domain() const
119 if(!impl) return DOMString();
120 return ((HTMLDocumentImpl *)impl)->domain();
123 DOMString HTMLDocument::lastModified() const
125 if(!impl) return DOMString();
126 return ((HTMLDocumentImpl *)impl)->lastModified();
129 DOMString HTMLDocument::URL() const
131 if(!impl) return DOMString();
132 return ((HTMLDocumentImpl *)impl)->URL();
135 HTMLElement HTMLDocument::body() const
138 return ((HTMLDocumentImpl *)impl)->body();
141 void HTMLDocument::setBody(const HTMLElement &_body)
144 int exceptioncode = 0;
145 ((HTMLDocumentImpl *)impl)->setBody(static_cast<HTMLElementImpl *>(_body.handle()), exceptioncode);
147 throw DOMException( exceptioncode );
151 HTMLCollection HTMLDocument::images() const
153 if(!impl) return HTMLCollection();
154 return HTMLCollection(impl, HTMLCollectionImpl::DOC_IMAGES);
157 HTMLCollection HTMLDocument::applets() const
159 if(!impl) return HTMLCollection();
160 return HTMLCollection(impl, HTMLCollectionImpl::DOC_APPLETS);
163 HTMLCollection HTMLDocument::embeds() const
165 if(!impl) return HTMLCollection();
166 return HTMLCollection(impl, HTMLCollectionImpl::DOC_EMBEDS);
169 HTMLCollection HTMLDocument::links() const
171 if(!impl) return HTMLCollection();
172 return HTMLCollection(impl, HTMLCollectionImpl::DOC_LINKS);
175 HTMLCollection HTMLDocument::forms() const
177 if(!impl) return HTMLCollection();
178 return HTMLCollection(impl, HTMLCollectionImpl::DOC_FORMS);
181 HTMLCollection HTMLDocument::anchors() const
183 if(!impl) return HTMLCollection();
184 return HTMLCollection(impl, HTMLCollectionImpl::DOC_ANCHORS);
187 HTMLCollection HTMLDocument::all() const
189 if(!impl) return HTMLCollection();
190 return HTMLCollection(impl, HTMLCollectionImpl::DOC_ALL);
193 DOMString HTMLDocument::cookie() const
195 if (!impl) return DOMString();
196 return ((HTMLDocumentImpl *)impl)->cookie();
199 void HTMLDocument::setCookie( const DOMString & value )
202 ((HTMLDocumentImpl *)impl)->setCookie(value);
208 void HTMLDocument::setPolicyBaseURL( const DOMString &s )
211 ((HTMLDocumentImpl *)impl)->setPolicyBaseURL(s);
216 void HTMLDocument::open( )
219 ((HTMLDocumentImpl *)impl)->open( );
222 void HTMLDocument::close( )
225 ((HTMLDocumentImpl *)impl)->close( );
228 void HTMLDocument::write( const DOMString &text )
231 ((HTMLDocumentImpl *)impl)->write( text );
234 void HTMLDocument::writeln( const DOMString &text )
237 ((HTMLDocumentImpl *)impl)->writeln( text );
240 NodeList HTMLDocument::getElementsByName( const DOMString &elementName )
243 return new NameNodeListImpl(impl, elementName);