Part of fix for bug 278981 (Extension mechanism for XPath extension functions) - Support aggregation of nsXPathEvaluator. r/sr=jst.

This commit is contained in:
peterv%propagandism.org 2005-11-02 07:42:45 +00:00
parent 08767d5e9a
commit 57bf3369b1
3 changed files with 32 additions and 22 deletions

View File

@ -163,17 +163,21 @@ nsXPath1SchemeProcessor::Evaluate(nsIDOMDocument *aDocument,
if (!nsresolver) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsRefPtr<nsXPathEvaluator> e(new nsXPathEvaluator());
nsRefPtr<nsXPathEvaluator> e(new nsXPathEvaluator(nsnull));
if (!e) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = e->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMXPathResult> result;
nsresult rv = e->Evaluate(aData,
aDocument,
nsresolver,
nsIDOMXPathResult::ORDERED_NODE_ITERATOR_TYPE,
nsnull,
getter_AddRefs(result));
rv = e->Evaluate(aData,
aDocument,
nsresolver,
nsIDOMXPathResult::ORDERED_NODE_ITERATOR_TYPE,
nsnull,
getter_AddRefs(result));
if (NS_FAILED(rv)) {
if ((rv == NS_ERROR_DOM_INVALID_EXPRESSION_ERR) ||
(rv == NS_ERROR_DOM_NAMESPACE_ERR) ||

View File

@ -57,21 +57,24 @@
extern nsINameSpaceManager* gTxNameSpaceManager;
NS_IMPL_ADDREF(nsXPathEvaluator)
NS_IMPL_RELEASE(nsXPathEvaluator)
NS_INTERFACE_MAP_BEGIN(nsXPathEvaluator)
NS_INTERFACE_MAP_ENTRY(nsIDOMXPathEvaluator)
NS_INTERFACE_MAP_ENTRY(nsIXPathEvaluatorInternal)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMXPathEvaluator)
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XPathEvaluator)
NS_IMPL_AGGREGATED(nsXPathEvaluator)
NS_INTERFACE_MAP_BEGIN_AGGREGATED(nsXPathEvaluator)
NS_INTERFACE_MAP_ENTRY(nsIDOMXPathEvaluator)
NS_INTERFACE_MAP_ENTRY(nsIXPathEvaluatorInternal)
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XPathEvaluator)
NS_INTERFACE_MAP_END
nsXPathEvaluator::nsXPathEvaluator()
nsXPathEvaluator::nsXPathEvaluator(nsISupports *aOuter)
{
NS_INIT_AGGREGATED(aOuter);
}
nsXPathEvaluator::~nsXPathEvaluator()
nsresult
nsXPathEvaluator::Init()
{
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(fOuter);
return document ? SetDocument(document) : NS_OK;
}
NS_IMETHODIMP

View File

@ -45,8 +45,7 @@
#include "nsIWeakReference.h"
#include "nsAutoPtr.h"
#include "txResultRecycler.h"
class nsIDOMDocument;
#include "nsAgg.h"
/**
* A class for evaluating an XPath expression string
@ -55,11 +54,15 @@ class nsXPathEvaluator : public nsIDOMXPathEvaluator,
public nsIXPathEvaluatorInternal
{
public:
nsXPathEvaluator();
virtual ~nsXPathEvaluator();
nsXPathEvaluator(nsISupports *aOuter);
virtual ~nsXPathEvaluator()
{
}
// nsISupports interface
NS_DECL_ISUPPORTS
nsresult Init();
// nsISupports interface (support aggregation)
NS_DECL_AGGREGATED
// nsIDOMXPathEvaluator interface
NS_DECL_NSIDOMXPATHEVALUATOR