Part of fix for bug 278981 (Extension mechanism for XPath extension functions) - Support aggregation of nsXPathEvaluator. r/sr=jst.
This commit is contained in:
Родитель
4f736e2a69
Коммит
7d2561e337
|
@ -118,6 +118,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
|||
#include "nsHTMLAtoms.h"
|
||||
|
||||
#include "nsScriptEventManager.h"
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
#include "nsIXPathEvaluatorInternal.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
|
@ -667,35 +668,6 @@ nsDocumentChildNodes::DropReference()
|
|||
mDocument = nsnull;
|
||||
}
|
||||
|
||||
class nsXPathDocumentTearoff : public nsIDOMXPathEvaluator
|
||||
{
|
||||
public:
|
||||
nsXPathDocumentTearoff(nsIDOMXPathEvaluator* aEvaluator,
|
||||
nsIDocument* aDocument)
|
||||
: mEvaluator(aEvaluator), mDocument(aDocument)
|
||||
{
|
||||
}
|
||||
virtual ~nsXPathDocumentTearoff()
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_FORWARD_NSIDOMXPATHEVALUATOR(mEvaluator->)
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMXPathEvaluator> mEvaluator;
|
||||
nsIDocument* mDocument;
|
||||
};
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsXPathDocumentTearoff)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXPathEvaluator)
|
||||
NS_INTERFACE_MAP_END_AGGREGATED(mDocument)
|
||||
|
||||
NS_IMPL_ADDREF_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
|
||||
NS_IMPL_RELEASE_USING_AGGREGATOR(nsXPathDocumentTearoff, mDocument)
|
||||
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
// ==================================================================
|
||||
|
@ -808,7 +780,6 @@ nsDocument::~nsDocument()
|
|||
|
||||
delete mHeaderData;
|
||||
delete mBoxObjectTable;
|
||||
delete mXPathDocument;
|
||||
}
|
||||
|
||||
PRBool gCheckedForXPathDOM = PR_FALSE;
|
||||
|
@ -837,38 +808,32 @@ NS_INTERFACE_MAP_BEGIN(nsDocument)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRadioGroupContainer)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocument)
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator))) {
|
||||
nsresult rv;
|
||||
if (!gCheckedForXPathDOM) {
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
rv = NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIXPathEvaluatorInternal))) {
|
||||
if (!mXPathEvaluatorTearoff) {
|
||||
nsresult rv;
|
||||
if (!gCheckedForXPathDOM) {
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
rv = NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
gCheckedForXPathDOM = PR_TRUE;
|
||||
gCheckedForXPathDOM = PR_TRUE;
|
||||
|
||||
cr->IsContractIDRegistered(NS_XPATH_EVALUATOR_CONTRACTID,
|
||||
&gHaveXPathDOM);
|
||||
}
|
||||
|
||||
if (!gHaveXPathDOM) {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (!mXPathDocument) {
|
||||
nsCOMPtr<nsIDOMXPathEvaluator> evaluator;
|
||||
evaluator = do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIXPathEvaluatorInternal> internal =
|
||||
do_QueryInterface(evaluator);
|
||||
if (internal) {
|
||||
internal->SetDocument(this);
|
||||
cr->IsContractIDRegistered(NS_XPATH_EVALUATOR_CONTRACTID,
|
||||
&gHaveXPathDOM);
|
||||
}
|
||||
|
||||
mXPathDocument = new nsXPathDocumentTearoff(evaluator, this);
|
||||
NS_ENSURE_TRUE(mXPathDocument, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (!gHaveXPathDOM) {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
mXPathEvaluatorTearoff =
|
||||
do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID,
|
||||
NS_STATIC_CAST(nsIDocument *, this), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
foundInterface = mXPathDocument;
|
||||
|
||||
return mXPathEvaluatorTearoff->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
else
|
||||
NS_INTERFACE_MAP_END
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
#include "nsIURI.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
#include "nsIRadioGroupContainer.h"
|
||||
#include "nsIScriptEventManager.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
|
@ -103,7 +102,6 @@ class nsDOMStyleSheetList;
|
|||
class nsIOutputStream;
|
||||
class nsDocument;
|
||||
class nsIDTD;
|
||||
class nsXPathDocumentTearoff;
|
||||
class nsIRadioVisitor;
|
||||
class nsIFormControl;
|
||||
struct nsRadioGroupStruct;
|
||||
|
@ -768,7 +766,7 @@ private:
|
|||
|
||||
nsSmallVoidArray mPresShells;
|
||||
|
||||
nsXPathDocumentTearoff* mXPathDocument;
|
||||
nsCOMPtr<nsISupports> mXPathEvaluatorTearoff;
|
||||
|
||||
// The layout history state that should be used by nodes in this
|
||||
// document. We only actually store a pointer to it when:
|
||||
|
|
|
@ -1,324 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Peter Van der Beken.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@propagandism.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIDOMNSXPathExpression.h"
|
||||
#include "nsIDOMXPathExpression.h"
|
||||
#include "nsIDOMXPathNSResolver.h"
|
||||
#include "nsIDOMXPathResult.h"
|
||||
#include "nsIErrorService.h"
|
||||
#include "nsIExceptionService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXPathEvaluator.h"
|
||||
#include "nsXPathException.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "txAtoms.h"
|
||||
#include "txMozillaXSLTProcessor.h"
|
||||
#include "TxLog.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "txXSLTProcessor.h"
|
||||
#include "nsXPath1Scheme.h"
|
||||
|
||||
#ifndef DISABLE_XFORMS_HOOKS
|
||||
#include "nsXFormsXPathEvaluator.h"
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPath1SchemeProcessor)
|
||||
|
||||
/* 1c1a3c01-14f6-11d6-a7f2-ea502af815dc */
|
||||
#define TRANSFORMIIX_DOMCI_EXTENSION_CID \
|
||||
{ 0x1c1a3c01, 0x14f6, 0x11d6, {0xa7, 0xf2, 0xea, 0x50, 0x2a, 0xf8, 0x15, 0xdc} }
|
||||
|
||||
/* {0C351177-0159-4500-86B0-A219DFDE4258} */
|
||||
#define TRANSFORMIIX_XPATH1_SCHEME_CID \
|
||||
{ 0xc351177, 0x159, 0x4500, { 0x86, 0xb0, 0xa2, 0x19, 0xdf, 0xde, 0x42, 0x58 } }
|
||||
|
||||
#define TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID \
|
||||
"@mozilla.org/transformiix-domci-extender;1"
|
||||
|
||||
NS_DOMCI_EXTENSION(Transformiix)
|
||||
static NS_DEFINE_CID(kXSLTProcessorCID, TRANSFORMIIX_XSLT_PROCESSOR_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XSLTProcessor)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIXSLTProcessor)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIXSLTProcessorObsolete) // XXX DEPRECATED
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XSLTProcessor, nsIXSLTProcessor, PR_TRUE,
|
||||
&kXSLTProcessorCID)
|
||||
|
||||
static NS_DEFINE_CID(kXPathEvaluatorCID, TRANSFORMIIX_XPATH_EVALUATOR_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathEvaluator)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathEvaluator)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathEvaluator, nsIDOMXPathEvaluator, PR_TRUE,
|
||||
&kXPathEvaluatorCID)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathException)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathException)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIException)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathException, nsIDOMXPathException, PR_TRUE,
|
||||
nsnull)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathExpression)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathExpression)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMNSXPathExpression)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathExpression, nsIDOMXPathExpression,
|
||||
PR_TRUE, nsnull)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathNSResolver)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathNSResolver)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathNSResolver, nsIDOMXPathNSResolver,
|
||||
PR_TRUE, nsnull)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathResult)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathResult)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathResult, nsIDOMXPathResult, PR_TRUE,
|
||||
nsnull)
|
||||
NS_DOMCI_EXTENSION_END
|
||||
|
||||
// Factory Constructor
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(txMozillaXSLTProcessor)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPathEvaluator)
|
||||
#ifndef DISABLE_XFORMS_HOOKS
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXFormsXPathEvaluator)
|
||||
#endif
|
||||
|
||||
NS_DECL_DOM_CLASSINFO(XSLTProcessor)
|
||||
NS_DECL_DOM_CLASSINFO(XPathEvaluator)
|
||||
NS_DECL_DOM_CLASSINFO(XPathException)
|
||||
NS_DECL_DOM_CLASSINFO(XPathExpression)
|
||||
NS_DECL_DOM_CLASSINFO(XPathNSResolver)
|
||||
NS_DECL_DOM_CLASSINFO(XPathResult)
|
||||
|
||||
static NS_METHOD
|
||||
RegisterTransformiix(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsXPIDLCString previous;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XSLTProcessor",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathEvaluator",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathException",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathExpression",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathNSResolver",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathResult",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char* iidString = NS_GET_IID(nsIXSLTProcessorObsolete).ToString();
|
||||
if (!iidString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIXSLTProcessorObsolete",
|
||||
iidString,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
nsCRT::free(iidString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
iidString = NS_GET_IID(nsIXSLTProcessor).ToString();
|
||||
if (!iidString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIXSLTProcessor",
|
||||
iidString,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
nsCRT::free(iidString);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
static nsIExceptionProvider *gXPathExceptionProvider = 0;
|
||||
nsINameSpaceManager *gTxNameSpaceManager = 0;
|
||||
nsIParserService *gTxParserService = 0;
|
||||
|
||||
// Perform our one-time intialization for this module
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
Initialize(nsIModule* aSelf)
|
||||
{
|
||||
NS_PRECONDITION(!gInitialized, "module already initialized");
|
||||
if (gInitialized)
|
||||
return NS_OK;
|
||||
|
||||
gInitialized = PR_TRUE;
|
||||
|
||||
gXPathExceptionProvider = new nsXPathExceptionProvider();
|
||||
if (!gXPathExceptionProvider)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(gXPathExceptionProvider);
|
||||
nsCOMPtr<nsIExceptionService> xs =
|
||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
||||
if (xs)
|
||||
xs->RegisterExceptionProvider(gXPathExceptionProvider,
|
||||
NS_ERROR_MODULE_DOM_XPATH);
|
||||
|
||||
if (!txXSLTProcessor::init()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID,
|
||||
&gTxSecurityManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
gTxSecurityManager = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CallGetService(NS_NAMESPACEMANAGER_CONTRACTID, &gTxNameSpaceManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
gTxNameSpaceManager = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CallGetService("@mozilla.org/parser/parser-service;1",
|
||||
&gTxParserService);
|
||||
if (NS_FAILED(rv)) {
|
||||
gTxParserService = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIErrorService> errorService =
|
||||
do_GetService(NS_ERRORSERVICE_CONTRACTID);
|
||||
if (errorService) {
|
||||
errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_XSLT,
|
||||
XSLT_MSGS_URL);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Shutdown this module, releasing all of the module resources
|
||||
PR_STATIC_CALLBACK(void)
|
||||
Shutdown(nsIModule* aSelf)
|
||||
{
|
||||
NS_PRECONDITION(gInitialized, "module not initialized");
|
||||
if (!gInitialized)
|
||||
return;
|
||||
|
||||
gInitialized = PR_FALSE;
|
||||
if (gXPathExceptionProvider) {
|
||||
nsCOMPtr<nsIExceptionService> xs =
|
||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
||||
if (xs)
|
||||
xs->UnregisterExceptionProvider(gXPathExceptionProvider,
|
||||
NS_ERROR_MODULE_DOM_XPATH);
|
||||
NS_RELEASE(gXPathExceptionProvider);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XSLTProcessor));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathEvaluator));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathException));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathExpression));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathNSResolver));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathResult));
|
||||
|
||||
txXSLTProcessor::shutdown();
|
||||
|
||||
NS_IF_RELEASE(gTxSecurityManager);
|
||||
NS_IF_RELEASE(gTxNameSpaceManager);
|
||||
NS_IF_RELEASE(gTxParserService);
|
||||
}
|
||||
|
||||
// Component Table
|
||||
static const nsModuleComponentInfo gComponents[] = {
|
||||
{ "XSLTProcessor",
|
||||
TRANSFORMIIX_XSLT_PROCESSOR_CID,
|
||||
TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID,
|
||||
txMozillaXSLTProcessorConstructor,
|
||||
RegisterTransformiix },
|
||||
{ "XPathEvaluator",
|
||||
TRANSFORMIIX_XPATH_EVALUATOR_CID,
|
||||
NS_XPATH_EVALUATOR_CONTRACTID,
|
||||
nsXPathEvaluatorConstructor },
|
||||
#ifndef DISABLE_XFORMS_HOOKS
|
||||
{ "XFormsXPathEvaluator",
|
||||
TRANSFORMIIX_XFORMS_XPATH_EVALUATOR_CID,
|
||||
NS_XFORMS_XPATH_EVALUATOR_CONTRACTID,
|
||||
nsXFormsXPathEvaluatorConstructor },
|
||||
#endif
|
||||
{ "Transformiix DOMCI Extender",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CID,
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
NS_DOMCI_EXTENSION_CONSTRUCTOR(Transformiix) },
|
||||
{ "XPath1 XPointer Scheme Processor",
|
||||
TRANSFORMIIX_XPATH1_SCHEME_CID,
|
||||
NS_XPOINTER_SCHEME_PROCESSOR_BASE "xpath1",
|
||||
nsXPath1SchemeProcessorConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(TransformiixModule, gComponents,
|
||||
Initialize, Shutdown)
|
|
@ -1,234 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Heikki Toivonen <heikki@netscape.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* This file implements the xpath1 XPointer scheme, and the xmlns scheme
|
||||
* as well but only for xpath1.
|
||||
*
|
||||
* http://www.simonstl.com/ietf/draft-stlaurent-xpath-frag-00.html
|
||||
*/
|
||||
|
||||
#include "nsXPath1Scheme.h"
|
||||
#include "nsXPathEvaluator.h"
|
||||
#include "nsXPathException.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsXPathResult.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMXPathNSResolver.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIModifyableXPointer.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
|
||||
|
||||
/**
|
||||
* nsXPath1SchemeNSResolver
|
||||
*
|
||||
* This will effectively give us xmlns scheme support.
|
||||
*/
|
||||
class nsXPath1SchemeNSResolver : public nsIDOMXPathNSResolver
|
||||
{
|
||||
public:
|
||||
nsXPath1SchemeNSResolver(nsIXPointerSchemeContext *aContext)
|
||||
: mContext(aContext)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsXPath1SchemeNSResolver()
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMXPATHNSRESOLVER
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIXPointerSchemeContext> mContext;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXPath1SchemeNSResolver, nsIDOMXPathNSResolver)
|
||||
|
||||
//DOMString lookupNamespaceURI(in DOMString prefix);
|
||||
NS_IMETHODIMP
|
||||
nsXPath1SchemeNSResolver::LookupNamespaceURI(const nsAString &aPrefix,
|
||||
nsAString &aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
|
||||
// This method will be called each time the XPath engine encounters
|
||||
// a prefix.
|
||||
|
||||
// We could cache the extracted prefix + URI pairs in a hash table,
|
||||
// and do a lookup from that first. But typical XPointers only have
|
||||
// a few scheme + data pairs (and only some of those will be xmlns
|
||||
// schemes), and typical XPath expressions only have a few prefixes
|
||||
// as well, so we'll see if we can manage without...
|
||||
|
||||
if (!mContext) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(xmlns, "xmlns");
|
||||
|
||||
PRUint32 count;
|
||||
mContext->GetCount(&count);
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsAutoString scheme, data;
|
||||
mContext->GetSchemeData(i, scheme, data);
|
||||
if (scheme.Equals(xmlns)) {
|
||||
PRInt32 sep = data.FindChar('=');
|
||||
if (sep > 0 && aPrefix.Equals(Substring(data, 0, sep))) {
|
||||
aURI.Assign(Substring(data, sep + 1, data.Length() - sep - 1));
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetDOMStringToNull(aURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsXPath1SchemeProcessor
|
||||
nsXPath1SchemeProcessor::nsXPath1SchemeProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
nsXPath1SchemeProcessor::~nsXPath1SchemeProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXPath1SchemeProcessor, nsIXPointerSchemeProcessor)
|
||||
|
||||
/**
|
||||
* Evaluate.
|
||||
*
|
||||
* @param aDocument The document in which to resolve the XPointer.
|
||||
* @param aContext The XPointer context in which to process aData.
|
||||
* @param aData The data in the scheme that needs to be resolved.
|
||||
* @return The result of the evaluation.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsXPath1SchemeProcessor::Evaluate(nsIDOMDocument *aDocument,
|
||||
nsIXPointerSchemeContext *aContext,
|
||||
const nsAString &aData,
|
||||
nsIXPointerResult **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocument);
|
||||
NS_ENSURE_ARG_POINTER(aContext);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
|
||||
// Resolve expression
|
||||
nsCOMPtr<nsIDOMXPathNSResolver> nsresolver(new nsXPath1SchemeNSResolver(aContext));
|
||||
if (!nsresolver) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsRefPtr<nsXPathEvaluator> e(new nsXPathEvaluator());
|
||||
if (!e) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsCOMPtr<nsIDOMXPathResult> result;
|
||||
nsresult 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) ||
|
||||
(rv == NS_ERROR_DOM_TYPE_ERR)) {
|
||||
// These errors are benign, change them to NS_OK so that
|
||||
// we will not terminate the processor.
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Create return result
|
||||
// XXX perf: just store the XPathResult and resolve as XPointerResult on demand
|
||||
nsCOMPtr<nsIXPointerResult> xpointerResult(
|
||||
do_CreateInstance("@mozilla.org/xmlextras/xpointerresult;1", &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIModifyableXPointerResult> privatePointerResult(do_QueryInterface(xpointerResult));
|
||||
if (!privatePointerResult) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
rv = result->IterateNext(getter_AddRefs(node));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Fill in return result
|
||||
while (node) {
|
||||
nsCOMPtr<nsIDOMRange> range(do_CreateInstance(kRangeCID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
rv = range->SelectNode(node);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
rv = privatePointerResult->AppendRange(range);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
rv = result->IterateNext(getter_AddRefs(node));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
}
|
||||
|
||||
PRUint32 count;
|
||||
xpointerResult->GetLength(&count);
|
||||
if (NS_SUCCEEDED(rv) && (count > 0)) {
|
||||
*aResult = xpointerResult;
|
||||
NS_ADDREF(*aResult);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -1,210 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@propagandism.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsXPathEvaluator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsXPathException.h"
|
||||
#include "nsXPathExpression.h"
|
||||
#include "nsXPathNSResolver.h"
|
||||
#include "nsXPathResult.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "Expr.h"
|
||||
#include "ExprParser.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "txError.h"
|
||||
|
||||
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_INTERFACE_MAP_END
|
||||
|
||||
nsXPathEvaluator::nsXPathEvaluator()
|
||||
{
|
||||
}
|
||||
|
||||
nsXPathEvaluator::~nsXPathEvaluator()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsIDOMXPathExpression **aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!mRecycler) {
|
||||
nsRefPtr<txResultRecycler> recycler = new txResultRecycler;
|
||||
NS_ENSURE_TRUE(recycler, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = recycler->init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mRecycler = recycler;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
|
||||
ParseContextImpl pContext(aResolver, !doc || doc->IsCaseSensitive());
|
||||
nsAutoPtr<Expr> expression;
|
||||
rv = txExprParser::createExpr(PromiseFlatString(aExpression), &pContext,
|
||||
getter_Transfers(expression));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv == NS_ERROR_DOM_NAMESPACE_ERR) {
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
return NS_ERROR_DOM_INVALID_EXPRESSION_ERR;
|
||||
}
|
||||
|
||||
*aResult = new nsXPathExpression(expression, mRecycler);
|
||||
if (!*aResult) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPathEvaluator::CreateNSResolver(nsIDOMNode *aNodeResolver,
|
||||
nsIDOMXPathNSResolver **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG(aNodeResolver);
|
||||
if (!URIUtils::CanCallerAccess(aNodeResolver))
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
|
||||
*aResult = new nsXPathNSResolver(aNodeResolver);
|
||||
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPathEvaluator::Evaluate(const nsAString & aExpression,
|
||||
nsIDOMNode *aContextNode,
|
||||
nsIDOMXPathNSResolver *aResolver,
|
||||
PRUint16 aType,
|
||||
nsISupports *aInResult,
|
||||
nsISupports **aResult)
|
||||
{
|
||||
// XXX Need to check document of aContextNode if created by
|
||||
// QI'ing a document.
|
||||
|
||||
nsCOMPtr<nsIDOMXPathExpression> expression;
|
||||
nsresult rv = CreateExpression(aExpression, aResolver,
|
||||
getter_AddRefs(expression));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return expression->Evaluate(aContextNode, aType, aInResult, aResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPathEvaluator::SetDocument(nsIDOMDocument* aDocument)
|
||||
{
|
||||
mDocument = do_GetWeakReference(aDocument);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of txIParseContext private to nsXPathEvaluator
|
||||
* ParseContextImpl bases on a nsIDOMXPathNSResolver
|
||||
*/
|
||||
|
||||
nsresult nsXPathEvaluator::ParseContextImpl::resolveNamespacePrefix
|
||||
(nsIAtom* aPrefix, PRInt32& aID)
|
||||
{
|
||||
aID = kNameSpaceID_Unknown;
|
||||
|
||||
if (!mResolver) {
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
nsAutoString prefix;
|
||||
if (aPrefix) {
|
||||
aPrefix->ToString(prefix);
|
||||
}
|
||||
|
||||
nsVoidableString ns;
|
||||
nsresult rv = mResolver->LookupNamespaceURI(prefix, ns);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (DOMStringIsNull(ns)) {
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
if (ns.IsEmpty()) {
|
||||
aID = kNameSpaceID_None;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// get the namespaceID for the URI
|
||||
return gTxNameSpaceManager->RegisterNameSpace(ns, aID);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXPathEvaluator::ParseContextImpl::resolveFunctionCall(nsIAtom* aName,
|
||||
PRInt32 aID,
|
||||
FunctionCall*& aFn)
|
||||
{
|
||||
return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
|
||||
}
|
||||
|
||||
PRBool nsXPathEvaluator::ParseContextImpl::caseInsensitiveNameTests()
|
||||
{
|
||||
return !mIsCaseSensitive;
|
||||
}
|
||||
|
||||
void
|
||||
nsXPathEvaluator::ParseContextImpl::SetErrorOffset(PRUint32 aOffset)
|
||||
{
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@propagandism.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsXPathEvaluator_h__
|
||||
#define nsXPathEvaluator_h__
|
||||
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
#include "txIXPathContext.h"
|
||||
#include "nsIXPathEvaluatorInternal.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "txResultRecycler.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
|
||||
/**
|
||||
* A class for evaluating an XPath expression string
|
||||
*/
|
||||
class nsXPathEvaluator : public nsIDOMXPathEvaluator,
|
||||
public nsIXPathEvaluatorInternal
|
||||
{
|
||||
public:
|
||||
nsXPathEvaluator();
|
||||
virtual ~nsXPathEvaluator();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMXPathEvaluator interface
|
||||
NS_DECL_NSIDOMXPATHEVALUATOR
|
||||
|
||||
// nsIXPathEvaluatorInternal interface
|
||||
NS_IMETHOD SetDocument(nsIDOMDocument* aDocument);
|
||||
|
||||
private:
|
||||
// txIParseContext implementation
|
||||
class ParseContextImpl : public txIParseContext
|
||||
{
|
||||
public:
|
||||
ParseContextImpl(nsIDOMXPathNSResolver* aResolver,
|
||||
PRBool aIsCaseSensitive)
|
||||
: mResolver(aResolver), mLastError(NS_OK),
|
||||
mIsCaseSensitive(aIsCaseSensitive)
|
||||
{
|
||||
}
|
||||
|
||||
~ParseContextImpl()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult getError()
|
||||
{
|
||||
return mLastError;
|
||||
}
|
||||
|
||||
nsresult resolveNamespacePrefix(nsIAtom* aPrefix, PRInt32& aID);
|
||||
nsresult resolveFunctionCall(nsIAtom* aName, PRInt32 aID,
|
||||
FunctionCall*& aFunction);
|
||||
PRBool caseInsensitiveNameTests();
|
||||
void SetErrorOffset(PRUint32 aOffset);
|
||||
|
||||
private:
|
||||
nsIDOMXPathNSResolver* mResolver;
|
||||
nsresult mLastError;
|
||||
PRBool mIsCaseSensitive;
|
||||
};
|
||||
|
||||
nsWeakPtr mDocument;
|
||||
nsRefPtr<txResultRecycler> mRecycler;
|
||||
};
|
||||
|
||||
/* d0a75e02-b5e7-11d5-a7f2-df109fb8a1fc */
|
||||
#define TRANSFORMIIX_XPATH_EVALUATOR_CID \
|
||||
{ 0xd0a75e02, 0xb5e7, 0x11d5, { 0xa7, 0xf2, 0xdf, 0x10, 0x9f, 0xb8, 0xa1, 0xfc } }
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче