fix logic
[personal-kdelibs.git] / khtml / dom / html_document.h
blobb860aa1526de1aeada5839e14be15bb2e7308214
1 /*
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>
38 class KHTMLView;
39 class KHTMLPart;
41 namespace DOM {
43 class HTMLDocumentImpl;
44 class DOMImplementation;
45 class HTMLCollection;
46 class NodeList;
47 class Element;
48 class HTMLElement;
50 /**
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:
59 * \li \c alinkColor
61 * \li \c background
63 * \li \c bgColor
65 * \li \c fgColor
67 * \li \c linkColor
69 * \li \c vlinkColor
73 class KHTML_EXPORT HTMLDocument : public Document
75 friend class ::KHTMLView;
76 friend class ::KHTMLPart;
77 friend class DOMImplementation;
78 public:
79 HTMLDocument();
80 /**
81 * The parent is the widget the document should render itself in.
82 * Rendering information (like sizes, etc...) is only created if
83 * parent != 0
85 HTMLDocument(KHTMLView *parent);
86 HTMLDocument(const HTMLDocument &other);
87 HTMLDocument(const Node &other) : Document(false)
88 {(*this)=other;}
89 protected:
90 HTMLDocument(HTMLDocumentImpl *impl);
91 public:
93 HTMLDocument & operator = (const HTMLDocument &other);
94 HTMLDocument & operator = (const Node &other);
96 ~HTMLDocument();
98 /**
99 * The title of a document as specified by the \c TITLE
100 * element in the head of the document.
103 DOMString title() const;
106 * see title
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
120 * name.
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;
140 * see body
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
163 * \c href attribute.
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
192 * attribute.
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;
208 * see cookie
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
219 * mechanism.
221 * Open a document stream for writing. If a document exists in
222 * the target, this method clears it.
224 * @return
227 void open ( );
230 * Closes a document stream opened by \c open() and
231 * forces rendering.
233 * @return
236 void close ( );
239 * Write a string of text to a document stream opened by
240 * \c open() . The text is parsed into the document's
241 * structure model.
243 * @param text The string to be parsed into some structure in the
244 * document structure model.
246 * @return
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.
259 * @return
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
269 * an element.
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
281 * the missing parts.
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
297 * a document.
299 HTMLCollection all() const;
302 } //namespace
304 #endif