KHtml

html_document.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  *
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.
10  *
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.
15  *
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.
20  *
21  * This file includes excerpts from the Document Object Model (DOM)
22  * Level 1 Specification (Recommendation)
23  * https://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.
27  *
28  */
29 
30 #ifndef HTML_DOCUMENT_H
31 #define HTML_DOCUMENT_H
32 
33 #include <khtml_export.h>
34 
35 #include <dom/dom_doc.h>
36 #include <dom/dom_string.h>
37 
38 class KHTMLView;
39 class KHTMLPart;
40 
41 namespace DOM
42 {
43 
44 class HTMLDocumentImpl;
45 class DOMImplementation;
46 class HTMLCollection;
47 class NodeList;
48 class Element;
49 class HTMLElement;
50 
51 /**
52  * An \c HTMLDocument is the root of the HTML hierarchy
53  * and holds the entire content. Beside providing access to the
54  * hierarchy, it also provides some convenience methods for accessing
55  * certain sets of information from the document.
56  *
57  * The following properties have been deprecated in favor of the
58  * corresponding ones for the BODY element:
59  *
60  * \li \c alinkColor
61  *
62  * \li \c background
63  *
64  * \li \c bgColor
65  *
66  * \li \c fgColor
67  *
68  * \li \c linkColor
69  *
70  * \li \c vlinkColor
71  *
72  *
73  */
74 class KHTML_EXPORT HTMLDocument : public Document
75 {
76  friend class ::KHTMLView;
77  friend class ::KHTMLPart;
78  friend class DOMImplementation;
79 public:
80  HTMLDocument();
81  /**
82  * The parent is the widget the document should render itself in.
83  * Rendering information (like sizes, etc...) is only created if
84  * parent != 0
85  */
86  HTMLDocument(KHTMLView *parent);
87  HTMLDocument(const HTMLDocument &other);
88  HTMLDocument(const Node &other) : Document(false)
89  {
90  (*this) = other;
91  }
92 protected:
93  HTMLDocument(HTMLDocumentImpl *impl);
94 public:
95 
96  HTMLDocument &operator = (const HTMLDocument &other);
97  HTMLDocument &operator = (const Node &other);
98 
99  ~HTMLDocument();
100 
101  /**
102  * The title of a document as specified by the \c TITLE
103  * element in the head of the document.
104  *
105  */
106  DOMString title() const;
107 
108  /**
109  * see title
110  */
111  void setTitle(const DOMString &);
112 
113  /**
114  * Returns the URI of the page that linked to this page. The value
115  * is an empty string if the user navigated to the page directly
116  * (not through a link, but, for example, via a bookmark).
117  */
118  DOMString referrer() const;
119 
120  /**
121  * The domain name of the server that served the document, or a
122  * null string if the server cannot be identified by a domain
123  * name.
124  *
125  */
126  DOMString domain() const;
127 
128  /**
129  * The absolute URI of the document.
130  */
131  DOMString URL() const;
132 
133  /**
134  * The element that contains the content for the document. In
135  * documents with \c BODY contents, returns the
136  * \c BODY element, and in frameset documents, this returns
137  * the outermost \c FRAMESET element.
138  *
139  */
140  HTMLElement body() const;
141 
142  /**
143  * see body
144  */
145  void setBody(const HTMLElement &);
146 
147  /**
148  * A collection of all the \c IMG elements in a
149  * document. The behavior is limited to \c IMG
150  * elements for backwards compatibility.
151  *
152  */
153  HTMLCollection images() const;
154 
155  /**
156  * A collection of all the \c OBJECT elements that
157  * include applets and \c APPLET ( deprecated )
158  * elements in a document.
159  *
160  */
161  HTMLCollection applets() const;
162 
163  /**
164  * A collection of all \c AREA elements and anchor (
165  * \c A ) elements in a document with a value for the
166  * \c href attribute.
167  *
168  */
169  HTMLCollection links() const;
170 
171  /**
172  * A collection of all the forms of a document.
173  *
174  */
175  HTMLCollection forms() const;
176 
177  /**
178  * A collection of all the layers of a document.
179  *
180  */
181  HTMLCollection layers() const;
182 
183  /**
184  * A collection of all the scripts in the document.
185  *
186  */
187  HTMLCollection scripts() const;
188 
189  /**
190  * A collection of all the anchor ( \c A ) elements in
191  * a document with a value for the \c name attribute.
192  * Note. For reasons of backwards compatibility, the returned set
193  * of anchors only contains those anchors created with the
194  * \c name attribute, not those created with the \c id
195  * attribute.
196  *
197  */
198  HTMLCollection anchors() const;
199 
200  /**
201  * The cookies associated with this document. If there are none,
202  * the value is an empty string. Otherwise, the value is a string:
203  * a semicolon-delimited list of "name, value" pairs for all the
204  * cookies associated with the page. For example,
205  * \c name=value;expires=date .
206  *
207  */
208  DOMString cookie() const;
209 
210  /**
211  * see cookie
212  */
213  void setCookie(const DOMString &);
214 
215  /**
216  * Note. This method and the ones following allow a user to add to
217  * or replace the structure model of a document using strings of
218  * unparsed HTML. At the time of writing alternate methods for
219  * providing similar functionality for both HTML and XML documents
220  * were being considered. The following methods may be deprecated
221  * at some point in the future in favor of a more general-purpose
222  * mechanism.
223  *
224  * Open a document stream for writing. If a document exists in
225  * the target, this method clears it.
226  *
227  * @return
228  *
229  */
230  void open();
231 
232  /**
233  * Closes a document stream opened by \c open() and
234  * forces rendering.
235  *
236  * @return
237  *
238  */
239  void close();
240 
241  /**
242  * Write a string of text to a document stream opened by
243  * \c open() . The text is parsed into the document's
244  * structure model.
245  *
246  * @param text The string to be parsed into some structure in the
247  * document structure model.
248  *
249  * @return
250  *
251  */
252  void write(const DOMString &text);
253 
254  /**
255  * Write a string of text followed by a newline character to a
256  * document stream opened by \c open() . The text is
257  * parsed into the document's structure model.
258  *
259  * @param text The string to be parsed into some structure in the
260  * document structure model.
261  *
262  * @return
263  *
264  */
265  void writeln(const DOMString &text);
266 
267  /**
268  * Returns the (possibly empty) collection of elements whose
269  * \c name value is given by \c elementName .
270  *
271  * @param elementName The \c name attribute value for
272  * an element.
273  *
274  * @return The matching elements.
275  *
276  */
277  NodeList getElementsByName(const DOMString &elementName);
278 
279  /**
280  * not part of the DOM
281  *
282  * converts the given (potentially relative) URL in a
283  * full-qualified one, using the baseURL / document URL for
284  * the missing parts.
285  */
286  DOMString completeURL(const DOMString &url) const;
287 
288  /**
289  * Not part of the DOM
290  *
291  * The date the document was last modified.
292  */
293  DOMString lastModified() const;
294 
295  /**
296  * Not part of the DOM
297  *
298  * A collection of all the \c IMG, \c OBJECT,
299  * \c AREA, \c A, forms and anchor elements of
300  * a document.
301  */
302  HTMLCollection all() const;
303 };
304 
305 } //namespace
306 
307 #endif
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
An HTMLDocument is the root of the HTML hierarchy and holds the entire content.
Definition: html_document.h:74
This class is khtml&#39;s main class.
Definition: khtml_part.h:208
The DOMImplementation interface provides a number of methods for performing operations that are indep...
Definition: dom_doc.h:78
Renders and displays HTML in a QScrollArea.
Definition: khtmlview.h:97
An HTMLCollection is a list of nodes.
Definition: html_misc.h:133
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.
Definition: dom_node.h:976
This library provides a full-featured HTML parser and widget.
All HTML element interfaces derive from this class.
Definition: html_element.h:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 22:48:05 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.