1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/xpath/nsXPathExpression.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsXPathExpression_h__ 1.10 +#define nsXPathExpression_h__ 1.11 + 1.12 +#include "nsIDOMXPathExpression.h" 1.13 +#include "nsIDOMNSXPathExpression.h" 1.14 +#include "txIXPathContext.h" 1.15 +#include "txResultRecycler.h" 1.16 +#include "nsAutoPtr.h" 1.17 +#include "nsCycleCollectionParticipant.h" 1.18 +#include "mozilla/Attributes.h" 1.19 + 1.20 +class Expr; 1.21 +class txXPathNode; 1.22 + 1.23 +/** 1.24 + * A class for evaluating an XPath expression string 1.25 + */ 1.26 +class nsXPathExpression MOZ_FINAL : public nsIDOMXPathExpression, 1.27 + public nsIDOMNSXPathExpression 1.28 +{ 1.29 +public: 1.30 + nsXPathExpression(nsAutoPtr<Expr>& aExpression, txResultRecycler* aRecycler, 1.31 + nsIDOMDocument *aDocument); 1.32 + 1.33 + // nsISupports interface 1.34 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.35 + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXPathExpression, 1.36 + nsIDOMXPathExpression) 1.37 + 1.38 + // nsIDOMXPathExpression interface 1.39 + NS_DECL_NSIDOMXPATHEXPRESSION 1.40 + 1.41 + // nsIDOMNSXPathExpression interface 1.42 + NS_DECL_NSIDOMNSXPATHEXPRESSION 1.43 + 1.44 +private: 1.45 + nsAutoPtr<Expr> mExpression; 1.46 + nsRefPtr<txResultRecycler> mRecycler; 1.47 + nsCOMPtr<nsIDOMDocument> mDocument; 1.48 + 1.49 + class EvalContextImpl : public txIEvalContext 1.50 + { 1.51 + public: 1.52 + EvalContextImpl(const txXPathNode& aContextNode, 1.53 + uint32_t aContextPosition, uint32_t aContextSize, 1.54 + txResultRecycler* aRecycler) 1.55 + : mContextNode(aContextNode), 1.56 + mContextPosition(aContextPosition), 1.57 + mContextSize(aContextSize), 1.58 + mLastError(NS_OK), 1.59 + mRecycler(aRecycler) 1.60 + { 1.61 + } 1.62 + 1.63 + nsresult getError() 1.64 + { 1.65 + return mLastError; 1.66 + } 1.67 + 1.68 + TX_DECL_EVAL_CONTEXT; 1.69 + 1.70 + private: 1.71 + const txXPathNode& mContextNode; 1.72 + uint32_t mContextPosition; 1.73 + uint32_t mContextSize; 1.74 + nsresult mLastError; 1.75 + nsRefPtr<txResultRecycler> mRecycler; 1.76 + }; 1.77 +}; 1.78 + 1.79 +#endif