2 * This file is part of the DOM implementation for KDE.
4 * (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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, 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 <dom/dom_doc.h>
34 #include <dom/dom_string.h>
41 class HTMLDocumentImpl;
42 class DOMImplementation;
49 * An <code> HTMLDocument </code> is the root of the HTML hierarchy
50 * and holds the entire content. Beside providing access to the
51 * hierarchy, it also provides some convenience methods for accessing
52 * certain sets of information from the document.
54 * The following properties have been deprecated in favor of the
55 * corresponding ones for the BODY element:
57 * <ulist> <item> alinkColor
59 * </item> <item> background
61 * </item> <item> bgColor
63 * </item> <item> fgColor
65 * </item> <item> linkColor
67 * </item> <item> vlinkColor
72 class HTMLDocument : public Document
74 friend class ::KHTMLView;
75 friend class ::KHTMLPart;
76 friend class DOMImplementation;
80 * The parent is the widget the document should render itself in.
81 * Rendering information (like sizes, etc...) is only created if
84 HTMLDocument(KHTMLView *parent);
85 HTMLDocument(const HTMLDocument &other);
86 HTMLDocument(const Node &other) : Document(false)
89 HTMLDocument(HTMLDocumentImpl *impl);
92 HTMLDocument & operator = (const HTMLDocument &other);
93 HTMLDocument & operator = (const Node &other);
98 * The title of a document as specified by the <code> TITLE
99 * </code> element in the head of the document.
102 DOMString title() const;
107 void setTitle( const DOMString & );
110 * Returns the URI of the page that linked to this page. The value
111 * is an empty string if the user navigated to the page directly
112 * (not through a link, but, for example, via a bookmark).
114 DOMString referrer() const;
117 * The domain name of the server that served the document, or a
118 * null string if the server cannot be identified by a domain
122 DOMString domain() const;
125 * The absolute URI of the document.
127 DOMString URL() const;
130 * The element that contains the content for the document. In
131 * documents with <code> BODY </code> contents, returns the <code>
132 * BODY </code> element, and in frameset documents, this returns
133 * the outermost <code> FRAMESET </code> element.
136 HTMLElement body() const;
141 void setBody(const HTMLElement &);
144 * A collection of all the <code> IMG </code> elements in a
145 * document. The behavior is limited to <code> IMG </code>
146 * elements for backwards compatibility.
149 HTMLCollection images() const;
152 * A collection of all the <code> OBJECT </code> elements that
153 * include applets and <code> APPLET </code> ( deprecated )
154 * elements in a document.
157 HTMLCollection applets() const;
160 * A collection of all the <embed> OBJECT </embed> elements that
161 * include embedded elements in a document.
164 HTMLCollection embeds() const;
167 * A collection of all <code> AREA </code> elements and anchor (
168 * <code> A </code> ) elements in a document with a value for the
169 * <code> href </code> attribute.
172 HTMLCollection links() const;
175 * A collection of all the forms of a document.
178 HTMLCollection forms() const;
181 * A collection of all the anchor ( <code> A </code> ) elements in
182 * a document with a value for the <code> name </code> attribute.
183 * Note. For reasons of backwards compatibility, the returned set
184 * of anchors only contains those anchors created with the <code>
185 * name </code> attribute, not those created with the <code> id
189 HTMLCollection anchors() const;
192 * The cookies associated with this document. If there are none,
193 * the value is an empty string. Otherwise, the value is a string:
194 * a semicolon-delimited list of "name, value" pairs for all the
195 * cookies associated with the page. For example, <code>
196 * name=value;expires=date </code> .
199 DOMString cookie() const;
204 void setCookie( const DOMString & );
208 * The base URL of the top level document. This is used to determine cookie policy.
210 void setPolicyBaseURL( const DOMString & );
214 * Note. This method and the ones following allow a user to add to
215 * or replace the structure model of a document using strings of
216 * unparsed HTML. At the time of writing alternate methods for
217 * providing similar functionality for both HTML and XML documents
218 * were being considered. The following methods may be deprecated
219 * at some point in the future in favor of a more general-purpose
222 * Open a document stream for writing. If a document exists in
223 * the target, this method clears it.
231 * Closes a document stream opened by <code> open() </code> and
240 * Write a string of text to a document stream opened by <code>
241 * open() </code> . The text is parsed into the document's
244 * @param text The string to be parsed into some structure in the
245 * document structure model.
250 void write ( const DOMString &text );
253 * Write a string of text followed by a newline character to a
254 * document stream opened by <code> open() </code> . The text is
255 * parsed into the document's structure model.
257 * @param text The string to be parsed into some structure in the
258 * document structure model.
263 void writeln ( const DOMString &text );
266 * Returns the (possibly empty) collection of elements whose
267 * <code> name </code> value is given by <code> elementName
270 * @param elementName The <code> name </code> attribute value for
273 * @return The matching elements.
276 NodeList getElementsByName ( const DOMString &elementName );
279 * not part of the DOM
281 * converts the given (potentially relative) URL in a
282 * full-qualified one, using the baseURL / document URL for
285 DOMString completeURL( const DOMString& url) const;
288 * Not part of the DOM
290 * The date the document was last modified.
292 DOMString lastModified() const;
295 * Not part of the DOM
297 * A collection of all the <code>IMG</code>, <code>OBJECT</code>,
298 * <code>AREA</code>, <code>A</code>, forms and anchor elements of
301 HTMLCollection all() const;
304 * Not part of the DOM
306 * A collection of all the <code>IMG</code>, <code>OBJECT</code>,
307 * <code>EMBED</code>, <code>APPLET</code>, and <code>FORM</code> tags in
308 * a document. Used when looking up elements by name as properties on the document
309 * object, e.g. document.myForm for a form with name attribute of "myForm".
311 HTMLCollection nameableItems() const;