2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsXPathExpression_h__
|
|
|
|
#define nsXPathExpression_h__
|
|
|
|
|
|
|
|
#include "nsIDOMXPathExpression.h"
|
|
|
|
#include "nsIDOMNSXPathExpression.h"
|
|
|
|
#include "txIXPathContext.h"
|
|
|
|
#include "txResultRecycler.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2007-09-27 09:39:13 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class Expr;
|
|
|
|
class txXPathNode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class for evaluating an XPath expression string
|
|
|
|
*/
|
2012-06-18 19:30:09 -07:00
|
|
|
class nsXPathExpression MOZ_FINAL : public nsIDOMXPathExpression,
|
|
|
|
public nsIDOMNSXPathExpression
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXPathExpression(nsAutoPtr<Expr>& aExpression, txResultRecycler* aRecycler,
|
|
|
|
nsIDOMDocument *aDocument);
|
|
|
|
|
|
|
|
// nsISupports interface
|
2007-09-27 09:39:13 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXPathExpression,
|
|
|
|
nsIDOMXPathExpression)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIDOMXPathExpression interface
|
|
|
|
NS_DECL_NSIDOMXPATHEXPRESSION
|
|
|
|
|
|
|
|
// nsIDOMNSXPathExpression interface
|
|
|
|
NS_DECL_NSIDOMNSXPATHEXPRESSION
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsAutoPtr<Expr> mExpression;
|
|
|
|
nsRefPtr<txResultRecycler> mRecycler;
|
|
|
|
nsCOMPtr<nsIDOMDocument> mDocument;
|
|
|
|
|
|
|
|
class EvalContextImpl : public txIEvalContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EvalContextImpl(const txXPathNode& aContextNode,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aContextPosition, uint32_t aContextSize,
|
2007-03-22 10:30:00 -07:00
|
|
|
txResultRecycler* aRecycler)
|
|
|
|
: mContextNode(aContextNode),
|
|
|
|
mContextPosition(aContextPosition),
|
|
|
|
mContextSize(aContextSize),
|
|
|
|
mLastError(NS_OK),
|
|
|
|
mRecycler(aRecycler)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult getError()
|
|
|
|
{
|
|
|
|
return mLastError;
|
|
|
|
}
|
|
|
|
|
|
|
|
TX_DECL_EVAL_CONTEXT;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const txXPathNode& mContextNode;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mContextPosition;
|
|
|
|
uint32_t mContextSize;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult mLastError;
|
|
|
|
nsRefPtr<txResultRecycler> mRecycler;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|