KHtml

html_miscimpl.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 1999 Lars Knoll ([email protected])
5  * (C) 1999 Antti Koivisto ([email protected])
6  *
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.
11  *
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.
16  *
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., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 #ifndef HTML_MISCIMPL_H
24 #define HTML_MISCIMPL_H
25 
26 #include "html_elementimpl.h"
27 #include "xml/dom_nodelistimpl.h"
28 #include "misc/shared.h"
29 
30 namespace DOM
31 {
32 
33 class Node;
34 class DOMString;
35 class HTMLCollection;
36 
37 class HTMLBaseFontElementImpl : public HTMLElementImpl
38 {
39 public:
40  HTMLBaseFontElementImpl(DocumentImpl *doc);
41 
42  ~HTMLBaseFontElementImpl();
43 
44  Id id() const override;
45 };
46 
47 // -------------------------------------------------------------------------
48 
49 class HTMLCollectionImpl : public DynamicNodeListImpl
50 {
51  friend class DOM::HTMLCollection;
52 public:
53  enum Type {
54  // from HTMLDocument
55  DOC_IMAGES = LAST_NODE_LIST + 1, // all IMG elements in the document
56  DOC_APPLETS, // all OBJECT and APPLET elements
57  DOC_FORMS, // all FORMS
58  DOC_LAYERS, // all LAYERS
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  DOC_SCRIPTS, // all SCRIPT elements
62  // from HTMLTable, HTMLTableSection, HTMLTableRow
63  TABLE_ROWS, // all rows in this table
64  TABLE_TBODIES, // all TBODY elements in this table
65  TSECTION_ROWS, // all rows elements in this table section
66  TR_CELLS, // all CELLS in this row
67  // from SELECT
68  SELECT_OPTIONS,
69  // from HTMLMap
70  MAP_AREAS,
71  FORMLESS_INPUT, // input elements that do not have form associated w/them
72  DOC_ALL, // "all" elements (IE)
73  NODE_CHILDREN, // first-level children (IE)
74  FORM_ELEMENTS, // input elements in a form
75  WINDOW_NAMED_ITEMS,
76  DOCUMENT_NAMED_ITEMS,
77  LAST_TYPE
78  };
79 
80  HTMLCollectionImpl(NodeImpl *_base, int _tagId);
81 
82  NodeImpl *item(unsigned long index) const override;
83 
84  // obsolete and not domtree changes save
85  virtual NodeImpl *firstItem() const;
86  virtual NodeImpl *nextItem() const;
87 
88  virtual NodeImpl *namedItem(const DOMString &name) const;
89  // In case of multiple items named the same way
90  virtual NodeImpl *nextNamedItem(const DOMString &name) const;
91 
92  QList<NodeImpl *> namedItems(const DOMString &name) const;
93 
94  int getType() const
95  {
96  return type;
97  }
98 
99  NodeImpl *base()
100  {
101  return m_refNode;
102  }
103 protected:
104  unsigned long calcLength(NodeImpl *start) const override;
105 
106  // The collection list the following elements
107  int type: 8;
108 
109  // Reimplemented from DynamicNodeListImpl
110  bool nodeMatches(NodeImpl *testNode, bool &doRecurse) const override;
111 
112  // Helper for name iteration: checks whether ID matches,
113  // and inserts any name-matching things into namedItemsWithName
114  bool checkForNameMatch(NodeImpl *node, const DOMString &name) const;
115 };
116 
117 // this whole class is just a big hack to find form elements even in
118 // malformed HTML elements
119 // the famous <table><tr><form><td> problem
120 class HTMLFormCollectionImpl : public HTMLCollectionImpl
121 {
122 public:
123  // base must inherit HTMLGenericFormElementImpl or this won't work
124  HTMLFormCollectionImpl(NodeImpl *_base);
125  ~HTMLFormCollectionImpl() { }
126 
127  NodeImpl *item(unsigned long index) const override;
128 
129  NodeImpl *namedItem(const DOMString &name) const override;
130  // In case of multiple items named the same way
131  NodeImpl *nextNamedItem(const DOMString &name) const override;
132 protected:
133  unsigned long calcLength(NodeImpl *start) const override;
134 
135 private:
136  mutable unsigned currentNamePos;
137  mutable unsigned currentNameImgPos;
138  mutable bool foundInput;
139 };
140 
141 /*
142  Special collection for items of given name/id under document. or window.; but using
143  iteration interface
144 */
145 class HTMLMappedNameCollectionImpl : public HTMLCollectionImpl
146 {
147 public:
148  HTMLMappedNameCollectionImpl(NodeImpl *_base, int type, const DOMString &name);
149  bool nodeMatches(NodeImpl *testNode, bool &doRecurse) const override;
150 
151  static bool matchesName(ElementImpl *el, int type, const DOMString &name);
152 private:
153  DOMString name;
154 };
155 
156 } //namespace
157 
158 #endif
QString name(const QVariant &location)
An HTMLCollection is a list of nodes.
Definition: html_misc.h:133
Type type(const QSqlDatabase &db)
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
int64_t Id
This library provides a full-featured HTML parser and widget.
Node base() const
Definition: html_misc.cpp:195
Node item(unsigned long index) const
This method retrieves a node specified by ordinal index.
Definition: html_misc.cpp:179
Node namedItem(const DOMString &name) const
This method retrieves a Node using a name.
Definition: html_misc.cpp:187
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.