File indexing completed on 2024-04-28 15:22:59
0001 /* 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright 1999 Lars Knoll (knoll@kde.org) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 * This file includes excerpts from the Document Object Model (DOM) 0022 * Level 1 Specification (Recommendation) 0023 * https://www.w3.org/TR/REC-DOM-Level-1/ 0024 * Copyright © World Wide Web Consortium , (Massachusetts Institute of 0025 * Technology , Institut National de Recherche en Informatique et en 0026 * Automatique , Keio University ). All Rights Reserved. 0027 * 0028 */ 0029 0030 #ifndef HTML_DOCUMENT_H 0031 #define HTML_DOCUMENT_H 0032 0033 #include <khtml_export.h> 0034 0035 #include <dom/dom_doc.h> 0036 #include <dom/dom_string.h> 0037 0038 class KHTMLView; 0039 class KHTMLPart; 0040 0041 namespace DOM 0042 { 0043 0044 class HTMLDocumentImpl; 0045 class DOMImplementation; 0046 class HTMLCollection; 0047 class NodeList; 0048 class Element; 0049 class HTMLElement; 0050 0051 /** 0052 * An \c HTMLDocument is the root of the HTML hierarchy 0053 * and holds the entire content. Beside providing access to the 0054 * hierarchy, it also provides some convenience methods for accessing 0055 * certain sets of information from the document. 0056 * 0057 * The following properties have been deprecated in favor of the 0058 * corresponding ones for the BODY element: 0059 * 0060 * \li \c alinkColor 0061 * 0062 * \li \c background 0063 * 0064 * \li \c bgColor 0065 * 0066 * \li \c fgColor 0067 * 0068 * \li \c linkColor 0069 * 0070 * \li \c vlinkColor 0071 * 0072 * 0073 */ 0074 class KHTML_EXPORT HTMLDocument : public Document 0075 { 0076 friend class ::KHTMLView; 0077 friend class ::KHTMLPart; 0078 friend class DOMImplementation; 0079 public: 0080 HTMLDocument(); 0081 /** 0082 * The parent is the widget the document should render itself in. 0083 * Rendering information (like sizes, etc...) is only created if 0084 * parent != 0 0085 */ 0086 HTMLDocument(KHTMLView *parent); 0087 HTMLDocument(const HTMLDocument &other); 0088 HTMLDocument(const Node &other) : Document(false) 0089 { 0090 (*this) = other; 0091 } 0092 protected: 0093 HTMLDocument(HTMLDocumentImpl *impl); 0094 public: 0095 0096 HTMLDocument &operator = (const HTMLDocument &other); 0097 HTMLDocument &operator = (const Node &other); 0098 0099 ~HTMLDocument(); 0100 0101 /** 0102 * The title of a document as specified by the \c TITLE 0103 * element in the head of the document. 0104 * 0105 */ 0106 DOMString title() const; 0107 0108 /** 0109 * see title 0110 */ 0111 void setTitle(const DOMString &); 0112 0113 /** 0114 * Returns the URI of the page that linked to this page. The value 0115 * is an empty string if the user navigated to the page directly 0116 * (not through a link, but, for example, via a bookmark). 0117 */ 0118 DOMString referrer() const; 0119 0120 /** 0121 * The domain name of the server that served the document, or a 0122 * null string if the server cannot be identified by a domain 0123 * name. 0124 * 0125 */ 0126 DOMString domain() const; 0127 0128 /** 0129 * The absolute URI of the document. 0130 */ 0131 DOMString URL() const; 0132 0133 /** 0134 * The element that contains the content for the document. In 0135 * documents with \c BODY contents, returns the 0136 * \c BODY element, and in frameset documents, this returns 0137 * the outermost \c FRAMESET element. 0138 * 0139 */ 0140 HTMLElement body() const; 0141 0142 /** 0143 * see body 0144 */ 0145 void setBody(const HTMLElement &); 0146 0147 /** 0148 * A collection of all the \c IMG elements in a 0149 * document. The behavior is limited to \c IMG 0150 * elements for backwards compatibility. 0151 * 0152 */ 0153 HTMLCollection images() const; 0154 0155 /** 0156 * A collection of all the \c OBJECT elements that 0157 * include applets and \c APPLET ( deprecated ) 0158 * elements in a document. 0159 * 0160 */ 0161 HTMLCollection applets() const; 0162 0163 /** 0164 * A collection of all \c AREA elements and anchor ( 0165 * \c A ) elements in a document with a value for the 0166 * \c href attribute. 0167 * 0168 */ 0169 HTMLCollection links() const; 0170 0171 /** 0172 * A collection of all the forms of a document. 0173 * 0174 */ 0175 HTMLCollection forms() const; 0176 0177 /** 0178 * A collection of all the layers of a document. 0179 * 0180 */ 0181 HTMLCollection layers() const; 0182 0183 /** 0184 * A collection of all the scripts in the document. 0185 * 0186 */ 0187 HTMLCollection scripts() const; 0188 0189 /** 0190 * A collection of all the anchor ( \c A ) elements in 0191 * a document with a value for the \c name attribute. 0192 * Note. For reasons of backwards compatibility, the returned set 0193 * of anchors only contains those anchors created with the 0194 * \c name attribute, not those created with the \c id 0195 * attribute. 0196 * 0197 */ 0198 HTMLCollection anchors() const; 0199 0200 /** 0201 * The cookies associated with this document. If there are none, 0202 * the value is an empty string. Otherwise, the value is a string: 0203 * a semicolon-delimited list of "name, value" pairs for all the 0204 * cookies associated with the page. For example, 0205 * \c name=value;expires=date . 0206 * 0207 */ 0208 DOMString cookie() const; 0209 0210 /** 0211 * see cookie 0212 */ 0213 void setCookie(const DOMString &); 0214 0215 /** 0216 * Note. This method and the ones following allow a user to add to 0217 * or replace the structure model of a document using strings of 0218 * unparsed HTML. At the time of writing alternate methods for 0219 * providing similar functionality for both HTML and XML documents 0220 * were being considered. The following methods may be deprecated 0221 * at some point in the future in favor of a more general-purpose 0222 * mechanism. 0223 * 0224 * Open a document stream for writing. If a document exists in 0225 * the target, this method clears it. 0226 * 0227 * @return 0228 * 0229 */ 0230 void open(); 0231 0232 /** 0233 * Closes a document stream opened by \c open() and 0234 * forces rendering. 0235 * 0236 * @return 0237 * 0238 */ 0239 void close(); 0240 0241 /** 0242 * Write a string of text to a document stream opened by 0243 * \c open() . The text is parsed into the document's 0244 * structure model. 0245 * 0246 * @param text The string to be parsed into some structure in the 0247 * document structure model. 0248 * 0249 * @return 0250 * 0251 */ 0252 void write(const DOMString &text); 0253 0254 /** 0255 * Write a string of text followed by a newline character to a 0256 * document stream opened by \c open() . The text is 0257 * parsed into the document's structure model. 0258 * 0259 * @param text The string to be parsed into some structure in the 0260 * document structure model. 0261 * 0262 * @return 0263 * 0264 */ 0265 void writeln(const DOMString &text); 0266 0267 /** 0268 * Returns the (possibly empty) collection of elements whose 0269 * \c name value is given by \c elementName . 0270 * 0271 * @param elementName The \c name attribute value for 0272 * an element. 0273 * 0274 * @return The matching elements. 0275 * 0276 */ 0277 NodeList getElementsByName(const DOMString &elementName); 0278 0279 /** 0280 * not part of the DOM 0281 * 0282 * converts the given (potentially relative) URL in a 0283 * full-qualified one, using the baseURL / document URL for 0284 * the missing parts. 0285 */ 0286 DOMString completeURL(const DOMString &url) const; 0287 0288 /** 0289 * Not part of the DOM 0290 * 0291 * The date the document was last modified. 0292 */ 0293 DOMString lastModified() const; 0294 0295 /** 0296 * Not part of the DOM 0297 * 0298 * A collection of all the \c IMG, \c OBJECT, 0299 * \c AREA, \c A, forms and anchor elements of 0300 * a document. 0301 */ 0302 HTMLCollection all() const; 0303 }; 0304 0305 } //namespace 0306 0307 #endif