2 * This file is part of the DOM implementation for KDE.
4 * Copyright 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.
21 * This file includes excerpts from the Document Object Model (DOM)
22 * Level 1 Specification (Recommendation)
23 * http://www.w3.org/TR/REC-DOM-Level-1/
24 * Copyright © World Wide Web Consortium , (Massachusetts Institute of
25 * Technology , Institut National de Recherche en Informatique et en
26 * Automatique , Keio University ). All Rights Reserved.
30 #ifndef HTML_DOCUMENT_H
31 #define HTML_DOCUMENT_H
33 #include <khtml_export.h>
35 #include <dom/dom_doc.h>
36 #include <dom/dom_string.h>
43 class HTMLDocumentImpl
;
44 class DOMImplementation
;
51 * An \c HTMLDocument is the root of the HTML hierarchy
52 * and holds the entire content. Beside providing access to the
53 * hierarchy, it also provides some convenience methods for accessing
54 * certain sets of information from the document.
56 * The following properties have been deprecated in favor of the
57 * corresponding ones for the BODY element:
73 class KHTML_EXPORT HTMLDocument
: public Document
75 friend class ::KHTMLView
;
76 friend class ::KHTMLPart
;
77 friend class DOMImplementation
;
81 * The parent is the widget the document should render itself in.
82 * Rendering information (like sizes, etc...) is only created if
85 HTMLDocument(KHTMLView
*parent
);
86 HTMLDocument(const HTMLDocument
&other
);
87 HTMLDocument(const Node
&other
) : Document(false)
90 HTMLDocument(HTMLDocumentImpl
*impl
);
93 HTMLDocument
& operator = (const HTMLDocument
&other
);
94 HTMLDocument
& operator = (const Node
&other
);
99 * The title of a document as specified by the \c TITLE
100 * element in the head of the document.
103 DOMString
title() const;
108 void setTitle( const DOMString
& );
111 * Returns the URI of the page that linked to this page. The value
112 * is an empty string if the user navigated to the page directly
113 * (not through a link, but, for example, via a bookmark).
115 DOMString
referrer() const;
118 * The domain name of the server that served the document, or a
119 * null string if the server cannot be identified by a domain
123 DOMString
domain() const;
126 * The absolute URI of the document.
128 DOMString
URL() const;
131 * The element that contains the content for the document. In
132 * documents with \c BODY contents, returns the
133 * \c BODY element, and in frameset documents, this returns
134 * the outermost \c FRAMESET element.
137 HTMLElement
body() const;
142 void setBody(const HTMLElement
&);
145 * A collection of all the \c IMG elements in a
146 * document. The behavior is limited to \c IMG
147 * elements for backwards compatibility.
150 HTMLCollection
images() const;
153 * A collection of all the \c OBJECT elements that
154 * include applets and \c APPLET ( deprecated )
155 * elements in a document.
158 HTMLCollection
applets() const;
161 * A collection of all \c AREA elements and anchor (
162 * \c A ) elements in a document with a value for the
166 HTMLCollection
links() const;
169 * A collection of all the forms of a document.
172 HTMLCollection
forms() const;
175 * A collection of all the layers of a document.
178 HTMLCollection
layers() const;
181 * A collection of all the scripts in the document.
184 HTMLCollection
scripts() const;
187 * A collection of all the anchor ( \c A ) elements in
188 * a document with a value for the \c name attribute.
189 * Note. For reasons of backwards compatibility, the returned set
190 * of anchors only contains those anchors created with the
191 * \c name attribute, not those created with the \c id
195 HTMLCollection
anchors() const;
198 * The cookies associated with this document. If there are none,
199 * the value is an empty string. Otherwise, the value is a string:
200 * a semicolon-delimited list of "name, value" pairs for all the
201 * cookies associated with the page. For example,
202 * \c name=value;expires=date .
205 DOMString
cookie() const;
210 void setCookie( const DOMString
& );
213 * Note. This method and the ones following allow a user to add to
214 * or replace the structure model of a document using strings of
215 * unparsed HTML. At the time of writing alternate methods for
216 * providing similar functionality for both HTML and XML documents
217 * were being considered. The following methods may be deprecated
218 * at some point in the future in favor of a more general-purpose
221 * Open a document stream for writing. If a document exists in
222 * the target, this method clears it.
230 * Closes a document stream opened by \c open() and
239 * Write a string of text to a document stream opened by
240 * \c open() . The text is parsed into the document's
243 * @param text The string to be parsed into some structure in the
244 * document structure model.
249 void write ( const DOMString
&text
);
252 * Write a string of text followed by a newline character to a
253 * document stream opened by \c open() . The text is
254 * parsed into the document's structure model.
256 * @param text The string to be parsed into some structure in the
257 * document structure model.
262 void writeln ( const DOMString
&text
);
265 * Returns the (possibly empty) collection of elements whose
266 * \c name value is given by \c elementName .
268 * @param elementName The \c name attribute value for
271 * @return The matching elements.
274 NodeList
getElementsByName ( const DOMString
&elementName
);
277 * not part of the DOM
279 * converts the given (potentially relative) URL in a
280 * full-qualified one, using the baseURL / document URL for
283 DOMString
completeURL( const DOMString
& url
) const;
286 * Not part of the DOM
288 * The date the document was last modified.
290 DOMString
lastModified() const;
293 * Not part of the DOM
295 * A collection of all the \c IMG, \c OBJECT,
296 * \c AREA, \c A, forms and anchor elements of
299 HTMLCollection
all() const;