2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef HTML_MISCIMPL_H
24 #define HTML_MISCIMPL_H
26 #include "html_elementimpl.h"
27 #include "misc/shared.h"
35 class HTMLBaseFontElementImpl : public HTMLElementImpl
38 HTMLBaseFontElementImpl(DocumentPtr *doc);
40 ~HTMLBaseFontElementImpl();
42 virtual Id id() const;
45 // -------------------------------------------------------------------------
47 class HTMLCollectionImpl : public khtml::Shared<HTMLCollectionImpl>
49 friend class DOM::HTMLCollection;
53 DOC_IMAGES = 0, // all IMG elements in the document
54 DOC_APPLETS, // all OBJECT and APPLET elements
55 DOC_EMBEDS, // all EMBED elements
56 DOC_FORMS, // all FORMS
57 DOC_LINKS, // all A _and_ AREA elements with a value for href
58 DOC_ANCHORS, // all A elements with a value for name
59 // from HTMLTable, HTMLTableSection, HTMLTableRow
60 TABLE_ROWS, // all rows in this table or tablesection
61 TABLE_TBODIES, // all TBODY elements in this table
62 TSECTION_ROWS, // all rows elements in this table section
63 TR_CELLS, // all CELLS in this row
68 DOC_ALL, // "all" elements (IE)
69 NODE_CHILDREN, // first-level children (IE)
73 HTMLCollectionImpl(NodeImpl *_base, int _tagId);
74 virtual ~HTMLCollectionImpl();
76 unsigned long length() const;
78 virtual NodeImpl *item ( unsigned long index ) const;
79 virtual NodeImpl *firstItem() const;
80 virtual NodeImpl *nextItem() const;
82 NodeImpl *namedItem ( const DOMString &name, bool caseSensitive = true ) const;
83 // In case of multiple items named the same way
84 NodeImpl *nextNamedItem( const DOMString &name ) const;
86 struct CollectionInfo {
87 CollectionInfo() : version(0), current(0), position(0), length(0), haslength(false) {}
90 unsigned int position;
96 virtual unsigned long calcLength(NodeImpl *current) const;
97 virtual NodeImpl *getItem(NodeImpl *current, int index, int &pos) const;
98 virtual NodeImpl *getNamedItem(NodeImpl *current, int attr_id, const DOMString &name, bool caseSensitive = true) const;
99 virtual NodeImpl *nextNamedItemInternal( const DOMString &name ) const;
100 virtual void resetCollectionInfo() const;
101 // the base node, the collection refers to
103 // The collection list the following elements
105 mutable CollectionInfo *info;
107 // For nextNamedItem()
108 mutable bool idsDone;
111 // this whole class is just a big hack to find form elements even in
112 // malformed HTML elements
113 // the famous <table><tr><form><td> problem
114 class HTMLFormCollectionImpl : public HTMLCollectionImpl
117 // base must inherit HTMLGenericFormElementImpl or this won't work
118 HTMLFormCollectionImpl(NodeImpl* _base)
119 : HTMLCollectionImpl(_base, 0)
121 ~HTMLFormCollectionImpl() {}
123 struct FormCollectionInfo {
124 FormCollectionInfo();
126 int elementsArrayPosition;
129 virtual NodeImpl *item ( unsigned long index ) const;
130 virtual NodeImpl *firstItem() const;
131 virtual NodeImpl *nextItem() const;
133 virtual unsigned long calcLength(NodeImpl* current) const;
134 virtual NodeImpl *getNamedItem(NodeImpl* current, int attr_id, const DOMString& name, bool caseSensitive) const;
135 virtual NodeImpl *nextNamedItemInternal( const DOMString &name ) const;
137 virtual void resetCollectionInfo() const;
138 NodeImpl* getNamedFormItem(int attr_id, const DOMString& name, int duplicateNumber, bool caseSensitive) const;
139 mutable FormCollectionInfo formInfo;
140 mutable int currentPos;