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) { if (!nsresolver) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
nsRefPtr<nsXPathEvaluator> e(new nsXPathEvaluator()); nsRefPtr<nsXPathEvaluator> e(new nsXPathEvaluator(nsnull));
if (!e) { if (!e) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
nsresult rv = e->Init();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMXPathResult> result; nsCOMPtr<nsIDOMXPathResult> result;
nsresult rv = e->Evaluate(aData, rv = e->Evaluate(aData,
aDocument, aDocument,
nsresolver, nsresolver,
nsIDOMXPathResult::ORDERED_NODE_ITERATOR_TYPE, nsIDOMXPathResult::ORDERED_NODE_ITERATOR_TYPE,
nsnull, nsnull,
getter_AddRefs(result)); getter_AddRefs(result));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
if ((rv == NS_ERROR_DOM_INVALID_EXPRESSION_ERR) || if ((rv == NS_ERROR_DOM_INVALID_EXPRESSION_ERR) ||
(rv == NS_ERROR_DOM_NAMESPACE_ERR) || (rv == NS_ERROR_DOM_NAMESPACE_ERR) ||

View File

@ -57,21 +57,24 @@
extern nsINameSpaceManager* gTxNameSpaceManager; extern nsINameSpaceManager* gTxNameSpaceManager;
NS_IMPL_ADDREF(nsXPathEvaluator) NS_IMPL_AGGREGATED(nsXPathEvaluator)
NS_IMPL_RELEASE(nsXPathEvaluator) NS_INTERFACE_MAP_BEGIN_AGGREGATED(nsXPathEvaluator)
NS_INTERFACE_MAP_BEGIN(nsXPathEvaluator) NS_INTERFACE_MAP_ENTRY(nsIDOMXPathEvaluator)
NS_INTERFACE_MAP_ENTRY(nsIDOMXPathEvaluator) NS_INTERFACE_MAP_ENTRY(nsIXPathEvaluatorInternal)
NS_INTERFACE_MAP_ENTRY(nsIXPathEvaluatorInternal) NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XPathEvaluator)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMXPathEvaluator)
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XPathEvaluator)
NS_INTERFACE_MAP_END 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 NS_IMETHODIMP

View File

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