Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_XPathEvaluator_h |
michael@0 | 7 | #define mozilla_dom_XPathEvaluator_h |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIDOMXPathEvaluator.h" |
michael@0 | 10 | #include "nsIWeakReference.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | #include "mozilla/Attributes.h" |
michael@0 | 14 | #include "mozilla/ErrorResult.h" |
michael@0 | 15 | #include "nsIDocument.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsINode; |
michael@0 | 18 | class txResultRecycler; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | namespace dom { |
michael@0 | 22 | |
michael@0 | 23 | class GlobalObject; |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * A class for evaluating an XPath expression string |
michael@0 | 27 | */ |
michael@0 | 28 | class XPathEvaluator MOZ_FINAL : public nsIDOMXPathEvaluator |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | XPathEvaluator(nsIDocument* aDocument = nullptr); |
michael@0 | 32 | |
michael@0 | 33 | NS_DECL_ISUPPORTS |
michael@0 | 34 | |
michael@0 | 35 | // nsIDOMXPathEvaluator interface |
michael@0 | 36 | NS_DECL_NSIDOMXPATHEVALUATOR |
michael@0 | 37 | |
michael@0 | 38 | // WebIDL API |
michael@0 | 39 | JSObject* WrapObject(JSContext* aCx); |
michael@0 | 40 | nsIDocument* GetParentObject() |
michael@0 | 41 | { |
michael@0 | 42 | nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument); |
michael@0 | 43 | return doc; |
michael@0 | 44 | } |
michael@0 | 45 | static already_AddRefed<XPathEvaluator> |
michael@0 | 46 | Constructor(const GlobalObject& aGlobal, ErrorResult& rv); |
michael@0 | 47 | already_AddRefed<nsIDOMXPathExpression> |
michael@0 | 48 | CreateExpression(const nsAString& aExpression, |
michael@0 | 49 | nsIDOMXPathNSResolver* aResolver, |
michael@0 | 50 | ErrorResult& rv); |
michael@0 | 51 | already_AddRefed<nsIDOMXPathNSResolver> |
michael@0 | 52 | CreateNSResolver(nsINode* aNodeResolver, ErrorResult& rv); |
michael@0 | 53 | already_AddRefed<nsISupports> |
michael@0 | 54 | Evaluate(const nsAString& aExpression, nsINode* aContextNode, |
michael@0 | 55 | nsIDOMXPathNSResolver* aResolver, uint16_t aType, |
michael@0 | 56 | nsISupports* aResult, ErrorResult& rv); |
michael@0 | 57 | private: |
michael@0 | 58 | nsWeakPtr mDocument; |
michael@0 | 59 | nsRefPtr<txResultRecycler> mRecycler; |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | inline nsISupports* |
michael@0 | 63 | ToSupports(XPathEvaluator* e) |
michael@0 | 64 | { |
michael@0 | 65 | return static_cast<nsIDOMXPathEvaluator*>(e); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | /* d0a75e02-b5e7-11d5-a7f2-df109fb8a1fc */ |
michael@0 | 69 | #define TRANSFORMIIX_XPATH_EVALUATOR_CID \ |
michael@0 | 70 | { 0xd0a75e02, 0xb5e7, 0x11d5, { 0xa7, 0xf2, 0xdf, 0x10, 0x9f, 0xb8, 0xa1, 0xfc } } |
michael@0 | 71 | |
michael@0 | 72 | } // namespace dom |
michael@0 | 73 | } // namespace mozilla |
michael@0 | 74 | |
michael@0 | 75 | #endif /* mozilla_dom_XPathEvaluator_h */ |