File indexing completed on 2024-04-28 15:23:00
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 #ifndef HTML_ELEMENT_H 0030 #define HTML_ELEMENT_H 0031 0032 #include <khtml_export.h> 0033 #include <dom/dom_element.h> 0034 0035 class KHTMLView; 0036 0037 namespace DOM 0038 { 0039 0040 class HTMLElementImpl; 0041 class DOMString; 0042 class Element; 0043 class HTMLCollection; 0044 0045 /** 0046 * All HTML element interfaces derive from this class. Elements that 0047 * only expose the HTML core attributes are represented by the base 0048 * \c HTMLElement interface. These elements are as 0049 * follows: 0050 * 0051 * \li \c HEAD 0052 * 0053 * \li special: <tt> SUB, SUP, SPAN, BDO </tt> 0054 * 0055 * \li font: <tt> TT, I, B, U, S, STRIKE, BIG, SMALL </tt> 0056 * 0057 * \li phrase: <tt> EM, STRONG, DFN, CODE, SAMP, KBD, VAR, 0058 * CITE, ACRONYM, ABBR</tt> 0059 * 0060 * \li list: <tt> DD, DT </tt> 0061 * 0062 * \li <tt> NOFRAMES, NOSCRIPT </tt> 0063 * 0064 * \li <tt> ADDRESS, CENTER </tt> 0065 * 0066 * Note: The \c style attribute for this 0067 * interface is reserved for future usage. 0068 * 0069 */ 0070 class KHTML_EXPORT HTMLElement : public Element 0071 { 0072 friend class HTMLDocument; 0073 friend class ::KHTMLView; 0074 friend class HTMLTableElement; 0075 friend class HTMLTableRowElement; 0076 friend class HTMLTableSectionElement; 0077 0078 public: 0079 HTMLElement(); 0080 HTMLElement(const HTMLElement &other); 0081 HTMLElement(const Node &other) : Element() 0082 { 0083 (*this) = other; 0084 } 0085 0086 protected: 0087 HTMLElement(HTMLElementImpl *impl); 0088 public: 0089 0090 HTMLElement &operator = (const HTMLElement &other); 0091 HTMLElement &operator = (const Node &other); 0092 0093 ~HTMLElement(); 0094 0095 /** 0096 * The element's identifier. See the <a 0097 * href="https://www.w3.org/TR/REC-html40/struct/global.html#adef-id"> 0098 * id attribute definition </a> in HTML 4.0. 0099 * 0100 */ 0101 DOMString id() const; 0102 0103 /** 0104 * see id 0105 */ 0106 void setId(const DOMString &); 0107 0108 /** 0109 * The element's advisory title. See the <a 0110 * href="https://www.w3.org/TR/REC-html40/struct/global.html#adef-title"> 0111 * title attribute definition </a> in HTML 4.0. 0112 * 0113 */ 0114 DOMString title() const; 0115 0116 /** 0117 * see title 0118 */ 0119 void setTitle(const DOMString &); 0120 0121 /** 0122 * Language code defined in RFC 1766. See the <a 0123 * href="https://www.w3.org/TR/REC-html40/struct/dirlang.html#adef-lang"> 0124 * lang attribute definition </a> in HTML 4.0. 0125 * 0126 */ 0127 DOMString lang() const; 0128 0129 /** 0130 * see lang 0131 */ 0132 void setLang(const DOMString &); 0133 0134 /** 0135 * Specifies the base direction of directionally neutral text and 0136 * the directionality of tables. See the <a 0137 * href="https://www.w3.org/TR/REC-html40/struct/dirlang.html#adef-dir"> 0138 * dir attribute definition </a> in HTML 4.0. 0139 * 0140 */ 0141 DOMString dir() const; 0142 0143 /** 0144 * see dir 0145 */ 0146 void setDir(const DOMString &); 0147 0148 /** 0149 * The class attribute of the element. This attribute has been 0150 * renamed due to conflicts with the "class" keyword exposed by 0151 * many languages. See the <a 0152 * href="https://www.w3.org/TR/REC-html40/struct/global.html#adef-class"> 0153 * class attribute definition </a> in HTML 4.0. 0154 * 0155 */ 0156 DOMString className() const; 0157 0158 /** 0159 * see className 0160 */ 0161 void setClassName(const DOMString &); 0162 0163 /** 0164 * The HTML code contained in this element. 0165 * This function is not part of the DOM specifications as defined by the w3c. 0166 */ 0167 DOMString innerHTML() const; 0168 0169 /** 0170 * Set the HTML content of this node. 0171 * 0172 * @exception DOMException 0173 * NO_MODIFICATION_ALLOWED_ERR: Raised if there is the element does not allow 0174 * children. 0175 */ 0176 void setInnerHTML(const DOMString &html); 0177 0178 /** 0179 * The text contained in this element. 0180 * This function is not part of the DOM specifications as defined by the w3c. 0181 */ 0182 DOMString innerText() const; 0183 0184 /** 0185 * Set the text content of this node. 0186 * 0187 * @exception DOMException 0188 * NO_MODIFICATION_ALLOWED_ERR: Raised if there is the element does not allow 0189 * children. 0190 */ 0191 void setInnerText(const DOMString &text); 0192 0193 /** 0194 * Retrieves a collection of nodes that are direct descendants of this node. 0195 * IE-specific extension. 0196 */ 0197 HTMLCollection children() const; 0198 0199 /** 0200 * Retrieves a collection of all nodes that descend from this node. 0201 * IE-specific extension. 0202 */ 0203 HTMLCollection all() const; 0204 0205 /** 0206 * Returns whether this element is editable. 0207 * 0208 * This function is not part of the DOM specifications as defined by the w3c. 0209 */ 0210 bool isContentEditable() const; 0211 0212 /** 0213 * Returns the kind of editability that applies to this element. 0214 * 0215 * The returned string is one of: 0216 * \li true: This element has been set to be editable. 0217 * \li false: This element has been set not to be editable. 0218 * \li inherit: This element inherits its editability from the parent. 0219 * 0220 * This function is not part of the DOM specifications as defined by the w3c. 0221 */ 0222 DOMString contentEditable() const; 0223 0224 /** 0225 * Sets the editability of this element. 0226 * 0227 * This function is not part of the DOM specifications as defined by the w3c. 0228 * @param enabled may be one of: 0229 * \li true: make element editable 0230 * \li false: make element not editable 0231 * \li inherit: make element inherit editability from parent. 0232 */ 0233 void setContentEditable(const DOMString &enabled); 0234 0235 /* 0236 * @internal 0237 */ 0238 void removeCSSProperty(const DOMString &property); 0239 0240 /* 0241 * @internal 0242 */ 0243 void addCSSProperty(const DOMString &property, const DOMString &value); 0244 0245 protected: 0246 /* 0247 * @internal 0248 */ 0249 void assignOther(const Node &other, int elementId); 0250 }; 0251 0252 } //namespace 0253 0254 #endif