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_XPathExpression_h
7 #define mozilla_dom_XPathExpression_h
9 #include "nsCycleCollectionParticipant.h"
10 #include "nsIWeakReferenceUtils.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/NonRefcountedDOMObject.h"
13 #include "mozilla/dom/XPathExpressionBinding.h"
14 #include "mozilla/UniquePtr.h"
19 class txResultRecycler
;
21 namespace mozilla::dom
{
27 * A class for evaluating an XPath expression string
29 class XPathExpression final
: public NonRefcountedDOMObject
{
31 XPathExpression(mozilla::UniquePtr
<Expr
>&& aExpression
,
32 txResultRecycler
* aRecycler
, Document
* aDocument
);
35 bool WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
,
36 JS::MutableHandle
<JSObject
*> aReflector
) {
37 return XPathExpression_Binding::Wrap(aCx
, this, aGivenProto
, aReflector
);
40 already_AddRefed
<XPathResult
> Evaluate(JSContext
* aCx
, nsINode
& aContextNode
,
42 JS::Handle
<JSObject
*> aInResult
,
44 return EvaluateWithContext(aCx
, aContextNode
, 1, 1, aType
, aInResult
, aRv
);
46 already_AddRefed
<XPathResult
> EvaluateWithContext(
47 JSContext
* aCx
, nsINode
& aContextNode
, uint32_t aContextPosition
,
48 uint32_t aContextSize
, uint16_t aType
, JS::Handle
<JSObject
*> aInResult
,
50 already_AddRefed
<XPathResult
> Evaluate(nsINode
& aContextNode
, uint16_t aType
,
51 XPathResult
* aInResult
,
53 return EvaluateWithContext(aContextNode
, 1, 1, aType
, aInResult
, aRv
);
55 already_AddRefed
<XPathResult
> EvaluateWithContext(
56 nsINode
& aContextNode
, uint32_t aContextPosition
, uint32_t aContextSize
,
57 uint16_t aType
, XPathResult
* aInResult
, ErrorResult
& aRv
);
60 mozilla::UniquePtr
<Expr
> mExpression
;
61 RefPtr
<txResultRecycler
> mRecycler
;
66 } // namespace mozilla::dom
68 #endif /* mozilla_dom_XPathExpression_h */