зеркало из https://github.com/mozilla/pjs.git
Add DOM ClassInfo for Transformiix classes. r=Pike, sr=jst.
This commit is contained in:
Родитель
7c2b39f485
Коммит
9a92abfadc
|
@ -173,6 +173,11 @@ enum nsDOMClassInfoID {
|
|||
eDOMClassInfo_DOMSerializer_id,
|
||||
eDOMClassInfo_DOMParser_id,
|
||||
|
||||
// Transformiix classes
|
||||
eDOMClassInfo_XSLTProcessor_id,
|
||||
eDOMClassInfo_XPathProcessor_id,
|
||||
eDOMClassInfo_NodeSet_id,
|
||||
|
||||
// This one better be the last one in this list
|
||||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
|
|
@ -476,6 +476,14 @@ nsDOMClassInfoData sClassInfoData[] = {
|
|||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
// Transformiix classes
|
||||
NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(XPathProcessor, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(NodeSet, nsArraySH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
};
|
||||
|
||||
nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
|
||||
|
|
|
@ -26,13 +26,11 @@
|
|||
#include "nsIGenericFactory.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "prprf.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "XSLTProcessor.h"
|
||||
#include "XPathProcessor.h"
|
||||
#include "nsSyncLoader.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
// Factory Constructor
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(XSLTProcessor)
|
||||
|
@ -41,9 +39,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoader)
|
|||
|
||||
static NS_METHOD
|
||||
RegisterTransformiix(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMNodeList;
|
||||
#include "domstubs.idl"
|
||||
%{C++
|
||||
#include "nsString.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* The nsIXPathNodeSelector can be used to query a DOM tree using XPath.
|
||||
|
@ -35,7 +37,7 @@ interface nsIXPathNodeSelector : nsISupports
|
|||
* @returns The result of the XPath query.
|
||||
*/
|
||||
nsIDOMNodeList selectNodes(in nsIDOMNode aContextNode,
|
||||
in string aPattern);
|
||||
in DOMString aPattern);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -28,28 +28,48 @@
|
|||
#include "ProcessorState.h"
|
||||
#include "Expr.h"
|
||||
#include "nsNodeSet.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(XPathProcessor,
|
||||
nsIXPathNodeSelector,
|
||||
nsISecurityCheckedComponent)
|
||||
|
||||
/**
|
||||
// XPConnect interface list for XPathProcessor
|
||||
NS_CLASSINFO_MAP_BEGIN(XPathProcessor)
|
||||
NS_CLASSINFO_MAP_ENTRY(nsIXPathNodeSelector)
|
||||
NS_CLASSINFO_MAP_END
|
||||
|
||||
|
||||
// QueryInterface implementation for XPathProcessor
|
||||
NS_INTERFACE_MAP_BEGIN(XPathProcessor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXPathNodeSelector)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XPathProcessor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(XPathProcessor)
|
||||
NS_IMPL_RELEASE(XPathProcessor)
|
||||
|
||||
|
||||
/*
|
||||
* Creates a new XPathProcessor
|
||||
**/
|
||||
XPathProcessor::XPathProcessor() {
|
||||
|
||||
NS_INIT_ISUPPORTS();
|
||||
} //-- XPathProcessor
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
**/
|
||||
XPathProcessor::~XPathProcessor() {
|
||||
} //-- ~XPathProcessor
|
||||
|
||||
/* nsIDOMNodeList selectNodes (in nsIDOMNode aContextNode, in string aPattern); */
|
||||
NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char *aPattern, nsIDOMNodeList **_retval)
|
||||
*/
|
||||
XPathProcessor::XPathProcessor()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
/*
|
||||
* Default destructor
|
||||
*/
|
||||
XPathProcessor::~XPathProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
/* nsIDOMNodeList selectNodes (in nsIDOMNode aContextNode, in DOMString aPattern); */
|
||||
NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode,
|
||||
const nsAReadableString & aPattern,
|
||||
nsIDOMNodeList **_retval)
|
||||
{
|
||||
String pattern(PromiseFlatString(aPattern).get());
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> aOwnerDOMDocument;
|
||||
aContextNode->GetOwnerDocument(getter_AddRefs(aOwnerDOMDocument));
|
||||
nsCOMPtr<nsIDocument> aOwnerDocument = do_QueryInterface(aOwnerDOMDocument);
|
||||
|
@ -59,10 +79,10 @@ NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char *
|
|||
ProcessorState* aProcessorState = new ProcessorState();
|
||||
ExprParser aParser;
|
||||
|
||||
Expr* aExpression = aParser.createExpr(aPattern);
|
||||
Expr* aExpression = aParser.createExpr(pattern);
|
||||
ExprResult* exprResult = aExpression->evaluate(aNode, aProcessorState);
|
||||
nsNodeSet* resultSet;
|
||||
if ( exprResult->getResultType() == ExprResult::NODESET ) {
|
||||
if (exprResult->getResultType() == ExprResult::NODESET) {
|
||||
resultSet = new nsNodeSet((NodeSet*)exprResult);
|
||||
}
|
||||
else {
|
||||
|
@ -79,53 +99,3 @@ NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char *
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsISecurityCheckedComponent
|
||||
*/
|
||||
|
||||
static const char* kAllAccess = "AllAccess";
|
||||
|
||||
/* string canCreateWrapper (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP
|
||||
XPathProcessor::CanCreateWrapper(const nsIID * iid, char **_retval)
|
||||
{
|
||||
if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) {
|
||||
*_retval = nsCRT::strdup(kAllAccess);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
|
||||
NS_IMETHODIMP
|
||||
XPathProcessor::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
|
||||
{
|
||||
if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) {
|
||||
*_retval = nsCRT::strdup(kAllAccess);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
|
||||
NS_IMETHODIMP
|
||||
XPathProcessor::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
|
||||
{
|
||||
if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) {
|
||||
*_retval = nsCRT::strdup(kAllAccess);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
|
||||
NS_IMETHODIMP
|
||||
XPathProcessor::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
|
||||
{
|
||||
if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) {
|
||||
*_retval = nsCRT::strdup(kAllAccess);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#define XPathProcessor_h__
|
||||
|
||||
#include "nsIXPathNodeSelector.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
|
||||
/* e4172588-1dd1-11b2-bf09-ec309437245a */
|
||||
#define TRANSFORMIIX_XPATH_PROCESSOR_CID \
|
||||
|
@ -39,8 +38,7 @@
|
|||
/**
|
||||
* A class for processing an XPath query
|
||||
**/
|
||||
class XPathProcessor : public nsIXPathNodeSelector,
|
||||
public nsISecurityCheckedComponent
|
||||
class XPathProcessor : public nsIXPathNodeSelector
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -58,10 +56,6 @@ public:
|
|||
|
||||
// nsIXPathNodeSelector interface
|
||||
NS_DECL_NSIXPATHNODESELECTOR
|
||||
|
||||
// nsISecurityCheckedComponent
|
||||
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
||||
|
||||
}; //-- XPathProcessor
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,14 +24,27 @@
|
|||
*/
|
||||
|
||||
#include "nsNodeSet.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsNodeSet, nsIDOMNodeList)
|
||||
|
||||
// XPConnect interface list for NodeSet
|
||||
NS_CLASSINFO_MAP_BEGIN(NodeSet)
|
||||
NS_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
|
||||
NS_CLASSINFO_MAP_END
|
||||
|
||||
|
||||
// QueryInterface implementation for nsNodeSet
|
||||
NS_INTERFACE_MAP_BEGIN(nsNodeSet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(NodeSet)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsNodeSet)
|
||||
NS_IMPL_RELEASE(nsNodeSet)
|
||||
|
||||
|
||||
nsNodeSet::nsNodeSet(NodeSet* aNodeSet) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* Olivier Gerardin
|
||||
* -- Changed behavior of passing parameters to templates
|
||||
*
|
||||
* $Id: XSLTProcessor.cpp,v 1.46 2001-05-15 06:13:02 axel%pike.org Exp $
|
||||
* $Id: XSLTProcessor.cpp,v 1.47 2001-05-15 20:34:58 peterv%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include "XSLTProcessor.h"
|
||||
|
@ -59,6 +59,7 @@
|
|||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
//#include "nslog.h"
|
||||
#else
|
||||
#include "printers.h"
|
||||
|
@ -72,7 +73,7 @@
|
|||
/**
|
||||
* XSLTProcessor is a class for Processing XSL stylesheets
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.46 $ $Date: 2001-05-15 06:13:02 $
|
||||
* @version $Revision: 1.47 $ $Date: 2001-05-15 20:34:58 $
|
||||
**/
|
||||
|
||||
/**
|
||||
|
@ -138,7 +139,23 @@ XSLTProcessor::~XSLTProcessor() {
|
|||
} //-- ~XSLTProcessor
|
||||
|
||||
#ifdef MOZ_XSL
|
||||
NS_IMPL_ISUPPORTS1(XSLTProcessor, nsIDocumentTransformer)
|
||||
|
||||
// XPConnect interface list for XSLTProcessor
|
||||
NS_CLASSINFO_MAP_BEGIN(XSLTProcessor)
|
||||
NS_CLASSINFO_MAP_ENTRY(nsIDocumentTransformer)
|
||||
NS_CLASSINFO_MAP_END
|
||||
|
||||
|
||||
// QueryInterface implementation for XSLTProcessor
|
||||
NS_INTERFACE_MAP_BEGIN(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(XSLTProcessor)
|
||||
NS_IMPL_RELEASE(XSLTProcessor)
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче