1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll (knoll@kde.org)
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 #ifndef HTML_MISC_H
30 #define HTML_MISC_H
31 
32 #include <khtml_export.h>
33 #include <dom/html_element.h>
34 
35 namespace DOM
36 {
37 
38 class HTMLBaseFontElementImpl;
39 class DOMString;
40 class HTMLCollectionImpl;
41 
42 /**
43  * Base font. See the <a
44  * href="https://www.w3.org/TR/REC-html40/present/graphics.html#edef-BASEFONT">
45  * BASEFONT element definition </a> in HTML 4.0. This element is
46  * deprecated in HTML 4.0.
47  *
48  */
49 class KHTML_EXPORT HTMLBaseFontElement : public HTMLElement
50 {
51 public:
52     HTMLBaseFontElement();
53     HTMLBaseFontElement(const HTMLBaseFontElement &other);
HTMLBaseFontElement(const Node & other)54     HTMLBaseFontElement(const Node &other) : HTMLElement()
55     {
56         (*this) = other;
57     }
58 protected:
59     HTMLBaseFontElement(HTMLBaseFontElementImpl *impl);
60 public:
61 
62     HTMLBaseFontElement &operator = (const HTMLBaseFontElement &other);
63     HTMLBaseFontElement &operator = (const Node &other);
64 
65     ~HTMLBaseFontElement();
66 
67     /**
68      * Font color. See the <a href="https://www.w3.org/TR/REC-html40/">
69      * color attribute definition </a> in HTML 4.0. This attribute is
70      * deprecated in HTML 4.0.
71      *
72      */
73     DOMString color() const;
74 
75     /**
76      * see color
77      */
78     void setColor(const DOMString &);
79 
80     /**
81      * Font face identifier. See the <a
82      * href="https://www.w3.org/TR/REC-html40/"> face attribute
83      * definition </a> in HTML 4.0. This attribute is deprecated in
84      * HTML 4.0.
85      *
86      */
87     DOMString face() const;
88 
89     /**
90      * see face
91      */
92     void setFace(const DOMString &);
93 
94     /**
95      * Computed Font size. See the <a
96      * href="https://www.w3.org/TR/REC-html40/present/graphics.html#adef-size-BASEFONT">
97      * size attribute definition </a> in HTML 4.0. This attribute is
98      * deprecated in HTML 4.0.
99      *
100      */
101     long getSize() const;
102 
103     /**
104      * see size
105      */
106     void setSize(long);
107 
108     /**
109      * @deprecated
110      */
111 #ifndef KHTML_NO_DEPRECATED
112     KHTML_DEPRECATED DOMString size() const;
113 #endif
114 
115     /**
116      * @deprecated
117      */
118 #ifndef KHTML_NO_DEPRECATED
119     KHTML_DEPRECATED void setSize(const DOMString &);
120 #endif
121 };
122 
123 // --------------------------------------------------------------------------
124 
125 /**
126  * An \c HTMLCollection is a list of nodes. An individual
127  * node may be accessed by either ordinal index or the node's
128  * \c name or \c id attributes. Note: Collections in
129  * the HTML DOM are assumed to be live meaning that they are
130  * automatically updated when the underlying document is changed.
131  *
132  */
133 class KHTML_EXPORT HTMLCollection
134 {
135     friend class HTMLDocument;
136     friend class HTMLSelectElement;
137     friend class HTMLImageElement;
138     friend class HTMLMapElement;
139     friend class HTMLTableElement;
140     friend class HTMLTableRowElement;
141     friend class HTMLTableSectionElement;
142     friend class HTMLLayerElement;
143     friend class HTMLElement;
144 
145 public:
146     HTMLCollection();
147     HTMLCollection(const HTMLCollection &other);
148 protected:
149     HTMLCollection(HTMLCollectionImpl *impl);
150     HTMLCollection(NodeImpl *base, int type);
151 public:
152 
153     HTMLCollection &operator = (const HTMLCollection &other);
154 
155     ~HTMLCollection();
156 
157     /**
158      * This attribute specifies the length or size of the list.
159      *
160      */
161     unsigned long length() const;
162 
163     /**
164      * This method retrieves a node specified by ordinal index. Nodes
165      * are numbered in tree order (depth-first traversal order).
166      *
167      * @param index The index of the node to be fetched. The index
168      * origin is 0.
169      *
170      * @return The \c Node at the corresponding position
171      * upon success. A value of \c null is returned if the
172      * index is out of range.
173      *
174      */
175     Node item(unsigned long index) const;
176 
177     /**
178      * This method retrieves a \c Node using a name. It
179      * first searches for a \c Node with a matching
180      * \c id attribute. If it doesn't find one, it then searches
181      * for a \c Node with a matching \c name
182      * attribute, but only on those elements that are allowed a name
183      * attribute.
184      *
185      * @param name The name of the \c Node to be fetched.
186      *
187      * @return The \c Node with a \c name or
188      * \c id attribute whose value corresponds to the
189      * specified string. Upon failure (e.g., no node with this name
190      * exists), returns \c null .
191      *
192      */
193     Node namedItem(const DOMString &name) const;
194 
195     /**
196      * @internal
197      * not part of the DOM
198      */
199     Node base() const;
200     HTMLCollectionImpl *handle() const;
201     bool isNull() const;
202     // Fast iteration
203     Node firstItem() const;
204     Node nextItem() const;
205     // In case of multiple items named the same way
206     Node nextNamedItem(const DOMString &name) const;
207 
208 protected:
209     HTMLCollectionImpl *impl;
210 };
211 
212 class KHTML_EXPORT HTMLFormCollection : public HTMLCollection
213 {
214     friend class HTMLFormElement;
215 protected:
216     HTMLFormCollection(NodeImpl *base);
217 };
218 
219 } //namespace
220 
221 #endif
222