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"
29 #include <qptrvector.h>
37 class HTMLBaseFontElementImpl : public HTMLElementImpl
40 HTMLBaseFontElementImpl(DocumentPtr *doc);
42 ~HTMLBaseFontElementImpl();
44 virtual Id id() const;
47 // -------------------------------------------------------------------------
49 class HTMLCollectionImpl : public khtml::Shared<HTMLCollectionImpl>
51 friend class DOM::HTMLCollection;
55 DOC_IMAGES = 0, // all IMG elements in the document
56 DOC_APPLETS, // all OBJECT and APPLET elements
57 DOC_EMBEDS, // all EMBED elements
58 DOC_FORMS, // all FORMS
59 DOC_LINKS, // all A _and_ AREA elements with a value for href
60 DOC_ANCHORS, // all A elements with a value for name
61 // from HTMLTable, HTMLTableSection, HTMLTableRow
62 TABLE_ROWS, // all rows in this table or tablesection
63 TABLE_TBODIES, // all TBODY elements in this table
64 TSECTION_ROWS, // all rows elements in this table section
65 TR_CELLS, // all CELLS in this row
70 DOC_ALL, // "all" elements (IE)
71 NODE_CHILDREN, // first-level children (IE)
75 HTMLCollectionImpl(NodeImpl *_base, int _tagId);
76 virtual ~HTMLCollectionImpl();
78 unsigned long length() const;
80 virtual NodeImpl *item ( unsigned long index ) const;
81 virtual NodeImpl *firstItem() const;
82 virtual NodeImpl *nextItem() const;
84 NodeImpl *namedItem ( const DOMString &name, bool caseSensitive = true ) const;
85 // In case of multiple items named the same way
86 NodeImpl *nextNamedItem( const DOMString &name ) const;
88 QValueList<Node> namedItems( const DOMString &name ) const;
90 struct CollectionInfo {
95 unsigned int position;
98 int elementsArrayPosition;
99 QDict<QPtrVector<NodeImpl> > idCache;
100 QDict<QPtrVector<NodeImpl> > nameCache;
105 virtual void updateNameCache() const;
107 virtual NodeImpl *traverseNextItem(NodeImpl *start) const;
108 bool checkForNameMatch(NodeImpl *node, bool checkName, const DOMString &name, bool caseSensitive) const;
109 virtual unsigned long calcLength() const;
110 virtual void resetCollectionInfo() const;
111 // the base node, the collection refers to
113 // The collection list the following elements
115 mutable CollectionInfo *info;
117 // For nextNamedItem()
118 mutable bool idsDone;
121 // this whole class is just a big hack to find form elements even in
122 // malformed HTML elements
123 // the famous <table><tr><form><td> problem
124 class HTMLFormCollectionImpl : public HTMLCollectionImpl
127 // base must inherit HTMLGenericFormElementImpl or this won't work
128 HTMLFormCollectionImpl(NodeImpl* _base);
129 ~HTMLFormCollectionImpl();
131 virtual NodeImpl *item ( unsigned long index ) const;
132 virtual NodeImpl *firstItem() const;
133 virtual NodeImpl *nextItem() const;
135 NodeImpl *namedItem ( const DOMString &name, bool caseSensitive = true ) const;
136 NodeImpl *nextNamedItem( const DOMString &name ) const;
139 virtual void updateNameCache() const;
140 virtual unsigned long calcLength() const;
141 virtual NodeImpl *getNamedItem(NodeImpl* current, int attr_id, const DOMString& name, bool caseSensitive) const;
142 virtual NodeImpl *nextNamedItemInternal( const DOMString &name ) const;
144 NodeImpl* getNamedFormItem(int attr_id, const DOMString& name, int duplicateNumber, bool caseSensitive) const;
145 mutable int currentPos;