KHtml

kjs_traversal.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2001 Peter Kelly ([email protected])
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef _KJS_TRAVERSAL_H_
21 #define _KJS_TRAVERSAL_H_
22 
23 #include "ecma/kjs_binding.h"
24 #include "ecma/kjs_dom.h"
25 #include "dom/dom2_traversal.h"
26 
27 namespace KJS
28 {
29 
30 class DOMNodeIterator : public DOMObject
31 {
32 public:
33  DOMNodeIterator(ExecState *exec, DOM::NodeIteratorImpl *ni);
34  ~DOMNodeIterator();
35  using KJS::JSObject::getOwnPropertySlot;
36  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
37  JSValue *getValueProperty(ExecState *exec, int token) const;
38  // no put - all read-only
39  const ClassInfo *classInfo() const override
40  {
41  return &info;
42  }
43  static const ClassInfo info;
44  enum { Filter, Root, WhatToShow, ExpandEntityReferences,
45  NextNode, PreviousNode, Detach
46  };
47  DOM::NodeIteratorImpl *impl() const
48  {
49  return m_impl.get();
50  }
51 protected:
52  SharedPtr<DOM::NodeIteratorImpl> m_impl;
53 };
54 
55 // Constructor object NodeFilter
56 class NodeFilterConstructor : public DOMObject
57 {
58 public:
59  NodeFilterConstructor(ExecState *);
60  using KJS::JSObject::getOwnPropertySlot;
61  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
62  JSValue *getValueProperty(ExecState *exec, int token) const;
63  // no put - all read-only
64  const ClassInfo *classInfo() const override
65  {
66  return &info;
67  }
68  static const ClassInfo info;
69 };
70 
71 class DOMTreeWalker : public DOMObject
72 {
73 public:
74  DOMTreeWalker(ExecState *exec, DOM::TreeWalkerImpl *tw);
75  ~DOMTreeWalker();
76  using KJS::JSObject::getOwnPropertySlot;
77  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
78  JSValue *getValueProperty(ExecState *exec, int token) const;
79  void mark() override;
80  using KJS::JSObject::put;
81  virtual void put(ExecState *exec, const Identifier &propertyName,
82  JSValue *value, int attr = None) override;
83  const ClassInfo *classInfo() const override
84  {
85  return &info;
86  }
87  static const ClassInfo info;
88  enum { Root, WhatToShow, Filter, ExpandEntityReferences, CurrentNode,
89  ParentNode, FirstChild, LastChild, PreviousSibling, NextSibling,
90  PreviousNode, NextNode
91  };
92  DOM::TreeWalkerImpl *impl() const
93  {
94  return m_impl.get();
95  }
96 protected:
97  SharedPtr<DOM::TreeWalkerImpl> m_impl;
98 };
99 
100 JSValue *getDOMNodeIterator(ExecState *exec, DOM::NodeIteratorImpl *ni);
101 JSValue *getNodeFilterConstructor(ExecState *exec);
102 JSValue *getDOMNodeFilter(ExecState *exec, DOM::NodeFilterImpl *nf);
103 JSValue *getDOMTreeWalker(ExecState *exec, DOM::TreeWalkerImpl *tw);
104 
105 /**
106  * Convert an object to a NodeFilter. Returns a null Node if not possible.
107  */
108 DOM::NodeFilterImpl *toNodeFilter(JSValue *);
109 
110 class JSNodeFilter : public DOM::NodeFilterImpl
111 {
112 public:
113  JSNodeFilter(JSObject *_filter);
114  virtual ~JSNodeFilter();
115 
116  bool isJSFilter() const override;
117  short acceptNode(const DOM::Node &n, void *&bindingsException) override;
118 
119  void mark();
120 
121  JSObject *filter() const
122  {
123  return m_filter;
124  }
125 
126  // Extracts a JSNodeFilter contained insode a DOM::NodeFilterImpl,
127  // if any (or returns 0);
128  static JSNodeFilter *fromDOMFilter(DOM::NodeFilterImpl *nf);
129 protected:
130  // The filter here can be either a function or
131  // an object with the acceptNode property. We will use either one.
132 
133  // Memory management note: we expect the wrapper object to mark us.
134  JSObject *m_filter;
135 };
136 
137 } // namespace
138 
139 #endif
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
KIOCORE_EXPORT TransferJob * put(const QUrl &url, int permissions, JobFlags flags=DefaultFlags)
QFuture< void > filter(Sequence &sequence, KeepFunctor filterFunction)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.