michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_XPathEvaluator_h michael@0: #define mozilla_dom_XPathEvaluator_h michael@0: michael@0: #include "nsIDOMXPathEvaluator.h" michael@0: #include "nsIWeakReference.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "nsIDocument.h" michael@0: michael@0: class nsINode; michael@0: class txResultRecycler; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class GlobalObject; michael@0: michael@0: /** michael@0: * A class for evaluating an XPath expression string michael@0: */ michael@0: class XPathEvaluator MOZ_FINAL : public nsIDOMXPathEvaluator michael@0: { michael@0: public: michael@0: XPathEvaluator(nsIDocument* aDocument = nullptr); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsIDOMXPathEvaluator interface michael@0: NS_DECL_NSIDOMXPATHEVALUATOR michael@0: michael@0: // WebIDL API michael@0: JSObject* WrapObject(JSContext* aCx); michael@0: nsIDocument* GetParentObject() michael@0: { michael@0: nsCOMPtr doc = do_QueryReferent(mDocument); michael@0: return doc; michael@0: } michael@0: static already_AddRefed michael@0: Constructor(const GlobalObject& aGlobal, ErrorResult& rv); michael@0: already_AddRefed michael@0: CreateExpression(const nsAString& aExpression, michael@0: nsIDOMXPathNSResolver* aResolver, michael@0: ErrorResult& rv); michael@0: already_AddRefed michael@0: CreateNSResolver(nsINode* aNodeResolver, ErrorResult& rv); michael@0: already_AddRefed michael@0: Evaluate(const nsAString& aExpression, nsINode* aContextNode, michael@0: nsIDOMXPathNSResolver* aResolver, uint16_t aType, michael@0: nsISupports* aResult, ErrorResult& rv); michael@0: private: michael@0: nsWeakPtr mDocument; michael@0: nsRefPtr mRecycler; michael@0: }; michael@0: michael@0: inline nsISupports* michael@0: ToSupports(XPathEvaluator* e) michael@0: { michael@0: return static_cast(e); michael@0: } michael@0: michael@0: /* d0a75e02-b5e7-11d5-a7f2-df109fb8a1fc */ michael@0: #define TRANSFORMIIX_XPATH_EVALUATOR_CID \ michael@0: { 0xd0a75e02, 0xb5e7, 0x11d5, { 0xa7, 0xf2, 0xdf, 0x10, 0x9f, 0xb8, 0xa1, 0xfc } } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* mozilla_dom_XPathEvaluator_h */