1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_XPathEvaluator_h
7 #define mozilla_dom_XPathEvaluator_h
9 #include "mozilla/dom/NonRefcountedDOMObject.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/Document.h"
15 class txIParseContext
;
16 class txResultRecycler
;
24 class XPathExpression
;
25 class XPathNSResolver
;
29 * A class for evaluating an XPath expression string
31 class XPathEvaluator final
: public NonRefcountedDOMObject
{
33 explicit XPathEvaluator(Document
* aDocument
= nullptr);
37 bool WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
,
38 JS::MutableHandle
<JSObject
*> aReflector
);
39 Document
* GetParentObject() { return mDocument
; }
40 static UniquePtr
<XPathEvaluator
> Constructor(const GlobalObject
& aGlobal
);
41 UniquePtr
<XPathExpression
> CreateExpression(const nsAString
& aExpression
,
42 XPathNSResolver
* aResolver
,
44 UniquePtr
<XPathExpression
> CreateExpression(const nsAString
& aExpression
,
47 UniquePtr
<XPathExpression
> CreateExpression(const nsAString
& aExpression
,
48 txIParseContext
* aContext
,
51 nsINode
* CreateNSResolver(nsINode
& aNodeResolver
) { return &aNodeResolver
; }
52 already_AddRefed
<XPathResult
> Evaluate(
53 JSContext
* aCx
, const nsAString
& aExpression
, nsINode
& aContextNode
,
54 XPathNSResolver
* aResolver
, uint16_t aType
, JS::Handle
<JSObject
*> aResult
,
58 WeakPtr
<Document
> mDocument
;
59 RefPtr
<txResultRecycler
> mRecycler
;
63 } // namespace mozilla
65 #endif /* mozilla_dom_XPathEvaluator_h */