KHtml

kjs_xpath.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2010 Maksim Orlovich <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser 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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser 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 #include "kjs_binding.h"
20 #include "xml/dom3_xpathimpl.h"
21 
22 namespace KJS
23 {
24 
25 DEFINE_PSEUDO_CONSTRUCTOR(XPathResultPseudoCtor)
26 
27 class XPathResult: public DOMWrapperObject<khtml::XPathResultImpl>
28 {
29 public:
30  XPathResult(ExecState *exec, khtml::XPathResultImpl *impl);
31 
32  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
33  using JSObject::getOwnPropertySlot;
34  JSValue *getValueProperty(ExecState *exec, int token) const;
35 
36  const ClassInfo *classInfo() const override
37  {
38  return &info;
39  }
40  static const ClassInfo info;
41 
42  // The various constants are in separate constant table node
43  enum {
44  // properties:
45  ResultType, NumberValue, StringValue, BooleanValue,
46  SingleNodeValue, InvalidIteratorState, SnapshotLength,
47  // functions:
48  IterateNext, SnapshotItem
49  };
50 };
51 
52 DEFINE_PSEUDO_CONSTRUCTOR(XPathExpressionPseudoCtor)
53 
54 class XPathExpression: public DOMWrapperObject<khtml::XPathExpressionImpl>
55 {
56 public:
57  XPathExpression(ExecState *exec, khtml::XPathExpressionImpl *impl);
58 
59  const ClassInfo *classInfo() const override
60  {
61  return &info;
62  }
63  static const ClassInfo info;
64 
65  enum {
66  // functions:
67  Evaluate
68  };
69 
70  void mark() override;
71 
72  void setAssociatedResolver(JSObject *res)
73  {
74  jsResolver = res;
75  }
76 private:
77  JSObject *jsResolver; // see notes below.
78 };
79 
80 // For NS resolver, we need to do two things:
81 // 1) wrap native NS resolvers, such as those returned by
82 // Document::createNSResolver
83 //
84 // 2) Pass in JS-implemented resolvers to DOM methods, which might retain them.
85 // This is a bit tricky memory management-wise, as it involves the DOM
86 // referring to a JS object. The solution we take is to have the wrapper
87 // for XPathExpression mark the corresponding resolver.
88 //
89 // The class XPathNSResolver does (1)
90 // The class JSXPathNSResolver does (2).
91 //
92 // Further, the method ... to avoid having wrappers-inside-wrappers
93 DEFINE_PSEUDO_CONSTRUCTOR(XPathNSResolverPseudoCtor)
94 class XPathNSResolver: public DOMWrapperObject<khtml::XPathNSResolverImpl>
95 {
96 public:
97  XPathNSResolver(ExecState *exec, khtml::XPathNSResolverImpl *impl);
98 
99  const ClassInfo *classInfo() const override
100  {
101  return &info;
102  }
103  static const ClassInfo info;
104 
105  enum {
106  // functions:
107  LookupNamespaceURI
108  };
109 };
110 
111 class JSXPathNSResolver: public khtml::XPathNSResolverImpl
112 {
113 public:
114  JSXPathNSResolver(Interpreter *ctx, JSObject *impl);
115  Type type() override;
116  DOM::DOMString lookupNamespaceURI(const DOM::DOMString &prefix) override;
117 
118  JSObject *resolverObject()
119  {
120  return impl;
121  }
122 private:
123  JSObject *impl;
124  Interpreter *ctx;
125 };
126 
127 // Convert JS -> DOM. Might make a new JSXPathNSResolver. It does not
128 // protect the JS resolver from collection in any way.
129 khtml::XPathNSResolverImpl *toResolver(ExecState *exec, JSValue *impl);
130 
131 }
132 
This file is part of the HTML rendering engine for KDE.
Type type(const QSqlDatabase &db)
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:06 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.