|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
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/. */ |
|
5 |
|
6 #ifndef mozilla_dom_XPathEvaluator_h |
|
7 #define mozilla_dom_XPathEvaluator_h |
|
8 |
|
9 #include "nsIDOMXPathEvaluator.h" |
|
10 #include "nsIWeakReference.h" |
|
11 #include "nsAutoPtr.h" |
|
12 #include "nsString.h" |
|
13 #include "mozilla/Attributes.h" |
|
14 #include "mozilla/ErrorResult.h" |
|
15 #include "nsIDocument.h" |
|
16 |
|
17 class nsINode; |
|
18 class txResultRecycler; |
|
19 |
|
20 namespace mozilla { |
|
21 namespace dom { |
|
22 |
|
23 class GlobalObject; |
|
24 |
|
25 /** |
|
26 * A class for evaluating an XPath expression string |
|
27 */ |
|
28 class XPathEvaluator MOZ_FINAL : public nsIDOMXPathEvaluator |
|
29 { |
|
30 public: |
|
31 XPathEvaluator(nsIDocument* aDocument = nullptr); |
|
32 |
|
33 NS_DECL_ISUPPORTS |
|
34 |
|
35 // nsIDOMXPathEvaluator interface |
|
36 NS_DECL_NSIDOMXPATHEVALUATOR |
|
37 |
|
38 // WebIDL API |
|
39 JSObject* WrapObject(JSContext* aCx); |
|
40 nsIDocument* GetParentObject() |
|
41 { |
|
42 nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument); |
|
43 return doc; |
|
44 } |
|
45 static already_AddRefed<XPathEvaluator> |
|
46 Constructor(const GlobalObject& aGlobal, ErrorResult& rv); |
|
47 already_AddRefed<nsIDOMXPathExpression> |
|
48 CreateExpression(const nsAString& aExpression, |
|
49 nsIDOMXPathNSResolver* aResolver, |
|
50 ErrorResult& rv); |
|
51 already_AddRefed<nsIDOMXPathNSResolver> |
|
52 CreateNSResolver(nsINode* aNodeResolver, ErrorResult& rv); |
|
53 already_AddRefed<nsISupports> |
|
54 Evaluate(const nsAString& aExpression, nsINode* aContextNode, |
|
55 nsIDOMXPathNSResolver* aResolver, uint16_t aType, |
|
56 nsISupports* aResult, ErrorResult& rv); |
|
57 private: |
|
58 nsWeakPtr mDocument; |
|
59 nsRefPtr<txResultRecycler> mRecycler; |
|
60 }; |
|
61 |
|
62 inline nsISupports* |
|
63 ToSupports(XPathEvaluator* e) |
|
64 { |
|
65 return static_cast<nsIDOMXPathEvaluator*>(e); |
|
66 } |
|
67 |
|
68 /* d0a75e02-b5e7-11d5-a7f2-df109fb8a1fc */ |
|
69 #define TRANSFORMIIX_XPATH_EVALUATOR_CID \ |
|
70 { 0xd0a75e02, 0xb5e7, 0x11d5, { 0xa7, 0xf2, 0xdf, 0x10, 0x9f, 0xb8, 0xa1, 0xfc } } |
|
71 |
|
72 } // namespace dom |
|
73 } // namespace mozilla |
|
74 |
|
75 #endif /* mozilla_dom_XPathEvaluator_h */ |