File indexing completed on 2024-04-28 15:23:02

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_MISC_H
0030 #define HTML_MISC_H
0031 
0032 #include <khtml_export.h>
0033 #include <dom/html_element.h>
0034 
0035 namespace DOM
0036 {
0037 
0038 class HTMLBaseFontElementImpl;
0039 class DOMString;
0040 class HTMLCollectionImpl;
0041 
0042 /**
0043  * Base font. See the <a
0044  * href="https://www.w3.org/TR/REC-html40/present/graphics.html#edef-BASEFONT">
0045  * BASEFONT element definition </a> in HTML 4.0. This element is
0046  * deprecated in HTML 4.0.
0047  *
0048  */
0049 class KHTML_EXPORT HTMLBaseFontElement : public HTMLElement
0050 {
0051 public:
0052     HTMLBaseFontElement();
0053     HTMLBaseFontElement(const HTMLBaseFontElement &other);
0054     HTMLBaseFontElement(const Node &other) : HTMLElement()
0055     {
0056         (*this) = other;
0057     }
0058 protected:
0059     HTMLBaseFontElement(HTMLBaseFontElementImpl *impl);
0060 public:
0061 
0062     HTMLBaseFontElement &operator = (const HTMLBaseFontElement &other);
0063     HTMLBaseFontElement &operator = (const Node &other);
0064 
0065     ~HTMLBaseFontElement();
0066 
0067     /**
0068      * Font color. See the <a href="https://www.w3.org/TR/REC-html40/">
0069      * color attribute definition </a> in HTML 4.0. This attribute is
0070      * deprecated in HTML 4.0.
0071      *
0072      */
0073     DOMString color() const;
0074 
0075     /**
0076      * see color
0077      */
0078     void setColor(const DOMString &);
0079 
0080     /**
0081      * Font face identifier. See the <a
0082      * href="https://www.w3.org/TR/REC-html40/"> face attribute
0083      * definition </a> in HTML 4.0. This attribute is deprecated in
0084      * HTML 4.0.
0085      *
0086      */
0087     DOMString face() const;
0088 
0089     /**
0090      * see face
0091      */
0092     void setFace(const DOMString &);
0093 
0094     /**
0095      * Computed Font size. See the <a
0096      * href="https://www.w3.org/TR/REC-html40/present/graphics.html#adef-size-BASEFONT">
0097      * size attribute definition </a> in HTML 4.0. This attribute is
0098      * deprecated in HTML 4.0.
0099      *
0100      */
0101     long getSize() const;
0102 
0103     /**
0104      * see size
0105      */
0106     void setSize(long);
0107 
0108     /**
0109      * @deprecated
0110      */
0111 #ifndef KHTML_NO_DEPRECATED
0112     KHTML_DEPRECATED DOMString size() const;
0113 #endif
0114 
0115     /**
0116      * @deprecated
0117      */
0118 #ifndef KHTML_NO_DEPRECATED
0119     KHTML_DEPRECATED void setSize(const DOMString &);
0120 #endif
0121 };
0122 
0123 // --------------------------------------------------------------------------
0124 
0125 /**
0126  * An \c HTMLCollection is a list of nodes. An individual
0127  * node may be accessed by either ordinal index or the node's
0128  * \c name or \c id attributes. Note: Collections in
0129  * the HTML DOM are assumed to be live meaning that they are
0130  * automatically updated when the underlying document is changed.
0131  *
0132  */
0133 class KHTML_EXPORT HTMLCollection
0134 {
0135     friend class HTMLDocument;
0136     friend class HTMLSelectElement;
0137     friend class HTMLImageElement;
0138     friend class HTMLMapElement;
0139     friend class HTMLTableElement;
0140     friend class HTMLTableRowElement;
0141     friend class HTMLTableSectionElement;
0142     friend class HTMLLayerElement;
0143     friend class HTMLElement;
0144 
0145 public:
0146     HTMLCollection();
0147     HTMLCollection(const HTMLCollection &other);
0148 protected:
0149     HTMLCollection(HTMLCollectionImpl *impl);
0150     HTMLCollection(NodeImpl *base, int type);
0151 public:
0152 
0153     HTMLCollection &operator = (const HTMLCollection &other);
0154 
0155     ~HTMLCollection();
0156 
0157     /**
0158      * This attribute specifies the length or size of the list.
0159      *
0160      */
0161     unsigned long length() const;
0162 
0163     /**
0164      * This method retrieves a node specified by ordinal index. Nodes
0165      * are numbered in tree order (depth-first traversal order).
0166      *
0167      * @param index The index of the node to be fetched. The index
0168      * origin is 0.
0169      *
0170      * @return The \c Node at the corresponding position
0171      * upon success. A value of \c null is returned if the
0172      * index is out of range.
0173      *
0174      */
0175     Node item(unsigned long index) const;
0176 
0177     /**
0178      * This method retrieves a \c Node using a name. It
0179      * first searches for a \c Node with a matching
0180      * \c id attribute. If it doesn't find one, it then searches
0181      * for a \c Node with a matching \c name
0182      * attribute, but only on those elements that are allowed a name
0183      * attribute.
0184      *
0185      * @param name The name of the \c Node to be fetched.
0186      *
0187      * @return The \c Node with a \c name or
0188      * \c id attribute whose value corresponds to the
0189      * specified string. Upon failure (e.g., no node with this name
0190      * exists), returns \c null .
0191      *
0192      */
0193     Node namedItem(const DOMString &name) const;
0194 
0195     /**
0196      * @internal
0197      * not part of the DOM
0198      */
0199     Node base() const;
0200     HTMLCollectionImpl *handle() const;
0201     bool isNull() const;
0202     // Fast iteration
0203     Node firstItem() const;
0204     Node nextItem() const;
0205     // In case of multiple items named the same way
0206     Node nextNamedItem(const DOMString &name) const;
0207 
0208 protected:
0209     HTMLCollectionImpl *impl;
0210 };
0211 
0212 class KHTML_EXPORT HTMLFormCollection : public HTMLCollection
0213 {
0214     friend class HTMLFormElement;
0215 protected:
0216     HTMLFormCollection(NodeImpl *base);
0217 };
0218 
0219 } //namespace
0220 
0221 #endif