Bug 1029104 - Convert XPathExpression to WebIDL bindings, move EvalContextImpl out of header. r=bz.

--HG--
rename : dom/xslt/xpath/nsXPathExpression.cpp => dom/xslt/xpath/XPathExpression.cpp
rename : dom/xslt/xpath/nsXPathExpression.h => dom/xslt/xpath/XPathExpression.h
extra : rebase_source : a8f2deb3244c8e556ff1778292dd1f96647f3ace
This commit is contained in:
Peter Van der Beken 2013-07-09 12:09:39 -04:00
parent 24fc02615b
commit d185434119
3 changed files with 40 additions and 41 deletions

View File

@ -20,6 +20,7 @@
#include "nsDOMString.h"
#include "nsNameSpaceManager.h"
#include "nsContentUtils.h"
#include "txIXPathContext.h"
#include "mozilla/dom/XPathEvaluatorBinding.h"
#include "mozilla/dom/BindingUtils.h"

View File

@ -22,6 +22,35 @@ DOMCI_DATA(XPathExpression, mozilla::dom::XPathExpression)
namespace mozilla {
namespace dom {
class EvalContextImpl : public txIEvalContext
{
public:
EvalContextImpl(const txXPathNode& aContextNode,
uint32_t aContextPosition, uint32_t aContextSize,
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;
uint32_t mContextPosition;
uint32_t mContextSize;
nsresult mLastError;
nsRefPtr<txResultRecycler> mRecycler;
};
NS_IMPL_CYCLE_COLLECTION(XPathExpression, mDocument)
NS_IMPL_CYCLE_COLLECTING_ADDREF(XPathExpression)
@ -157,55 +186,54 @@ XPathExpression::EvaluateWithContext(nsIDOMNode *aContextNode,
*/
nsresult
XPathExpression::EvalContextImpl::getVariable(int32_t aNamespace,
nsIAtom* aLName,
txAExprResult*& aResult)
EvalContextImpl::getVariable(int32_t aNamespace,
nsIAtom* aLName,
txAExprResult*& aResult)
{
aResult = 0;
return NS_ERROR_INVALID_ARG;
}
bool
XPathExpression::EvalContextImpl::isStripSpaceAllowed(const txXPathNode& aNode)
EvalContextImpl::isStripSpaceAllowed(const txXPathNode& aNode)
{
return false;
}
void*
XPathExpression::EvalContextImpl::getPrivateContext()
EvalContextImpl::getPrivateContext()
{
// we don't have a private context here.
return nullptr;
}
txResultRecycler*
XPathExpression::EvalContextImpl::recycler()
EvalContextImpl::recycler()
{
return mRecycler;
}
void
XPathExpression::EvalContextImpl::receiveError(const nsAString& aMsg,
nsresult aRes)
EvalContextImpl::receiveError(const nsAString& aMsg, nsresult aRes)
{
mLastError = aRes;
// forward aMsg to console service?
}
const txXPathNode&
XPathExpression::EvalContextImpl::getContextNode()
EvalContextImpl::getContextNode()
{
return mContextNode;
}
uint32_t
XPathExpression::EvalContextImpl::size()
EvalContextImpl::size()
{
return mContextSize;
}
uint32_t
XPathExpression::EvalContextImpl::position()
EvalContextImpl::position()
{
return mContextPosition;
}

View File

@ -8,7 +8,6 @@
#include "nsIDOMXPathExpression.h"
#include "nsIDOMNSXPathExpression.h"
#include "txIXPathContext.h"
#include "txResultRecycler.h"
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
@ -47,35 +46,6 @@ private:
nsAutoPtr<Expr> mExpression;
nsRefPtr<txResultRecycler> mRecycler;
nsCOMPtr<nsIDOMDocument> mDocument;
class EvalContextImpl : public txIEvalContext
{
public:
EvalContextImpl(const txXPathNode& aContextNode,
uint32_t aContextPosition, uint32_t aContextSize,
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;
uint32_t mContextPosition;
uint32_t mContextSize;
nsresult mLastError;
nsRefPtr<txResultRecycler> mRecycler;
};
};
} // namespace dom