• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • dom
dom2_traversal.h
Go to the documentation of this file.
1/*
2 * This file is part of the DOM implementation for KDE.
3 *
4 * Copyright 1999 Lars Knoll (knoll@kde.org)
5 * Copyright 2000 Frederik Holljen (frederik.holljen@hig.no)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 * This file includes excerpts from the Document Object Model (DOM)
22 * Level 2 Specification (Candidate Recommendation)
23 * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
24 * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
25 *
26 */
27#ifndef _dom2_traversal_h_
28#define _dom2_traversal_h_
29
30#include <khtml_export.h>
31#include <dom/dom_node.h>
32#include <dom/dom_misc.h>
33
34namespace DOM {
35class Node;
36class NodeFilter;
37class NodeIteratorImpl;
38class NodeFilterImpl;
39class TreeWalkerImpl;
40class CustomNodeFilter;
41class CustomNodeFilterImpl;
42
59class KHTML_EXPORT NodeIterator
60{
61 friend class NodeIteratorImpl;
62 friend class Document;
63public:
64 NodeIterator();
65 NodeIterator(const NodeIterator &other);
66
67 NodeIterator & operator = (const NodeIterator &other);
68
69 ~NodeIterator();
70
74 Node root();
75
83 unsigned long whatToShow();
84
88 NodeFilter filter();
89
106 bool expandEntityReferences();
107
122 Node nextNode();
123
137 Node previousNode();
138
145 void detach();
146
151 NodeIteratorImpl *handle() const;
152 bool isNull() const;
153
154protected:
155 NodeIteratorImpl *impl;
156 NodeIterator(NodeIteratorImpl *i);
157};
158
159
183class KHTML_EXPORT NodeFilter
184{
185 friend class NodeIterator;
186 friend class NodeIteratorImpl;
187 friend class TreeWalker;
188 friend class TreeWalkerImpl;
189 friend class NodeFilterImpl;
190public:
191 NodeFilter();
192 NodeFilter(const NodeFilter &other);
193 NodeFilter(NodeFilterImpl *i);
194
195 virtual NodeFilter & operator = (const NodeFilter &other);
196
197 virtual ~NodeFilter();
203 enum AcceptCode {
204 FILTER_ACCEPT = 1,
205 FILTER_REJECT = 2,
206 FILTER_SKIP = 3
207 };
208
216 enum ShowCode {
217 SHOW_ALL = (int)0xFFFFFFFF,
218 SHOW_ELEMENT = 0x00000001,
219 SHOW_ATTRIBUTE = 0x00000002,
220 SHOW_TEXT = 0x00000004,
221 SHOW_CDATA_SECTION = 0x00000008,
222 SHOW_ENTITY_REFERENCE = 0x00000010,
223 SHOW_ENTITY = 0x00000020,
224 SHOW_PROCESSING_INSTRUCTION = 0x00000040,
225 SHOW_COMMENT = 0x00000080,
226 SHOW_DOCUMENT = 0x00000100,
227 SHOW_DOCUMENT_TYPE = 0x00000200,
228 SHOW_DOCUMENT_FRAGMENT = 0x00000400,
229 SHOW_NOTATION = 0x00000800
230 };
231
246 virtual short acceptNode (const Node &n);
247
252 virtual NodeFilterImpl *handle() const;
253 virtual bool isNull() const;
254
255 void setCustomNodeFilter(CustomNodeFilter *custom);
256 CustomNodeFilter *customNodeFilter();
257 static NodeFilter createCustom(CustomNodeFilter *custom);
258
259protected:
260 NodeFilterImpl *impl;
261};
262
293
294class KHTML_EXPORT CustomNodeFilter : public DomShared {
295public:
296 CustomNodeFilter();
297 virtual ~CustomNodeFilter();
298 virtual short acceptNode (const Node &n);
299 virtual bool isNull();
300
309 virtual DOMString customNodeFilterType();
310
311protected:
316 CustomNodeFilterImpl *impl;
317};
318
338class KHTML_EXPORT TreeWalker
339{
340 friend class Document;
341 friend class TreeWalkerImpl;
342public:
343 TreeWalker();
344 TreeWalker(const TreeWalker &other);
345
346 TreeWalker & operator = (const TreeWalker &other);
347
348 ~TreeWalker();
349
350
354 Node root();
355
363 unsigned long whatToShow();
364
368 NodeFilter filter();
369
384 bool expandEntityReferences();
385
399 Node currentNode();
400
404 void setCurrentNode(const Node &_currentNode);
405
420 Node parentNode();
421
436 Node firstChild();
437
452 Node lastChild();
453
468 Node previousSibling();
469
484 Node nextSibling();
485
500 Node previousNode();
501
516 Node nextNode();
517
522 TreeWalkerImpl *handle() const;
523 bool isNull() const;
524
525protected:
526 TreeWalker(TreeWalkerImpl *i);
527 TreeWalkerImpl *impl;
528};
529
530
531} // namespace
532
533#endif
DOM::CustomNodeFilter
CustomNodeFilter can be used to define your own NodeFilter for use with NodeIterators and TreeWalkers...
Definition dom2_traversal.h:294
DOM::CustomNodeFilter::impl
CustomNodeFilterImpl * impl
Definition dom2_traversal.h:316
DOM::CustomNodeFilter::customNodeFilterType
virtual DOMString customNodeFilterType()
Definition dom2_traversal.cpp:224
DOM::CustomNodeFilter::CustomNodeFilter
CustomNodeFilter()
Definition dom2_traversal.cpp:205
DOM::CustomNodeFilter::isNull
virtual bool isNull()
Definition dom2_traversal.cpp:219
DOM::CustomNodeFilter::acceptNode
virtual short acceptNode(const Node &n)
Definition dom2_traversal.cpp:214
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition dom_string.h:44
DOM::DomShared::DomShared
DomShared()
Definition dom_misc.h:39
DOM::NodeFilter
Filters are objects that know how to "filter out" nodes.
Definition dom2_traversal.h:184
DOM::NodeFilter::TreeWalkerImpl
friend class TreeWalkerImpl
Definition dom2_traversal.h:188
DOM::NodeFilter::NodeIteratorImpl
friend class NodeIteratorImpl
Definition dom2_traversal.h:186
DOM::NodeFilter::NodeFilterImpl
friend class NodeFilterImpl
Definition dom2_traversal.h:189
DOM::NodeFilter::NodeFilter
NodeFilter()
Definition dom2_traversal.cpp:137
DOM::NodeFilter::AcceptCode
AcceptCode
The following constants are returned by the acceptNode() method:
Definition dom2_traversal.h:203
DOM::NodeFilter::FILTER_REJECT
@ FILTER_REJECT
Definition dom2_traversal.h:205
DOM::NodeFilter::FILTER_ACCEPT
@ FILTER_ACCEPT
Definition dom2_traversal.h:204
DOM::NodeFilter::FILTER_SKIP
@ FILTER_SKIP
Definition dom2_traversal.h:206
DOM::NodeFilter::TreeWalker
friend class TreeWalker
Definition dom2_traversal.h:187
DOM::NodeFilter::NodeIterator
friend class NodeIterator
Definition dom2_traversal.h:185
DOM::NodeFilter::impl
NodeFilterImpl * impl
Definition dom2_traversal.h:260
DOM::NodeFilter::ShowCode
ShowCode
These are the available values for the whatToShow parameter.
Definition dom2_traversal.h:216
DOM::NodeFilter::SHOW_ENTITY
@ SHOW_ENTITY
Definition dom2_traversal.h:223
DOM::NodeFilter::SHOW_ALL
@ SHOW_ALL
Definition dom2_traversal.h:217
DOM::NodeFilter::SHOW_DOCUMENT_TYPE
@ SHOW_DOCUMENT_TYPE
Definition dom2_traversal.h:227
DOM::NodeFilter::SHOW_ELEMENT
@ SHOW_ELEMENT
Definition dom2_traversal.h:218
DOM::NodeFilter::SHOW_TEXT
@ SHOW_TEXT
Definition dom2_traversal.h:220
DOM::NodeFilter::SHOW_CDATA_SECTION
@ SHOW_CDATA_SECTION
Definition dom2_traversal.h:221
DOM::NodeFilter::SHOW_DOCUMENT
@ SHOW_DOCUMENT
Definition dom2_traversal.h:226
DOM::NodeFilter::SHOW_ENTITY_REFERENCE
@ SHOW_ENTITY_REFERENCE
Definition dom2_traversal.h:222
DOM::NodeFilter::SHOW_NOTATION
@ SHOW_NOTATION
Definition dom2_traversal.h:229
DOM::NodeFilter::SHOW_ATTRIBUTE
@ SHOW_ATTRIBUTE
Definition dom2_traversal.h:219
DOM::NodeFilter::SHOW_PROCESSING_INSTRUCTION
@ SHOW_PROCESSING_INSTRUCTION
Definition dom2_traversal.h:224
DOM::NodeFilter::SHOW_COMMENT
@ SHOW_COMMENT
Definition dom2_traversal.h:225
DOM::NodeFilter::SHOW_DOCUMENT_FRAGMENT
@ SHOW_DOCUMENT_FRAGMENT
Definition dom2_traversal.h:228
DOM::NodeIterator::root
Node root()
The root node of the NodeIterator, as specified when it was created.
Definition dom2_traversal.cpp:63
DOM::NodeIterator::detach
void detach()
Detaches the NodeIterator from the set which it iterated over, releasing any computational resources ...
Definition dom2_traversal.cpp:114
DOM::NodeIterator::filter
NodeFilter filter()
The NodeFilter used to screen nodes.
Definition dom2_traversal.cpp:75
DOM::NodeIterator::NodeIteratorImpl
friend class NodeIteratorImpl
Definition dom2_traversal.h:61
DOM::NodeIterator::whatToShow
unsigned long whatToShow()
This attribute determines which node types are presented via the iterator.
Definition dom2_traversal.cpp:69
DOM::NodeIterator::NodeIterator
NodeIterator()
Definition dom2_traversal.cpp:31
DOM::NodeIterator::impl
NodeIteratorImpl * impl
Definition dom2_traversal.h:155
DOM::NodeIterator::Document
friend class Document
Definition dom2_traversal.h:62
DOM::NodeIterator::handle
NodeIteratorImpl * handle() const
Definition dom2_traversal.cpp:125
DOM::NodeIterator::nextNode
Node nextNode()
Returns the next node in the set and advances the position of the Iterator in the set.
Definition dom2_traversal.cpp:87
DOM::NodeIterator::isNull
bool isNull() const
Definition dom2_traversal.cpp:130
DOM::NodeIterator::previousNode
Node previousNode()
Returns the previous node in the set and moves the position of the Iterator backwards in the set.
Definition dom2_traversal.cpp:100
DOM::NodeIterator::expandEntityReferences
bool expandEntityReferences()
The value of this flag determines whether the children of entity reference nodes are visible to the i...
Definition dom2_traversal.cpp:81
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition dom_node.h:271
DOM::TreeWalker::TreeWalkerImpl
friend class TreeWalkerImpl
Definition dom2_traversal.h:341
DOM::TreeWalker::previousNode
Node previousNode()
Moves the TreeWalker to the previous node in document order relative to the current node,...
Definition dom2_traversal.cpp:337
DOM::TreeWalker::handle
TreeWalkerImpl * handle() const
Definition dom2_traversal.cpp:351
DOM::TreeWalker::isNull
bool isNull() const
Definition dom2_traversal.cpp:356
DOM::TreeWalker::lastChild
Node lastChild()
Moves the TreeWalker to the last child of the current node, and returns the new node.
Definition dom2_traversal.cpp:316
DOM::TreeWalker::parentNode
Node parentNode()
Moves to and returns the parent node of the current node.
Definition dom2_traversal.cpp:302
DOM::TreeWalker::firstChild
Node firstChild()
Moves the TreeWalker to the first child of the current node, and returns the new node.
Definition dom2_traversal.cpp:309
DOM::TreeWalker::root
Node root()
The root node of the TreeWalker, as specified when it was created.
Definition dom2_traversal.cpp:264
DOM::TreeWalker::whatToShow
unsigned long whatToShow()
This attribute determines which node types are presented via the TreeWalker.
Definition dom2_traversal.cpp:270
DOM::TreeWalker::setCurrentNode
void setCurrentNode(const Node &_currentNode)
see currentNode
Definition dom2_traversal.cpp:294
DOM::TreeWalker::Document
friend class Document
Definition dom2_traversal.h:340
DOM::TreeWalker::expandEntityReferences
bool expandEntityReferences()
The value of this flag determines whether the children of entity reference nodes are visible to the T...
Definition dom2_traversal.cpp:282
DOM::TreeWalker::nextNode
Node nextNode()
Moves the TreeWalker to the next node in document order relative to the current node,...
Definition dom2_traversal.cpp:344
DOM::TreeWalker::currentNode
Node currentNode()
The node at which the TreeWalker is currently positioned.
Definition dom2_traversal.cpp:288
DOM::TreeWalker::filter
NodeFilter filter()
The filter used to screen nodes.
Definition dom2_traversal.cpp:276
DOM::TreeWalker::impl
TreeWalkerImpl * impl
Definition dom2_traversal.h:527
DOM::TreeWalker::nextSibling
Node nextSibling()
Moves the TreeWalker to the next sibling of the current node, and returns the new node.
Definition dom2_traversal.cpp:330
DOM::TreeWalker::previousSibling
Node previousSibling()
Moves the TreeWalker to the previous sibling of the current node, and returns the new node.
Definition dom2_traversal.cpp:323
DOM::TreeWalker::TreeWalker
TreeWalker()
Definition dom2_traversal.cpp:231
dom_misc.h
dom_node.h
khtml_export.h
DOM
This library provides a full-featured HTML parser and widget.
Definition design.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal