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)
72 DOC_NAMEABLE_ITEMS, // all IMG, FORM, APPLET, EMBED and OBJECT elements, used to look
73 // up element name as document property
77 HTMLCollectionImpl(NodeImpl *_base, int _tagId);
78 virtual ~HTMLCollectionImpl();
80 unsigned long length() const;
82 virtual NodeImpl *item ( unsigned long index ) const;
83 virtual NodeImpl *firstItem() const;
84 virtual NodeImpl *nextItem() const;
86 NodeImpl *namedItem ( const DOMString &name, bool caseSensitive = true ) const;
87 // In case of multiple items named the same way
88 NodeImpl *nextNamedItem( const DOMString &name ) const;
90 QValueList<Node> namedItems( const DOMString &name ) const;
92 struct CollectionInfo {
97 unsigned int position;
100 int elementsArrayPosition;
101 QDict<QPtrVector<NodeImpl> > idCache;
102 QDict<QPtrVector<NodeImpl> > nameCache;
107 virtual void updateNameCache() const;
109 virtual NodeImpl *traverseNextItem(NodeImpl *start) const;
110 bool checkForNameMatch(NodeImpl *node, bool checkName, const DOMString &name, bool caseSensitive) const;
111 virtual unsigned long calcLength() const;
112 virtual void resetCollectionInfo() const;
113 // the base node, the collection refers to
115 // The collection list the following elements
117 mutable CollectionInfo *info;
119 // For nextNamedItem()
120 mutable bool idsDone;
123 // this whole class is just a big hack to find form elements even in
124 // malformed HTML elements
125 // the famous <table><tr><form><td> problem
126 class HTMLFormCollectionImpl : public HTMLCollectionImpl
129 // base must inherit HTMLGenericFormElementImpl or this won't work
130 HTMLFormCollectionImpl(NodeImpl* _base);
131 ~HTMLFormCollectionImpl();
133 virtual NodeImpl *item ( unsigned long index ) const;
134 virtual NodeImpl *firstItem() const;
135 virtual NodeImpl *nextItem() const;
137 NodeImpl *namedItem ( const DOMString &name, bool caseSensitive = true ) const;
138 NodeImpl *nextNamedItem( const DOMString &name ) const;
141 virtual void updateNameCache() const;
142 virtual unsigned long calcLength() const;
143 virtual NodeImpl *getNamedItem(NodeImpl* current, int attr_id, const DOMString& name, bool caseSensitive) const;
144 virtual NodeImpl *nextNamedItemInternal( const DOMString &name ) const;
146 NodeImpl* getNamedFormItem(int attr_id, const DOMString& name, int duplicateNumber, bool caseSensitive) const;
147 mutable int currentPos;