зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 92377 (Build failure: dom/src/base/nsDOMClassInfo.cpp depends on extensions/xmlextras). r=shaver, sr=jst, a=asa.
This commit is contained in:
Родитель
a2b990d970
Коммит
9bfe5c5491
|
@ -41,7 +41,8 @@ REQUIRES = content \
|
|||
js \
|
||||
caps \
|
||||
locale \
|
||||
view
|
||||
view \
|
||||
xpconnect
|
||||
|
||||
CPPSRCS = \
|
||||
nsSVGDocument.cpp \
|
||||
|
|
|
@ -43,6 +43,7 @@ REQUIRES = content \
|
|||
caps \
|
||||
locale \
|
||||
view \
|
||||
xpconnect \
|
||||
$(null)
|
||||
|
||||
|
||||
|
|
|
@ -186,11 +186,6 @@ enum nsDOMClassInfoID {
|
|||
eDOMClassInfo_CRMFObject_id,
|
||||
eDOMClassInfo_Pkcs11_id,
|
||||
|
||||
// XML extras classes
|
||||
eDOMClassInfo_XMLHttpRequest_id,
|
||||
eDOMClassInfo_DOMSerializer_id,
|
||||
eDOMClassInfo_DOMParser_id,
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// The SVG document
|
||||
eDOMClassInfo_SVGDocument_id,
|
||||
|
@ -241,11 +236,6 @@ enum nsDOMClassInfoID {
|
|||
eDOMClassInfo_SVGAnimatedRect_id,
|
||||
#endif
|
||||
|
||||
// Transformiix classes
|
||||
eDOMClassInfo_XSLTProcessor_id,
|
||||
eDOMClassInfo_XPathProcessor_id,
|
||||
eDOMClassInfo_NodeSet_id,
|
||||
|
||||
// DOM Traversal classes
|
||||
eDOMClassInfo_TreeWalker_id,
|
||||
|
||||
|
@ -261,6 +251,28 @@ enum nsDOMClassInfoID {
|
|||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
||||
#include "nsIXPCScriptable.h"
|
||||
|
||||
#define DEFAULT_SCRIPTABLE_FLAGS \
|
||||
(nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
|
||||
nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY | \
|
||||
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY | \
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE | \
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE | \
|
||||
nsIXPCScriptable::DONT_ASK_INSTANCE_FOR_SCRIPTABLE | \
|
||||
nsIXPCScriptable::DONT_REFLECT_INTERFACE_NAMES | \
|
||||
nsIXPCScriptable::WANT_CHECKACCESS | \
|
||||
nsIXPCScriptable::WANT_POSTCREATE)
|
||||
|
||||
#define DOM_DEFAULT_SCRIPTABLE_FLAGS \
|
||||
(DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
|
||||
nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY)
|
||||
|
||||
|
||||
typedef nsIClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
|
||||
(const char* aName);
|
||||
|
||||
|
||||
/**
|
||||
* nsIClassInfo helper macros
|
||||
|
@ -281,21 +293,136 @@ enum nsDOMClassInfoID {
|
|||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
#define NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
|
||||
\
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID)); \
|
||||
if (sof) { \
|
||||
foundInterface = \
|
||||
sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
||||
\
|
||||
if (foundInterface) { \
|
||||
*aInstancePtr = foundInterface; \
|
||||
\
|
||||
return NS_OK; \
|
||||
} \
|
||||
} \
|
||||
#define NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
|
||||
\
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID)); \
|
||||
if (sof) { \
|
||||
foundInterface = \
|
||||
sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
||||
\
|
||||
if (foundInterface) { \
|
||||
*aInstancePtr = foundInterface; \
|
||||
\
|
||||
return NS_OK; \
|
||||
} \
|
||||
} \
|
||||
} else
|
||||
|
||||
// Looks up the nsIClassInfo for a class name registered with the
|
||||
// nsScriptNamespaceManager. Remember to release NS_CLASSINFO_NAME(_class)
|
||||
// (eg. when your module unloads).
|
||||
#define NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
|
||||
extern nsISupports *NS_CLASSINFO_NAME(_class); \
|
||||
if (NS_CLASSINFO_NAME(_class)) { \
|
||||
foundInterface = NS_CLASSINFO_NAME(_class); \
|
||||
} else { \
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
|
||||
\
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID)); \
|
||||
if (sof) { \
|
||||
foundInterface = \
|
||||
sof->GetExternalClassInfoInstance(NS_LITERAL_STRING(#_class)); \
|
||||
\
|
||||
if (foundInterface) \
|
||||
NS_CLASSINFO_NAME(_class) = foundInterface; \
|
||||
} \
|
||||
} \
|
||||
} else
|
||||
|
||||
|
||||
#define NS_DECL_DOM_CLASSINFO(_class) \
|
||||
nsISupports *NS_CLASSINFO_NAME(_class) = nsnull;
|
||||
|
||||
// {891a7b01-1b61-11d6-a7f2-f690b638899c}
|
||||
#define NS_IDOMCI_EXTENSION_IID \
|
||||
{ 0x891a7b01, 0x1b61, 0x11d6, \
|
||||
{ 0xa7, 0xf2, 0xf6, 0x90, 0xb6, 0x38, 0x89, 0x9c } }
|
||||
|
||||
class nsIDOMScriptObjectFactory;
|
||||
|
||||
class nsIDOMCIExtension : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMCI_EXTENSION_IID)
|
||||
|
||||
NS_IMETHOD RegisterDOMCI(const char* aName,
|
||||
nsIDOMScriptObjectFactory* aDOMSOFactory) = 0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DOMCI_EXTENSION_NAME(_module) ns##_module##DOMCIExtension
|
||||
#define NS_DOMCI_EXTENSION_CONSTRUCTOR(_module) \
|
||||
ns##_module##DOMCIExtensionConstructor
|
||||
#define NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(_extension) \
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(_extension)
|
||||
|
||||
#define NS_DOMCI_EXTENSION(_module) \
|
||||
class NS_DOMCI_EXTENSION_NAME(_module) : public nsIDOMCIExtension \
|
||||
{ \
|
||||
public: \
|
||||
NS_DOMCI_EXTENSION_NAME(_module)(); \
|
||||
virtual ~NS_DOMCI_EXTENSION_NAME(_module)(); \
|
||||
\
|
||||
NS_DECL_ISUPPORTS \
|
||||
\
|
||||
NS_IMETHOD RegisterDOMCI(const char* aName, \
|
||||
nsIDOMScriptObjectFactory* aDOMSOFactory); \
|
||||
}; \
|
||||
\
|
||||
NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(NS_DOMCI_EXTENSION_NAME(_module)) \
|
||||
\
|
||||
NS_DOMCI_EXTENSION_NAME(_module)::NS_DOMCI_EXTENSION_NAME(_module)() \
|
||||
{ \
|
||||
NS_INIT_ISUPPORTS(); \
|
||||
}; \
|
||||
\
|
||||
NS_DOMCI_EXTENSION_NAME(_module)::~NS_DOMCI_EXTENSION_NAME(_module)() \
|
||||
{ \
|
||||
}; \
|
||||
\
|
||||
NS_IMPL_ISUPPORTS1(NS_DOMCI_EXTENSION_NAME(_module), nsIDOMCIExtension) \
|
||||
\
|
||||
NS_IMETHODIMP \
|
||||
NS_DOMCI_EXTENSION_NAME(_module)::RegisterDOMCI(const char* aName, \
|
||||
nsIDOMScriptObjectFactory* aDOMSOFactory) \
|
||||
{
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_BEGIN(_class) \
|
||||
if (nsCRT::strcmp(aName, #_class) == 0) { \
|
||||
static const nsIID* interfaces[] = {
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_INTERFACE(_interface) \
|
||||
&NS_GET_IID(_interface),
|
||||
|
||||
// Don't forget to register the primary interface (_proto) in the
|
||||
// JAVASCRIPT_DOM_INTERFACE category, or prototypes for this class
|
||||
// won't work (except if the interface name starts with nsIDOM).
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, _proto, _hasclassif, \
|
||||
_constructorcid) \
|
||||
nsnull \
|
||||
}; \
|
||||
aDOMSOFactory->RegisterDOMClassInfo(#_class, nsnull, _proto, \
|
||||
interfaces, \
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS, \
|
||||
_hasclassif, _constructorcid); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_END(_class, _proto, _hasclassif, \
|
||||
_constructorcid) \
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, &NS_GET_IID(_proto), \
|
||||
_hasclassif, _constructorcid)
|
||||
|
||||
#define NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(_class, _hasclassif, \
|
||||
_constructorcid) \
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, nsnull, _hasclassif, \
|
||||
_constructorcid)
|
||||
|
||||
#define NS_DOMCI_EXTENSION_END \
|
||||
return NS_ERROR_FAILURE; \
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIDOMClassInfo_h___ */
|
||||
|
|
|
@ -66,6 +66,20 @@ public:
|
|||
nsIScriptGlobalObject **aGlobal) = 0;
|
||||
|
||||
NS_IMETHOD_(nsISupports *)GetClassInfoInstance(nsDOMClassInfoID aID) = 0;
|
||||
NS_IMETHOD_(nsISupports *)GetExternalClassInfoInstance(const nsAString& aName) = 0;
|
||||
|
||||
// Register the info for an external class. aName must be static
|
||||
// data, it will not be deleted by the DOM code. aProtoChainInterface
|
||||
// must be registered in the JAVASCRIPT_DOM_INTERFACE category, or
|
||||
// prototypes for this class won't work (except if the interface
|
||||
// name starts with nsIDOM).
|
||||
NS_IMETHOD RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDOMScriptObjectFactory_h__ */
|
||||
|
|
|
@ -51,4 +51,10 @@
|
|||
#define JAVASCRIPT_GLOBAL_DYNAMIC_NAMESET_CATEGORY \
|
||||
"JavaScript global dynamic nameset"
|
||||
|
||||
#define JAVASCRIPT_DOM_CLASS \
|
||||
"JavaScript DOM class"
|
||||
|
||||
#define JAVASCRIPT_DOM_INTERFACE \
|
||||
"JavaScript DOM interface"
|
||||
|
||||
#endif /* nsIScriptNameSpaceManager_h__ */
|
||||
|
|
|
@ -36,7 +36,6 @@ REQUIRES = xpcom \
|
|||
gfx \
|
||||
layout \
|
||||
content \
|
||||
content_xsl \
|
||||
caps \
|
||||
docshell \
|
||||
xpconnect \
|
||||
|
@ -56,10 +55,8 @@ REQUIRES = xpcom \
|
|||
windowwatcher \
|
||||
htmlparser \
|
||||
chardet \
|
||||
transformiix \
|
||||
xmlextras \
|
||||
find \
|
||||
appshell \
|
||||
find \
|
||||
appshell \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -84,7 +81,7 @@ FORCE_STATIC_LIB = 1
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += -I$(srcdir)/../build
|
||||
CXXFLAGS += -I$(srcdir) -I$(srcdir)/../build
|
||||
|
||||
DEFINES += -D_IMPL_NS_DOM
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ REQUIRES = xpcom \
|
|||
layout_xul \
|
||||
content \
|
||||
content_xul \
|
||||
content_xsl \
|
||||
caps \
|
||||
docshell \
|
||||
xpconnect \
|
||||
|
@ -56,10 +55,8 @@ REQUIRES = xpcom \
|
|||
windowwatcher \
|
||||
htmlparser \
|
||||
chardet \
|
||||
transformiix \
|
||||
xmlextras \
|
||||
find \
|
||||
appshell \
|
||||
find \
|
||||
appshell \
|
||||
$(NULL)
|
||||
|
||||
MODULE=dom
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "nsDOMClassInfo.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -264,11 +266,6 @@
|
|||
#include "nsIOutlinerSelection.h"
|
||||
#include "nsIOutlinerContentView.h"
|
||||
#include "nsIOutlinerView.h"
|
||||
#include "nsIXMLHttpRequest.h"
|
||||
#include "nsIDOMSerializer.h"
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsIDocumentTransformer.h"
|
||||
#include "nsIXPathNodeSelector.h"
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsIDOMSVGAnimatedLength.h"
|
||||
|
@ -302,23 +299,11 @@
|
|||
#include "nsIDOMSVGAnimatedRect.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
#define DEFAULT_SCRIPTABLE_FLAGS \
|
||||
(nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
|
||||
nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY | \
|
||||
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY | \
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE | \
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE | \
|
||||
nsIXPCScriptable::DONT_ASK_INSTANCE_FOR_SCRIPTABLE | \
|
||||
nsIXPCScriptable::DONT_REFLECT_INTERFACE_NAMES | \
|
||||
nsIXPCScriptable::WANT_CHECKACCESS | \
|
||||
nsIXPCScriptable::WANT_POSTCREATE)
|
||||
|
||||
#define DOM_DEFAULT_SCRIPTABLE_FLAGS \
|
||||
(DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
|
||||
nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY)
|
||||
// NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
|
||||
// are defined in nsIDOMClassInfo.h.
|
||||
|
||||
#define NODE_SCRIPTABLE_FLAGS \
|
||||
((DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
|
@ -341,24 +326,6 @@ static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
|||
nsIXPCScriptable::WANT_GETPROPERTY)
|
||||
|
||||
|
||||
typedef nsIClassInfo* (*nsDOMClassInfoConstructorFnc)
|
||||
(nsDOMClassInfoID aID);
|
||||
|
||||
struct nsDOMClassInfoData
|
||||
{
|
||||
const char *mName;
|
||||
nsDOMClassInfoConstructorFnc mConstructorFptr;
|
||||
nsIClassInfo *mCachedClassInfo;
|
||||
const nsIID *mProtoChainInterface;
|
||||
const nsIID **mInterfaces;
|
||||
PRUint32 mScriptableFlags : 31; // flags must not use more than 31 bits!
|
||||
PRBool mHasClassInterface : 1;
|
||||
#ifdef NS_DEBUG
|
||||
PRUint32 mDebugID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
#define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
|
||||
eDOMClassInfo_##_class##_id,
|
||||
|
@ -684,14 +651,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(Pkcs11, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
// XML extras classes
|
||||
NS_DEFINE_CLASSINFO_DATA(XMLHttpRequest, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMSerializer, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
// SVG document
|
||||
NS_DEFINE_CLASSINFO_DATA(SVGDocument, nsDocumentSH,
|
||||
|
@ -785,14 +744,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
|
||||
// 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)
|
||||
|
||||
// DOM Traversal classes
|
||||
NS_DEFINE_CLASSINFO_DATA(TreeWalker, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
@ -1000,13 +951,18 @@ nsDOMClassInfo::ThrowJSException(JSContext *cx, nsresult aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoID aID) : mID(aID)
|
||||
nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsDOMClassInfo::~nsDOMClassInfo()
|
||||
{
|
||||
if (IS_EXTERNAL(mData->mCachedClassInfo)) {
|
||||
// Some compilers don't like delete'ing a const nsDOMClassInfo*
|
||||
nsDOMClassInfoData* data = NS_CONST_CAST(nsDOMClassInfoData*, mData);
|
||||
delete NS_STATIC_CAST(nsExternalDOMClassInfoData*, data);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMClassInfo);
|
||||
|
@ -1031,13 +987,11 @@ CutPrefix(const char *aName) {
|
|||
static const char prefix_nsIDOM[] = "nsIDOM";
|
||||
static const char prefix_nsI[] = "nsI";
|
||||
|
||||
if (nsCRT::strncmp(aName, prefix_nsIDOM,
|
||||
(PRUint32)(sizeof(prefix_nsIDOM) - 1)) == 0) {
|
||||
if (strncmp(aName, prefix_nsIDOM, sizeof(prefix_nsIDOM) - 1) == 0) {
|
||||
return aName + sizeof(prefix_nsIDOM) - 1;
|
||||
}
|
||||
|
||||
if (nsCRT::strncmp(aName, prefix_nsI,
|
||||
(PRUint32)(sizeof(prefix_nsI) - 1)) == 0) {
|
||||
if (strncmp(aName, prefix_nsI, sizeof(prefix_nsI) - 1) == 0) {
|
||||
return aName + sizeof(prefix_nsI) - 1;
|
||||
}
|
||||
|
||||
|
@ -1112,6 +1066,55 @@ nsDOMClassInfo::RegisterClassProtos(PRInt32 aClassInfoID)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsDOMClassInfo::RegisterExternalClasses()
|
||||
{
|
||||
extern nsScriptNameSpaceManager *gNameSpaceManager;
|
||||
NS_ENSURE_TRUE(gNameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString categoryEntry, contractId;
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
|
||||
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
|
||||
nsCOMPtr<nsISupportsString> category(do_QueryInterface(entry));
|
||||
|
||||
if (!category) {
|
||||
NS_WARNING("Category entry not an nsISupportsString!");
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = category->GetData(getter_Copies(categoryEntry));
|
||||
|
||||
cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry,
|
||||
getter_Copies(contractId));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCID cid;
|
||||
rv = nsComponentManager::ContractIDToClassID(contractId, &cid);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Bad contract id registered with the script namespace manager");
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = gNameSpaceManager->RegisterExternalClassName(categoryEntry, cid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = gNameSpaceManager->RegisterExternalInterfaces(PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if) \
|
||||
{ \
|
||||
|
@ -1154,6 +1157,10 @@ nsDOMClassInfo::Init()
|
|||
{
|
||||
NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
|
||||
|
||||
NS_ASSERTION(sizeof(PtrBits) == sizeof(void*),
|
||||
"BAD! You'll need to adjust the size of PtrBits to the size "
|
||||
"of a pointer on your platform.");
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
|
||||
|
@ -1793,20 +1800,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPkcs11)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_PRIMARY_INTERFACE(XMLHttpRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIJSXMLHttpRequest)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_PRIMARY_INTERFACE(DOMSerializer)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSerializer)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_PRIMARY_INTERFACE(DOMParser)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMParser)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#define DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES \
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement) \
|
||||
|
@ -2016,18 +2009,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_PRIMARY_INTERFACE(XSLTProcessor)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDocumentTransformer)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_PRIMARY_INTERFACE(XPathProcessor)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIXPathNodeSelector)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(NodeSet, nsIDOMNodeList)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
|
||||
|
@ -2115,6 +2096,8 @@ nsDOMClassInfo::Init()
|
|||
RegisterClassProtos(i);
|
||||
}
|
||||
|
||||
RegisterExternalClasses();
|
||||
|
||||
sIsInitialized = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2152,9 +2135,7 @@ nsDOMClassInfo::GetInterfaces(PRUint32 *aCount, nsIID ***aArray)
|
|||
{
|
||||
PRUint32 count = 0;
|
||||
|
||||
const nsDOMClassInfoData& data = sClassInfoData[mID];
|
||||
|
||||
while (data.mInterfaces[count]) {
|
||||
while (mData->mInterfaces[count]) {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -2173,7 +2154,7 @@ nsDOMClassInfo::GetInterfaces(PRUint32 *aCount, nsIID ***aArray)
|
|||
PRUint32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIID *iid =
|
||||
NS_STATIC_CAST(nsIID *, nsMemory::Clone(data.mInterfaces[i],
|
||||
NS_STATIC_CAST(nsIID *, nsMemory::Clone(mData->mInterfaces[i],
|
||||
sizeof(nsIID)));
|
||||
|
||||
if (!iid) {
|
||||
|
@ -2250,7 +2231,7 @@ nsDOMClassInfo::GetFlags(PRUint32 *aFlags)
|
|||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::GetClassName(char **aClassName)
|
||||
{
|
||||
*aClassName = nsCRT::strdup(sClassInfoData[mID].mName);
|
||||
*aClassName = nsCRT::strdup(mData->mName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2258,7 +2239,7 @@ nsDOMClassInfo::GetClassName(char **aClassName)
|
|||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::GetScriptableFlags(PRUint32 *aFlags)
|
||||
{
|
||||
*aFlags = sClassInfoData[mID].mScriptableFlags;
|
||||
*aFlags = mData->mScriptableFlags;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2286,11 +2267,10 @@ nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
|||
JSContext *cx, JSObject *obj)
|
||||
{
|
||||
static const nsIID *sSupportsIID = &NS_GET_IID(nsISupports);
|
||||
const nsDOMClassInfoData &ci_data = sClassInfoData[mID];
|
||||
|
||||
// This is safe because...
|
||||
if (ci_data.mProtoChainInterface == sSupportsIID ||
|
||||
!ci_data.mProtoChainInterface) {
|
||||
if (mData->mProtoChainInterface == sSupportsIID ||
|
||||
!mData->mProtoChainInterface) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2315,20 +2295,20 @@ nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ci_data.mHasClassInterface) {
|
||||
if (mData->mHasClassInterface) {
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
|
||||
if (iim) {
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||
iim->GetInfoForIID(ci_data.mProtoChainInterface,
|
||||
iim->GetInfoForIID(mData->mProtoChainInterface,
|
||||
getter_AddRefs(if_info));
|
||||
|
||||
if (if_info) {
|
||||
nsXPIDLCString name;
|
||||
if_info->GetName(getter_Copies(name));
|
||||
|
||||
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), ci_data.mName) == 0,
|
||||
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
|
||||
"Class name and proto chain interface name mismatch!");
|
||||
}
|
||||
}
|
||||
|
@ -2338,7 +2318,7 @@ nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
|
|||
JSObject *global = GetGlobalJSObject(cx, obj);
|
||||
|
||||
jsval val;
|
||||
if (!::JS_GetProperty(cx, global, ci_data.mName, &val)) {
|
||||
if (!::JS_GetProperty(cx, global, mData->mName, &val)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -2394,7 +2374,7 @@ nsDOMClassInfo::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
|
||||
// Ask the security manager if it's OK to enumerate
|
||||
nsresult rv =
|
||||
sSecMan->CheckPropertyAccess(cx, obj, sClassInfoData[mID].mName,
|
||||
sSecMan->CheckPropertyAccess(cx, obj, mData->mName,
|
||||
STRING_TO_JSVAL(sEnumerate_id),
|
||||
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
||||
|
||||
|
@ -2458,7 +2438,7 @@ nsDOMClassInfo::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv =
|
||||
sSecMan->CheckPropertyAccess(cx, real_obj, sClassInfoData[mID].mName, id,
|
||||
sSecMan->CheckPropertyAccess(cx, real_obj, mData->mName, id,
|
||||
nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -2529,12 +2509,15 @@ nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoID aID)
|
|||
if (!sClassInfoData[aID].mCachedClassInfo) {
|
||||
nsDOMClassInfoData& data = sClassInfoData[aID];
|
||||
|
||||
data.mCachedClassInfo = data.mConstructorFptr(aID);
|
||||
data.mCachedClassInfo = data.mConstructorFptr(&data);
|
||||
NS_ENSURE_TRUE(data.mCachedClassInfo, nsnull);
|
||||
|
||||
NS_ADDREF(data.mCachedClassInfo);
|
||||
}
|
||||
|
||||
NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
|
||||
"This is bad, internal class marked as external!");
|
||||
|
||||
nsIClassInfo *classinfo = sClassInfoData[aID].mCachedClassInfo;
|
||||
|
||||
NS_ADDREF(classinfo);
|
||||
|
@ -2542,6 +2525,33 @@ nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoID aID)
|
|||
return classinfo;
|
||||
}
|
||||
|
||||
// static
|
||||
nsIClassInfo *
|
||||
nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
|
||||
{
|
||||
NS_ASSERTION(IS_EXTERNAL(aData->mCachedClassInfo)
|
||||
|| !aData->mCachedClassInfo,
|
||||
"This is bad, external class marked as internal!");
|
||||
|
||||
if (!aData->mCachedClassInfo) {
|
||||
if (aData->mExternalConstructorFptr) {
|
||||
aData->mCachedClassInfo = aData->mExternalConstructorFptr(aData->mName);
|
||||
} else {
|
||||
aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
|
||||
}
|
||||
NS_ENSURE_TRUE(aData->mCachedClassInfo, nsnull);
|
||||
|
||||
NS_ADDREF(aData->mCachedClassInfo);
|
||||
aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
|
||||
}
|
||||
|
||||
nsIClassInfo *classinfo = GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
|
||||
|
||||
NS_ADDREF(classinfo);
|
||||
|
||||
return classinfo;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsDOMClassInfo::ShutDown()
|
||||
|
@ -2735,8 +2745,7 @@ nsWindowSH::doCheckPropertyAccess(JSContext *cx, JSObject *obj, jsval id,
|
|||
|
||||
JSObject *global = sgo->GetGlobalJSObject();
|
||||
|
||||
return sSecMan->CheckPropertyAccess(cx, global,
|
||||
sClassInfoData[mID].mName,
|
||||
return sSecMan->CheckPropertyAccess(cx, global, mData->mName,
|
||||
id, accessMode);
|
||||
}
|
||||
|
||||
|
@ -2963,7 +2972,12 @@ StubConstructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
extern nsScriptNameSpaceManager *gNameSpaceManager;
|
||||
|
||||
NS_ENSURE_TRUE(gNameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
if (!gNameSpaceManager) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_NOT_INITIALIZED);
|
||||
NS_ERROR("No nsScriptNameSpaceManager!");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
const char *name = ::JS_GetFunctionName(fun);
|
||||
|
||||
|
@ -2975,12 +2989,59 @@ StubConstructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
nsresult rv = gNameSpaceManager->LookupName(nameStr, &name_struct);
|
||||
|
||||
if (NS_FAILED(rv) || !name_struct ||
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
(name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructor &&
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfoCreator &&
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, JS_FALSE);
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(name_struct->mCID, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, rv);
|
||||
NS_ERROR("Couldn't create the DOMCI extender");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
||||
if (sof) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
|
||||
NS_ERROR("Couldn't get the DOM script object factory");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
rv = creator->RegisterDOMCI(name, sof);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, rv);
|
||||
NS_ERROR("Failed to register the DOM ClassInfo data");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
rv = gNameSpaceManager->LookupName(nameStr, &name_struct);
|
||||
if (NS_FAILED(rv) || !name_struct ||
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
|
||||
NS_ERROR("Couldn't get the DOM ClassInfo data");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> native;
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
native = do_CreateInstance(name_struct->mCID, &rv);
|
||||
} else {
|
||||
native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, rv);
|
||||
NS_ERROR("Failed to create the object");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
|
||||
if (initializer) {
|
||||
|
@ -2996,8 +3057,10 @@ StubConstructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
nsCOMPtr<nsIScriptContext> context;
|
||||
|
||||
nsJSUtils::GetStaticScriptContext(cx, obj, getter_AddRefs(context));
|
||||
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
|
||||
if (!context) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JSObject* new_obj;
|
||||
rv = owner->GetScriptObject(context, (void**)&new_obj);
|
||||
|
@ -3140,7 +3203,7 @@ NativeConstructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
// ignore return value, we return JS_FALSE anyway
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
NS_ASSERTION(0, "object instantiated without constructor");
|
||||
NS_ERROR("object instantiated without constructor");
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -3170,6 +3233,25 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj,
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(name_struct->mCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
||||
NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
|
||||
|
||||
rv = creator->RegisterDOMCI(NS_ConvertUCS2toUTF8(name).get(), sof);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = gNameSpaceManager->LookupName(name, &name_struct);
|
||||
if (NS_FAILED(rv) || !name_struct ||
|
||||
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
NS_ERROR("Couldn't get the DOM ClassInfo data.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
|
||||
rv = DefineInterfaceProperty(cx, obj, str);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -3180,10 +3262,19 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj,
|
|||
}
|
||||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo ||
|
||||
name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
|
||||
JSFunction *cfnc = ::JS_DefineFunction(cx, obj,
|
||||
NS_ConvertUCS2toUTF8(name).get(),
|
||||
NativeConstructor, 0, 0);
|
||||
JSNative native;
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
|
||||
name_struct->mData->mConstructorCID) {
|
||||
native = StubConstructor;
|
||||
} else {
|
||||
native = NativeConstructor;
|
||||
}
|
||||
|
||||
JSFunction *cfnc = ::JS_DefineFunction(cx, obj, ::JS_GetStringBytes(str),
|
||||
native, 0, 0);
|
||||
|
||||
if (!cfnc) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -3199,6 +3290,8 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj,
|
|||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
|
||||
name_struct->mDOMClassInfoID >= 0) {
|
||||
ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
|
||||
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
ci_data = name_struct->mData;
|
||||
}
|
||||
|
||||
const nsIID *primary_iid = &NS_GET_IID(nsISupports);
|
||||
|
@ -3293,7 +3386,7 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj,
|
|||
|
||||
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||
NS_ABORT_IF_FALSE(name_struct->mDOMClassInfoID >= 0,
|
||||
"Negative DOM clssinfo?!?");
|
||||
"Negative DOM classinfo?!?");
|
||||
|
||||
nsDOMClassInfoID ci_id = (nsDOMClassInfoID)name_struct->mDOMClassInfoID;
|
||||
|
||||
|
@ -3312,6 +3405,27 @@ nsWindowSH::GlobalResolve(nsISupports *native, JSContext *cx, JSObject *obj,
|
|||
|
||||
JSObject *xpc_proto_proto = ::JS_GetPrototype(cx, dot_prototype);
|
||||
|
||||
if (proto && JS_GET_CLASS(cx, xpc_proto_proto) == sObjectClass) {
|
||||
if (!::JS_SetPrototype(cx, dot_prototype, proto)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
nsCOMPtr<nsIClassInfo> ci(getter_AddRefs(GetClassInfoInstance(name_struct->mData)));
|
||||
NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
|
||||
|
||||
nsresult rv =
|
||||
sXPConnect->GetWrappedNativePrototype(cx, obj, ci,
|
||||
getter_AddRefs(proto_holder));
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
|
||||
|
||||
rv = proto_holder->GetJSObject(&dot_prototype);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSObject *xpc_proto_proto = ::JS_GetPrototype(cx, dot_prototype);
|
||||
|
||||
if (proto && JS_GET_CLASS(cx, xpc_proto_proto) == sObjectClass) {
|
||||
if (!::JS_SetPrototype(cx, dot_prototype, proto)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -5210,7 +5324,7 @@ nsHistorySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
}
|
||||
|
||||
nsresult rv =
|
||||
sSecMan->CheckPropertyAccess(cx, obj, sClassInfoData[mID].mName,
|
||||
sSecMan->CheckPropertyAccess(cx, obj, mData->mName,
|
||||
STRING_TO_JSVAL(sItem_id),
|
||||
nsIXPCSecurityManager::ACCESS_CALL_METHOD);
|
||||
|
||||
|
|
|
@ -49,12 +49,51 @@ class nsIDOMNSHTMLOptionCollection;
|
|||
class nsIPluginInstance;
|
||||
class nsIForm;
|
||||
|
||||
struct nsDOMClassInfoData;
|
||||
|
||||
typedef nsIClassInfo* (*nsDOMClassInfoConstructorFnc)
|
||||
(nsDOMClassInfoData* aData);
|
||||
|
||||
|
||||
struct nsDOMClassInfoData
|
||||
{
|
||||
const char *mName;
|
||||
union {
|
||||
nsDOMClassInfoConstructorFnc mConstructorFptr;
|
||||
nsDOMClassInfoExternalConstructorFnc mExternalConstructorFptr;
|
||||
};
|
||||
nsIClassInfo *mCachedClassInfo; // low bit is set to 1 if external,
|
||||
// so be sure to mask if necessary!
|
||||
const nsIID *mProtoChainInterface;
|
||||
const nsIID **mInterfaces;
|
||||
PRUint32 mScriptableFlags : 31; // flags must not use more than 31 bits!
|
||||
PRBool mHasClassInterface : 1;
|
||||
#ifdef NS_DEBUG
|
||||
PRUint32 mDebugID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
|
||||
{
|
||||
const nsCID *mConstructorCID;
|
||||
};
|
||||
|
||||
|
||||
typedef unsigned long PtrBits;
|
||||
|
||||
// To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
|
||||
// The low bit is set when we created a generic helper for an external
|
||||
// (which holds on to the nsDOMClassInfoData).
|
||||
#define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(PtrBits(_ptr) & ~0x1)
|
||||
#define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(PtrBits(_ptr) | 0x1)
|
||||
#define IS_EXTERNAL(_ptr) (PtrBits(_ptr) & 0x1)
|
||||
|
||||
|
||||
class nsDOMClassInfo : public nsIXPCScriptable,
|
||||
public nsIClassInfo
|
||||
{
|
||||
public:
|
||||
nsDOMClassInfo(nsDOMClassInfoID aID);
|
||||
nsDOMClassInfo(nsDOMClassInfoData* aData);
|
||||
virtual ~nsDOMClassInfo();
|
||||
|
||||
NS_DECL_NSIXPCSCRIPTABLE
|
||||
|
@ -73,12 +112,13 @@ public:
|
|||
// them the right to do that?
|
||||
|
||||
static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoID aID);
|
||||
static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoData* aData);
|
||||
|
||||
static void ShutDown();
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsDOMClassInfo(aID);
|
||||
return new nsDOMClassInfo(aData);
|
||||
}
|
||||
|
||||
static nsresult WrapNative(JSContext *cx, JSObject *scope,
|
||||
|
@ -87,11 +127,12 @@ public:
|
|||
static nsresult ThrowJSException(JSContext *cx, nsresult aResult);
|
||||
|
||||
protected:
|
||||
const nsDOMClassInfoID mID;
|
||||
const nsDOMClassInfoData* mData;
|
||||
|
||||
static nsresult Init();
|
||||
static nsresult RegisterClassName(PRInt32 aDOMClassInfoID);
|
||||
static nsresult RegisterClassProtos(PRInt32 aDOMClassInfoID);
|
||||
static nsresult RegisterExternalClasses();
|
||||
|
||||
// Checks if id is a number and returns the number, if aIsNumber is
|
||||
// non-null it's set to true if the id is a number and false if it's
|
||||
|
@ -202,7 +243,7 @@ typedef nsDOMClassInfo nsDOMGenericSH;
|
|||
class nsEventRecieverSH : public nsDOMGenericSH
|
||||
{
|
||||
protected:
|
||||
nsEventRecieverSH(nsDOMClassInfoID aID) : nsDOMGenericSH(aID)
|
||||
nsEventRecieverSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -242,7 +283,7 @@ public:
|
|||
class nsWindowSH : public nsEventRecieverSH
|
||||
{
|
||||
protected:
|
||||
nsWindowSH(nsDOMClassInfoID aID) : nsEventRecieverSH(aID)
|
||||
nsWindowSH(nsDOMClassInfoData* aData) : nsEventRecieverSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -277,9 +318,9 @@ public:
|
|||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsWindowSH(aID);
|
||||
return new nsWindowSH(aData);
|
||||
}
|
||||
|
||||
static PRBool sDoSecurityCheckInAddProperty;
|
||||
|
@ -292,7 +333,7 @@ public:
|
|||
class nsNodeSH : public nsEventRecieverSH
|
||||
{
|
||||
protected:
|
||||
nsNodeSH(nsDOMClassInfoID aID) : nsEventRecieverSH(aID)
|
||||
nsNodeSH(nsDOMClassInfoData* aData) : nsEventRecieverSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -306,9 +347,9 @@ public:
|
|||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsNodeSH(aID);
|
||||
return new nsNodeSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -318,7 +359,7 @@ public:
|
|||
class nsElementSH : public nsNodeSH
|
||||
{
|
||||
protected:
|
||||
nsElementSH(nsDOMClassInfoID aID) : nsNodeSH(aID)
|
||||
nsElementSH(nsDOMClassInfoData* aData) : nsNodeSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -330,9 +371,9 @@ public:
|
|||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsElementSH(aID);
|
||||
return new nsElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -342,7 +383,7 @@ public:
|
|||
class nsArraySH : public nsDOMClassInfo
|
||||
{
|
||||
protected:
|
||||
nsArraySH(nsDOMClassInfoID aID) : nsDOMClassInfo(aID)
|
||||
nsArraySH(nsDOMClassInfoData* aData) : nsDOMClassInfo(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -357,9 +398,9 @@ public:
|
|||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsArraySH(aID);
|
||||
return new nsArraySH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -369,7 +410,7 @@ public:
|
|||
class nsNamedArraySH : public nsArraySH
|
||||
{
|
||||
protected:
|
||||
nsNamedArraySH(nsDOMClassInfoID aID) : nsArraySH(aID)
|
||||
nsNamedArraySH(nsDOMClassInfoData* aData) : nsArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -391,7 +432,7 @@ public:
|
|||
class nsNamedNodeMapSH : public nsNamedArraySH
|
||||
{
|
||||
protected:
|
||||
nsNamedNodeMapSH(nsDOMClassInfoID aID) : nsNamedArraySH(aID)
|
||||
nsNamedNodeMapSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -409,9 +450,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsNamedNodeMapSH(aID);
|
||||
return new nsNamedNodeMapSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -421,7 +462,7 @@ public:
|
|||
class nsHTMLCollectionSH : public nsNamedArraySH
|
||||
{
|
||||
protected:
|
||||
nsHTMLCollectionSH(nsDOMClassInfoID aID) : nsNamedArraySH(aID)
|
||||
nsHTMLCollectionSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -439,9 +480,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLCollectionSH(aID);
|
||||
return new nsHTMLCollectionSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -451,7 +492,7 @@ public:
|
|||
class nsFormControlListSH : public nsHTMLCollectionSH
|
||||
{
|
||||
protected:
|
||||
nsFormControlListSH(nsDOMClassInfoID aID) : nsHTMLCollectionSH(aID)
|
||||
nsFormControlListSH(nsDOMClassInfoData* aData) : nsHTMLCollectionSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -465,9 +506,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsFormControlListSH(aID);
|
||||
return new nsFormControlListSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -477,7 +518,7 @@ public:
|
|||
class nsDocumentSH : public nsNodeSH
|
||||
{
|
||||
public:
|
||||
nsDocumentSH(nsDOMClassInfoID aID) : nsNodeSH(aID)
|
||||
nsDocumentSH(nsDOMClassInfoData* aData) : nsNodeSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -492,9 +533,9 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsDocumentSH(aID);
|
||||
return new nsDocumentSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -504,7 +545,7 @@ public:
|
|||
class nsHTMLDocumentSH : public nsDocumentSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLDocumentSH(nsDOMClassInfoID aID) : nsDocumentSH(aID)
|
||||
nsHTMLDocumentSH(nsDOMClassInfoData* aData) : nsDocumentSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -526,9 +567,9 @@ public:
|
|||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLDocumentSH(aID);
|
||||
return new nsHTMLDocumentSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -538,7 +579,7 @@ public:
|
|||
class nsHTMLElementSH : public nsElementSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLElementSH(nsDOMClassInfoID aID) : nsElementSH(aID)
|
||||
nsHTMLElementSH(nsDOMClassInfoData* aData) : nsElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -555,9 +596,9 @@ public:
|
|||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLElementSH(aID);
|
||||
return new nsHTMLElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -567,7 +608,7 @@ public:
|
|||
class nsHTMLFormElementSH : public nsHTMLElementSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLFormElementSH(nsDOMClassInfoID aID) : nsHTMLElementSH(aID)
|
||||
nsHTMLFormElementSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -586,9 +627,9 @@ public:
|
|||
JSObject *obj, jsval id, jsval *vp,
|
||||
PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLFormElementSH(aID);
|
||||
return new nsHTMLFormElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -598,7 +639,7 @@ public:
|
|||
class nsHTMLSelectElementSH : public nsHTMLElementSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLSelectElementSH(nsDOMClassInfoID aID) : nsHTMLElementSH(aID)
|
||||
nsHTMLSelectElementSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -616,9 +657,9 @@ public:
|
|||
static nsresult SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
|
||||
nsIDOMNSHTMLOptionCollection *aOptCollection);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLSelectElementSH(aID);
|
||||
return new nsHTMLSelectElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -629,7 +670,7 @@ public:
|
|||
class nsHTMLExternalObjSH : public nsHTMLElementSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLExternalObjSH(nsDOMClassInfoID aID) : nsHTMLElementSH(aID)
|
||||
nsHTMLExternalObjSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -656,7 +697,7 @@ public:
|
|||
class nsHTMLAppletElementSH : public nsHTMLExternalObjSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLAppletElementSH(nsDOMClassInfoID aID) : nsHTMLExternalObjSH(aID)
|
||||
nsHTMLAppletElementSH(nsDOMClassInfoData* aData) : nsHTMLExternalObjSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -670,9 +711,9 @@ protected:
|
|||
JSObject **plugin_proto);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLAppletElementSH(aID);
|
||||
return new nsHTMLAppletElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -682,7 +723,7 @@ public:
|
|||
class nsHTMLPluginObjElementSH : public nsHTMLAppletElementSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLPluginObjElementSH(nsDOMClassInfoID aID) : nsHTMLAppletElementSH(aID)
|
||||
nsHTMLPluginObjElementSH(nsDOMClassInfoData* aData) : nsHTMLAppletElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -700,9 +741,9 @@ public:
|
|||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLPluginObjElementSH(aID);
|
||||
return new nsHTMLPluginObjElementSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -712,7 +753,7 @@ public:
|
|||
class nsHTMLOptionCollectionSH : public nsHTMLCollectionSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLOptionCollectionSH(nsDOMClassInfoID aID) : nsHTMLCollectionSH(aID)
|
||||
nsHTMLOptionCollectionSH(nsDOMClassInfoData* aData) : nsHTMLCollectionSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -724,9 +765,9 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLOptionCollectionSH(aID);
|
||||
return new nsHTMLOptionCollectionSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -736,7 +777,7 @@ public:
|
|||
class nsPluginSH : public nsNamedArraySH
|
||||
{
|
||||
protected:
|
||||
nsPluginSH(nsDOMClassInfoID aID) : nsNamedArraySH(aID)
|
||||
nsPluginSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -754,9 +795,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsPluginSH(aID);
|
||||
return new nsPluginSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -766,7 +807,7 @@ public:
|
|||
class nsPluginArraySH : public nsNamedArraySH
|
||||
{
|
||||
protected:
|
||||
nsPluginArraySH(nsDOMClassInfoID aID) : nsNamedArraySH(aID)
|
||||
nsPluginArraySH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -784,9 +825,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsPluginArraySH(aID);
|
||||
return new nsPluginArraySH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -796,7 +837,7 @@ public:
|
|||
class nsMimeTypeArraySH : public nsNamedArraySH
|
||||
{
|
||||
protected:
|
||||
nsMimeTypeArraySH(nsDOMClassInfoID aID) : nsNamedArraySH(aID)
|
||||
nsMimeTypeArraySH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -814,9 +855,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsMimeTypeArraySH(aID);
|
||||
return new nsMimeTypeArraySH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -826,7 +867,7 @@ public:
|
|||
class nsStringArraySH : public nsDOMClassInfo
|
||||
{
|
||||
protected:
|
||||
nsStringArraySH(nsDOMClassInfoID aID) : nsDOMClassInfo(aID)
|
||||
nsStringArraySH(nsDOMClassInfoData* aData) : nsDOMClassInfo(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -848,7 +889,7 @@ public:
|
|||
class nsHistorySH : public nsStringArraySH
|
||||
{
|
||||
protected:
|
||||
nsHistorySH(nsDOMClassInfoID aID) : nsStringArraySH(aID)
|
||||
nsHistorySH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -863,9 +904,9 @@ public:
|
|||
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHistorySH(aID);
|
||||
return new nsHistorySH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -875,7 +916,7 @@ public:
|
|||
class nsMediaListSH : public nsStringArraySH
|
||||
{
|
||||
protected:
|
||||
nsMediaListSH(nsDOMClassInfoID aID) : nsStringArraySH(aID)
|
||||
nsMediaListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -887,9 +928,9 @@ protected:
|
|||
nsAWritableString& aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsMediaListSH(aID);
|
||||
return new nsMediaListSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -899,7 +940,7 @@ public:
|
|||
class nsStyleSheetListSH : public nsArraySH
|
||||
{
|
||||
protected:
|
||||
nsStyleSheetListSH(nsDOMClassInfoID aID) : nsArraySH(aID)
|
||||
nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -913,9 +954,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsStyleSheetListSH(aID);
|
||||
return new nsStyleSheetListSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -925,7 +966,7 @@ public:
|
|||
class nsCSSStyleDeclSH : public nsStringArraySH
|
||||
{
|
||||
protected:
|
||||
nsCSSStyleDeclSH(nsDOMClassInfoID aID) : nsStringArraySH(aID)
|
||||
nsCSSStyleDeclSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -937,9 +978,9 @@ protected:
|
|||
nsAWritableString& aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsCSSStyleDeclSH(aID);
|
||||
return new nsCSSStyleDeclSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -949,7 +990,7 @@ public:
|
|||
class nsCSSRuleListSH : public nsArraySH
|
||||
{
|
||||
protected:
|
||||
nsCSSRuleListSH(nsDOMClassInfoID aID) : nsArraySH(aID)
|
||||
nsCSSRuleListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -963,9 +1004,9 @@ protected:
|
|||
nsISupports **aResult);
|
||||
|
||||
public:
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoID aID)
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsCSSRuleListSH(aID);
|
||||
return new nsCSSRuleListSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5195,7 +5195,7 @@ NavigatorImpl::Preference()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
//--Check to see if the caller is allowed to access prefs
|
||||
if (sPrefInternal_id = JSVAL_VOID)
|
||||
if (sPrefInternal_id == JSVAL_VOID)
|
||||
sPrefInternal_id = STRING_TO_JSVAL(::JS_InternString(cx, "preferenceinternal"));
|
||||
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
|
|
|
@ -50,8 +50,9 @@
|
|||
#include "xptinfo.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
|
||||
#define NS_INTERFACE_PREFIX "nsI"
|
||||
#define NS_DOM_INTERFACE_PREFIX "nsIDOM"
|
||||
|
||||
// Our extended PLDHashEntryHdr
|
||||
|
@ -99,6 +100,18 @@ GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|||
// An entry is being cleared, let the key (nsString) do its own
|
||||
// cleanup.
|
||||
e->mKey.~nsString();
|
||||
if (e->mGlobalName.mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
nsIClassInfo* ci = GET_CLEAN_CI_PTR(e->mGlobalName.mData->mCachedClassInfo);
|
||||
|
||||
// If we constructed an internal helper, we'll let the helper delete
|
||||
// the nsDOMClassInfoData structure, if not we do it here.
|
||||
if (!ci || e->mGlobalName.mData->mExternalConstructorFptr) {
|
||||
delete e->mGlobalName.mData;
|
||||
}
|
||||
|
||||
// Release our pointer to the helper.
|
||||
NS_IF_RELEASE(ci);
|
||||
}
|
||||
|
||||
// This will set e->mGlobalName.mType to
|
||||
// nsGlobalNameStruct::eTypeNotInitialized
|
||||
|
@ -112,7 +125,7 @@ GlobalNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
|||
GlobalNameMapEntry *e = NS_STATIC_CAST(GlobalNameMapEntry *, entry);
|
||||
const nsAString *keyStr = NS_STATIC_CAST(const nsAString *, key);
|
||||
|
||||
// Inititlize the key in the entry with placement new
|
||||
// Initialize the key in the entry with placement new
|
||||
nsString *str = new (&e->mKey) nsString(*keyStr);
|
||||
|
||||
// This will set e->mGlobalName.mType to
|
||||
|
@ -219,15 +232,16 @@ nsScriptNameSpaceManager::FillHashWithDOMInterfaces()
|
|||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIEnumerator> e;
|
||||
// First look for all interfaces whose name starts with nsIDOM
|
||||
nsCOMPtr<nsIEnumerator> domInterfaces;
|
||||
nsresult rv =
|
||||
iim->EnumerateInterfacesWhoseNamesStartWith(NS_DOM_INTERFACE_PREFIX,
|
||||
getter_AddRefs(e));
|
||||
getter_AddRefs(domInterfaces));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
|
||||
rv = e->First();
|
||||
rv = domInterfaces->First();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Empty interface list?
|
||||
|
@ -237,63 +251,170 @@ nsScriptNameSpaceManager::FillHashWithDOMInterfaces()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
for ( ; e->IsDone() == NS_COMFALSE; e->Next()) {
|
||||
rv = e->CurrentItem(getter_AddRefs(entry));
|
||||
PRBool found_old;
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||
nsXPIDLCString if_name;
|
||||
|
||||
for ( ; domInterfaces->IsDone() == NS_COMFALSE; domInterfaces->Next()) {
|
||||
rv = domInterfaces->CurrentItem(getter_AddRefs(entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info(do_QueryInterface(entry));
|
||||
if_info->GetName(getter_Copies(if_name));
|
||||
rv = RegisterInterface(if_info,
|
||||
if_name.get() + sizeof(NS_DOM_INTERFACE_PREFIX) - 1,
|
||||
&found_old);
|
||||
|
||||
NS_ASSERTION(if_info, "Interface info not an nsIInterfaceInfo!");
|
||||
#ifdef DEBUG
|
||||
NS_ASSERTION(!found_old,
|
||||
"Whaaa, interface name already in hash!");
|
||||
#endif
|
||||
}
|
||||
|
||||
// With the InterfaceInfo system it is actually cheaper to get the
|
||||
// interface name than to get the count of constants. The former is
|
||||
// always cached. The latter might require loading an xpt file!
|
||||
// Next, look for externally registered DOM interfaces
|
||||
rv = RegisterExternalInterfaces(PR_FALSE);
|
||||
|
||||
nsXPIDLCString if_name;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = if_info->GetName(getter_Copies(if_name));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint16 constant_count = 0;
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_INTERFACE,
|
||||
getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString IID_string, category_entry;
|
||||
const char* if_name;
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||
PRBool found_old, dom_prefix;
|
||||
|
||||
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
|
||||
nsCOMPtr<nsISupportsString> category(do_QueryInterface(entry));
|
||||
|
||||
if (!category) {
|
||||
NS_WARNING("Category entry not an nsISupportsString!");
|
||||
|
||||
rv = if_info->GetConstantCount(&constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (constant_count) {
|
||||
PRUint16 parent_constant_count = 0;
|
||||
rv = category->GetData(getter_Copies(category_entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> parent_info;
|
||||
rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry,
|
||||
getter_Copies(IID_string));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if_info->GetParent(getter_AddRefs(parent_info));
|
||||
nsIID primary_IID;
|
||||
if (!primary_IID.Parse(IID_string) ||
|
||||
primary_IID.Equals(NS_GET_IID(nsISupports))) {
|
||||
NS_ERROR("Invalid IID registered with the script namespace manager!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parent_info) {
|
||||
rv = parent_info->GetConstantCount(&parent_constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
continue;
|
||||
iim->GetInfoForIID(&primary_IID, getter_AddRefs(if_info));
|
||||
|
||||
while (if_info) {
|
||||
const nsIID *iid;
|
||||
if_info->GetIIDShared(&iid);
|
||||
NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (iid->Equals(NS_GET_IID(nsISupports))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if_info->GetNameShared(&if_name);
|
||||
dom_prefix = (strncmp(if_name, NS_DOM_INTERFACE_PREFIX,
|
||||
sizeof(NS_DOM_INTERFACE_PREFIX) - 1) == 0);
|
||||
|
||||
const char* name;
|
||||
if (dom_prefix) {
|
||||
if (!aAsProto) {
|
||||
// nsIDOM* interfaces have already been registered.
|
||||
break;
|
||||
}
|
||||
name = if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1;
|
||||
} else {
|
||||
name = if_name + sizeof(NS_INTERFACE_PREFIX) - 1;
|
||||
}
|
||||
|
||||
if (constant_count != parent_constant_count) {
|
||||
nsGlobalNameStruct *s =
|
||||
AddToHash(NS_ConvertASCIItoUCS2(if_name.get() +
|
||||
strlen(NS_DOM_INTERFACE_PREFIX)));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized,
|
||||
"Whaaa, interface name already in hash!");
|
||||
#endif
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeInterface;
|
||||
if (aAsProto) {
|
||||
RegisterClassProto(name, iid, &found_old);
|
||||
} else {
|
||||
RegisterInterface(if_info, name, &found_old);
|
||||
}
|
||||
|
||||
if (found_old) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
|
||||
tmp->GetParent(getter_AddRefs(if_info));
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterInterface(nsIInterfaceInfo* aIfInfo,
|
||||
const char* aIfName,
|
||||
PRBool* aFoundOld)
|
||||
{
|
||||
NS_ASSERTION(aIfInfo, "Interface info not an nsIInterfaceInfo!");
|
||||
|
||||
// With the InterfaceInfo system it is actually cheaper to get the
|
||||
// interface name than to get the count of constants. The former is
|
||||
// always cached. The latter might require loading an xpt file!
|
||||
|
||||
PRUint16 constant_count = 0;
|
||||
*aFoundOld = PR_FALSE;
|
||||
|
||||
nsresult rv = aIfInfo->GetConstantCount(&constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (constant_count) {
|
||||
PRUint16 parent_constant_count = 0;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> parent_info;
|
||||
|
||||
aIfInfo->GetParent(getter_AddRefs(parent_info));
|
||||
|
||||
if (parent_info) {
|
||||
rv = parent_info->GetConstantCount(&parent_constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (constant_count != parent_constant_count) {
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aIfName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
|
||||
*aFoundOld = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeInterface;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -394,6 +515,10 @@ nsresult
|
|||
nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
||||
PRInt32 aDOMClassInfoID)
|
||||
{
|
||||
if (!nsCRT::IsAscii(aClassName)) {
|
||||
NS_ERROR("Trying to register a non-ASCII class name");
|
||||
return NS_OK;
|
||||
}
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -408,8 +533,8 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(!(s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
||||
s->mType != nsGlobalNameStruct::eTypeInterface),
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
||||
"Whaaa, JS environment name clash!");
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
|
||||
|
@ -442,3 +567,72 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
|
||||
nsCID& aCID)
|
||||
{
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// If an external constructor is already defined with aClassName we
|
||||
// won't overwrite it.
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
||||
"Whaaa, JS environment name clash!");
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfoCreator;
|
||||
s->mCID = aCID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterDOMCIData(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
{
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// If an external constructor is already defined with aClassName we
|
||||
// won't overwrite it.
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX Should we bail out here?
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
||||
"Someone tries to register classinfo data for a class that isn't new or external!");
|
||||
|
||||
s->mData = new nsExternalDOMClassInfoData;
|
||||
NS_ENSURE_TRUE(s->mData, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfo;
|
||||
s->mData->mName = aName;
|
||||
if (aConstructorFptr)
|
||||
s->mData->mExternalConstructorFptr = aConstructorFptr;
|
||||
else
|
||||
// null constructor will cause us to use nsDOMGenericSH::doCreate
|
||||
s->mData->mExternalConstructorFptr = nsnull;
|
||||
s->mData->mCachedClassInfo = nsnull;
|
||||
s->mData->mProtoChainInterface = aProtoChainInterface;
|
||||
s->mData->mInterfaces = aInterfaces;
|
||||
s->mData->mScriptableFlags = aScriptableFlags;
|
||||
s->mData->mHasClassInterface = aHasClassInterface;
|
||||
s->mData->mConstructorCID = aConstructorCID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "nsID.h"
|
||||
#include "pldhash.h"
|
||||
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
struct nsGlobalNameStruct
|
||||
{
|
||||
enum nametype {
|
||||
|
@ -51,12 +53,15 @@ struct nsGlobalNameStruct
|
|||
eTypeStaticNameSet,
|
||||
eTypeDynamicNameSet,
|
||||
eTypeClassConstructor,
|
||||
eTypeClassProto
|
||||
eTypeClassProto,
|
||||
eTypeExternalClassInfoCreator,
|
||||
eTypeExternalClassInfo
|
||||
} mType;
|
||||
|
||||
union {
|
||||
PRInt32 mDOMClassInfoID; // eTypeClassConstructor
|
||||
nsIID mIID; // eTypeClassProto
|
||||
nsExternalDOMClassInfoData* mData; // eTypeExternalClassInfo
|
||||
nsCID mCID; // All other types...
|
||||
};
|
||||
|
||||
|
@ -92,6 +97,21 @@ public:
|
|||
const nsIID *aConstructorProtoIID,
|
||||
PRBool *aFoundOld);
|
||||
|
||||
nsresult RegisterExternalInterfaces(PRBool aAsProto);
|
||||
|
||||
nsresult RegisterExternalClassName(const char *aClassName,
|
||||
nsCID& aCID);
|
||||
|
||||
// Register the info for an external class. aName must be static
|
||||
// data, it will not be deleted by the DOM code.
|
||||
nsresult RegisterDOMCIData(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID);
|
||||
|
||||
protected:
|
||||
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
||||
// that aKey will be mapped to. If mType in the returned
|
||||
|
@ -103,6 +123,9 @@ protected:
|
|||
const char *aCategory,
|
||||
nsGlobalNameStruct::nametype aType);
|
||||
nsresult FillHashWithDOMInterfaces();
|
||||
nsresult RegisterInterface(nsIInterfaceInfo* aIfInfo,
|
||||
const char* aIfName,
|
||||
PRBool* aFoundOld);
|
||||
|
||||
// Inline PLDHashTable, init with PL_DHashTableInit() and delete
|
||||
// with PL_DHashTableFinish().
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIJSContextStack.h"
|
||||
#include "nsIExceptionService.h"
|
||||
|
||||
#include "nsScriptNameSpaceManager.h"
|
||||
|
||||
extern nsresult NS_CreateScriptContext(nsIScriptGlobalObject *aGlobal,
|
||||
nsIScriptContext **aContext);
|
||||
|
@ -93,6 +94,15 @@ public:
|
|||
nsIScriptGlobalObject **aGlobal);
|
||||
|
||||
NS_IMETHOD_(nsISupports *)GetClassInfoInstance(nsDOMClassInfoID aID);
|
||||
NS_IMETHOD_(nsISupports *)GetExternalClassInfoInstance(const nsAString& aName);
|
||||
|
||||
NS_IMETHOD RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID);
|
||||
};
|
||||
|
||||
nsDOMSOFactory::nsDOMSOFactory()
|
||||
|
@ -159,6 +169,37 @@ nsDOMSOFactory::GetClassInfoInstance(nsDOMClassInfoID aID)
|
|||
return nsDOMClassInfo::GetClassInfoInstance(aID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsISupports *)
|
||||
nsDOMSOFactory::GetExternalClassInfoInstance(const nsAString& aName)
|
||||
{
|
||||
extern nsScriptNameSpaceManager *gNameSpaceManager;
|
||||
|
||||
NS_ENSURE_TRUE(gNameSpaceManager, nsnull);
|
||||
|
||||
const nsGlobalNameStruct *globalStruct;
|
||||
gNameSpaceManager->LookupName(aName, &globalStruct);
|
||||
if (globalStruct) {
|
||||
if (globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(globalStruct->mCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
rv = creator->RegisterDOMCI(NS_ConvertUCS2toUTF8(aName).get(), this);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
rv = gNameSpaceManager->LookupName(aName, &globalStruct);
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && globalStruct, nsnull);
|
||||
|
||||
NS_ASSERTION(globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
|
||||
"The classinfo data for this class didn't get registered.");
|
||||
}
|
||||
if (globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
return nsDOMClassInfo::GetClassInfoInstance(globalStruct->mData);
|
||||
}
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSOFactory::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
|
@ -202,6 +243,28 @@ nsDOMSOFactory::GetException(nsresult result, nsIException *aDefaultException,
|
|||
return NS_NewDOMException(result, aDefaultException, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSOFactory::RegisterDOMClassInfo(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
{
|
||||
extern nsScriptNameSpaceManager *gNameSpaceManager;
|
||||
|
||||
NS_ENSURE_TRUE(gNameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return gNameSpaceManager->RegisterDOMCIData(aName,
|
||||
aConstructorFptr,
|
||||
aProtoChainInterface,
|
||||
aInterfaces,
|
||||
aScriptableFlags,
|
||||
aHasClassInterface,
|
||||
aConstructorCID);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSOFactory);
|
||||
|
|
|
@ -50,8 +50,9 @@
|
|||
#include "xptinfo.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
|
||||
#define NS_INTERFACE_PREFIX "nsI"
|
||||
#define NS_DOM_INTERFACE_PREFIX "nsIDOM"
|
||||
|
||||
// Our extended PLDHashEntryHdr
|
||||
|
@ -99,6 +100,18 @@ GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|||
// An entry is being cleared, let the key (nsString) do its own
|
||||
// cleanup.
|
||||
e->mKey.~nsString();
|
||||
if (e->mGlobalName.mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
nsIClassInfo* ci = GET_CLEAN_CI_PTR(e->mGlobalName.mData->mCachedClassInfo);
|
||||
|
||||
// If we constructed an internal helper, we'll let the helper delete
|
||||
// the nsDOMClassInfoData structure, if not we do it here.
|
||||
if (!ci || e->mGlobalName.mData->mExternalConstructorFptr) {
|
||||
delete e->mGlobalName.mData;
|
||||
}
|
||||
|
||||
// Release our pointer to the helper.
|
||||
NS_IF_RELEASE(ci);
|
||||
}
|
||||
|
||||
// This will set e->mGlobalName.mType to
|
||||
// nsGlobalNameStruct::eTypeNotInitialized
|
||||
|
@ -112,7 +125,7 @@ GlobalNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
|||
GlobalNameMapEntry *e = NS_STATIC_CAST(GlobalNameMapEntry *, entry);
|
||||
const nsAString *keyStr = NS_STATIC_CAST(const nsAString *, key);
|
||||
|
||||
// Inititlize the key in the entry with placement new
|
||||
// Initialize the key in the entry with placement new
|
||||
nsString *str = new (&e->mKey) nsString(*keyStr);
|
||||
|
||||
// This will set e->mGlobalName.mType to
|
||||
|
@ -219,15 +232,16 @@ nsScriptNameSpaceManager::FillHashWithDOMInterfaces()
|
|||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIEnumerator> e;
|
||||
// First look for all interfaces whose name starts with nsIDOM
|
||||
nsCOMPtr<nsIEnumerator> domInterfaces;
|
||||
nsresult rv =
|
||||
iim->EnumerateInterfacesWhoseNamesStartWith(NS_DOM_INTERFACE_PREFIX,
|
||||
getter_AddRefs(e));
|
||||
getter_AddRefs(domInterfaces));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
|
||||
rv = e->First();
|
||||
rv = domInterfaces->First();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Empty interface list?
|
||||
|
@ -237,63 +251,170 @@ nsScriptNameSpaceManager::FillHashWithDOMInterfaces()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
for ( ; e->IsDone() == NS_COMFALSE; e->Next()) {
|
||||
rv = e->CurrentItem(getter_AddRefs(entry));
|
||||
PRBool found_old;
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||
nsXPIDLCString if_name;
|
||||
|
||||
for ( ; domInterfaces->IsDone() == NS_COMFALSE; domInterfaces->Next()) {
|
||||
rv = domInterfaces->CurrentItem(getter_AddRefs(entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info(do_QueryInterface(entry));
|
||||
if_info->GetName(getter_Copies(if_name));
|
||||
rv = RegisterInterface(if_info,
|
||||
if_name.get() + sizeof(NS_DOM_INTERFACE_PREFIX) - 1,
|
||||
&found_old);
|
||||
|
||||
NS_ASSERTION(if_info, "Interface info not an nsIInterfaceInfo!");
|
||||
#ifdef DEBUG
|
||||
NS_ASSERTION(!found_old,
|
||||
"Whaaa, interface name already in hash!");
|
||||
#endif
|
||||
}
|
||||
|
||||
// With the InterfaceInfo system it is actually cheaper to get the
|
||||
// interface name than to get the count of constants. The former is
|
||||
// always cached. The latter might require loading an xpt file!
|
||||
// Next, look for externally registered DOM interfaces
|
||||
rv = RegisterExternalInterfaces(PR_FALSE);
|
||||
|
||||
nsXPIDLCString if_name;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = if_info->GetName(getter_Copies(if_name));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint16 constant_count = 0;
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_INTERFACE,
|
||||
getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString IID_string, category_entry;
|
||||
const char* if_name;
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
||||
PRBool found_old, dom_prefix;
|
||||
|
||||
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
|
||||
nsCOMPtr<nsISupportsString> category(do_QueryInterface(entry));
|
||||
|
||||
if (!category) {
|
||||
NS_WARNING("Category entry not an nsISupportsString!");
|
||||
|
||||
rv = if_info->GetConstantCount(&constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (constant_count) {
|
||||
PRUint16 parent_constant_count = 0;
|
||||
rv = category->GetData(getter_Copies(category_entry));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> parent_info;
|
||||
rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry,
|
||||
getter_Copies(IID_string));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if_info->GetParent(getter_AddRefs(parent_info));
|
||||
nsIID primary_IID;
|
||||
if (!primary_IID.Parse(IID_string) ||
|
||||
primary_IID.Equals(NS_GET_IID(nsISupports))) {
|
||||
NS_ERROR("Invalid IID registered with the script namespace manager!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parent_info) {
|
||||
rv = parent_info->GetConstantCount(&parent_constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
continue;
|
||||
iim->GetInfoForIID(&primary_IID, getter_AddRefs(if_info));
|
||||
|
||||
while (if_info) {
|
||||
const nsIID *iid;
|
||||
if_info->GetIIDShared(&iid);
|
||||
NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (iid->Equals(NS_GET_IID(nsISupports))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if_info->GetNameShared(&if_name);
|
||||
dom_prefix = (strncmp(if_name, NS_DOM_INTERFACE_PREFIX,
|
||||
sizeof(NS_DOM_INTERFACE_PREFIX) - 1) == 0);
|
||||
|
||||
const char* name;
|
||||
if (dom_prefix) {
|
||||
if (!aAsProto) {
|
||||
// nsIDOM* interfaces have already been registered.
|
||||
break;
|
||||
}
|
||||
name = if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1;
|
||||
} else {
|
||||
name = if_name + sizeof(NS_INTERFACE_PREFIX) - 1;
|
||||
}
|
||||
|
||||
if (constant_count != parent_constant_count) {
|
||||
nsGlobalNameStruct *s =
|
||||
AddToHash(NS_ConvertASCIItoUCS2(if_name.get() +
|
||||
strlen(NS_DOM_INTERFACE_PREFIX)));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized,
|
||||
"Whaaa, interface name already in hash!");
|
||||
#endif
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeInterface;
|
||||
if (aAsProto) {
|
||||
RegisterClassProto(name, iid, &found_old);
|
||||
} else {
|
||||
RegisterInterface(if_info, name, &found_old);
|
||||
}
|
||||
|
||||
if (found_old) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
|
||||
tmp->GetParent(getter_AddRefs(if_info));
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterInterface(nsIInterfaceInfo* aIfInfo,
|
||||
const char* aIfName,
|
||||
PRBool* aFoundOld)
|
||||
{
|
||||
NS_ASSERTION(aIfInfo, "Interface info not an nsIInterfaceInfo!");
|
||||
|
||||
// With the InterfaceInfo system it is actually cheaper to get the
|
||||
// interface name than to get the count of constants. The former is
|
||||
// always cached. The latter might require loading an xpt file!
|
||||
|
||||
PRUint16 constant_count = 0;
|
||||
*aFoundOld = PR_FALSE;
|
||||
|
||||
nsresult rv = aIfInfo->GetConstantCount(&constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (constant_count) {
|
||||
PRUint16 parent_constant_count = 0;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> parent_info;
|
||||
|
||||
aIfInfo->GetParent(getter_AddRefs(parent_info));
|
||||
|
||||
if (parent_info) {
|
||||
rv = parent_info->GetConstantCount(&parent_constant_count);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("can't get constant count");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (constant_count != parent_constant_count) {
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aIfName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
|
||||
*aFoundOld = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeInterface;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -394,6 +515,10 @@ nsresult
|
|||
nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
||||
PRInt32 aDOMClassInfoID)
|
||||
{
|
||||
if (!nsCRT::IsAscii(aClassName)) {
|
||||
NS_ERROR("Trying to register a non-ASCII class name");
|
||||
return NS_OK;
|
||||
}
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -408,8 +533,8 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(!(s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
||||
s->mType != nsGlobalNameStruct::eTypeInterface),
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
||||
"Whaaa, JS environment name clash!");
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
|
||||
|
@ -442,3 +567,72 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
|
||||
nsCID& aCID)
|
||||
{
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// If an external constructor is already defined with aClassName we
|
||||
// won't overwrite it.
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
||||
"Whaaa, JS environment name clash!");
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfoCreator;
|
||||
s->mCID = aCID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptNameSpaceManager::RegisterDOMCIData(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID)
|
||||
{
|
||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aName));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// If an external constructor is already defined with aClassName we
|
||||
// won't overwrite it.
|
||||
|
||||
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX Should we bail out here?
|
||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
||||
"Someone tries to register classinfo data for a class that isn't new or external!");
|
||||
|
||||
s->mData = new nsExternalDOMClassInfoData;
|
||||
NS_ENSURE_TRUE(s->mData, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfo;
|
||||
s->mData->mName = aName;
|
||||
if (aConstructorFptr)
|
||||
s->mData->mExternalConstructorFptr = aConstructorFptr;
|
||||
else
|
||||
// null constructor will cause us to use nsDOMGenericSH::doCreate
|
||||
s->mData->mExternalConstructorFptr = nsnull;
|
||||
s->mData->mCachedClassInfo = nsnull;
|
||||
s->mData->mProtoChainInterface = aProtoChainInterface;
|
||||
s->mData->mInterfaces = aInterfaces;
|
||||
s->mData->mScriptableFlags = aScriptableFlags;
|
||||
s->mData->mHasClassInterface = aHasClassInterface;
|
||||
s->mData->mConstructorCID = aConstructorCID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "nsID.h"
|
||||
#include "pldhash.h"
|
||||
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
struct nsGlobalNameStruct
|
||||
{
|
||||
enum nametype {
|
||||
|
@ -51,12 +53,15 @@ struct nsGlobalNameStruct
|
|||
eTypeStaticNameSet,
|
||||
eTypeDynamicNameSet,
|
||||
eTypeClassConstructor,
|
||||
eTypeClassProto
|
||||
eTypeClassProto,
|
||||
eTypeExternalClassInfoCreator,
|
||||
eTypeExternalClassInfo
|
||||
} mType;
|
||||
|
||||
union {
|
||||
PRInt32 mDOMClassInfoID; // eTypeClassConstructor
|
||||
nsIID mIID; // eTypeClassProto
|
||||
nsExternalDOMClassInfoData* mData; // eTypeExternalClassInfo
|
||||
nsCID mCID; // All other types...
|
||||
};
|
||||
|
||||
|
@ -92,6 +97,21 @@ public:
|
|||
const nsIID *aConstructorProtoIID,
|
||||
PRBool *aFoundOld);
|
||||
|
||||
nsresult RegisterExternalInterfaces(PRBool aAsProto);
|
||||
|
||||
nsresult RegisterExternalClassName(const char *aClassName,
|
||||
nsCID& aCID);
|
||||
|
||||
// Register the info for an external class. aName must be static
|
||||
// data, it will not be deleted by the DOM code.
|
||||
nsresult RegisterDOMCIData(const char *aName,
|
||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
||||
const nsIID *aProtoChainInterface,
|
||||
const nsIID **aInterfaces,
|
||||
PRUint32 aScriptableFlags,
|
||||
PRBool aHasClassInterface,
|
||||
const nsCID *aConstructorCID);
|
||||
|
||||
protected:
|
||||
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
||||
// that aKey will be mapped to. If mType in the returned
|
||||
|
@ -103,6 +123,9 @@ protected:
|
|||
const char *aCategory,
|
||||
nsGlobalNameStruct::nametype aType);
|
||||
nsresult FillHashWithDOMInterfaces();
|
||||
nsresult RegisterInterface(nsIInterfaceInfo* aIfInfo,
|
||||
const char* aIfName,
|
||||
PRBool* aFoundOld);
|
||||
|
||||
// Inline PLDHashTable, init with PL_DHashTableInit() and delete
|
||||
// with PL_DHashTableFinish().
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsSyncLoader.h"
|
||||
|
@ -33,11 +34,39 @@
|
|||
#include "XSLTProcessor.h"
|
||||
#include "XPathProcessor.h"
|
||||
|
||||
/* 1c1a3c01-14f6-11d6-a7f2-ea502af815dc */
|
||||
#define TRANSFORMIIX_DOMCI_EXTENSION_CID \
|
||||
{ 0x1c1a3c01, 0x14f6, 0x11d6, {0xa7, 0xf2, 0xea, 0x50, 0x2a, 0xf8, 0x15, 0xdc} }
|
||||
|
||||
#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(nsIDocumentTransformer)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XSLTProcessor, nsIDocumentTransformer, PR_FALSE, &kXSLTProcessorCID)
|
||||
|
||||
static NS_DEFINE_CID(kXPathProcessorCID, TRANSFORMIIX_XPATH_PROCESSOR_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathProcessor)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIXPathNodeSelector)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathProcessor, nsIXPathNodeSelector, PR_FALSE, &kXPathProcessorCID)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(NodeSet)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMNodeList)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(NodeSet, nsIDOMNodeList, PR_FALSE, nsnull)
|
||||
NS_DOMCI_EXTENSION_END
|
||||
|
||||
// Factory Constructor
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(XSLTProcessor)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(XPathProcessor)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoader)
|
||||
|
||||
NS_DECL_DOM_CLASSINFO(XSLTProcessor)
|
||||
NS_DECL_DOM_CLASSINFO(XPathProcessor)
|
||||
NS_DECL_DOM_CLASSINFO(NodeSet)
|
||||
|
||||
static NS_METHOD
|
||||
RegisterTransformiix(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
|
@ -54,15 +83,33 @@ RegisterTransformiix(nsIComponentManager *aCompMgr,
|
|||
return rv;
|
||||
|
||||
nsXPIDLCString previous;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XSLTProcessor",
|
||||
TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID,
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathProcessor",
|
||||
TRANSFORMIIX_XPATH_PROCESSOR_CONTRACTID,
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"NodeSet",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIDocumentTransformer",
|
||||
NS_GET_IID(nsIDocumentTransformer).ToString(),
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIXPathNodeSelector",
|
||||
NS_GET_IID(nsIXPathNodeSelector).ToString(),
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
|
||||
return rv;
|
||||
|
@ -101,6 +148,10 @@ Shutdown(nsIModule* aSelf)
|
|||
|
||||
gInitialized = PR_FALSE;
|
||||
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XSLTProcessor));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathProcessor));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(NodeSet));
|
||||
|
||||
txXMLAtoms::shutdown();
|
||||
txXPathAtoms::shutdown();
|
||||
txXSLTAtoms::shutdown();
|
||||
|
@ -121,7 +172,11 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||
{ "Transformiix Synchronous Loader",
|
||||
TRANSFORMIIX_SYNCLOADER_CID,
|
||||
TRANSFORMIIX_SYNCLOADER_CONTRACTID,
|
||||
nsSyncLoaderConstructor }
|
||||
nsSyncLoaderConstructor },
|
||||
{ "Transformiix DOMCI Extender",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CID,
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
NS_DOMCI_EXTENSION_CONSTRUCTOR(Transformiix) }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(TransformiixModule, gComponents,
|
||||
|
|
|
@ -28,6 +28,8 @@ REQUIRES = xpcom \
|
|||
content_xsl \
|
||||
necko \
|
||||
content \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ REQUIRES = string \
|
|||
layout \
|
||||
content \
|
||||
widget \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -46,15 +46,13 @@
|
|||
|
||||
|
||||
// QueryInterface implementation for XPathProcessor
|
||||
NS_INTERFACE_MAP_BEGIN(XPathProcessor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXPathNodeSelector)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XPathProcessor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(XPathProcessor)
|
||||
NS_IMPL_RELEASE(XPathProcessor)
|
||||
NS_INTERFACE_MAP_BEGIN(XPathProcessor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXPathNodeSelector)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XPathProcessor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -26,6 +26,8 @@ REQUIRES = string \
|
|||
dom \
|
||||
widget \
|
||||
content \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
|
|
@ -40,19 +40,14 @@
|
|||
#include "nsNodeSet.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
|
||||
// QueryInterface implementation for nsNodeSet
|
||||
NS_INTERFACE_MAP_BEGIN(nsNodeSet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(NodeSet)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsNodeSet)
|
||||
NS_IMPL_RELEASE(nsNodeSet)
|
||||
NS_INTERFACE_MAP_BEGIN(nsNodeSet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(NodeSet)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
nsNodeSet::nsNodeSet(NodeSet* aNodeSet) {
|
||||
|
|
|
@ -39,6 +39,8 @@ REQUIRES = string \
|
|||
widget \
|
||||
necko \
|
||||
unicharutil \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -165,17 +165,14 @@ XSLTProcessor::~XSLTProcessor()
|
|||
// XXX Mozilla module only code. This should move to txMozillaXSLTProcessor
|
||||
// XXX
|
||||
|
||||
// QueryInterface implementation for XSLTProcessor
|
||||
NS_INTERFACE_MAP_BEGIN(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptLoaderObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocumentTransformer)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(XSLTProcessor)
|
||||
NS_IMPL_RELEASE(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_BEGIN(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptLoaderObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocumentTransformer)
|
||||
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XSLTProcessor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// XXX
|
||||
// XXX Mozilla module only code. This should move to txMozillaXSLTProcessor
|
||||
|
|
|
@ -29,6 +29,8 @@ REQUIRES = string \
|
|||
content_xsl \
|
||||
content \
|
||||
unicharutil \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMParser)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOMLoadListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
#endif
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(DOMParser)
|
||||
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(DOMParser)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ nsDOMSerializer::~nsDOMSerializer()
|
|||
NS_INTERFACE_MAP_BEGIN(nsDOMSerializer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSerializer)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(DOMSerializer)
|
||||
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(DOMSerializer)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ NS_INTERFACE_MAP_BEGIN(nsXMLHttpRequest)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XMLHttpRequest)
|
||||
NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(XMLHttpRequest)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
|
||||
#include "nsSOAPHeaderBlock.h"
|
||||
#include "nsSOAPParameter.h"
|
||||
|
@ -68,10 +69,6 @@
|
|||
#include "wspprivate.h"
|
||||
#endif // MOZ_WSP
|
||||
|
||||
#include "nsString.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Define the contructor function for the objects
|
||||
|
@ -81,6 +78,37 @@
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXMLHttpRequest)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMParser)
|
||||
|
||||
NS_DECL_DOM_CLASSINFO(DOMSerializer)
|
||||
NS_DECL_DOM_CLASSINFO(XMLHttpRequest)
|
||||
NS_DECL_DOM_CLASSINFO(DOMParser)
|
||||
|
||||
/* 6fb64081-1da6-11d6-a7f2-9babb25552bc */
|
||||
#define XMLEXTRAS_DOMCI_EXTENSION_CID \
|
||||
{ 0x6fb64081, 0x1da6, 0x11d6, {0xa7, 0xf2, 0x9b, 0xab, 0xb2, 0x55, 0x52, 0xbc} }
|
||||
|
||||
#define XMLEXTRAS_DOMCI_EXTENSION_CONTRACTID \
|
||||
"@mozilla.org/xmlextras-domci-extender;1"
|
||||
|
||||
NS_DOMCI_EXTENSION(XMLExtras)
|
||||
static NS_DEFINE_CID(kXMLSerializerCID, NS_XMLSERIALIZER_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(DOMSerializer)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMSerializer)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(DOMSerializer, PR_TRUE, &kXMLSerializerCID)
|
||||
|
||||
static NS_DEFINE_CID(kXMLHttpRequestCID, NS_XMLHTTPREQUEST_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XMLHttpRequest)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIXMLHttpRequest)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIJSXMLHttpRequest)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMEventTarget)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(XMLHttpRequest, PR_TRUE, &kXMLHttpRequestCID)
|
||||
|
||||
static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(DOMParser)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMParser)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(DOMParser, PR_TRUE, &kDOMParserCID)
|
||||
NS_DOMCI_EXTENSION_END
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPCall)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPResponse)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPEncoding)
|
||||
|
@ -227,21 +255,33 @@ RegisterXMLExtras(nsIComponentManager *aCompMgr,
|
|||
return rv;
|
||||
|
||||
nsXPIDLCString previous;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XMLSerializer",
|
||||
NS_XMLSERIALIZER_CONTRACTID,
|
||||
XMLEXTRAS_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XMLHttpRequest",
|
||||
NS_XMLHTTPREQUEST_CONTRACTID,
|
||||
XMLEXTRAS_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"DOMParser",
|
||||
NS_DOMPARSER_CONTRACTID,
|
||||
XMLEXTRAS_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIXMLHttpRequest",
|
||||
NS_GET_IID(nsIXMLHttpRequest).ToString(),
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIJSXMLHttpRequest",
|
||||
NS_GET_IID(nsIJSXMLHttpRequest).ToString(),
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -317,6 +357,9 @@ static const nsModuleComponentInfo components[] = {
|
|||
nsXMLHttpRequestConstructor },
|
||||
{ "DOM Parser", NS_DOMPARSER_CID, NS_DOMPARSER_CONTRACTID,
|
||||
nsDOMParserConstructor },
|
||||
{ "XML Extras DOMCI Extender",
|
||||
XMLEXTRAS_DOMCI_EXTENSION_CID, XMLEXTRAS_DOMCI_EXTENSION_CONTRACTID,
|
||||
NS_DOMCI_EXTENSION_CONSTRUCTOR(XMLExtras) },
|
||||
{ "SOAP Call", NS_SOAPCALL_CID, NS_SOAPCALL_CONTRACTID,
|
||||
nsSOAPCallConstructor, nsnull, nsnull, nsnull,
|
||||
NS_CI_INTERFACE_GETTER_NAME(nsSOAPCall),
|
||||
|
@ -558,6 +601,10 @@ static const nsModuleComponentInfo components[] = {
|
|||
void PR_CALLBACK
|
||||
XMLExtrasModuleDestructor(nsIModule* self)
|
||||
{
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(DOMSerializer));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XMLHttpRequest));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(DOMParser));
|
||||
|
||||
nsSchemaAtoms::DestroySchemaAtoms();
|
||||
#ifdef MOZ_WSP
|
||||
nsWSDLAtoms::DestroyWSDLAtoms();
|
||||
|
|
|
@ -49,7 +49,9 @@ REQUIRES = xpcom \
|
|||
gfx2 \
|
||||
imglib2 \
|
||||
unicharutil \
|
||||
webbrwsr \
|
||||
webbrwsr \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -45,6 +45,8 @@ REQUIRES = xpcom \
|
|||
gfx \
|
||||
content \
|
||||
layout \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
|
|
@ -41,7 +41,9 @@ REQUIRES = xpcom \
|
|||
necko \
|
||||
gfx2 \
|
||||
imglib2 \
|
||||
webbrwsr \
|
||||
webbrwsr \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -36,6 +36,8 @@ REQUIRES = xpcom \
|
|||
gfx \
|
||||
content \
|
||||
content_xul \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
|
Загрузка…
Ссылка в новой задаче